babylon.d.ts 3.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: Nullable<AbstractActionManager>;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * 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.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * 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.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * 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.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<BaseTexture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** 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 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * 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)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Nullable<Scene>;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * 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.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Nullable<Scene>;
  12245. /**
  12246. * The engine the particle system belongs to.
  12247. */
  12248. protected _engine: ThinEngine;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * 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.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * 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)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Interface used to define entities containing multiple clip planes
  12447. */
  12448. export interface IClipPlanesHolder {
  12449. /**
  12450. * Gets or sets the active clipplane 1
  12451. */
  12452. clipPlane: Nullable<Plane>;
  12453. /**
  12454. * Gets or sets the active clipplane 2
  12455. */
  12456. clipPlane2: Nullable<Plane>;
  12457. /**
  12458. * Gets or sets the active clipplane 3
  12459. */
  12460. clipPlane3: Nullable<Plane>;
  12461. /**
  12462. * Gets or sets the active clipplane 4
  12463. */
  12464. clipPlane4: Nullable<Plane>;
  12465. /**
  12466. * Gets or sets the active clipplane 5
  12467. */
  12468. clipPlane5: Nullable<Plane>;
  12469. /**
  12470. * Gets or sets the active clipplane 6
  12471. */
  12472. clipPlane6: Nullable<Plane>;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12478. *
  12479. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12480. *
  12481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12482. */
  12483. export class ThinMaterialHelper {
  12484. /**
  12485. * Binds the clip plane information from the holder to the effect.
  12486. * @param effect The effect we are binding the data to
  12487. * @param holder The entity containing the clip plane information
  12488. */
  12489. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. interface ThinEngine {
  12494. /**
  12495. * Sets alpha constants used by some alpha blending modes
  12496. * @param r defines the red component
  12497. * @param g defines the green component
  12498. * @param b defines the blue component
  12499. * @param a defines the alpha component
  12500. */
  12501. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12502. /**
  12503. * Sets the current alpha mode
  12504. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12505. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12506. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12507. */
  12508. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12509. /**
  12510. * Gets the current alpha mode
  12511. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12512. * @returns the current alpha mode
  12513. */
  12514. getAlphaMode(): number;
  12515. /**
  12516. * Sets the current alpha equation
  12517. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12518. */
  12519. setAlphaEquation(equation: number): void;
  12520. /**
  12521. * Gets the current alpha equation.
  12522. * @returns the current alpha equation
  12523. */
  12524. getAlphaEquation(): number;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * This represents a particle system in Babylon.
  12530. * 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.
  12531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12532. * @example https://doc.babylonjs.com/babylon101/particles
  12533. */
  12534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12535. /**
  12536. * Billboard mode will only apply to Y axis
  12537. */
  12538. static readonly BILLBOARDMODE_Y: number;
  12539. /**
  12540. * Billboard mode will apply to all axes
  12541. */
  12542. static readonly BILLBOARDMODE_ALL: number;
  12543. /**
  12544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12545. */
  12546. static readonly BILLBOARDMODE_STRETCHED: number;
  12547. /**
  12548. * This function can be defined to provide custom update for active particles.
  12549. * This function will be called instead of regular update (age, position, color, etc.).
  12550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12551. */
  12552. updateFunction: (particles: Particle[]) => void;
  12553. private _emitterWorldMatrix;
  12554. /**
  12555. * This function can be defined to specify initial direction for every new particle.
  12556. * It by default use the emitterType defined function
  12557. */
  12558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12559. /**
  12560. * This function can be defined to specify initial position for every new particle.
  12561. * It by default use the emitterType defined function
  12562. */
  12563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12564. /**
  12565. * @hidden
  12566. */
  12567. _inheritedVelocityOffset: Vector3;
  12568. /**
  12569. * An event triggered when the system is disposed
  12570. */
  12571. onDisposeObservable: Observable<IParticleSystem>;
  12572. private _onDisposeObserver;
  12573. /**
  12574. * Sets a callback that will be triggered when the system is disposed
  12575. */
  12576. set onDispose(callback: () => void);
  12577. private _particles;
  12578. private _epsilon;
  12579. private _capacity;
  12580. private _stockParticles;
  12581. private _newPartsExcess;
  12582. private _vertexData;
  12583. private _vertexBuffer;
  12584. private _vertexBuffers;
  12585. private _spriteBuffer;
  12586. private _indexBuffer;
  12587. private _effect;
  12588. private _customEffect;
  12589. private _cachedDefines;
  12590. private _scaledColorStep;
  12591. private _colorDiff;
  12592. private _scaledDirection;
  12593. private _scaledGravity;
  12594. private _currentRenderId;
  12595. private _alive;
  12596. private _useInstancing;
  12597. private _started;
  12598. private _stopped;
  12599. private _actualFrame;
  12600. private _scaledUpdateSpeed;
  12601. private _vertexBufferSize;
  12602. /** @hidden */
  12603. _currentEmitRateGradient: Nullable<FactorGradient>;
  12604. /** @hidden */
  12605. _currentEmitRate1: number;
  12606. /** @hidden */
  12607. _currentEmitRate2: number;
  12608. /** @hidden */
  12609. _currentStartSizeGradient: Nullable<FactorGradient>;
  12610. /** @hidden */
  12611. _currentStartSize1: number;
  12612. /** @hidden */
  12613. _currentStartSize2: number;
  12614. private readonly _rawTextureWidth;
  12615. private _rampGradientsTexture;
  12616. private _useRampGradients;
  12617. /** Gets or sets a matrix to use to compute projection */
  12618. defaultProjectionMatrix: Matrix;
  12619. /** Gets or sets a matrix to use to compute view */
  12620. defaultViewMatrix: Matrix;
  12621. /** Gets or sets a boolean indicating that ramp gradients must be used
  12622. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12623. */
  12624. get useRampGradients(): boolean;
  12625. set useRampGradients(value: boolean);
  12626. /**
  12627. * 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.
  12628. * 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: [])
  12629. */
  12630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12631. private _subEmitters;
  12632. /**
  12633. * @hidden
  12634. * If the particle systems emitter should be disposed when the particle system is disposed
  12635. */
  12636. _disposeEmitterOnDispose: boolean;
  12637. /**
  12638. * The current active Sub-systems, this property is used by the root particle system only.
  12639. */
  12640. activeSubSystems: Array<ParticleSystem>;
  12641. /**
  12642. * Specifies if the particles are updated in emitter local space or world space
  12643. */
  12644. isLocal: boolean;
  12645. private _rootParticleSystem;
  12646. /**
  12647. * Gets the current list of active particles
  12648. */
  12649. get particles(): Particle[];
  12650. /**
  12651. * Gets the number of particles active at the same time.
  12652. * @returns The number of active particles.
  12653. */
  12654. getActiveCount(): number;
  12655. /**
  12656. * Returns the string "ParticleSystem"
  12657. * @returns a string containing the class name
  12658. */
  12659. getClassName(): string;
  12660. /**
  12661. * Gets a boolean indicating that the system is stopping
  12662. * @returns true if the system is currently stopping
  12663. */
  12664. isStopping(): boolean;
  12665. /**
  12666. * Gets the custom effect used to render the particles
  12667. * @param blendMode Blend mode for which the effect should be retrieved
  12668. * @returns The effect
  12669. */
  12670. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12671. /**
  12672. * Sets the custom effect used to render the particles
  12673. * @param effect The effect to set
  12674. * @param blendMode Blend mode for which the effect should be set
  12675. */
  12676. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12677. /** @hidden */
  12678. private _onBeforeDrawParticlesObservable;
  12679. /**
  12680. * Observable that will be called just before the particles are drawn
  12681. */
  12682. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12683. /**
  12684. * Gets the name of the particle vertex shader
  12685. */
  12686. get vertexShaderName(): string;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. * @param capacity The max number of particles alive at the same time
  12692. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12693. * @param customEffect a custom effect used to change the way particles are rendered by default
  12694. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12695. * @param epsilon Offset used to render the particles
  12696. */
  12697. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12698. private _addFactorGradient;
  12699. private _removeFactorGradient;
  12700. /**
  12701. * Adds a new life time gradient
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the life time factor to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific life time gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new size gradient
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the size factor to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeSizeGradient(gradient: number): IParticleSystem;
  12728. /**
  12729. * Adds a new color remap gradient
  12730. * @param gradient defines the gradient to use (between 0 and 1)
  12731. * @param min defines the color remap minimal range
  12732. * @param max defines the color remap maximal range
  12733. * @returns the current particle system
  12734. */
  12735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12736. /**
  12737. * Remove a specific color remap gradient
  12738. * @param gradient defines the gradient to remove
  12739. * @returns the current particle system
  12740. */
  12741. removeColorRemapGradient(gradient: number): IParticleSystem;
  12742. /**
  12743. * Adds a new alpha remap gradient
  12744. * @param gradient defines the gradient to use (between 0 and 1)
  12745. * @param min defines the alpha remap minimal range
  12746. * @param max defines the alpha remap maximal range
  12747. * @returns the current particle system
  12748. */
  12749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12750. /**
  12751. * Remove a specific alpha remap gradient
  12752. * @param gradient defines the gradient to remove
  12753. * @returns the current particle system
  12754. */
  12755. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12756. /**
  12757. * Adds a new angular speed gradient
  12758. * @param gradient defines the gradient to use (between 0 and 1)
  12759. * @param factor defines the angular speed to affect to the specified gradient
  12760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12761. * @returns the current particle system
  12762. */
  12763. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12764. /**
  12765. * Remove a specific angular speed gradient
  12766. * @param gradient defines the gradient to remove
  12767. * @returns the current particle system
  12768. */
  12769. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12770. /**
  12771. * Adds a new velocity gradient
  12772. * @param gradient defines the gradient to use (between 0 and 1)
  12773. * @param factor defines the velocity to affect to the specified gradient
  12774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12775. * @returns the current particle system
  12776. */
  12777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12778. /**
  12779. * Remove a specific velocity gradient
  12780. * @param gradient defines the gradient to remove
  12781. * @returns the current particle system
  12782. */
  12783. removeVelocityGradient(gradient: number): IParticleSystem;
  12784. /**
  12785. * Adds a new limit velocity gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the limit velocity value to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific limit velocity gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new drag gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the drag value to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific drag gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeDragGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param factor defines the emit rate value to affect to the specified gradient
  12816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12817. * @returns the current particle system
  12818. */
  12819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific emit rate gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeEmitRateGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param factor defines the start size value to affect to the specified gradient
  12830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12831. * @returns the current particle system
  12832. */
  12833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific start size gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeStartSizeGradient(gradient: number): IParticleSystem;
  12840. private _createRampGradientTexture;
  12841. /**
  12842. * Gets the current list of ramp gradients.
  12843. * You must use addRampGradient and removeRampGradient to udpate this list
  12844. * @returns the list of ramp gradients
  12845. */
  12846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12847. /** Force the system to rebuild all gradients that need to be resync */
  12848. forceRefreshGradients(): void;
  12849. private _syncRampGradientTexture;
  12850. /**
  12851. * Adds a new ramp gradient used to remap particle colors
  12852. * @param gradient defines the gradient to use (between 0 and 1)
  12853. * @param color defines the color to affect to the specified gradient
  12854. * @returns the current particle system
  12855. */
  12856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12857. /**
  12858. * Remove a specific ramp gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeRampGradient(gradient: number): ParticleSystem;
  12863. /**
  12864. * Adds a new color gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param color1 defines the color to affect to the specified gradient
  12867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12868. * @returns this particle system
  12869. */
  12870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12871. /**
  12872. * Remove a specific color gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns this particle system
  12875. */
  12876. removeColorGradient(gradient: number): IParticleSystem;
  12877. private _fetchR;
  12878. protected _reset(): void;
  12879. private _resetEffect;
  12880. private _createVertexBuffers;
  12881. private _createIndexBuffer;
  12882. /**
  12883. * Gets the maximum number of particles active at the same time.
  12884. * @returns The max number of active particles.
  12885. */
  12886. getCapacity(): number;
  12887. /**
  12888. * Gets whether there are still active particles in the system.
  12889. * @returns True if it is alive, otherwise false.
  12890. */
  12891. isAlive(): boolean;
  12892. /**
  12893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12894. * @returns True if it has been started, otherwise false.
  12895. */
  12896. isStarted(): boolean;
  12897. private _prepareSubEmitterInternalArray;
  12898. /**
  12899. * Starts the particle system and begins to emit
  12900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12901. */
  12902. start(delay?: number): void;
  12903. /**
  12904. * Stops the particle system.
  12905. * @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.
  12906. */
  12907. stop(stopSubEmitters?: boolean): void;
  12908. /**
  12909. * Remove all active particles
  12910. */
  12911. reset(): void;
  12912. /**
  12913. * @hidden (for internal use only)
  12914. */
  12915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12916. /**
  12917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12918. * Its lifetime will start back at 0.
  12919. */
  12920. recycleParticle: (particle: Particle) => void;
  12921. private _stopSubEmitters;
  12922. private _createParticle;
  12923. private _removeFromRoot;
  12924. private _emitFromParticle;
  12925. private _update;
  12926. /** @hidden */
  12927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12928. /** @hidden */
  12929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12930. /**
  12931. * Fill the defines array according to the current settings of the particle system
  12932. * @param defines Array to be updated
  12933. * @param blendMode blend mode to take into account when updating the array
  12934. */
  12935. fillDefines(defines: Array<string>, blendMode: number): void;
  12936. /**
  12937. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12938. * @param uniforms Uniforms array to fill
  12939. * @param attributes Attributes array to fill
  12940. * @param samplers Samplers array to fill
  12941. */
  12942. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12943. /** @hidden */
  12944. private _getEffect;
  12945. /**
  12946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12948. */
  12949. animate(preWarmOnly?: boolean): void;
  12950. private _appendParticleVertices;
  12951. /**
  12952. * Rebuilds the particle system.
  12953. */
  12954. rebuild(): void;
  12955. /**
  12956. * Is this system ready to be used/rendered
  12957. * @return true if the system is ready
  12958. */
  12959. isReady(): boolean;
  12960. private _render;
  12961. /**
  12962. * Renders the particle system in its current state.
  12963. * @returns the current number of particles
  12964. */
  12965. render(): number;
  12966. /**
  12967. * Disposes the particle system and free the associated resources
  12968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12969. */
  12970. dispose(disposeTexture?: boolean): void;
  12971. /**
  12972. * Clones the particle system.
  12973. * @param name The name of the cloned object
  12974. * @param newEmitter The new emitter to use
  12975. * @returns the cloned particle system
  12976. */
  12977. clone(name: string, newEmitter: any): ParticleSystem;
  12978. /**
  12979. * Serializes the particle system to a JSON object
  12980. * @param serializeTexture defines if the texture must be serialized as well
  12981. * @returns the JSON object
  12982. */
  12983. serialize(serializeTexture?: boolean): any;
  12984. /** @hidden */
  12985. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12986. /** @hidden */
  12987. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12988. /**
  12989. * Parses a JSON object to create a particle system.
  12990. * @param parsedParticleSystem The JSON object to parse
  12991. * @param sceneOrEngine The scene or the engine to create the particle system in
  12992. * @param rootUrl The root url to use to load external dependencies like texture
  12993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12994. * @returns the Parsed particle system
  12995. */
  12996. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * A particle represents one of the element emitted by a particle system.
  13002. * This is mainly define by its coordinates, direction, velocity and age.
  13003. */
  13004. export class Particle {
  13005. /**
  13006. * The particle system the particle belongs to.
  13007. */
  13008. particleSystem: ParticleSystem;
  13009. private static _Count;
  13010. /**
  13011. * Unique ID of the particle
  13012. */
  13013. id: number;
  13014. /**
  13015. * The world position of the particle in the scene.
  13016. */
  13017. position: Vector3;
  13018. /**
  13019. * The world direction of the particle in the scene.
  13020. */
  13021. direction: Vector3;
  13022. /**
  13023. * The color of the particle.
  13024. */
  13025. color: Color4;
  13026. /**
  13027. * The color change of the particle per step.
  13028. */
  13029. colorStep: Color4;
  13030. /**
  13031. * Defines how long will the life of the particle be.
  13032. */
  13033. lifeTime: number;
  13034. /**
  13035. * The current age of the particle.
  13036. */
  13037. age: number;
  13038. /**
  13039. * The current size of the particle.
  13040. */
  13041. size: number;
  13042. /**
  13043. * The current scale of the particle.
  13044. */
  13045. scale: Vector2;
  13046. /**
  13047. * The current angle of the particle.
  13048. */
  13049. angle: number;
  13050. /**
  13051. * Defines how fast is the angle changing.
  13052. */
  13053. angularSpeed: number;
  13054. /**
  13055. * Defines the cell index used by the particle to be rendered from a sprite.
  13056. */
  13057. cellIndex: number;
  13058. /**
  13059. * The information required to support color remapping
  13060. */
  13061. remapData: Vector4;
  13062. /** @hidden */
  13063. _randomCellOffset?: number;
  13064. /** @hidden */
  13065. _initialDirection: Nullable<Vector3>;
  13066. /** @hidden */
  13067. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13068. /** @hidden */
  13069. _initialStartSpriteCellID: number;
  13070. /** @hidden */
  13071. _initialEndSpriteCellID: number;
  13072. /** @hidden */
  13073. _currentColorGradient: Nullable<ColorGradient>;
  13074. /** @hidden */
  13075. _currentColor1: Color4;
  13076. /** @hidden */
  13077. _currentColor2: Color4;
  13078. /** @hidden */
  13079. _currentSizeGradient: Nullable<FactorGradient>;
  13080. /** @hidden */
  13081. _currentSize1: number;
  13082. /** @hidden */
  13083. _currentSize2: number;
  13084. /** @hidden */
  13085. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13086. /** @hidden */
  13087. _currentAngularSpeed1: number;
  13088. /** @hidden */
  13089. _currentAngularSpeed2: number;
  13090. /** @hidden */
  13091. _currentVelocityGradient: Nullable<FactorGradient>;
  13092. /** @hidden */
  13093. _currentVelocity1: number;
  13094. /** @hidden */
  13095. _currentVelocity2: number;
  13096. /** @hidden */
  13097. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13098. /** @hidden */
  13099. _currentLimitVelocity1: number;
  13100. /** @hidden */
  13101. _currentLimitVelocity2: number;
  13102. /** @hidden */
  13103. _currentDragGradient: Nullable<FactorGradient>;
  13104. /** @hidden */
  13105. _currentDrag1: number;
  13106. /** @hidden */
  13107. _currentDrag2: number;
  13108. /** @hidden */
  13109. _randomNoiseCoordinates1: Vector3;
  13110. /** @hidden */
  13111. _randomNoiseCoordinates2: Vector3;
  13112. /** @hidden */
  13113. _localPosition?: Vector3;
  13114. /**
  13115. * Creates a new instance Particle
  13116. * @param particleSystem the particle system the particle belongs to
  13117. */
  13118. constructor(
  13119. /**
  13120. * The particle system the particle belongs to.
  13121. */
  13122. particleSystem: ParticleSystem);
  13123. private updateCellInfoFromSystem;
  13124. /**
  13125. * Defines how the sprite cell index is updated for the particle
  13126. */
  13127. updateCellIndex(): void;
  13128. /** @hidden */
  13129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13130. /** @hidden */
  13131. _inheritParticleInfoToSubEmitters(): void;
  13132. /** @hidden */
  13133. _reset(): void;
  13134. /**
  13135. * Copy the properties of particle to another one.
  13136. * @param other the particle to copy the information to.
  13137. */
  13138. copyTo(other: Particle): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter represents a volume emitting particles.
  13144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13145. */
  13146. export interface IParticleEmitterType {
  13147. /**
  13148. * Called by the particle System when the direction is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param directionToUpdate is the direction vector to update with the result
  13151. * @param particle is the particle we are computed the direction for
  13152. * @param isLocal defines if the direction should be set in local space
  13153. */
  13154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Called by the particle System when the position is computed for the created particle.
  13157. * @param worldMatrix is the world matrix of the particle system
  13158. * @param positionToUpdate is the position vector to update with the result
  13159. * @param particle is the particle we are computed the position for
  13160. * @param isLocal defines if the position should be set in local space
  13161. */
  13162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13163. /**
  13164. * Clones the current emitter and returns a copy of it
  13165. * @returns the new emitter
  13166. */
  13167. clone(): IParticleEmitterType;
  13168. /**
  13169. * Called by the GPUParticleSystem to setup the update shader
  13170. * @param effect defines the update shader
  13171. */
  13172. applyToShader(effect: Effect): void;
  13173. /**
  13174. * Returns a string to use to update the GPU particles update shader
  13175. * @returns the effect defines string
  13176. */
  13177. getEffectDefines(): string;
  13178. /**
  13179. * Returns a string representing the class name
  13180. * @returns a string containing the class name
  13181. */
  13182. getClassName(): string;
  13183. /**
  13184. * Serializes the particle system to a JSON object.
  13185. * @returns the JSON object
  13186. */
  13187. serialize(): any;
  13188. /**
  13189. * Parse properties from a JSON object
  13190. * @param serializationObject defines the JSON object
  13191. * @param scene defines the hosting scene
  13192. */
  13193. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. /**
  13198. * Particle emitter emitting particles from the inside of a box.
  13199. * It emits the particles randomly between 2 given directions.
  13200. */
  13201. export class BoxParticleEmitter implements IParticleEmitterType {
  13202. /**
  13203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13204. */
  13205. direction1: Vector3;
  13206. /**
  13207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13208. */
  13209. direction2: Vector3;
  13210. /**
  13211. * 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.
  13212. */
  13213. minEmitBox: Vector3;
  13214. /**
  13215. * 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.
  13216. */
  13217. maxEmitBox: Vector3;
  13218. /**
  13219. * Creates a new instance BoxParticleEmitter
  13220. */
  13221. constructor();
  13222. /**
  13223. * Called by the particle System when the direction is computed for the created particle.
  13224. * @param worldMatrix is the world matrix of the particle system
  13225. * @param directionToUpdate is the direction vector to update with the result
  13226. * @param particle is the particle we are computed the direction for
  13227. * @param isLocal defines if the direction should be set in local space
  13228. */
  13229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13230. /**
  13231. * Called by the particle System when the position is computed for the created particle.
  13232. * @param worldMatrix is the world matrix of the particle system
  13233. * @param positionToUpdate is the position vector to update with the result
  13234. * @param particle is the particle we are computed the position for
  13235. * @param isLocal defines if the position should be set in local space
  13236. */
  13237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): BoxParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "BoxParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cone.
  13273. * It emits the particles alongside the cone volume from the base to the particle.
  13274. * The emission direction might be randomized.
  13275. */
  13276. export class ConeParticleEmitter implements IParticleEmitterType {
  13277. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13278. directionRandomizer: number;
  13279. private _radius;
  13280. private _angle;
  13281. private _height;
  13282. /**
  13283. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13284. */
  13285. radiusRange: number;
  13286. /**
  13287. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13288. */
  13289. heightRange: number;
  13290. /**
  13291. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13292. */
  13293. emitFromSpawnPointOnly: boolean;
  13294. /**
  13295. * Gets or sets the radius of the emission cone
  13296. */
  13297. get radius(): number;
  13298. set radius(value: number);
  13299. /**
  13300. * Gets or sets the angle of the emission cone
  13301. */
  13302. get angle(): number;
  13303. set angle(value: number);
  13304. private _buildHeight;
  13305. /**
  13306. * Creates a new instance ConeParticleEmitter
  13307. * @param radius the radius of the emission cone (1 by default)
  13308. * @param angle the cone base angle (PI by default)
  13309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13310. */
  13311. constructor(radius?: number, angle?: number,
  13312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13313. directionRandomizer?: number);
  13314. /**
  13315. * Called by the particle System when the direction is computed for the created particle.
  13316. * @param worldMatrix is the world matrix of the particle system
  13317. * @param directionToUpdate is the direction vector to update with the result
  13318. * @param particle is the particle we are computed the direction for
  13319. * @param isLocal defines if the direction should be set in local space
  13320. */
  13321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13322. /**
  13323. * Called by the particle System when the position is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param positionToUpdate is the position vector to update with the result
  13326. * @param particle is the particle we are computed the position for
  13327. * @param isLocal defines if the position should be set in local space
  13328. */
  13329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Clones the current emitter and returns a copy of it
  13332. * @returns the new emitter
  13333. */
  13334. clone(): ConeParticleEmitter;
  13335. /**
  13336. * Called by the GPUParticleSystem to setup the update shader
  13337. * @param effect defines the update shader
  13338. */
  13339. applyToShader(effect: Effect): void;
  13340. /**
  13341. * Returns a string to use to update the GPU particles update shader
  13342. * @returns a string containng the defines string
  13343. */
  13344. getEffectDefines(): string;
  13345. /**
  13346. * Returns the string "ConeParticleEmitter"
  13347. * @returns a string containing the class name
  13348. */
  13349. getClassName(): string;
  13350. /**
  13351. * Serializes the particle system to a JSON object.
  13352. * @returns the JSON object
  13353. */
  13354. serialize(): any;
  13355. /**
  13356. * Parse properties from a JSON object
  13357. * @param serializationObject defines the JSON object
  13358. */
  13359. parse(serializationObject: any): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Particle emitter emitting particles from the inside of a cylinder.
  13365. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13366. */
  13367. export class CylinderParticleEmitter implements IParticleEmitterType {
  13368. /**
  13369. * The radius of the emission cylinder.
  13370. */
  13371. radius: number;
  13372. /**
  13373. * The height of the emission cylinder.
  13374. */
  13375. height: number;
  13376. /**
  13377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13378. */
  13379. radiusRange: number;
  13380. /**
  13381. * How much to randomize the particle direction [0-1].
  13382. */
  13383. directionRandomizer: number;
  13384. /**
  13385. * Creates a new instance CylinderParticleEmitter
  13386. * @param radius the radius of the emission cylinder (1 by default)
  13387. * @param height the height of the emission cylinder (1 by default)
  13388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13389. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13390. */
  13391. constructor(
  13392. /**
  13393. * The radius of the emission cylinder.
  13394. */
  13395. radius?: number,
  13396. /**
  13397. * The height of the emission cylinder.
  13398. */
  13399. height?: number,
  13400. /**
  13401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13402. */
  13403. radiusRange?: number,
  13404. /**
  13405. * How much to randomize the particle direction [0-1].
  13406. */
  13407. directionRandomizer?: number);
  13408. /**
  13409. * Called by the particle System when the direction is computed for the created particle.
  13410. * @param worldMatrix is the world matrix of the particle system
  13411. * @param directionToUpdate is the direction vector to update with the result
  13412. * @param particle is the particle we are computed the direction for
  13413. * @param isLocal defines if the direction should be set in local space
  13414. */
  13415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13416. /**
  13417. * Called by the particle System when the position is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param positionToUpdate is the position vector to update with the result
  13420. * @param particle is the particle we are computed the position for
  13421. * @param isLocal defines if the position should be set in local space
  13422. */
  13423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Clones the current emitter and returns a copy of it
  13426. * @returns the new emitter
  13427. */
  13428. clone(): CylinderParticleEmitter;
  13429. /**
  13430. * Called by the GPUParticleSystem to setup the update shader
  13431. * @param effect defines the update shader
  13432. */
  13433. applyToShader(effect: Effect): void;
  13434. /**
  13435. * Returns a string to use to update the GPU particles update shader
  13436. * @returns a string containng the defines string
  13437. */
  13438. getEffectDefines(): string;
  13439. /**
  13440. * Returns the string "CylinderParticleEmitter"
  13441. * @returns a string containing the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Serializes the particle system to a JSON object.
  13446. * @returns the JSON object
  13447. */
  13448. serialize(): any;
  13449. /**
  13450. * Parse properties from a JSON object
  13451. * @param serializationObject defines the JSON object
  13452. */
  13453. parse(serializationObject: any): void;
  13454. }
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cylinder.
  13457. * It emits the particles randomly between two vectors.
  13458. */
  13459. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13460. /**
  13461. * The min limit of the emission direction.
  13462. */
  13463. direction1: Vector3;
  13464. /**
  13465. * The max limit of the emission direction.
  13466. */
  13467. direction2: Vector3;
  13468. /**
  13469. * Creates a new instance CylinderDirectedParticleEmitter
  13470. * @param radius the radius of the emission cylinder (1 by default)
  13471. * @param height the height of the emission cylinder (1 by default)
  13472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13473. * @param direction1 the min limit of the emission direction (up vector by default)
  13474. * @param direction2 the max limit of the emission direction (up vector by default)
  13475. */
  13476. constructor(radius?: number, height?: number, radiusRange?: number,
  13477. /**
  13478. * The min limit of the emission direction.
  13479. */
  13480. direction1?: Vector3,
  13481. /**
  13482. * The max limit of the emission direction.
  13483. */
  13484. direction2?: Vector3);
  13485. /**
  13486. * Called by the particle System when the direction is computed for the created particle.
  13487. * @param worldMatrix is the world matrix of the particle system
  13488. * @param directionToUpdate is the direction vector to update with the result
  13489. * @param particle is the particle we are computed the direction for
  13490. */
  13491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13492. /**
  13493. * Clones the current emitter and returns a copy of it
  13494. * @returns the new emitter
  13495. */
  13496. clone(): CylinderDirectedParticleEmitter;
  13497. /**
  13498. * Called by the GPUParticleSystem to setup the update shader
  13499. * @param effect defines the update shader
  13500. */
  13501. applyToShader(effect: Effect): void;
  13502. /**
  13503. * Returns a string to use to update the GPU particles update shader
  13504. * @returns a string containng the defines string
  13505. */
  13506. getEffectDefines(): string;
  13507. /**
  13508. * Returns the string "CylinderDirectedParticleEmitter"
  13509. * @returns a string containing the class name
  13510. */
  13511. getClassName(): string;
  13512. /**
  13513. * Serializes the particle system to a JSON object.
  13514. * @returns the JSON object
  13515. */
  13516. serialize(): any;
  13517. /**
  13518. * Parse properties from a JSON object
  13519. * @param serializationObject defines the JSON object
  13520. */
  13521. parse(serializationObject: any): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * Particle emitter emitting particles from the inside of a hemisphere.
  13527. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13528. */
  13529. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13530. /**
  13531. * The radius of the emission hemisphere.
  13532. */
  13533. radius: number;
  13534. /**
  13535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13536. */
  13537. radiusRange: number;
  13538. /**
  13539. * How much to randomize the particle direction [0-1].
  13540. */
  13541. directionRandomizer: number;
  13542. /**
  13543. * Creates a new instance HemisphericParticleEmitter
  13544. * @param radius the radius of the emission hemisphere (1 by default)
  13545. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13547. */
  13548. constructor(
  13549. /**
  13550. * The radius of the emission hemisphere.
  13551. */
  13552. radius?: number,
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange?: number,
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer?: number);
  13561. /**
  13562. * Called by the particle System when the direction is computed for the created particle.
  13563. * @param worldMatrix is the world matrix of the particle system
  13564. * @param directionToUpdate is the direction vector to update with the result
  13565. * @param particle is the particle we are computed the direction for
  13566. * @param isLocal defines if the direction should be set in local space
  13567. */
  13568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13569. /**
  13570. * Called by the particle System when the position is computed for the created particle.
  13571. * @param worldMatrix is the world matrix of the particle system
  13572. * @param positionToUpdate is the position vector to update with the result
  13573. * @param particle is the particle we are computed the position for
  13574. * @param isLocal defines if the position should be set in local space
  13575. */
  13576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): HemisphericParticleEmitter;
  13582. /**
  13583. * Called by the GPUParticleSystem to setup the update shader
  13584. * @param effect defines the update shader
  13585. */
  13586. applyToShader(effect: Effect): void;
  13587. /**
  13588. * Returns a string to use to update the GPU particles update shader
  13589. * @returns a string containng the defines string
  13590. */
  13591. getEffectDefines(): string;
  13592. /**
  13593. * Returns the string "HemisphericParticleEmitter"
  13594. * @returns a string containing the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Serializes the particle system to a JSON object.
  13599. * @returns the JSON object
  13600. */
  13601. serialize(): any;
  13602. /**
  13603. * Parse properties from a JSON object
  13604. * @param serializationObject defines the JSON object
  13605. */
  13606. parse(serializationObject: any): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * Particle emitter emitting particles from a point.
  13612. * It emits the particles randomly between 2 given directions.
  13613. */
  13614. export class PointParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13617. */
  13618. direction1: Vector3;
  13619. /**
  13620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13621. */
  13622. direction2: Vector3;
  13623. /**
  13624. * Creates a new instance PointParticleEmitter
  13625. */
  13626. constructor();
  13627. /**
  13628. * Called by the particle System when the direction is computed for the created particle.
  13629. * @param worldMatrix is the world matrix of the particle system
  13630. * @param directionToUpdate is the direction vector to update with the result
  13631. * @param particle is the particle we are computed the direction for
  13632. * @param isLocal defines if the direction should be set in local space
  13633. */
  13634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13635. /**
  13636. * Called by the particle System when the position is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param positionToUpdate is the position vector to update with the result
  13639. * @param particle is the particle we are computed the position for
  13640. * @param isLocal defines if the position should be set in local space
  13641. */
  13642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Clones the current emitter and returns a copy of it
  13645. * @returns the new emitter
  13646. */
  13647. clone(): PointParticleEmitter;
  13648. /**
  13649. * Called by the GPUParticleSystem to setup the update shader
  13650. * @param effect defines the update shader
  13651. */
  13652. applyToShader(effect: Effect): void;
  13653. /**
  13654. * Returns a string to use to update the GPU particles update shader
  13655. * @returns a string containng the defines string
  13656. */
  13657. getEffectDefines(): string;
  13658. /**
  13659. * Returns the string "PointParticleEmitter"
  13660. * @returns a string containing the class name
  13661. */
  13662. getClassName(): string;
  13663. /**
  13664. * Serializes the particle system to a JSON object.
  13665. * @returns the JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Parse properties from a JSON object
  13670. * @param serializationObject defines the JSON object
  13671. */
  13672. parse(serializationObject: any): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a sphere.
  13678. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13679. */
  13680. export class SphereParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission sphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance SphereParticleEmitter
  13695. * @param radius the radius of the emission sphere (1 by default)
  13696. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission sphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): SphereParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "SphereParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. /**
  13760. * Particle emitter emitting particles from the inside of a sphere.
  13761. * It emits the particles randomly between two vectors.
  13762. */
  13763. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13764. /**
  13765. * The min limit of the emission direction.
  13766. */
  13767. direction1: Vector3;
  13768. /**
  13769. * The max limit of the emission direction.
  13770. */
  13771. direction2: Vector3;
  13772. /**
  13773. * Creates a new instance SphereDirectedParticleEmitter
  13774. * @param radius the radius of the emission sphere (1 by default)
  13775. * @param direction1 the min limit of the emission direction (up vector by default)
  13776. * @param direction2 the max limit of the emission direction (up vector by default)
  13777. */
  13778. constructor(radius?: number,
  13779. /**
  13780. * The min limit of the emission direction.
  13781. */
  13782. direction1?: Vector3,
  13783. /**
  13784. * The max limit of the emission direction.
  13785. */
  13786. direction2?: Vector3);
  13787. /**
  13788. * Called by the particle System when the direction is computed for the created particle.
  13789. * @param worldMatrix is the world matrix of the particle system
  13790. * @param directionToUpdate is the direction vector to update with the result
  13791. * @param particle is the particle we are computed the direction for
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): SphereDirectedParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "SphereDirectedParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module BABYLON {
  13827. /**
  13828. * Particle emitter emitting particles from a custom list of positions.
  13829. */
  13830. export class CustomParticleEmitter implements IParticleEmitterType {
  13831. /**
  13832. * Gets or sets the position generator that will create the inital position of each particle.
  13833. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13834. */
  13835. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13836. /**
  13837. * Gets or sets the destination generator that will create the final destination of each particle.
  13838. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13839. */
  13840. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13841. /**
  13842. * Creates a new instance CustomParticleEmitter
  13843. */
  13844. constructor();
  13845. /**
  13846. * Called by the particle System when the direction is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param directionToUpdate is the direction vector to update with the result
  13849. * @param particle is the particle we are computed the direction for
  13850. * @param isLocal defines if the direction should be set in local space
  13851. */
  13852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Called by the particle System when the position is computed for the created particle.
  13855. * @param worldMatrix is the world matrix of the particle system
  13856. * @param positionToUpdate is the position vector to update with the result
  13857. * @param particle is the particle we are computed the position for
  13858. * @param isLocal defines if the position should be set in local space
  13859. */
  13860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13861. /**
  13862. * Clones the current emitter and returns a copy of it
  13863. * @returns the new emitter
  13864. */
  13865. clone(): CustomParticleEmitter;
  13866. /**
  13867. * Called by the GPUParticleSystem to setup the update shader
  13868. * @param effect defines the update shader
  13869. */
  13870. applyToShader(effect: Effect): void;
  13871. /**
  13872. * Returns a string to use to update the GPU particles update shader
  13873. * @returns a string containng the defines string
  13874. */
  13875. getEffectDefines(): string;
  13876. /**
  13877. * Returns the string "PointParticleEmitter"
  13878. * @returns a string containing the class name
  13879. */
  13880. getClassName(): string;
  13881. /**
  13882. * Serializes the particle system to a JSON object.
  13883. * @returns the JSON object
  13884. */
  13885. serialize(): any;
  13886. /**
  13887. * Parse properties from a JSON object
  13888. * @param serializationObject defines the JSON object
  13889. */
  13890. parse(serializationObject: any): void;
  13891. }
  13892. }
  13893. declare module BABYLON {
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a box.
  13896. * It emits the particles randomly between 2 given directions.
  13897. */
  13898. export class MeshParticleEmitter implements IParticleEmitterType {
  13899. private _indices;
  13900. private _positions;
  13901. private _normals;
  13902. private _storedNormal;
  13903. private _mesh;
  13904. /**
  13905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13914. */
  13915. useMeshNormalsForDirection: boolean;
  13916. /** Defines the mesh to use as source */
  13917. get mesh(): Nullable<AbstractMesh>;
  13918. set mesh(value: Nullable<AbstractMesh>);
  13919. /**
  13920. * Creates a new instance MeshParticleEmitter
  13921. * @param mesh defines the mesh to use as source
  13922. */
  13923. constructor(mesh?: Nullable<AbstractMesh>);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): MeshParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "BoxParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. * @param scene defines the hosting scene
  13969. */
  13970. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. /**
  13975. * Interface representing a particle system in Babylon.js.
  13976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13978. */
  13979. export interface IParticleSystem {
  13980. /**
  13981. * List of animations used by the particle system.
  13982. */
  13983. animations: Animation[];
  13984. /**
  13985. * The id of the Particle system.
  13986. */
  13987. id: string;
  13988. /**
  13989. * The name of the Particle system.
  13990. */
  13991. name: string;
  13992. /**
  13993. * The emitter represents the Mesh or position we are attaching the particle system to.
  13994. */
  13995. emitter: Nullable<AbstractMesh | Vector3>;
  13996. /**
  13997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13998. */
  13999. isBillboardBased: boolean;
  14000. /**
  14001. * The rendering group used by the Particle system to chose when to render.
  14002. */
  14003. renderingGroupId: number;
  14004. /**
  14005. * The layer mask we are rendering the particles through.
  14006. */
  14007. layerMask: number;
  14008. /**
  14009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14010. */
  14011. updateSpeed: number;
  14012. /**
  14013. * The amount of time the particle system is running (depends of the overall update speed).
  14014. */
  14015. targetStopDuration: number;
  14016. /**
  14017. * The texture used to render each particle. (this can be a spritesheet)
  14018. */
  14019. particleTexture: Nullable<BaseTexture>;
  14020. /**
  14021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14022. */
  14023. blendMode: number;
  14024. /**
  14025. * Minimum life time of emitting particles.
  14026. */
  14027. minLifeTime: number;
  14028. /**
  14029. * Maximum life time of emitting particles.
  14030. */
  14031. maxLifeTime: number;
  14032. /**
  14033. * Minimum Size of emitting particles.
  14034. */
  14035. minSize: number;
  14036. /**
  14037. * Maximum Size of emitting particles.
  14038. */
  14039. maxSize: number;
  14040. /**
  14041. * Minimum scale of emitting particles on X axis.
  14042. */
  14043. minScaleX: number;
  14044. /**
  14045. * Maximum scale of emitting particles on X axis.
  14046. */
  14047. maxScaleX: number;
  14048. /**
  14049. * Minimum scale of emitting particles on Y axis.
  14050. */
  14051. minScaleY: number;
  14052. /**
  14053. * Maximum scale of emitting particles on Y axis.
  14054. */
  14055. maxScaleY: number;
  14056. /**
  14057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14058. */
  14059. color1: Color4;
  14060. /**
  14061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14062. */
  14063. color2: Color4;
  14064. /**
  14065. * Color the particle will have at the end of its lifetime.
  14066. */
  14067. colorDead: Color4;
  14068. /**
  14069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14070. */
  14071. emitRate: number;
  14072. /**
  14073. * You can use gravity if you want to give an orientation to your particles.
  14074. */
  14075. gravity: Vector3;
  14076. /**
  14077. * Minimum power of emitting particles.
  14078. */
  14079. minEmitPower: number;
  14080. /**
  14081. * Maximum power of emitting particles.
  14082. */
  14083. maxEmitPower: number;
  14084. /**
  14085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14086. */
  14087. minAngularSpeed: number;
  14088. /**
  14089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14090. */
  14091. maxAngularSpeed: number;
  14092. /**
  14093. * Gets or sets the minimal initial rotation in radians.
  14094. */
  14095. minInitialRotation: number;
  14096. /**
  14097. * Gets or sets the maximal initial rotation in radians.
  14098. */
  14099. maxInitialRotation: number;
  14100. /**
  14101. * The particle emitter type defines the emitter used by the particle system.
  14102. * It can be for example box, sphere, or cone...
  14103. */
  14104. particleEmitterType: Nullable<IParticleEmitterType>;
  14105. /**
  14106. * Defines the delay in milliseconds before starting the system (0 by default)
  14107. */
  14108. startDelay: number;
  14109. /**
  14110. * 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
  14111. */
  14112. preWarmCycles: number;
  14113. /**
  14114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14115. */
  14116. preWarmStepOffset: number;
  14117. /**
  14118. * 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)
  14119. */
  14120. spriteCellChangeSpeed: number;
  14121. /**
  14122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14123. */
  14124. startSpriteCellID: number;
  14125. /**
  14126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14127. */
  14128. endSpriteCellID: number;
  14129. /**
  14130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14131. */
  14132. spriteCellWidth: number;
  14133. /**
  14134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14135. */
  14136. spriteCellHeight: number;
  14137. /**
  14138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14139. */
  14140. spriteRandomStartCell: boolean;
  14141. /**
  14142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14143. */
  14144. isAnimationSheetEnabled: boolean;
  14145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14146. translationPivot: Vector2;
  14147. /**
  14148. * Gets or sets a texture used to add random noise to particle positions
  14149. */
  14150. noiseTexture: Nullable<BaseTexture>;
  14151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14152. noiseStrength: Vector3;
  14153. /**
  14154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14156. */
  14157. billboardMode: number;
  14158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14159. limitVelocityDamping: number;
  14160. /**
  14161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14162. */
  14163. beginAnimationOnStart: boolean;
  14164. /**
  14165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14166. */
  14167. beginAnimationFrom: number;
  14168. /**
  14169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14170. */
  14171. beginAnimationTo: number;
  14172. /**
  14173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14174. */
  14175. beginAnimationLoop: boolean;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Specifies if the particles are updated in emitter local space or world space
  14182. */
  14183. isLocal: boolean;
  14184. /** Snippet ID if the particle system was created from the snippet server */
  14185. snippetId: string;
  14186. /** Gets or sets a matrix to use to compute projection */
  14187. defaultProjectionMatrix: Matrix;
  14188. /**
  14189. * Gets the maximum number of particles active at the same time.
  14190. * @returns The max number of active particles.
  14191. */
  14192. getCapacity(): number;
  14193. /**
  14194. * Gets the number of particles active at the same time.
  14195. * @returns The number of active particles.
  14196. */
  14197. getActiveCount(): number;
  14198. /**
  14199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14200. * @returns True if it has been started, otherwise false.
  14201. */
  14202. isStarted(): boolean;
  14203. /**
  14204. * Animates the particle system for this frame.
  14205. */
  14206. animate(): void;
  14207. /**
  14208. * Renders the particle system in its current state.
  14209. * @returns the current number of particles
  14210. */
  14211. render(): number;
  14212. /**
  14213. * Dispose the particle system and frees its associated resources.
  14214. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14215. */
  14216. dispose(disposeTexture?: boolean): void;
  14217. /**
  14218. * An event triggered when the system is disposed
  14219. */
  14220. onDisposeObservable: Observable<IParticleSystem>;
  14221. /**
  14222. * Clones the particle system.
  14223. * @param name The name of the cloned object
  14224. * @param newEmitter The new emitter to use
  14225. * @returns the cloned particle system
  14226. */
  14227. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14228. /**
  14229. * Serializes the particle system to a JSON object
  14230. * @param serializeTexture defines if the texture must be serialized as well
  14231. * @returns the JSON object
  14232. */
  14233. serialize(serializeTexture: boolean): any;
  14234. /**
  14235. * Rebuild the particle system
  14236. */
  14237. rebuild(): void;
  14238. /** Force the system to rebuild all gradients that need to be resync */
  14239. forceRefreshGradients(): void;
  14240. /**
  14241. * Starts the particle system and begins to emit
  14242. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14243. */
  14244. start(delay?: number): void;
  14245. /**
  14246. * Stops the particle system.
  14247. */
  14248. stop(): void;
  14249. /**
  14250. * Remove all active particles
  14251. */
  14252. reset(): void;
  14253. /**
  14254. * Gets a boolean indicating that the system is stopping
  14255. * @returns true if the system is currently stopping
  14256. */
  14257. isStopping(): boolean;
  14258. /**
  14259. * Is this system ready to be used/rendered
  14260. * @return true if the system is ready
  14261. */
  14262. isReady(): boolean;
  14263. /**
  14264. * Returns the string "ParticleSystem"
  14265. * @returns a string containing the class name
  14266. */
  14267. getClassName(): string;
  14268. /**
  14269. * Gets the custom effect used to render the particles
  14270. * @param blendMode Blend mode for which the effect should be retrieved
  14271. * @returns The effect
  14272. */
  14273. getCustomEffect(blendMode: number): Nullable<Effect>;
  14274. /**
  14275. * Sets the custom effect used to render the particles
  14276. * @param effect The effect to set
  14277. * @param blendMode Blend mode for which the effect should be set
  14278. */
  14279. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14280. /**
  14281. * Fill the defines array according to the current settings of the particle system
  14282. * @param defines Array to be updated
  14283. * @param blendMode blend mode to take into account when updating the array
  14284. */
  14285. fillDefines(defines: Array<string>, blendMode: number): void;
  14286. /**
  14287. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14288. * @param uniforms Uniforms array to fill
  14289. * @param attributes Attributes array to fill
  14290. * @param samplers Samplers array to fill
  14291. */
  14292. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14293. /**
  14294. * Observable that will be called just before the particles are drawn
  14295. */
  14296. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14297. /**
  14298. * Gets the name of the particle vertex shader
  14299. */
  14300. vertexShaderName: string;
  14301. /**
  14302. * Adds a new color gradient
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color1 defines the color to affect to the specified gradient
  14305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14306. * @returns the current particle system
  14307. */
  14308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14309. /**
  14310. * Remove a specific color gradient
  14311. * @param gradient defines the gradient to remove
  14312. * @returns the current particle system
  14313. */
  14314. removeColorGradient(gradient: number): IParticleSystem;
  14315. /**
  14316. * Adds a new size gradient
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the size factor to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific size gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeSizeGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of color gradients.
  14331. * You must use addColorGradient and removeColorGradient to udpate this list
  14332. * @returns the list of color gradients
  14333. */
  14334. getColorGradients(): Nullable<Array<ColorGradient>>;
  14335. /**
  14336. * Gets the current list of size gradients.
  14337. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14338. * @returns the list of size gradients
  14339. */
  14340. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14341. /**
  14342. * Gets the current list of angular speed gradients.
  14343. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14344. * @returns the list of angular speed gradients
  14345. */
  14346. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new angular speed gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the angular speed to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific angular speed gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of velocity gradients.
  14363. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14364. * @returns the list of velocity gradients
  14365. */
  14366. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Adds a new velocity gradient
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param factor defines the velocity to affect to the specified gradient
  14371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14372. * @returns the current particle system
  14373. */
  14374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14375. /**
  14376. * Remove a specific velocity gradient
  14377. * @param gradient defines the gradient to remove
  14378. * @returns the current particle system
  14379. */
  14380. removeVelocityGradient(gradient: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of limit velocity gradients.
  14383. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14384. * @returns the list of limit velocity gradients
  14385. */
  14386. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new limit velocity gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the limit velocity to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific limit velocity gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Adds a new drag gradient
  14403. * @param gradient defines the gradient to use (between 0 and 1)
  14404. * @param factor defines the drag to affect to the specified gradient
  14405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14406. * @returns the current particle system
  14407. */
  14408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14409. /**
  14410. * Remove a specific drag gradient
  14411. * @param gradient defines the gradient to remove
  14412. * @returns the current particle system
  14413. */
  14414. removeDragGradient(gradient: number): IParticleSystem;
  14415. /**
  14416. * Gets the current list of drag gradients.
  14417. * You must use addDragGradient and removeDragGradient to udpate this list
  14418. * @returns the list of drag gradients
  14419. */
  14420. getDragGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the emit rate to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific emit rate gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeEmitRateGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of emit rate gradients.
  14437. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14438. * @returns the list of emit rate gradients
  14439. */
  14440. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the start size to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific start size gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeStartSizeGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of start size gradients.
  14457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14458. * @returns the list of start size gradients
  14459. */
  14460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new life time gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the life time factor to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific life time gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of life time gradients.
  14477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14478. * @returns the list of life time gradients
  14479. */
  14480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of color gradients.
  14483. * You must use addColorGradient and removeColorGradient to udpate this list
  14484. * @returns the list of color gradients
  14485. */
  14486. getColorGradients(): Nullable<Array<ColorGradient>>;
  14487. /**
  14488. * Adds a new ramp gradient used to remap particle colors
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param color defines the color to affect to the specified gradient
  14491. * @returns the current particle system
  14492. */
  14493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14494. /**
  14495. * Gets the current list of ramp gradients.
  14496. * You must use addRampGradient and removeRampGradient to udpate this list
  14497. * @returns the list of ramp gradients
  14498. */
  14499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14500. /** Gets or sets a boolean indicating that ramp gradients must be used
  14501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14502. */
  14503. useRampGradients: boolean;
  14504. /**
  14505. * Adds a new color remap gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param min defines the color remap minimal range
  14508. * @param max defines the color remap maximal range
  14509. * @returns the current particle system
  14510. */
  14511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of color remap gradients.
  14514. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14515. * @returns the list of color remap gradients
  14516. */
  14517. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new alpha remap gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param min defines the alpha remap minimal range
  14522. * @param max defines the alpha remap maximal range
  14523. * @returns the current particle system
  14524. */
  14525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. /**
  14597. * Get hosting scene
  14598. * @returns the scene
  14599. */
  14600. getScene(): Nullable<Scene>;
  14601. }
  14602. }
  14603. declare module BABYLON {
  14604. /**
  14605. * 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.
  14606. * @see https://doc.babylonjs.com/how_to/transformnode
  14607. */
  14608. export class TransformNode extends Node {
  14609. /**
  14610. * Object will not rotate to face the camera
  14611. */
  14612. static BILLBOARDMODE_NONE: number;
  14613. /**
  14614. * Object will rotate to face the camera but only on the x axis
  14615. */
  14616. static BILLBOARDMODE_X: number;
  14617. /**
  14618. * Object will rotate to face the camera but only on the y axis
  14619. */
  14620. static BILLBOARDMODE_Y: number;
  14621. /**
  14622. * Object will rotate to face the camera but only on the z axis
  14623. */
  14624. static BILLBOARDMODE_Z: number;
  14625. /**
  14626. * Object will rotate to face the camera
  14627. */
  14628. static BILLBOARDMODE_ALL: number;
  14629. /**
  14630. * Object will rotate to face the camera's position instead of orientation
  14631. */
  14632. static BILLBOARDMODE_USE_POSITION: number;
  14633. private static _TmpRotation;
  14634. private static _TmpScaling;
  14635. private static _TmpTranslation;
  14636. private _forward;
  14637. private _forwardInverted;
  14638. private _up;
  14639. private _right;
  14640. private _rightInverted;
  14641. private _position;
  14642. private _rotation;
  14643. private _rotationQuaternion;
  14644. protected _scaling: Vector3;
  14645. protected _isDirty: boolean;
  14646. private _transformToBoneReferal;
  14647. private _isAbsoluteSynced;
  14648. private _billboardMode;
  14649. /**
  14650. * Gets or sets the billboard mode. Default is 0.
  14651. *
  14652. * | Value | Type | Description |
  14653. * | --- | --- | --- |
  14654. * | 0 | BILLBOARDMODE_NONE | |
  14655. * | 1 | BILLBOARDMODE_X | |
  14656. * | 2 | BILLBOARDMODE_Y | |
  14657. * | 4 | BILLBOARDMODE_Z | |
  14658. * | 7 | BILLBOARDMODE_ALL | |
  14659. *
  14660. */
  14661. get billboardMode(): number;
  14662. set billboardMode(value: number);
  14663. private _preserveParentRotationForBillboard;
  14664. /**
  14665. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14666. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14667. */
  14668. get preserveParentRotationForBillboard(): boolean;
  14669. set preserveParentRotationForBillboard(value: boolean);
  14670. /**
  14671. * 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
  14672. */
  14673. scalingDeterminant: number;
  14674. private _infiniteDistance;
  14675. /**
  14676. * Gets or sets the distance of the object to max, often used by skybox
  14677. */
  14678. get infiniteDistance(): boolean;
  14679. set infiniteDistance(value: boolean);
  14680. /**
  14681. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14682. * By default the system will update normals to compensate
  14683. */
  14684. ignoreNonUniformScaling: boolean;
  14685. /**
  14686. * 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
  14687. */
  14688. reIntegrateRotationIntoRotationQuaternion: boolean;
  14689. /** @hidden */
  14690. _poseMatrix: Nullable<Matrix>;
  14691. /** @hidden */
  14692. _localMatrix: Matrix;
  14693. private _usePivotMatrix;
  14694. private _absolutePosition;
  14695. private _absoluteScaling;
  14696. private _absoluteRotationQuaternion;
  14697. private _pivotMatrix;
  14698. private _pivotMatrixInverse;
  14699. /** @hidden */
  14700. _postMultiplyPivotMatrix: boolean;
  14701. protected _isWorldMatrixFrozen: boolean;
  14702. /** @hidden */
  14703. _indexInSceneTransformNodesArray: number;
  14704. /**
  14705. * An event triggered after the world matrix is updated
  14706. */
  14707. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14708. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14709. /**
  14710. * Gets a string identifying the name of the class
  14711. * @returns "TransformNode" string
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14716. */
  14717. get position(): Vector3;
  14718. set position(newPosition: Vector3);
  14719. /**
  14720. * 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)).
  14721. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14722. */
  14723. get rotation(): Vector3;
  14724. set rotation(newRotation: Vector3);
  14725. /**
  14726. * 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)).
  14727. */
  14728. get scaling(): Vector3;
  14729. set scaling(newScaling: Vector3);
  14730. /**
  14731. * 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).
  14732. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14733. */
  14734. get rotationQuaternion(): Nullable<Quaternion>;
  14735. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14736. /**
  14737. * The forward direction of that transform in world space.
  14738. */
  14739. get forward(): Vector3;
  14740. /**
  14741. * The up direction of that transform in world space.
  14742. */
  14743. get up(): Vector3;
  14744. /**
  14745. * The right direction of that transform in world space.
  14746. */
  14747. get right(): Vector3;
  14748. /**
  14749. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14750. * @param matrix the matrix to copy the pose from
  14751. * @returns this TransformNode.
  14752. */
  14753. updatePoseMatrix(matrix: Matrix): TransformNode;
  14754. /**
  14755. * Returns the mesh Pose matrix.
  14756. * @returns the pose matrix
  14757. */
  14758. getPoseMatrix(): Matrix;
  14759. /** @hidden */
  14760. _isSynchronized(): boolean;
  14761. /** @hidden */
  14762. _initCache(): void;
  14763. /**
  14764. * Flag the transform node as dirty (Forcing it to update everything)
  14765. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14766. * @returns this transform node
  14767. */
  14768. markAsDirty(property: string): TransformNode;
  14769. /**
  14770. * Returns the current mesh absolute position.
  14771. * Returns a Vector3.
  14772. */
  14773. get absolutePosition(): Vector3;
  14774. /**
  14775. * Returns the current mesh absolute scaling.
  14776. * Returns a Vector3.
  14777. */
  14778. get absoluteScaling(): Vector3;
  14779. /**
  14780. * Returns the current mesh absolute rotation.
  14781. * Returns a Quaternion.
  14782. */
  14783. get absoluteRotationQuaternion(): Quaternion;
  14784. /**
  14785. * Sets a new matrix to apply before all other transformation
  14786. * @param matrix defines the transform matrix
  14787. * @returns the current TransformNode
  14788. */
  14789. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14790. /**
  14791. * Sets a new pivot matrix to the current node
  14792. * @param matrix defines the new pivot matrix to use
  14793. * @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
  14794. * @returns the current TransformNode
  14795. */
  14796. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14797. /**
  14798. * Returns the mesh pivot matrix.
  14799. * Default : Identity.
  14800. * @returns the matrix
  14801. */
  14802. getPivotMatrix(): Matrix;
  14803. /**
  14804. * Instantiate (when possible) or clone that node with its hierarchy
  14805. * @param newParent defines the new parent to use for the instance (or clone)
  14806. * @param options defines options to configure how copy is done
  14807. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14808. * @returns an instance (or a clone) of the current node with its hiearchy
  14809. */
  14810. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14811. doNotInstantiate: boolean;
  14812. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14813. /**
  14814. * Prevents the World matrix to be computed any longer
  14815. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14816. * @returns the TransformNode.
  14817. */
  14818. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14819. /**
  14820. * Allows back the World matrix computation.
  14821. * @returns the TransformNode.
  14822. */
  14823. unfreezeWorldMatrix(): this;
  14824. /**
  14825. * True if the World matrix has been frozen.
  14826. */
  14827. get isWorldMatrixFrozen(): boolean;
  14828. /**
  14829. * Retuns the mesh absolute position in the World.
  14830. * @returns a Vector3.
  14831. */
  14832. getAbsolutePosition(): Vector3;
  14833. /**
  14834. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14835. * @param absolutePosition the absolute position to set
  14836. * @returns the TransformNode.
  14837. */
  14838. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14839. /**
  14840. * Sets the mesh position in its local space.
  14841. * @param vector3 the position to set in localspace
  14842. * @returns the TransformNode.
  14843. */
  14844. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14845. /**
  14846. * Returns the mesh position in the local space from the current World matrix values.
  14847. * @returns a new Vector3.
  14848. */
  14849. getPositionExpressedInLocalSpace(): Vector3;
  14850. /**
  14851. * Translates the mesh along the passed Vector3 in its local space.
  14852. * @param vector3 the distance to translate in localspace
  14853. * @returns the TransformNode.
  14854. */
  14855. locallyTranslate(vector3: Vector3): TransformNode;
  14856. private static _lookAtVectorCache;
  14857. /**
  14858. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14859. * @param targetPoint the position (must be in same space as current mesh) to look at
  14860. * @param yawCor optional yaw (y-axis) correction in radians
  14861. * @param pitchCor optional pitch (x-axis) correction in radians
  14862. * @param rollCor optional roll (z-axis) correction in radians
  14863. * @param space the choosen space of the target
  14864. * @returns the TransformNode.
  14865. */
  14866. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14867. /**
  14868. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14869. * This Vector3 is expressed in the World space.
  14870. * @param localAxis axis to rotate
  14871. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14872. */
  14873. getDirection(localAxis: Vector3): Vector3;
  14874. /**
  14875. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14876. * localAxis is expressed in the mesh local space.
  14877. * result is computed in the Wordl space from the mesh World matrix.
  14878. * @param localAxis axis to rotate
  14879. * @param result the resulting transformnode
  14880. * @returns this TransformNode.
  14881. */
  14882. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14883. /**
  14884. * Sets this transform node rotation to the given local axis.
  14885. * @param localAxis the axis in local space
  14886. * @param yawCor optional yaw (y-axis) correction in radians
  14887. * @param pitchCor optional pitch (x-axis) correction in radians
  14888. * @param rollCor optional roll (z-axis) correction in radians
  14889. * @returns this TransformNode
  14890. */
  14891. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14892. /**
  14893. * Sets a new pivot point to the current node
  14894. * @param point defines the new pivot point to use
  14895. * @param space defines if the point is in world or local space (local by default)
  14896. * @returns the current TransformNode
  14897. */
  14898. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14899. /**
  14900. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14901. * @returns the pivot point
  14902. */
  14903. getPivotPoint(): Vector3;
  14904. /**
  14905. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14906. * @param result the vector3 to store the result
  14907. * @returns this TransformNode.
  14908. */
  14909. getPivotPointToRef(result: Vector3): TransformNode;
  14910. /**
  14911. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14913. */
  14914. getAbsolutePivotPoint(): Vector3;
  14915. /**
  14916. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14917. * @param result vector3 to store the result
  14918. * @returns this TransformNode.
  14919. */
  14920. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14921. /**
  14922. * Defines the passed node as the parent of the current node.
  14923. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14924. * @see https://doc.babylonjs.com/how_to/parenting
  14925. * @param node the node ot set as the parent
  14926. * @returns this TransformNode.
  14927. */
  14928. setParent(node: Nullable<Node>): TransformNode;
  14929. private _nonUniformScaling;
  14930. /**
  14931. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14932. */
  14933. get nonUniformScaling(): boolean;
  14934. /** @hidden */
  14935. _updateNonUniformScalingState(value: boolean): boolean;
  14936. /**
  14937. * Attach the current TransformNode to another TransformNode associated with a bone
  14938. * @param bone Bone affecting the TransformNode
  14939. * @param affectedTransformNode TransformNode associated with the bone
  14940. * @returns this object
  14941. */
  14942. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14943. /**
  14944. * Detach the transform node if its associated with a bone
  14945. * @returns this object
  14946. */
  14947. detachFromBone(): TransformNode;
  14948. private static _rotationAxisCache;
  14949. /**
  14950. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14951. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14952. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14953. * The passed axis is also normalized.
  14954. * @param axis the axis to rotate around
  14955. * @param amount the amount to rotate in radians
  14956. * @param space Space to rotate in (Default: local)
  14957. * @returns the TransformNode.
  14958. */
  14959. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14960. /**
  14961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14962. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14963. * The passed axis is also normalized. .
  14964. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14965. * @param point the point to rotate around
  14966. * @param axis the axis to rotate around
  14967. * @param amount the amount to rotate in radians
  14968. * @returns the TransformNode
  14969. */
  14970. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14971. /**
  14972. * Translates the mesh along the axis vector for the passed distance in the given space.
  14973. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14974. * @param axis the axis to translate in
  14975. * @param distance the distance to translate
  14976. * @param space Space to rotate in (Default: local)
  14977. * @returns the TransformNode.
  14978. */
  14979. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14980. /**
  14981. * Adds a rotation step to the mesh current rotation.
  14982. * x, y, z are Euler angles expressed in radians.
  14983. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14984. * This means this rotation is made in the mesh local space only.
  14985. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14986. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14987. * ```javascript
  14988. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14989. * ```
  14990. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14991. * 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.
  14992. * @param x Rotation to add
  14993. * @param y Rotation to add
  14994. * @param z Rotation to add
  14995. * @returns the TransformNode.
  14996. */
  14997. addRotation(x: number, y: number, z: number): TransformNode;
  14998. /**
  14999. * @hidden
  15000. */
  15001. protected _getEffectiveParent(): Nullable<Node>;
  15002. /**
  15003. * Computes the world matrix of the node
  15004. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15005. * @returns the world matrix
  15006. */
  15007. computeWorldMatrix(force?: boolean): Matrix;
  15008. /**
  15009. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15010. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15011. */
  15012. resetLocalMatrix(independentOfChildren?: boolean): void;
  15013. protected _afterComputeWorldMatrix(): void;
  15014. /**
  15015. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15016. * @param func callback function to add
  15017. *
  15018. * @returns the TransformNode.
  15019. */
  15020. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15021. /**
  15022. * Removes a registered callback function.
  15023. * @param func callback function to remove
  15024. * @returns the TransformNode.
  15025. */
  15026. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15027. /**
  15028. * Gets the position of the current mesh in camera space
  15029. * @param camera defines the camera to use
  15030. * @returns a position
  15031. */
  15032. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15033. /**
  15034. * Returns the distance from the mesh to the active camera
  15035. * @param camera defines the camera to use
  15036. * @returns the distance
  15037. */
  15038. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15039. /**
  15040. * Clone the current transform node
  15041. * @param name Name of the new clone
  15042. * @param newParent New parent for the clone
  15043. * @param doNotCloneChildren Do not clone children hierarchy
  15044. * @returns the new transform node
  15045. */
  15046. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15047. /**
  15048. * Serializes the objects information.
  15049. * @param currentSerializationObject defines the object to serialize in
  15050. * @returns the serialized object
  15051. */
  15052. serialize(currentSerializationObject?: any): any;
  15053. /**
  15054. * Returns a new TransformNode object parsed from the source provided.
  15055. * @param parsedTransformNode is the source.
  15056. * @param scene the scne the object belongs to
  15057. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15058. * @returns a new TransformNode object parsed from the source provided.
  15059. */
  15060. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15061. /**
  15062. * Get all child-transformNodes of this node
  15063. * @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
  15064. * @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
  15065. * @returns an array of TransformNode
  15066. */
  15067. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15068. /**
  15069. * Releases resources associated with this transform node.
  15070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15072. */
  15073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15074. /**
  15075. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15076. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15077. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15078. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15079. * @returns the current mesh
  15080. */
  15081. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15082. private _syncAbsoluteScalingAndRotation;
  15083. }
  15084. }
  15085. declare module BABYLON {
  15086. /**
  15087. * Class used to override all child animations of a given target
  15088. */
  15089. export class AnimationPropertiesOverride {
  15090. /**
  15091. * Gets or sets a value indicating if animation blending must be used
  15092. */
  15093. enableBlending: boolean;
  15094. /**
  15095. * Gets or sets the blending speed to use when enableBlending is true
  15096. */
  15097. blendingSpeed: number;
  15098. /**
  15099. * Gets or sets the default loop mode to use
  15100. */
  15101. loopMode: number;
  15102. }
  15103. }
  15104. declare module BABYLON {
  15105. /**
  15106. * Class used to store bone information
  15107. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15108. */
  15109. export class Bone extends Node {
  15110. /**
  15111. * defines the bone name
  15112. */
  15113. name: string;
  15114. private static _tmpVecs;
  15115. private static _tmpQuat;
  15116. private static _tmpMats;
  15117. /**
  15118. * Gets the list of child bones
  15119. */
  15120. children: Bone[];
  15121. /** Gets the animations associated with this bone */
  15122. animations: Animation[];
  15123. /**
  15124. * Gets or sets bone length
  15125. */
  15126. length: number;
  15127. /**
  15128. * @hidden Internal only
  15129. * Set this value to map this bone to a different index in the transform matrices
  15130. * Set this value to -1 to exclude the bone from the transform matrices
  15131. */
  15132. _index: Nullable<number>;
  15133. private _skeleton;
  15134. private _localMatrix;
  15135. private _restPose;
  15136. private _bindPose;
  15137. private _baseMatrix;
  15138. private _absoluteTransform;
  15139. private _invertedAbsoluteTransform;
  15140. private _parent;
  15141. private _scalingDeterminant;
  15142. private _worldTransform;
  15143. private _localScaling;
  15144. private _localRotation;
  15145. private _localPosition;
  15146. private _needToDecompose;
  15147. private _needToCompose;
  15148. /** @hidden */
  15149. _linkedTransformNode: Nullable<TransformNode>;
  15150. /** @hidden */
  15151. _waitingTransformNodeId: Nullable<string>;
  15152. /** @hidden */
  15153. get _matrix(): Matrix;
  15154. /** @hidden */
  15155. set _matrix(value: Matrix);
  15156. /**
  15157. * Create a new bone
  15158. * @param name defines the bone name
  15159. * @param skeleton defines the parent skeleton
  15160. * @param parentBone defines the parent (can be null if the bone is the root)
  15161. * @param localMatrix defines the local matrix
  15162. * @param restPose defines the rest pose matrix
  15163. * @param baseMatrix defines the base matrix
  15164. * @param index defines index of the bone in the hiearchy
  15165. */
  15166. constructor(
  15167. /**
  15168. * defines the bone name
  15169. */
  15170. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15171. /**
  15172. * Gets the current object class name.
  15173. * @return the class name
  15174. */
  15175. getClassName(): string;
  15176. /**
  15177. * Gets the parent skeleton
  15178. * @returns a skeleton
  15179. */
  15180. getSkeleton(): Skeleton;
  15181. /**
  15182. * Gets parent bone
  15183. * @returns a bone or null if the bone is the root of the bone hierarchy
  15184. */
  15185. getParent(): Nullable<Bone>;
  15186. /**
  15187. * Returns an array containing the root bones
  15188. * @returns an array containing the root bones
  15189. */
  15190. getChildren(): Array<Bone>;
  15191. /**
  15192. * Gets the node index in matrix array generated for rendering
  15193. * @returns the node index
  15194. */
  15195. getIndex(): number;
  15196. /**
  15197. * Sets the parent bone
  15198. * @param parent defines the parent (can be null if the bone is the root)
  15199. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15200. */
  15201. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15202. /**
  15203. * Gets the local matrix
  15204. * @returns a matrix
  15205. */
  15206. getLocalMatrix(): Matrix;
  15207. /**
  15208. * Gets the base matrix (initial matrix which remains unchanged)
  15209. * @returns a matrix
  15210. */
  15211. getBaseMatrix(): Matrix;
  15212. /**
  15213. * Gets the rest pose matrix
  15214. * @returns a matrix
  15215. */
  15216. getRestPose(): Matrix;
  15217. /**
  15218. * Sets the rest pose matrix
  15219. * @param matrix the local-space rest pose to set for this bone
  15220. */
  15221. setRestPose(matrix: Matrix): void;
  15222. /**
  15223. * Gets the bind pose matrix
  15224. * @returns the bind pose matrix
  15225. */
  15226. getBindPose(): Matrix;
  15227. /**
  15228. * Sets the bind pose matrix
  15229. * @param matrix the local-space bind pose to set for this bone
  15230. */
  15231. setBindPose(matrix: Matrix): void;
  15232. /**
  15233. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15234. */
  15235. getWorldMatrix(): Matrix;
  15236. /**
  15237. * Sets the local matrix to rest pose matrix
  15238. */
  15239. returnToRest(): void;
  15240. /**
  15241. * Gets the inverse of the absolute transform matrix.
  15242. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15243. * @returns a matrix
  15244. */
  15245. getInvertedAbsoluteTransform(): Matrix;
  15246. /**
  15247. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15248. * @returns a matrix
  15249. */
  15250. getAbsoluteTransform(): Matrix;
  15251. /**
  15252. * Links with the given transform node.
  15253. * The local matrix of this bone is copied from the transform node every frame.
  15254. * @param transformNode defines the transform node to link to
  15255. */
  15256. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15257. /**
  15258. * Gets the node used to drive the bone's transformation
  15259. * @returns a transform node or null
  15260. */
  15261. getTransformNode(): Nullable<TransformNode>;
  15262. /** Gets or sets current position (in local space) */
  15263. get position(): Vector3;
  15264. set position(newPosition: Vector3);
  15265. /** Gets or sets current rotation (in local space) */
  15266. get rotation(): Vector3;
  15267. set rotation(newRotation: Vector3);
  15268. /** Gets or sets current rotation quaternion (in local space) */
  15269. get rotationQuaternion(): Quaternion;
  15270. set rotationQuaternion(newRotation: Quaternion);
  15271. /** Gets or sets current scaling (in local space) */
  15272. get scaling(): Vector3;
  15273. set scaling(newScaling: Vector3);
  15274. /**
  15275. * Gets the animation properties override
  15276. */
  15277. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15278. private _decompose;
  15279. private _compose;
  15280. /**
  15281. * Update the base and local matrices
  15282. * @param matrix defines the new base or local matrix
  15283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15284. * @param updateLocalMatrix defines if the local matrix should be updated
  15285. */
  15286. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15287. /** @hidden */
  15288. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15289. /**
  15290. * Flag the bone as dirty (Forcing it to update everything)
  15291. */
  15292. markAsDirty(): void;
  15293. /** @hidden */
  15294. _markAsDirtyAndCompose(): void;
  15295. private _markAsDirtyAndDecompose;
  15296. /**
  15297. * Translate the bone in local or world space
  15298. * @param vec The amount to translate the bone
  15299. * @param space The space that the translation is in
  15300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15301. */
  15302. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15303. /**
  15304. * Set the postion of the bone in local or world space
  15305. * @param position The position to set the bone
  15306. * @param space The space that the position is in
  15307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15308. */
  15309. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15310. /**
  15311. * Set the absolute position of the bone (world space)
  15312. * @param position The position to set the bone
  15313. * @param mesh The mesh that this bone is attached to
  15314. */
  15315. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15316. /**
  15317. * Scale the bone on the x, y and z axes (in local space)
  15318. * @param x The amount to scale the bone on the x axis
  15319. * @param y The amount to scale the bone on the y axis
  15320. * @param z The amount to scale the bone on the z axis
  15321. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15322. */
  15323. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15324. /**
  15325. * Set the bone scaling in local space
  15326. * @param scale defines the scaling vector
  15327. */
  15328. setScale(scale: Vector3): void;
  15329. /**
  15330. * Gets the current scaling in local space
  15331. * @returns the current scaling vector
  15332. */
  15333. getScale(): Vector3;
  15334. /**
  15335. * Gets the current scaling in local space and stores it in a target vector
  15336. * @param result defines the target vector
  15337. */
  15338. getScaleToRef(result: Vector3): void;
  15339. /**
  15340. * Set the yaw, pitch, and roll of the bone in local or world space
  15341. * @param yaw The rotation of the bone on the y axis
  15342. * @param pitch The rotation of the bone on the x axis
  15343. * @param roll The rotation of the bone on the z axis
  15344. * @param space The space that the axes of rotation are in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. */
  15347. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15348. /**
  15349. * Add a rotation to the bone on an axis in local or world space
  15350. * @param axis The axis to rotate the bone on
  15351. * @param amount The amount to rotate the bone
  15352. * @param space The space that the axis is in
  15353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15354. */
  15355. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15356. /**
  15357. * Set the rotation of the bone to a particular axis angle in local or world space
  15358. * @param axis The axis to rotate the bone on
  15359. * @param angle The angle that the bone should be rotated to
  15360. * @param space The space that the axis is in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. */
  15363. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15364. /**
  15365. * Set the euler rotation of the bone in local of world space
  15366. * @param rotation The euler rotation that the bone should be set to
  15367. * @param space The space that the rotation is in
  15368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15369. */
  15370. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15371. /**
  15372. * Set the quaternion rotation of the bone in local of world space
  15373. * @param quat The quaternion rotation that the bone should be set to
  15374. * @param space The space that the rotation is in
  15375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15376. */
  15377. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15378. /**
  15379. * Set the rotation matrix of the bone in local of world space
  15380. * @param rotMat The rotation matrix that the bone should be set to
  15381. * @param space The space that the rotation is in
  15382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15383. */
  15384. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15385. private _rotateWithMatrix;
  15386. private _getNegativeRotationToRef;
  15387. /**
  15388. * Get the position of the bone in local or world space
  15389. * @param space The space that the returned position is in
  15390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15391. * @returns The position of the bone
  15392. */
  15393. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15394. /**
  15395. * Copy the position of the bone to a vector3 in local or world space
  15396. * @param space The space that the returned position is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. * @param result The vector3 to copy the position to
  15399. */
  15400. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15401. /**
  15402. * Get the absolute position of the bone (world space)
  15403. * @param mesh The mesh that this bone is attached to
  15404. * @returns The absolute position of the bone
  15405. */
  15406. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15407. /**
  15408. * Copy the absolute position of the bone (world space) to the result param
  15409. * @param mesh The mesh that this bone is attached to
  15410. * @param result The vector3 to copy the absolute position to
  15411. */
  15412. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15413. /**
  15414. * Compute the absolute transforms of this bone and its children
  15415. */
  15416. computeAbsoluteTransforms(): void;
  15417. /**
  15418. * Get the world direction from an axis that is in the local space of the bone
  15419. * @param localAxis The local direction that is used to compute the world direction
  15420. * @param mesh The mesh that this bone is attached to
  15421. * @returns The world direction
  15422. */
  15423. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15424. /**
  15425. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15426. * @param localAxis The local direction that is used to compute the world direction
  15427. * @param mesh The mesh that this bone is attached to
  15428. * @param result The vector3 that the world direction will be copied to
  15429. */
  15430. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15431. /**
  15432. * Get the euler rotation of the bone in local or world space
  15433. * @param space The space that the rotation should be in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The euler rotation
  15436. */
  15437. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15440. * @param space The space that the rotation should be in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 that the rotation should be copied to
  15443. */
  15444. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15445. /**
  15446. * Get the quaternion rotation of the bone in either local or world space
  15447. * @param space The space that the rotation should be in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. * @returns The quaternion rotation
  15450. */
  15451. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15452. /**
  15453. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15454. * @param space The space that the rotation should be in
  15455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15456. * @param result The quaternion that the rotation should be copied to
  15457. */
  15458. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15459. /**
  15460. * Get the rotation matrix of the bone in local or world space
  15461. * @param space The space that the rotation should be in
  15462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15463. * @returns The rotation matrix
  15464. */
  15465. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15466. /**
  15467. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15468. * @param space The space that the rotation should be in
  15469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15470. * @param result The quaternion that the rotation should be copied to
  15471. */
  15472. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15473. /**
  15474. * Get the world position of a point that is in the local space of the bone
  15475. * @param position The local position
  15476. * @param mesh The mesh that this bone is attached to
  15477. * @returns The world position
  15478. */
  15479. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15480. /**
  15481. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15482. * @param position The local position
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @param result The vector3 that the world position should be copied to
  15485. */
  15486. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15487. /**
  15488. * Get the local position of a point that is in world space
  15489. * @param position The world position
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @returns The local position
  15492. */
  15493. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15494. /**
  15495. * Get the local position of a point that is in world space and copy it to the result param
  15496. * @param position The world position
  15497. * @param mesh The mesh that this bone is attached to
  15498. * @param result The vector3 that the local position should be copied to
  15499. */
  15500. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Defines a runtime animation
  15506. */
  15507. export class RuntimeAnimation {
  15508. private _events;
  15509. /**
  15510. * The current frame of the runtime animation
  15511. */
  15512. private _currentFrame;
  15513. /**
  15514. * The animation used by the runtime animation
  15515. */
  15516. private _animation;
  15517. /**
  15518. * The target of the runtime animation
  15519. */
  15520. private _target;
  15521. /**
  15522. * The initiating animatable
  15523. */
  15524. private _host;
  15525. /**
  15526. * The original value of the runtime animation
  15527. */
  15528. private _originalValue;
  15529. /**
  15530. * The original blend value of the runtime animation
  15531. */
  15532. private _originalBlendValue;
  15533. /**
  15534. * The offsets cache of the runtime animation
  15535. */
  15536. private _offsetsCache;
  15537. /**
  15538. * The high limits cache of the runtime animation
  15539. */
  15540. private _highLimitsCache;
  15541. /**
  15542. * Specifies if the runtime animation has been stopped
  15543. */
  15544. private _stopped;
  15545. /**
  15546. * The blending factor of the runtime animation
  15547. */
  15548. private _blendingFactor;
  15549. /**
  15550. * The BabylonJS scene
  15551. */
  15552. private _scene;
  15553. /**
  15554. * The current value of the runtime animation
  15555. */
  15556. private _currentValue;
  15557. /** @hidden */
  15558. _animationState: _IAnimationState;
  15559. /**
  15560. * The active target of the runtime animation
  15561. */
  15562. private _activeTargets;
  15563. private _currentActiveTarget;
  15564. private _directTarget;
  15565. /**
  15566. * The target path of the runtime animation
  15567. */
  15568. private _targetPath;
  15569. /**
  15570. * The weight of the runtime animation
  15571. */
  15572. private _weight;
  15573. /**
  15574. * The ratio offset of the runtime animation
  15575. */
  15576. private _ratioOffset;
  15577. /**
  15578. * The previous delay of the runtime animation
  15579. */
  15580. private _previousDelay;
  15581. /**
  15582. * The previous ratio of the runtime animation
  15583. */
  15584. private _previousRatio;
  15585. private _enableBlending;
  15586. private _keys;
  15587. private _minFrame;
  15588. private _maxFrame;
  15589. private _minValue;
  15590. private _maxValue;
  15591. private _targetIsArray;
  15592. /**
  15593. * Gets the current frame of the runtime animation
  15594. */
  15595. get currentFrame(): number;
  15596. /**
  15597. * Gets the weight of the runtime animation
  15598. */
  15599. get weight(): number;
  15600. /**
  15601. * Gets the current value of the runtime animation
  15602. */
  15603. get currentValue(): any;
  15604. /**
  15605. * Gets the target path of the runtime animation
  15606. */
  15607. get targetPath(): string;
  15608. /**
  15609. * Gets the actual target of the runtime animation
  15610. */
  15611. get target(): any;
  15612. /**
  15613. * Gets the additive state of the runtime animation
  15614. */
  15615. get isAdditive(): boolean;
  15616. /** @hidden */
  15617. _onLoop: () => void;
  15618. /**
  15619. * Create a new RuntimeAnimation object
  15620. * @param target defines the target of the animation
  15621. * @param animation defines the source animation object
  15622. * @param scene defines the hosting scene
  15623. * @param host defines the initiating Animatable
  15624. */
  15625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15626. private _preparePath;
  15627. /**
  15628. * Gets the animation from the runtime animation
  15629. */
  15630. get animation(): Animation;
  15631. /**
  15632. * Resets the runtime animation to the beginning
  15633. * @param restoreOriginal defines whether to restore the target property to the original value
  15634. */
  15635. reset(restoreOriginal?: boolean): void;
  15636. /**
  15637. * Specifies if the runtime animation is stopped
  15638. * @returns Boolean specifying if the runtime animation is stopped
  15639. */
  15640. isStopped(): boolean;
  15641. /**
  15642. * Disposes of the runtime animation
  15643. */
  15644. dispose(): void;
  15645. /**
  15646. * Apply the interpolated value to the target
  15647. * @param currentValue defines the value computed by the animation
  15648. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15649. */
  15650. setValue(currentValue: any, weight: number): void;
  15651. private _getOriginalValues;
  15652. private _setValue;
  15653. /**
  15654. * Gets the loop pmode of the runtime animation
  15655. * @returns Loop Mode
  15656. */
  15657. private _getCorrectLoopMode;
  15658. /**
  15659. * Move the current animation to a given frame
  15660. * @param frame defines the frame to move to
  15661. */
  15662. goToFrame(frame: number): void;
  15663. /**
  15664. * @hidden Internal use only
  15665. */
  15666. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15667. /**
  15668. * Execute the current animation
  15669. * @param delay defines the delay to add to the current frame
  15670. * @param from defines the lower bound of the animation range
  15671. * @param to defines the upper bound of the animation range
  15672. * @param loop defines if the current animation must loop
  15673. * @param speedRatio defines the current speed ratio
  15674. * @param weight defines the weight of the animation (default is -1 so no weight)
  15675. * @param onLoop optional callback called when animation loops
  15676. * @returns a boolean indicating if the animation is running
  15677. */
  15678. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15679. }
  15680. }
  15681. declare module BABYLON {
  15682. /**
  15683. * Class used to store an actual running animation
  15684. */
  15685. export class Animatable {
  15686. /** defines the target object */
  15687. target: any;
  15688. /** defines the starting frame number (default is 0) */
  15689. fromFrame: number;
  15690. /** defines the ending frame number (default is 100) */
  15691. toFrame: number;
  15692. /** defines if the animation must loop (default is false) */
  15693. loopAnimation: boolean;
  15694. /** defines a callback to call when animation ends if it is not looping */
  15695. onAnimationEnd?: (() => void) | null | undefined;
  15696. /** defines a callback to call when animation loops */
  15697. onAnimationLoop?: (() => void) | null | undefined;
  15698. /** defines whether the animation should be evaluated additively */
  15699. isAdditive: boolean;
  15700. private _localDelayOffset;
  15701. private _pausedDelay;
  15702. private _runtimeAnimations;
  15703. private _paused;
  15704. private _scene;
  15705. private _speedRatio;
  15706. private _weight;
  15707. private _syncRoot;
  15708. /**
  15709. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15710. * This will only apply for non looping animation (default is true)
  15711. */
  15712. disposeOnEnd: boolean;
  15713. /**
  15714. * Gets a boolean indicating if the animation has started
  15715. */
  15716. animationStarted: boolean;
  15717. /**
  15718. * Observer raised when the animation ends
  15719. */
  15720. onAnimationEndObservable: Observable<Animatable>;
  15721. /**
  15722. * Observer raised when the animation loops
  15723. */
  15724. onAnimationLoopObservable: Observable<Animatable>;
  15725. /**
  15726. * Gets the root Animatable used to synchronize and normalize animations
  15727. */
  15728. get syncRoot(): Nullable<Animatable>;
  15729. /**
  15730. * Gets the current frame of the first RuntimeAnimation
  15731. * Used to synchronize Animatables
  15732. */
  15733. get masterFrame(): number;
  15734. /**
  15735. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15736. */
  15737. get weight(): number;
  15738. set weight(value: number);
  15739. /**
  15740. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15741. */
  15742. get speedRatio(): number;
  15743. set speedRatio(value: number);
  15744. /**
  15745. * Creates a new Animatable
  15746. * @param scene defines the hosting scene
  15747. * @param target defines the target object
  15748. * @param fromFrame defines the starting frame number (default is 0)
  15749. * @param toFrame defines the ending frame number (default is 100)
  15750. * @param loopAnimation defines if the animation must loop (default is false)
  15751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15753. * @param animations defines a group of animation to add to the new Animatable
  15754. * @param onAnimationLoop defines a callback to call when animation loops
  15755. * @param isAdditive defines whether the animation should be evaluated additively
  15756. */
  15757. constructor(scene: Scene,
  15758. /** defines the target object */
  15759. target: any,
  15760. /** defines the starting frame number (default is 0) */
  15761. fromFrame?: number,
  15762. /** defines the ending frame number (default is 100) */
  15763. toFrame?: number,
  15764. /** defines if the animation must loop (default is false) */
  15765. loopAnimation?: boolean, speedRatio?: number,
  15766. /** defines a callback to call when animation ends if it is not looping */
  15767. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15768. /** defines a callback to call when animation loops */
  15769. onAnimationLoop?: (() => void) | null | undefined,
  15770. /** defines whether the animation should be evaluated additively */
  15771. isAdditive?: boolean);
  15772. /**
  15773. * Synchronize and normalize current Animatable with a source Animatable
  15774. * This is useful when using animation weights and when animations are not of the same length
  15775. * @param root defines the root Animatable to synchronize with
  15776. * @returns the current Animatable
  15777. */
  15778. syncWith(root: Animatable): Animatable;
  15779. /**
  15780. * Gets the list of runtime animations
  15781. * @returns an array of RuntimeAnimation
  15782. */
  15783. getAnimations(): RuntimeAnimation[];
  15784. /**
  15785. * Adds more animations to the current animatable
  15786. * @param target defines the target of the animations
  15787. * @param animations defines the new animations to add
  15788. */
  15789. appendAnimations(target: any, animations: Animation[]): void;
  15790. /**
  15791. * Gets the source animation for a specific property
  15792. * @param property defines the propertyu to look for
  15793. * @returns null or the source animation for the given property
  15794. */
  15795. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15796. /**
  15797. * Gets the runtime animation for a specific property
  15798. * @param property defines the propertyu to look for
  15799. * @returns null or the runtime animation for the given property
  15800. */
  15801. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15802. /**
  15803. * Resets the animatable to its original state
  15804. */
  15805. reset(): void;
  15806. /**
  15807. * Allows the animatable to blend with current running animations
  15808. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15809. * @param blendingSpeed defines the blending speed to use
  15810. */
  15811. enableBlending(blendingSpeed: number): void;
  15812. /**
  15813. * Disable animation blending
  15814. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15815. */
  15816. disableBlending(): void;
  15817. /**
  15818. * Jump directly to a given frame
  15819. * @param frame defines the frame to jump to
  15820. */
  15821. goToFrame(frame: number): void;
  15822. /**
  15823. * Pause the animation
  15824. */
  15825. pause(): void;
  15826. /**
  15827. * Restart the animation
  15828. */
  15829. restart(): void;
  15830. private _raiseOnAnimationEnd;
  15831. /**
  15832. * Stop and delete the current animation
  15833. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15834. * @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)
  15835. */
  15836. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15837. /**
  15838. * Wait asynchronously for the animation to end
  15839. * @returns a promise which will be fullfilled when the animation ends
  15840. */
  15841. waitAsync(): Promise<Animatable>;
  15842. /** @hidden */
  15843. _animate(delay: number): boolean;
  15844. }
  15845. interface Scene {
  15846. /** @hidden */
  15847. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15848. /** @hidden */
  15849. _processLateAnimationBindingsForMatrices(holder: {
  15850. totalWeight: number;
  15851. totalAdditiveWeight: number;
  15852. animations: RuntimeAnimation[];
  15853. additiveAnimations: RuntimeAnimation[];
  15854. originalValue: Matrix;
  15855. }): any;
  15856. /** @hidden */
  15857. _processLateAnimationBindingsForQuaternions(holder: {
  15858. totalWeight: number;
  15859. totalAdditiveWeight: number;
  15860. animations: RuntimeAnimation[];
  15861. additiveAnimations: RuntimeAnimation[];
  15862. originalValue: Quaternion;
  15863. }, refQuaternion: Quaternion): Quaternion;
  15864. /** @hidden */
  15865. _processLateAnimationBindings(): void;
  15866. /**
  15867. * Will start the animation sequence of a given target
  15868. * @param target defines the target
  15869. * @param from defines from which frame should animation start
  15870. * @param to defines until which frame should animation run.
  15871. * @param weight defines the weight to apply to the animation (1.0 by default)
  15872. * @param loop defines if the animation loops
  15873. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15874. * @param onAnimationEnd defines the function to be executed when the animation ends
  15875. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15877. * @param onAnimationLoop defines the callback to call when an animation loops
  15878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15879. * @returns the animatable object created for this animation
  15880. */
  15881. 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;
  15882. /**
  15883. * Will start the animation sequence of a given target
  15884. * @param target defines the target
  15885. * @param from defines from which frame should animation start
  15886. * @param to defines until which frame should animation run.
  15887. * @param loop defines if the animation loops
  15888. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15889. * @param onAnimationEnd defines the function to be executed when the animation ends
  15890. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15891. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15892. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15893. * @param onAnimationLoop defines the callback to call when an animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15895. * @returns the animatable object created for this animation
  15896. */
  15897. 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;
  15898. /**
  15899. * Will start the animation sequence of a given target and its hierarchy
  15900. * @param target defines the target
  15901. * @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.
  15902. * @param from defines from which frame should animation start
  15903. * @param to defines until which frame should animation run.
  15904. * @param loop defines if the animation loops
  15905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15906. * @param onAnimationEnd defines the function to be executed when the animation ends
  15907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15908. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15909. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15910. * @param onAnimationLoop defines the callback to call when an animation loops
  15911. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15912. * @returns the list of created animatables
  15913. */
  15914. 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[];
  15915. /**
  15916. * Begin a new animation on a given node
  15917. * @param target defines the target where the animation will take place
  15918. * @param animations defines the list of animations to start
  15919. * @param from defines the initial value
  15920. * @param to defines the final value
  15921. * @param loop defines if you want animation to loop (off by default)
  15922. * @param speedRatio defines the speed ratio to apply to all animations
  15923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15924. * @param onAnimationLoop defines the callback to call when an animation loops
  15925. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15926. * @returns the list of created animatables
  15927. */
  15928. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15929. /**
  15930. * Begin a new animation on a given node and its hierarchy
  15931. * @param target defines the root node where the animation will take place
  15932. * @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.
  15933. * @param animations defines the list of animations to start
  15934. * @param from defines the initial value
  15935. * @param to defines the final value
  15936. * @param loop defines if you want animation to loop (off by default)
  15937. * @param speedRatio defines the speed ratio to apply to all animations
  15938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15939. * @param onAnimationLoop defines the callback to call when an animation loops
  15940. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15941. * @returns the list of animatables created for all nodes
  15942. */
  15943. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15944. /**
  15945. * Gets the animatable associated with a specific target
  15946. * @param target defines the target of the animatable
  15947. * @returns the required animatable if found
  15948. */
  15949. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15950. /**
  15951. * Gets all animatables associated with a given target
  15952. * @param target defines the target to look animatables for
  15953. * @returns an array of Animatables
  15954. */
  15955. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15956. /**
  15957. * Stops and removes all animations that have been applied to the scene
  15958. */
  15959. stopAllAnimations(): void;
  15960. /**
  15961. * Gets the current delta time used by animation engine
  15962. */
  15963. deltaTime: number;
  15964. }
  15965. interface Bone {
  15966. /**
  15967. * Copy an animation range from another bone
  15968. * @param source defines the source bone
  15969. * @param rangeName defines the range name to copy
  15970. * @param frameOffset defines the frame offset
  15971. * @param rescaleAsRequired defines if rescaling must be applied if required
  15972. * @param skelDimensionsRatio defines the scaling ratio
  15973. * @returns true if operation was successful
  15974. */
  15975. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /**
  15980. * Class used to handle skinning animations
  15981. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15982. */
  15983. export class Skeleton implements IAnimatable {
  15984. /** defines the skeleton name */
  15985. name: string;
  15986. /** defines the skeleton Id */
  15987. id: string;
  15988. /**
  15989. * Defines the list of child bones
  15990. */
  15991. bones: Bone[];
  15992. /**
  15993. * Defines an estimate of the dimension of the skeleton at rest
  15994. */
  15995. dimensionsAtRest: Vector3;
  15996. /**
  15997. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15998. */
  15999. needInitialSkinMatrix: boolean;
  16000. /**
  16001. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16002. */
  16003. overrideMesh: Nullable<AbstractMesh>;
  16004. /**
  16005. * Gets the list of animations attached to this skeleton
  16006. */
  16007. animations: Array<Animation>;
  16008. private _scene;
  16009. private _isDirty;
  16010. private _transformMatrices;
  16011. private _transformMatrixTexture;
  16012. private _meshesWithPoseMatrix;
  16013. private _animatables;
  16014. private _identity;
  16015. private _synchronizedWithMesh;
  16016. private _ranges;
  16017. private _lastAbsoluteTransformsUpdateId;
  16018. private _canUseTextureForBones;
  16019. private _uniqueId;
  16020. /** @hidden */
  16021. _numBonesWithLinkedTransformNode: number;
  16022. /** @hidden */
  16023. _hasWaitingData: Nullable<boolean>;
  16024. /** @hidden */
  16025. _waitingOverrideMeshId: Nullable<string>;
  16026. /**
  16027. * Specifies if the skeleton should be serialized
  16028. */
  16029. doNotSerialize: boolean;
  16030. private _useTextureToStoreBoneMatrices;
  16031. /**
  16032. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16033. * Please note that this option is not available if the hardware does not support it
  16034. */
  16035. get useTextureToStoreBoneMatrices(): boolean;
  16036. set useTextureToStoreBoneMatrices(value: boolean);
  16037. private _animationPropertiesOverride;
  16038. /**
  16039. * Gets or sets the animation properties override
  16040. */
  16041. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16042. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16043. /**
  16044. * List of inspectable custom properties (used by the Inspector)
  16045. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16046. */
  16047. inspectableCustomProperties: IInspectable[];
  16048. /**
  16049. * An observable triggered before computing the skeleton's matrices
  16050. */
  16051. onBeforeComputeObservable: Observable<Skeleton>;
  16052. /**
  16053. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16054. */
  16055. get isUsingTextureForMatrices(): boolean;
  16056. /**
  16057. * Gets the unique ID of this skeleton
  16058. */
  16059. get uniqueId(): number;
  16060. /**
  16061. * Creates a new skeleton
  16062. * @param name defines the skeleton name
  16063. * @param id defines the skeleton Id
  16064. * @param scene defines the hosting scene
  16065. */
  16066. constructor(
  16067. /** defines the skeleton name */
  16068. name: string,
  16069. /** defines the skeleton Id */
  16070. id: string, scene: Scene);
  16071. /**
  16072. * Gets the current object class name.
  16073. * @return the class name
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Returns an array containing the root bones
  16078. * @returns an array containing the root bones
  16079. */
  16080. getChildren(): Array<Bone>;
  16081. /**
  16082. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16083. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16084. * @returns a Float32Array containing matrices data
  16085. */
  16086. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16087. /**
  16088. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16089. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16090. * @returns a raw texture containing the data
  16091. */
  16092. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16093. /**
  16094. * Gets the current hosting scene
  16095. * @returns a scene object
  16096. */
  16097. getScene(): Scene;
  16098. /**
  16099. * Gets a string representing the current skeleton data
  16100. * @param fullDetails defines a boolean indicating if we want a verbose version
  16101. * @returns a string representing the current skeleton data
  16102. */
  16103. toString(fullDetails?: boolean): string;
  16104. /**
  16105. * Get bone's index searching by name
  16106. * @param name defines bone's name to search for
  16107. * @return the indice of the bone. Returns -1 if not found
  16108. */
  16109. getBoneIndexByName(name: string): number;
  16110. /**
  16111. * Creater a new animation range
  16112. * @param name defines the name of the range
  16113. * @param from defines the start key
  16114. * @param to defines the end key
  16115. */
  16116. createAnimationRange(name: string, from: number, to: number): void;
  16117. /**
  16118. * Delete a specific animation range
  16119. * @param name defines the name of the range
  16120. * @param deleteFrames defines if frames must be removed as well
  16121. */
  16122. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16123. /**
  16124. * Gets a specific animation range
  16125. * @param name defines the name of the range to look for
  16126. * @returns the requested animation range or null if not found
  16127. */
  16128. getAnimationRange(name: string): Nullable<AnimationRange>;
  16129. /**
  16130. * Gets the list of all animation ranges defined on this skeleton
  16131. * @returns an array
  16132. */
  16133. getAnimationRanges(): Nullable<AnimationRange>[];
  16134. /**
  16135. * Copy animation range from a source skeleton.
  16136. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16137. * @param source defines the source skeleton
  16138. * @param name defines the name of the range to copy
  16139. * @param rescaleAsRequired defines if rescaling must be applied if required
  16140. * @returns true if operation was successful
  16141. */
  16142. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16143. /**
  16144. * Forces the skeleton to go to rest pose
  16145. */
  16146. returnToRest(): void;
  16147. private _getHighestAnimationFrame;
  16148. /**
  16149. * Begin a specific animation range
  16150. * @param name defines the name of the range to start
  16151. * @param loop defines if looping must be turned on (false by default)
  16152. * @param speedRatio defines the speed ratio to apply (1 by default)
  16153. * @param onAnimationEnd defines a callback which will be called when animation will end
  16154. * @returns a new animatable
  16155. */
  16156. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16157. /**
  16158. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16159. * @param skeleton defines the Skeleton containing the animation range to convert
  16160. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16161. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16162. * @returns the original skeleton
  16163. */
  16164. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16165. /** @hidden */
  16166. _markAsDirty(): void;
  16167. /** @hidden */
  16168. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16169. /** @hidden */
  16170. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16171. private _computeTransformMatrices;
  16172. /**
  16173. * Build all resources required to render a skeleton
  16174. */
  16175. prepare(): void;
  16176. /**
  16177. * Gets the list of animatables currently running for this skeleton
  16178. * @returns an array of animatables
  16179. */
  16180. getAnimatables(): IAnimatable[];
  16181. /**
  16182. * Clone the current skeleton
  16183. * @param name defines the name of the new skeleton
  16184. * @param id defines the id of the new skeleton
  16185. * @returns the new skeleton
  16186. */
  16187. clone(name: string, id?: string): Skeleton;
  16188. /**
  16189. * Enable animation blending for this skeleton
  16190. * @param blendingSpeed defines the blending speed to apply
  16191. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16192. */
  16193. enableBlending(blendingSpeed?: number): void;
  16194. /**
  16195. * Releases all resources associated with the current skeleton
  16196. */
  16197. dispose(): void;
  16198. /**
  16199. * Serialize the skeleton in a JSON object
  16200. * @returns a JSON object
  16201. */
  16202. serialize(): any;
  16203. /**
  16204. * Creates a new skeleton from serialized data
  16205. * @param parsedSkeleton defines the serialized data
  16206. * @param scene defines the hosting scene
  16207. * @returns a new skeleton
  16208. */
  16209. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16210. /**
  16211. * Compute all node absolute transforms
  16212. * @param forceUpdate defines if computation must be done even if cache is up to date
  16213. */
  16214. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16215. /**
  16216. * Gets the root pose matrix
  16217. * @returns a matrix
  16218. */
  16219. getPoseMatrix(): Nullable<Matrix>;
  16220. /**
  16221. * Sorts bones per internal index
  16222. */
  16223. sortBones(): void;
  16224. private _sortBones;
  16225. }
  16226. }
  16227. declare module BABYLON {
  16228. /**
  16229. * Creates an instance based on a source mesh.
  16230. */
  16231. export class InstancedMesh extends AbstractMesh {
  16232. private _sourceMesh;
  16233. private _currentLOD;
  16234. /** @hidden */
  16235. _indexInSourceMeshInstanceArray: number;
  16236. constructor(name: string, source: Mesh);
  16237. /**
  16238. * Returns the string "InstancedMesh".
  16239. */
  16240. getClassName(): string;
  16241. /** Gets the list of lights affecting that mesh */
  16242. get lightSources(): Light[];
  16243. _resyncLightSources(): void;
  16244. _resyncLightSource(light: Light): void;
  16245. _removeLightSource(light: Light, dispose: boolean): void;
  16246. /**
  16247. * If the source mesh receives shadows
  16248. */
  16249. get receiveShadows(): boolean;
  16250. /**
  16251. * The material of the source mesh
  16252. */
  16253. get material(): Nullable<Material>;
  16254. /**
  16255. * Visibility of the source mesh
  16256. */
  16257. get visibility(): number;
  16258. /**
  16259. * Skeleton of the source mesh
  16260. */
  16261. get skeleton(): Nullable<Skeleton>;
  16262. /**
  16263. * Rendering ground id of the source mesh
  16264. */
  16265. get renderingGroupId(): number;
  16266. set renderingGroupId(value: number);
  16267. /**
  16268. * Returns the total number of vertices (integer).
  16269. */
  16270. getTotalVertices(): number;
  16271. /**
  16272. * Returns a positive integer : the total number of indices in this mesh geometry.
  16273. * @returns the numner of indices or zero if the mesh has no geometry.
  16274. */
  16275. getTotalIndices(): number;
  16276. /**
  16277. * The source mesh of the instance
  16278. */
  16279. get sourceMesh(): Mesh;
  16280. /**
  16281. * Creates a new InstancedMesh object from the mesh model.
  16282. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16283. * @param name defines the name of the new instance
  16284. * @returns a new InstancedMesh
  16285. */
  16286. createInstance(name: string): InstancedMesh;
  16287. /**
  16288. * Is this node ready to be used/rendered
  16289. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16290. * @return {boolean} is it ready
  16291. */
  16292. isReady(completeCheck?: boolean): boolean;
  16293. /**
  16294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16295. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16296. * @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.
  16297. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16298. */
  16299. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16300. /**
  16301. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16302. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16303. * The `data` are either a numeric array either a Float32Array.
  16304. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16305. * 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).
  16306. * Note that a new underlying VertexBuffer object is created each call.
  16307. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16308. *
  16309. * Possible `kind` values :
  16310. * - VertexBuffer.PositionKind
  16311. * - VertexBuffer.UVKind
  16312. * - VertexBuffer.UV2Kind
  16313. * - VertexBuffer.UV3Kind
  16314. * - VertexBuffer.UV4Kind
  16315. * - VertexBuffer.UV5Kind
  16316. * - VertexBuffer.UV6Kind
  16317. * - VertexBuffer.ColorKind
  16318. * - VertexBuffer.MatricesIndicesKind
  16319. * - VertexBuffer.MatricesIndicesExtraKind
  16320. * - VertexBuffer.MatricesWeightsKind
  16321. * - VertexBuffer.MatricesWeightsExtraKind
  16322. *
  16323. * Returns the Mesh.
  16324. */
  16325. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16326. /**
  16327. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16328. * If the mesh has no geometry, it is simply returned as it is.
  16329. * The `data` are either a numeric array either a Float32Array.
  16330. * No new underlying VertexBuffer object is created.
  16331. * 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.
  16332. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16333. *
  16334. * Possible `kind` values :
  16335. * - VertexBuffer.PositionKind
  16336. * - VertexBuffer.UVKind
  16337. * - VertexBuffer.UV2Kind
  16338. * - VertexBuffer.UV3Kind
  16339. * - VertexBuffer.UV4Kind
  16340. * - VertexBuffer.UV5Kind
  16341. * - VertexBuffer.UV6Kind
  16342. * - VertexBuffer.ColorKind
  16343. * - VertexBuffer.MatricesIndicesKind
  16344. * - VertexBuffer.MatricesIndicesExtraKind
  16345. * - VertexBuffer.MatricesWeightsKind
  16346. * - VertexBuffer.MatricesWeightsExtraKind
  16347. *
  16348. * Returns the Mesh.
  16349. */
  16350. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16351. /**
  16352. * Sets the mesh indices.
  16353. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16354. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16355. * This method creates a new index buffer each call.
  16356. * Returns the Mesh.
  16357. */
  16358. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16359. /**
  16360. * Boolean : True if the mesh owns the requested kind of data.
  16361. */
  16362. isVerticesDataPresent(kind: string): boolean;
  16363. /**
  16364. * Returns an array of indices (IndicesArray).
  16365. */
  16366. getIndices(): Nullable<IndicesArray>;
  16367. get _positions(): Nullable<Vector3[]>;
  16368. /**
  16369. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16370. * This means the mesh underlying bounding box and sphere are recomputed.
  16371. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16372. * @returns the current mesh
  16373. */
  16374. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16375. /** @hidden */
  16376. _preActivate(): InstancedMesh;
  16377. /** @hidden */
  16378. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16379. /** @hidden */
  16380. _postActivate(): void;
  16381. getWorldMatrix(): Matrix;
  16382. get isAnInstance(): boolean;
  16383. /**
  16384. * Returns the current associated LOD AbstractMesh.
  16385. */
  16386. getLOD(camera: Camera): AbstractMesh;
  16387. /** @hidden */
  16388. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16389. /** @hidden */
  16390. _syncSubMeshes(): InstancedMesh;
  16391. /** @hidden */
  16392. _generatePointsArray(): boolean;
  16393. /** @hidden */
  16394. _updateBoundingInfo(): AbstractMesh;
  16395. /**
  16396. * Creates a new InstancedMesh from the current mesh.
  16397. * - name (string) : the cloned mesh name
  16398. * - newParent (optional Node) : the optional Node to parent the clone to.
  16399. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16400. *
  16401. * Returns the clone.
  16402. */
  16403. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16404. /**
  16405. * Disposes the InstancedMesh.
  16406. * Returns nothing.
  16407. */
  16408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16409. }
  16410. interface Mesh {
  16411. /**
  16412. * Register a custom buffer that will be instanced
  16413. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16414. * @param kind defines the buffer kind
  16415. * @param stride defines the stride in floats
  16416. */
  16417. registerInstancedBuffer(kind: string, stride: number): void;
  16418. /**
  16419. * true to use the edge renderer for all instances of this mesh
  16420. */
  16421. edgesShareWithInstances: boolean;
  16422. /** @hidden */
  16423. _userInstancedBuffersStorage: {
  16424. data: {
  16425. [key: string]: Float32Array;
  16426. };
  16427. sizes: {
  16428. [key: string]: number;
  16429. };
  16430. vertexBuffers: {
  16431. [key: string]: Nullable<VertexBuffer>;
  16432. };
  16433. strides: {
  16434. [key: string]: number;
  16435. };
  16436. };
  16437. }
  16438. interface AbstractMesh {
  16439. /**
  16440. * Object used to store instanced buffers defined by user
  16441. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16442. */
  16443. instancedBuffers: {
  16444. [key: string]: any;
  16445. };
  16446. }
  16447. }
  16448. declare module BABYLON {
  16449. /**
  16450. * Defines the options associated with the creation of a shader material.
  16451. */
  16452. export interface IShaderMaterialOptions {
  16453. /**
  16454. * Does the material work in alpha blend mode
  16455. */
  16456. needAlphaBlending: boolean;
  16457. /**
  16458. * Does the material work in alpha test mode
  16459. */
  16460. needAlphaTesting: boolean;
  16461. /**
  16462. * The list of attribute names used in the shader
  16463. */
  16464. attributes: string[];
  16465. /**
  16466. * The list of unifrom names used in the shader
  16467. */
  16468. uniforms: string[];
  16469. /**
  16470. * The list of UBO names used in the shader
  16471. */
  16472. uniformBuffers: string[];
  16473. /**
  16474. * The list of sampler names used in the shader
  16475. */
  16476. samplers: string[];
  16477. /**
  16478. * The list of defines used in the shader
  16479. */
  16480. defines: string[];
  16481. }
  16482. /**
  16483. * 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.
  16484. *
  16485. * This returned material effects how the mesh will look based on the code in the shaders.
  16486. *
  16487. * @see https://doc.babylonjs.com/how_to/shader_material
  16488. */
  16489. export class ShaderMaterial extends Material {
  16490. private _shaderPath;
  16491. private _options;
  16492. private _textures;
  16493. private _textureArrays;
  16494. private _floats;
  16495. private _ints;
  16496. private _floatsArrays;
  16497. private _colors3;
  16498. private _colors3Arrays;
  16499. private _colors4;
  16500. private _colors4Arrays;
  16501. private _vectors2;
  16502. private _vectors3;
  16503. private _vectors4;
  16504. private _matrices;
  16505. private _matrixArrays;
  16506. private _matrices3x3;
  16507. private _matrices2x2;
  16508. private _vectors2Arrays;
  16509. private _vectors3Arrays;
  16510. private _vectors4Arrays;
  16511. private _cachedWorldViewMatrix;
  16512. private _cachedWorldViewProjectionMatrix;
  16513. private _renderId;
  16514. private _multiview;
  16515. private _cachedDefines;
  16516. /** Define the Url to load snippets */
  16517. static SnippetUrl: string;
  16518. /** Snippet ID if the material was created from the snippet server */
  16519. snippetId: string;
  16520. /**
  16521. * Instantiate a new shader material.
  16522. * 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.
  16523. * This returned material effects how the mesh will look based on the code in the shaders.
  16524. * @see https://doc.babylonjs.com/how_to/shader_material
  16525. * @param name Define the name of the material in the scene
  16526. * @param scene Define the scene the material belongs to
  16527. * @param shaderPath Defines the route to the shader code in one of three ways:
  16528. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16529. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16530. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16531. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16532. * @param options Define the options used to create the shader
  16533. */
  16534. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16535. /**
  16536. * Gets the shader path used to define the shader code
  16537. * It can be modified to trigger a new compilation
  16538. */
  16539. get shaderPath(): any;
  16540. /**
  16541. * Sets the shader path used to define the shader code
  16542. * It can be modified to trigger a new compilation
  16543. */
  16544. set shaderPath(shaderPath: any);
  16545. /**
  16546. * Gets the options used to compile the shader.
  16547. * They can be modified to trigger a new compilation
  16548. */
  16549. get options(): IShaderMaterialOptions;
  16550. /**
  16551. * Gets the current class name of the material e.g. "ShaderMaterial"
  16552. * Mainly use in serialization.
  16553. * @returns the class name
  16554. */
  16555. getClassName(): string;
  16556. /**
  16557. * Specifies if the material will require alpha blending
  16558. * @returns a boolean specifying if alpha blending is needed
  16559. */
  16560. needAlphaBlending(): boolean;
  16561. /**
  16562. * Specifies if this material should be rendered in alpha test mode
  16563. * @returns a boolean specifying if an alpha test is needed.
  16564. */
  16565. needAlphaTesting(): boolean;
  16566. private _checkUniform;
  16567. /**
  16568. * Set a texture in the shader.
  16569. * @param name Define the name of the uniform samplers as defined in the shader
  16570. * @param texture Define the texture to bind to this sampler
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16574. /**
  16575. * Set a texture array in the shader.
  16576. * @param name Define the name of the uniform sampler array as defined in the shader
  16577. * @param textures Define the list of textures to bind to this sampler
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16581. /**
  16582. * Set a float in the shader.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setFloat(name: string, value: number): ShaderMaterial;
  16588. /**
  16589. * Set a int in the shader.
  16590. * @param name Define the name of the uniform as defined in the shader
  16591. * @param value Define the value to give to the uniform
  16592. * @return the material itself allowing "fluent" like uniform updates
  16593. */
  16594. setInt(name: string, value: number): ShaderMaterial;
  16595. /**
  16596. * Set an array of floats in the shader.
  16597. * @param name Define the name of the uniform as defined in the shader
  16598. * @param value Define the value to give to the uniform
  16599. * @return the material itself allowing "fluent" like uniform updates
  16600. */
  16601. setFloats(name: string, value: number[]): ShaderMaterial;
  16602. /**
  16603. * Set a vec3 in the shader from a Color3.
  16604. * @param name Define the name of the uniform as defined in the shader
  16605. * @param value Define the value to give to the uniform
  16606. * @return the material itself allowing "fluent" like uniform updates
  16607. */
  16608. setColor3(name: string, value: Color3): ShaderMaterial;
  16609. /**
  16610. * Set a vec3 array in the shader from a Color3 array.
  16611. * @param name Define the name of the uniform as defined in the shader
  16612. * @param value Define the value to give to the uniform
  16613. * @return the material itself allowing "fluent" like uniform updates
  16614. */
  16615. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16616. /**
  16617. * Set a vec4 in the shader from a Color4.
  16618. * @param name Define the name of the uniform as defined in the shader
  16619. * @param value Define the value to give to the uniform
  16620. * @return the material itself allowing "fluent" like uniform updates
  16621. */
  16622. setColor4(name: string, value: Color4): ShaderMaterial;
  16623. /**
  16624. * Set a vec4 array in the shader from a Color4 array.
  16625. * @param name Define the name of the uniform as defined in the shader
  16626. * @param value Define the value to give to the uniform
  16627. * @return the material itself allowing "fluent" like uniform updates
  16628. */
  16629. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16630. /**
  16631. * Set a vec2 in the shader from a Vector2.
  16632. * @param name Define the name of the uniform as defined in the shader
  16633. * @param value Define the value to give to the uniform
  16634. * @return the material itself allowing "fluent" like uniform updates
  16635. */
  16636. setVector2(name: string, value: Vector2): ShaderMaterial;
  16637. /**
  16638. * Set a vec3 in the shader from a Vector3.
  16639. * @param name Define the name of the uniform as defined in the shader
  16640. * @param value Define the value to give to the uniform
  16641. * @return the material itself allowing "fluent" like uniform updates
  16642. */
  16643. setVector3(name: string, value: Vector3): ShaderMaterial;
  16644. /**
  16645. * Set a vec4 in the shader from a Vector4.
  16646. * @param name Define the name of the uniform as defined in the shader
  16647. * @param value Define the value to give to the uniform
  16648. * @return the material itself allowing "fluent" like uniform updates
  16649. */
  16650. setVector4(name: string, value: Vector4): ShaderMaterial;
  16651. /**
  16652. * Set a mat4 in the shader from a Matrix.
  16653. * @param name Define the name of the uniform as defined in the shader
  16654. * @param value Define the value to give to the uniform
  16655. * @return the material itself allowing "fluent" like uniform updates
  16656. */
  16657. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16658. /**
  16659. * Set a float32Array in the shader from a matrix array.
  16660. * @param name Define the name of the uniform as defined in the shader
  16661. * @param value Define the value to give to the uniform
  16662. * @return the material itself allowing "fluent" like uniform updates
  16663. */
  16664. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16665. /**
  16666. * Set a mat3 in the shader from a Float32Array.
  16667. * @param name Define the name of the uniform as defined in the shader
  16668. * @param value Define the value to give to the uniform
  16669. * @return the material itself allowing "fluent" like uniform updates
  16670. */
  16671. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16672. /**
  16673. * Set a mat2 in the shader from a Float32Array.
  16674. * @param name Define the name of the uniform as defined in the shader
  16675. * @param value Define the value to give to the uniform
  16676. * @return the material itself allowing "fluent" like uniform updates
  16677. */
  16678. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16679. /**
  16680. * Set a vec2 array in the shader from a number array.
  16681. * @param name Define the name of the uniform as defined in the shader
  16682. * @param value Define the value to give to the uniform
  16683. * @return the material itself allowing "fluent" like uniform updates
  16684. */
  16685. setArray2(name: string, value: number[]): ShaderMaterial;
  16686. /**
  16687. * Set a vec3 array in the shader from a number array.
  16688. * @param name Define the name of the uniform as defined in the shader
  16689. * @param value Define the value to give to the uniform
  16690. * @return the material itself allowing "fluent" like uniform updates
  16691. */
  16692. setArray3(name: string, value: number[]): ShaderMaterial;
  16693. /**
  16694. * Set a vec4 array in the shader from a number array.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the material itself allowing "fluent" like uniform updates
  16698. */
  16699. setArray4(name: string, value: number[]): ShaderMaterial;
  16700. private _checkCache;
  16701. /**
  16702. * Specifies that the submesh is ready to be used
  16703. * @param mesh defines the mesh to check
  16704. * @param subMesh defines which submesh to check
  16705. * @param useInstances specifies that instances should be used
  16706. * @returns a boolean indicating that the submesh is ready or not
  16707. */
  16708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16709. /**
  16710. * Checks if the material is ready to render the requested mesh
  16711. * @param mesh Define the mesh to render
  16712. * @param useInstances Define whether or not the material is used with instances
  16713. * @returns true if ready, otherwise false
  16714. */
  16715. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16716. /**
  16717. * Binds the world matrix to the material
  16718. * @param world defines the world transformation matrix
  16719. * @param effectOverride - If provided, use this effect instead of internal effect
  16720. */
  16721. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16722. /**
  16723. * Binds the submesh to this material by preparing the effect and shader to draw
  16724. * @param world defines the world transformation matrix
  16725. * @param mesh defines the mesh containing the submesh
  16726. * @param subMesh defines the submesh to bind the material to
  16727. */
  16728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16729. /**
  16730. * Binds the material to the mesh
  16731. * @param world defines the world transformation matrix
  16732. * @param mesh defines the mesh to bind the material to
  16733. * @param effectOverride - If provided, use this effect instead of internal effect
  16734. */
  16735. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16736. protected _afterBind(mesh?: Mesh): void;
  16737. /**
  16738. * Gets the active textures from the material
  16739. * @returns an array of textures
  16740. */
  16741. getActiveTextures(): BaseTexture[];
  16742. /**
  16743. * Specifies if the material uses a texture
  16744. * @param texture defines the texture to check against the material
  16745. * @returns a boolean specifying if the material uses the texture
  16746. */
  16747. hasTexture(texture: BaseTexture): boolean;
  16748. /**
  16749. * Makes a duplicate of the material, and gives it a new name
  16750. * @param name defines the new name for the duplicated material
  16751. * @returns the cloned material
  16752. */
  16753. clone(name: string): ShaderMaterial;
  16754. /**
  16755. * Disposes the material
  16756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16758. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16759. */
  16760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16761. /**
  16762. * Serializes this material in a JSON representation
  16763. * @returns the serialized material object
  16764. */
  16765. serialize(): any;
  16766. /**
  16767. * Creates a shader material from parsed shader material data
  16768. * @param source defines the JSON represnetation of the material
  16769. * @param scene defines the hosting scene
  16770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16771. * @returns a new material
  16772. */
  16773. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16774. /**
  16775. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16776. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16777. * @param url defines the url to load from
  16778. * @param scene defines the hosting scene
  16779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16780. * @returns a promise that will resolve to the new ShaderMaterial
  16781. */
  16782. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16783. /**
  16784. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16785. * @param snippetId defines the snippet to load
  16786. * @param scene defines the hosting scene
  16787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16788. * @returns a promise that will resolve to the new ShaderMaterial
  16789. */
  16790. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16791. }
  16792. }
  16793. declare module BABYLON {
  16794. /** @hidden */
  16795. export var colorPixelShader: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module BABYLON {
  16801. /** @hidden */
  16802. export var colorVertexShader: {
  16803. name: string;
  16804. shader: string;
  16805. };
  16806. }
  16807. declare module BABYLON {
  16808. /**
  16809. * Line mesh
  16810. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16811. */
  16812. export class LinesMesh extends Mesh {
  16813. /**
  16814. * If vertex color should be applied to the mesh
  16815. */
  16816. readonly useVertexColor?: boolean | undefined;
  16817. /**
  16818. * If vertex alpha should be applied to the mesh
  16819. */
  16820. readonly useVertexAlpha?: boolean | undefined;
  16821. /**
  16822. * Color of the line (Default: White)
  16823. */
  16824. color: Color3;
  16825. /**
  16826. * Alpha of the line (Default: 1)
  16827. */
  16828. alpha: number;
  16829. /**
  16830. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16831. * This margin is expressed in world space coordinates, so its value may vary.
  16832. * Default value is 0.1
  16833. */
  16834. intersectionThreshold: number;
  16835. private _colorShader;
  16836. private color4;
  16837. /**
  16838. * Creates a new LinesMesh
  16839. * @param name defines the name
  16840. * @param scene defines the hosting scene
  16841. * @param parent defines the parent mesh if any
  16842. * @param source defines the optional source LinesMesh used to clone data from
  16843. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16844. * When false, achieved by calling a clone(), also passing False.
  16845. * This will make creation of children, recursive.
  16846. * @param useVertexColor defines if this LinesMesh supports vertex color
  16847. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16848. */
  16849. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16850. /**
  16851. * If vertex color should be applied to the mesh
  16852. */
  16853. useVertexColor?: boolean | undefined,
  16854. /**
  16855. * If vertex alpha should be applied to the mesh
  16856. */
  16857. useVertexAlpha?: boolean | undefined);
  16858. private _addClipPlaneDefine;
  16859. private _removeClipPlaneDefine;
  16860. isReady(): boolean;
  16861. /**
  16862. * Returns the string "LineMesh"
  16863. */
  16864. getClassName(): string;
  16865. /**
  16866. * @hidden
  16867. */
  16868. get material(): Material;
  16869. /**
  16870. * @hidden
  16871. */
  16872. set material(value: Material);
  16873. /**
  16874. * @hidden
  16875. */
  16876. get checkCollisions(): boolean;
  16877. /** @hidden */
  16878. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16879. /** @hidden */
  16880. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16881. /**
  16882. * Disposes of the line mesh
  16883. * @param doNotRecurse If children should be disposed
  16884. */
  16885. dispose(doNotRecurse?: boolean): void;
  16886. /**
  16887. * Returns a new LineMesh object cloned from the current one.
  16888. */
  16889. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16890. /**
  16891. * Creates a new InstancedLinesMesh object from the mesh model.
  16892. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16893. * @param name defines the name of the new instance
  16894. * @returns a new InstancedLinesMesh
  16895. */
  16896. createInstance(name: string): InstancedLinesMesh;
  16897. }
  16898. /**
  16899. * Creates an instance based on a source LinesMesh
  16900. */
  16901. export class InstancedLinesMesh extends InstancedMesh {
  16902. /**
  16903. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16904. * This margin is expressed in world space coordinates, so its value may vary.
  16905. * Initilized with the intersectionThreshold value of the source LinesMesh
  16906. */
  16907. intersectionThreshold: number;
  16908. constructor(name: string, source: LinesMesh);
  16909. /**
  16910. * Returns the string "InstancedLinesMesh".
  16911. */
  16912. getClassName(): string;
  16913. }
  16914. }
  16915. declare module BABYLON {
  16916. /** @hidden */
  16917. export var linePixelShader: {
  16918. name: string;
  16919. shader: string;
  16920. };
  16921. }
  16922. declare module BABYLON {
  16923. /** @hidden */
  16924. export var lineVertexShader: {
  16925. name: string;
  16926. shader: string;
  16927. };
  16928. }
  16929. declare module BABYLON {
  16930. interface Scene {
  16931. /** @hidden */
  16932. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16933. }
  16934. interface AbstractMesh {
  16935. /**
  16936. * Gets the edgesRenderer associated with the mesh
  16937. */
  16938. edgesRenderer: Nullable<EdgesRenderer>;
  16939. }
  16940. interface LinesMesh {
  16941. /**
  16942. * Enables the edge rendering mode on the mesh.
  16943. * This mode makes the mesh edges visible
  16944. * @param epsilon defines the maximal distance between two angles to detect a face
  16945. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16946. * @returns the currentAbstractMesh
  16947. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16948. */
  16949. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16950. }
  16951. interface InstancedLinesMesh {
  16952. /**
  16953. * Enables the edge rendering mode on the mesh.
  16954. * This mode makes the mesh edges visible
  16955. * @param epsilon defines the maximal distance between two angles to detect a face
  16956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16957. * @returns the current InstancedLinesMesh
  16958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16959. */
  16960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16961. }
  16962. /**
  16963. * Defines the minimum contract an Edges renderer should follow.
  16964. */
  16965. export interface IEdgesRenderer extends IDisposable {
  16966. /**
  16967. * Gets or sets a boolean indicating if the edgesRenderer is active
  16968. */
  16969. isEnabled: boolean;
  16970. /**
  16971. * Renders the edges of the attached mesh,
  16972. */
  16973. render(): void;
  16974. /**
  16975. * Checks wether or not the edges renderer is ready to render.
  16976. * @return true if ready, otherwise false.
  16977. */
  16978. isReady(): boolean;
  16979. /**
  16980. * List of instances to render in case the source mesh has instances
  16981. */
  16982. customInstances: SmartArray<Matrix>;
  16983. }
  16984. /**
  16985. * Defines the additional options of the edges renderer
  16986. */
  16987. export interface IEdgesRendererOptions {
  16988. /**
  16989. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16990. * If not defined, the default value is true
  16991. */
  16992. useAlternateEdgeFinder?: boolean;
  16993. /**
  16994. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16995. * If not defined, the default value is true.
  16996. * 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)
  16997. * This option is used only if useAlternateEdgeFinder = true
  16998. */
  16999. useFastVertexMerger?: boolean;
  17000. /**
  17001. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17002. * The default value is 1e-6
  17003. * This option is used only if useAlternateEdgeFinder = true
  17004. */
  17005. epsilonVertexMerge?: number;
  17006. /**
  17007. * 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
  17008. * 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.
  17009. * This option is used only if useAlternateEdgeFinder = true
  17010. */
  17011. applyTessellation?: boolean;
  17012. /**
  17013. * 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
  17014. * The default value is 1e-6
  17015. * This option is used only if useAlternateEdgeFinder = true
  17016. */
  17017. epsilonVertexAligned?: number;
  17018. }
  17019. /**
  17020. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17021. */
  17022. export class EdgesRenderer implements IEdgesRenderer {
  17023. /**
  17024. * Define the size of the edges with an orthographic camera
  17025. */
  17026. edgesWidthScalerForOrthographic: number;
  17027. /**
  17028. * Define the size of the edges with a perspective camera
  17029. */
  17030. edgesWidthScalerForPerspective: number;
  17031. protected _source: AbstractMesh;
  17032. protected _linesPositions: number[];
  17033. protected _linesNormals: number[];
  17034. protected _linesIndices: number[];
  17035. protected _epsilon: number;
  17036. protected _indicesCount: number;
  17037. protected _lineShader: ShaderMaterial;
  17038. protected _ib: DataBuffer;
  17039. protected _buffers: {
  17040. [key: string]: Nullable<VertexBuffer>;
  17041. };
  17042. protected _buffersForInstances: {
  17043. [key: string]: Nullable<VertexBuffer>;
  17044. };
  17045. protected _checkVerticesInsteadOfIndices: boolean;
  17046. protected _options: Nullable<IEdgesRendererOptions>;
  17047. private _meshRebuildObserver;
  17048. private _meshDisposeObserver;
  17049. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17050. isEnabled: boolean;
  17051. /**
  17052. * List of instances to render in case the source mesh has instances
  17053. */
  17054. customInstances: SmartArray<Matrix>;
  17055. private static GetShader;
  17056. /**
  17057. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17058. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17059. * @param source Mesh used to create edges
  17060. * @param epsilon sum of angles in adjacency to check for edge
  17061. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17062. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17063. * @param options The options to apply when generating the edges
  17064. */
  17065. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17066. protected _prepareRessources(): void;
  17067. /** @hidden */
  17068. _rebuild(): void;
  17069. /**
  17070. * Releases the required resources for the edges renderer
  17071. */
  17072. dispose(): void;
  17073. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17074. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17075. /**
  17076. * Checks if the pair of p0 and p1 is en edge
  17077. * @param faceIndex
  17078. * @param edge
  17079. * @param faceNormals
  17080. * @param p0
  17081. * @param p1
  17082. * @private
  17083. */
  17084. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17085. /**
  17086. * push line into the position, normal and index buffer
  17087. * @protected
  17088. */
  17089. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17090. /**
  17091. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17092. */
  17093. private _tessellateTriangle;
  17094. private _generateEdgesLinesAlternate;
  17095. /**
  17096. * Generates lines edges from adjacencjes
  17097. * @private
  17098. */
  17099. _generateEdgesLines(): void;
  17100. /**
  17101. * Checks wether or not the edges renderer is ready to render.
  17102. * @return true if ready, otherwise false.
  17103. */
  17104. isReady(): boolean;
  17105. /**
  17106. * Renders the edges of the attached mesh,
  17107. */
  17108. render(): void;
  17109. }
  17110. /**
  17111. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17112. */
  17113. export class LineEdgesRenderer extends EdgesRenderer {
  17114. /**
  17115. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17116. * @param source LineMesh used to generate edges
  17117. * @param epsilon not important (specified angle for edge detection)
  17118. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17119. */
  17120. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17121. /**
  17122. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17123. */
  17124. _generateEdgesLines(): void;
  17125. }
  17126. }
  17127. declare module BABYLON {
  17128. /**
  17129. * This represents the object necessary to create a rendering group.
  17130. * This is exclusively used and created by the rendering manager.
  17131. * To modify the behavior, you use the available helpers in your scene or meshes.
  17132. * @hidden
  17133. */
  17134. export class RenderingGroup {
  17135. index: number;
  17136. private static _zeroVector;
  17137. private _scene;
  17138. private _opaqueSubMeshes;
  17139. private _transparentSubMeshes;
  17140. private _alphaTestSubMeshes;
  17141. private _depthOnlySubMeshes;
  17142. private _particleSystems;
  17143. private _spriteManagers;
  17144. private _opaqueSortCompareFn;
  17145. private _alphaTestSortCompareFn;
  17146. private _transparentSortCompareFn;
  17147. private _renderOpaque;
  17148. private _renderAlphaTest;
  17149. private _renderTransparent;
  17150. /** @hidden */
  17151. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17152. onBeforeTransparentRendering: () => void;
  17153. /**
  17154. * Set the opaque sort comparison function.
  17155. * If null the sub meshes will be render in the order they were created
  17156. */
  17157. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17158. /**
  17159. * Set the alpha test sort comparison function.
  17160. * If null the sub meshes will be render in the order they were created
  17161. */
  17162. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17163. /**
  17164. * Set the transparent sort comparison function.
  17165. * If null the sub meshes will be render in the order they were created
  17166. */
  17167. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17168. /**
  17169. * Creates a new rendering group.
  17170. * @param index The rendering group index
  17171. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17172. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17173. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17174. */
  17175. 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>);
  17176. /**
  17177. * Render all the sub meshes contained in the group.
  17178. * @param customRenderFunction Used to override the default render behaviour of the group.
  17179. * @returns true if rendered some submeshes.
  17180. */
  17181. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17182. /**
  17183. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17184. * @param subMeshes The submeshes to render
  17185. */
  17186. private renderOpaqueSorted;
  17187. /**
  17188. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17189. * @param subMeshes The submeshes to render
  17190. */
  17191. private renderAlphaTestSorted;
  17192. /**
  17193. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17194. * @param subMeshes The submeshes to render
  17195. */
  17196. private renderTransparentSorted;
  17197. /**
  17198. * Renders the submeshes in a specified order.
  17199. * @param subMeshes The submeshes to sort before render
  17200. * @param sortCompareFn The comparison function use to sort
  17201. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17202. * @param transparent Specifies to activate blending if true
  17203. */
  17204. private static renderSorted;
  17205. /**
  17206. * Renders the submeshes in the order they were dispatched (no sort applied).
  17207. * @param subMeshes The submeshes to render
  17208. */
  17209. private static renderUnsorted;
  17210. /**
  17211. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17212. * are rendered back to front if in the same alpha index.
  17213. *
  17214. * @param a The first submesh
  17215. * @param b The second submesh
  17216. * @returns The result of the comparison
  17217. */
  17218. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17219. /**
  17220. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17221. * are rendered back to front.
  17222. *
  17223. * @param a The first submesh
  17224. * @param b The second submesh
  17225. * @returns The result of the comparison
  17226. */
  17227. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17228. /**
  17229. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17230. * are rendered front to back (prevent overdraw).
  17231. *
  17232. * @param a The first submesh
  17233. * @param b The second submesh
  17234. * @returns The result of the comparison
  17235. */
  17236. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17237. /**
  17238. * Resets the different lists of submeshes to prepare a new frame.
  17239. */
  17240. prepare(): void;
  17241. dispose(): void;
  17242. /**
  17243. * Inserts the submesh in its correct queue depending on its material.
  17244. * @param subMesh The submesh to dispatch
  17245. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17246. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17247. */
  17248. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17249. dispatchSprites(spriteManager: ISpriteManager): void;
  17250. dispatchParticles(particleSystem: IParticleSystem): void;
  17251. private _renderParticles;
  17252. private _renderSprites;
  17253. }
  17254. }
  17255. declare module BABYLON {
  17256. /**
  17257. * Interface describing the different options available in the rendering manager
  17258. * regarding Auto Clear between groups.
  17259. */
  17260. export interface IRenderingManagerAutoClearSetup {
  17261. /**
  17262. * Defines whether or not autoclear is enable.
  17263. */
  17264. autoClear: boolean;
  17265. /**
  17266. * Defines whether or not to autoclear the depth buffer.
  17267. */
  17268. depth: boolean;
  17269. /**
  17270. * Defines whether or not to autoclear the stencil buffer.
  17271. */
  17272. stencil: boolean;
  17273. }
  17274. /**
  17275. * This class is used by the onRenderingGroupObservable
  17276. */
  17277. export class RenderingGroupInfo {
  17278. /**
  17279. * The Scene that being rendered
  17280. */
  17281. scene: Scene;
  17282. /**
  17283. * The camera currently used for the rendering pass
  17284. */
  17285. camera: Nullable<Camera>;
  17286. /**
  17287. * The ID of the renderingGroup being processed
  17288. */
  17289. renderingGroupId: number;
  17290. }
  17291. /**
  17292. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17293. * It is enable to manage the different groups as well as the different necessary sort functions.
  17294. * This should not be used directly aside of the few static configurations
  17295. */
  17296. export class RenderingManager {
  17297. /**
  17298. * The max id used for rendering groups (not included)
  17299. */
  17300. static MAX_RENDERINGGROUPS: number;
  17301. /**
  17302. * The min id used for rendering groups (included)
  17303. */
  17304. static MIN_RENDERINGGROUPS: number;
  17305. /**
  17306. * Used to globally prevent autoclearing scenes.
  17307. */
  17308. static AUTOCLEAR: boolean;
  17309. /**
  17310. * @hidden
  17311. */
  17312. _useSceneAutoClearSetup: boolean;
  17313. private _scene;
  17314. private _renderingGroups;
  17315. private _depthStencilBufferAlreadyCleaned;
  17316. private _autoClearDepthStencil;
  17317. private _customOpaqueSortCompareFn;
  17318. private _customAlphaTestSortCompareFn;
  17319. private _customTransparentSortCompareFn;
  17320. private _renderingGroupInfo;
  17321. /**
  17322. * Instantiates a new rendering group for a particular scene
  17323. * @param scene Defines the scene the groups belongs to
  17324. */
  17325. constructor(scene: Scene);
  17326. private _clearDepthStencilBuffer;
  17327. /**
  17328. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17329. * @hidden
  17330. */
  17331. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17332. /**
  17333. * Resets the different information of the group to prepare a new frame
  17334. * @hidden
  17335. */
  17336. reset(): void;
  17337. /**
  17338. * Dispose and release the group and its associated resources.
  17339. * @hidden
  17340. */
  17341. dispose(): void;
  17342. /**
  17343. * Clear the info related to rendering groups preventing retention points during dispose.
  17344. */
  17345. freeRenderingGroups(): void;
  17346. private _prepareRenderingGroup;
  17347. /**
  17348. * Add a sprite manager to the rendering manager in order to render it this frame.
  17349. * @param spriteManager Define the sprite manager to render
  17350. */
  17351. dispatchSprites(spriteManager: ISpriteManager): void;
  17352. /**
  17353. * Add a particle system to the rendering manager in order to render it this frame.
  17354. * @param particleSystem Define the particle system to render
  17355. */
  17356. dispatchParticles(particleSystem: IParticleSystem): void;
  17357. /**
  17358. * Add a submesh to the manager in order to render it this frame
  17359. * @param subMesh The submesh to dispatch
  17360. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17361. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17362. */
  17363. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17364. /**
  17365. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17366. * This allowed control for front to back rendering or reversly depending of the special needs.
  17367. *
  17368. * @param renderingGroupId The rendering group id corresponding to its index
  17369. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17370. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17371. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17372. */
  17373. 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;
  17374. /**
  17375. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17376. *
  17377. * @param renderingGroupId The rendering group id corresponding to its index
  17378. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17379. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17380. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17381. */
  17382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17383. /**
  17384. * Gets the current auto clear configuration for one rendering group of the rendering
  17385. * manager.
  17386. * @param index the rendering group index to get the information for
  17387. * @returns The auto clear setup for the requested rendering group
  17388. */
  17389. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17390. }
  17391. }
  17392. declare module BABYLON {
  17393. /**
  17394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17395. */
  17396. export interface ICustomShaderOptions {
  17397. /**
  17398. * Gets or sets the custom shader name to use
  17399. */
  17400. shaderName: string;
  17401. /**
  17402. * The list of attribute names used in the shader
  17403. */
  17404. attributes?: string[];
  17405. /**
  17406. * The list of unifrom names used in the shader
  17407. */
  17408. uniforms?: string[];
  17409. /**
  17410. * The list of sampler names used in the shader
  17411. */
  17412. samplers?: string[];
  17413. /**
  17414. * The list of defines used in the shader
  17415. */
  17416. defines?: string[];
  17417. }
  17418. /**
  17419. * Interface to implement to create a shadow generator compatible with BJS.
  17420. */
  17421. export interface IShadowGenerator {
  17422. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17423. id: string;
  17424. /**
  17425. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17426. * @returns The render target texture if present otherwise, null
  17427. */
  17428. getShadowMap(): Nullable<RenderTargetTexture>;
  17429. /**
  17430. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17431. * @param subMesh The submesh we want to render in the shadow map
  17432. * @param useInstances Defines wether will draw in the map using instances
  17433. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17434. * @returns true if ready otherwise, false
  17435. */
  17436. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17437. /**
  17438. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17439. * @param defines Defines of the material we want to update
  17440. * @param lightIndex Index of the light in the enabled light list of the material
  17441. */
  17442. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17443. /**
  17444. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17445. * defined in the generator but impacting the effect).
  17446. * It implies the unifroms available on the materials are the standard BJS ones.
  17447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17448. * @param effect The effect we are binfing the information for
  17449. */
  17450. bindShadowLight(lightIndex: string, effect: Effect): void;
  17451. /**
  17452. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17453. * (eq to shadow prjection matrix * light transform matrix)
  17454. * @returns The transform matrix used to create the shadow map
  17455. */
  17456. getTransformMatrix(): Matrix;
  17457. /**
  17458. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17459. * Cube and 2D textures for instance.
  17460. */
  17461. recreateShadowMap(): void;
  17462. /**
  17463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17464. * @param onCompiled Callback triggered at the and of the effects compilation
  17465. * @param options Sets of optional options forcing the compilation with different modes
  17466. */
  17467. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17468. useInstances: boolean;
  17469. }>): void;
  17470. /**
  17471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17472. * @param options Sets of optional options forcing the compilation with different modes
  17473. * @returns A promise that resolves when the compilation completes
  17474. */
  17475. forceCompilationAsync(options?: Partial<{
  17476. useInstances: boolean;
  17477. }>): Promise<void>;
  17478. /**
  17479. * Serializes the shadow generator setup to a json object.
  17480. * @returns The serialized JSON object
  17481. */
  17482. serialize(): any;
  17483. /**
  17484. * Disposes the Shadow map and related Textures and effects.
  17485. */
  17486. dispose(): void;
  17487. }
  17488. /**
  17489. * Default implementation IShadowGenerator.
  17490. * This is the main object responsible of generating shadows in the framework.
  17491. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17492. */
  17493. export class ShadowGenerator implements IShadowGenerator {
  17494. /**
  17495. * Name of the shadow generator class
  17496. */
  17497. static CLASSNAME: string;
  17498. /**
  17499. * Shadow generator mode None: no filtering applied.
  17500. */
  17501. static readonly FILTER_NONE: number;
  17502. /**
  17503. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17505. */
  17506. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17507. /**
  17508. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17509. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17510. */
  17511. static readonly FILTER_POISSONSAMPLING: number;
  17512. /**
  17513. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17514. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17515. */
  17516. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17517. /**
  17518. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17519. * edge artifacts on steep falloff.
  17520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17521. */
  17522. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17523. /**
  17524. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17525. * edge artifacts on steep falloff.
  17526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17527. */
  17528. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17529. /**
  17530. * Shadow generator mode PCF: Percentage Closer Filtering
  17531. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17532. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17533. */
  17534. static readonly FILTER_PCF: number;
  17535. /**
  17536. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17538. * Contact Hardening
  17539. */
  17540. static readonly FILTER_PCSS: number;
  17541. /**
  17542. * Reserved for PCF and PCSS
  17543. * Highest Quality.
  17544. *
  17545. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17546. *
  17547. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17548. */
  17549. static readonly QUALITY_HIGH: number;
  17550. /**
  17551. * Reserved for PCF and PCSS
  17552. * Good tradeoff for quality/perf cross devices
  17553. *
  17554. * Execute PCF on a 3*3 kernel.
  17555. *
  17556. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17557. */
  17558. static readonly QUALITY_MEDIUM: number;
  17559. /**
  17560. * Reserved for PCF and PCSS
  17561. * The lowest quality but the fastest.
  17562. *
  17563. * Execute PCF on a 1*1 kernel.
  17564. *
  17565. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17566. */
  17567. static readonly QUALITY_LOW: number;
  17568. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17569. id: string;
  17570. /** Gets or sets the custom shader name to use */
  17571. customShaderOptions: ICustomShaderOptions;
  17572. /**
  17573. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17574. */
  17575. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17576. /**
  17577. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17578. */
  17579. onAfterShadowMapRenderObservable: Observable<Effect>;
  17580. /**
  17581. * Observable triggered before a mesh is rendered in the shadow map.
  17582. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17583. */
  17584. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17585. /**
  17586. * Observable triggered after a mesh is rendered in the shadow map.
  17587. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17588. */
  17589. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17590. protected _bias: number;
  17591. /**
  17592. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17593. */
  17594. get bias(): number;
  17595. /**
  17596. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17597. */
  17598. set bias(bias: number);
  17599. protected _normalBias: number;
  17600. /**
  17601. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17602. */
  17603. get normalBias(): number;
  17604. /**
  17605. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17606. */
  17607. set normalBias(normalBias: number);
  17608. protected _blurBoxOffset: number;
  17609. /**
  17610. * Gets the blur box offset: offset applied during the blur pass.
  17611. * Only useful if useKernelBlur = false
  17612. */
  17613. get blurBoxOffset(): number;
  17614. /**
  17615. * Sets the blur box offset: offset applied during the blur pass.
  17616. * Only useful if useKernelBlur = false
  17617. */
  17618. set blurBoxOffset(value: number);
  17619. protected _blurScale: number;
  17620. /**
  17621. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17622. * 2 means half of the size.
  17623. */
  17624. get blurScale(): number;
  17625. /**
  17626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17627. * 2 means half of the size.
  17628. */
  17629. set blurScale(value: number);
  17630. protected _blurKernel: number;
  17631. /**
  17632. * Gets the blur kernel: kernel size of the blur pass.
  17633. * Only useful if useKernelBlur = true
  17634. */
  17635. get blurKernel(): number;
  17636. /**
  17637. * Sets the blur kernel: kernel size of the blur pass.
  17638. * Only useful if useKernelBlur = true
  17639. */
  17640. set blurKernel(value: number);
  17641. protected _useKernelBlur: boolean;
  17642. /**
  17643. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17644. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17645. */
  17646. get useKernelBlur(): boolean;
  17647. /**
  17648. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17649. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17650. */
  17651. set useKernelBlur(value: boolean);
  17652. protected _depthScale: number;
  17653. /**
  17654. * Gets the depth scale used in ESM mode.
  17655. */
  17656. get depthScale(): number;
  17657. /**
  17658. * Sets the depth scale used in ESM mode.
  17659. * This can override the scale stored on the light.
  17660. */
  17661. set depthScale(value: number);
  17662. protected _validateFilter(filter: number): number;
  17663. protected _filter: number;
  17664. /**
  17665. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17667. */
  17668. get filter(): number;
  17669. /**
  17670. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17671. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17672. */
  17673. set filter(value: number);
  17674. /**
  17675. * Gets if the current filter is set to Poisson Sampling.
  17676. */
  17677. get usePoissonSampling(): boolean;
  17678. /**
  17679. * Sets the current filter to Poisson Sampling.
  17680. */
  17681. set usePoissonSampling(value: boolean);
  17682. /**
  17683. * Gets if the current filter is set to ESM.
  17684. */
  17685. get useExponentialShadowMap(): boolean;
  17686. /**
  17687. * Sets the current filter is to ESM.
  17688. */
  17689. set useExponentialShadowMap(value: boolean);
  17690. /**
  17691. * Gets if the current filter is set to filtered ESM.
  17692. */
  17693. get useBlurExponentialShadowMap(): boolean;
  17694. /**
  17695. * Gets if the current filter is set to filtered ESM.
  17696. */
  17697. set useBlurExponentialShadowMap(value: boolean);
  17698. /**
  17699. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17700. * exponential to prevent steep falloff artifacts).
  17701. */
  17702. get useCloseExponentialShadowMap(): boolean;
  17703. /**
  17704. * Sets the current filter to "close ESM" (using the inverse of the
  17705. * exponential to prevent steep falloff artifacts).
  17706. */
  17707. set useCloseExponentialShadowMap(value: boolean);
  17708. /**
  17709. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17710. * exponential to prevent steep falloff artifacts).
  17711. */
  17712. get useBlurCloseExponentialShadowMap(): boolean;
  17713. /**
  17714. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17715. * exponential to prevent steep falloff artifacts).
  17716. */
  17717. set useBlurCloseExponentialShadowMap(value: boolean);
  17718. /**
  17719. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17720. */
  17721. get usePercentageCloserFiltering(): boolean;
  17722. /**
  17723. * Sets the current filter to "PCF" (percentage closer filtering).
  17724. */
  17725. set usePercentageCloserFiltering(value: boolean);
  17726. protected _filteringQuality: number;
  17727. /**
  17728. * Gets the PCF or PCSS Quality.
  17729. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17730. */
  17731. get filteringQuality(): number;
  17732. /**
  17733. * Sets the PCF or PCSS Quality.
  17734. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17735. */
  17736. set filteringQuality(filteringQuality: number);
  17737. /**
  17738. * Gets if the current filter is set to "PCSS" (contact hardening).
  17739. */
  17740. get useContactHardeningShadow(): boolean;
  17741. /**
  17742. * Sets the current filter to "PCSS" (contact hardening).
  17743. */
  17744. set useContactHardeningShadow(value: boolean);
  17745. protected _contactHardeningLightSizeUVRatio: number;
  17746. /**
  17747. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17748. * Using a ratio helps keeping shape stability independently of the map size.
  17749. *
  17750. * It does not account for the light projection as it was having too much
  17751. * instability during the light setup or during light position changes.
  17752. *
  17753. * Only valid if useContactHardeningShadow is true.
  17754. */
  17755. get contactHardeningLightSizeUVRatio(): number;
  17756. /**
  17757. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17758. * Using a ratio helps keeping shape stability independently of the map size.
  17759. *
  17760. * It does not account for the light projection as it was having too much
  17761. * instability during the light setup or during light position changes.
  17762. *
  17763. * Only valid if useContactHardeningShadow is true.
  17764. */
  17765. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17766. protected _darkness: number;
  17767. /** Gets or sets the actual darkness of a shadow */
  17768. get darkness(): number;
  17769. set darkness(value: number);
  17770. /**
  17771. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17772. * 0 means strongest and 1 would means no shadow.
  17773. * @returns the darkness.
  17774. */
  17775. getDarkness(): number;
  17776. /**
  17777. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17778. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17779. * @returns the shadow generator allowing fluent coding.
  17780. */
  17781. setDarkness(darkness: number): ShadowGenerator;
  17782. protected _transparencyShadow: boolean;
  17783. /** Gets or sets the ability to have transparent shadow */
  17784. get transparencyShadow(): boolean;
  17785. set transparencyShadow(value: boolean);
  17786. /**
  17787. * Sets the ability to have transparent shadow (boolean).
  17788. * @param transparent True if transparent else False
  17789. * @returns the shadow generator allowing fluent coding
  17790. */
  17791. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17792. /**
  17793. * Enables or disables shadows with varying strength based on the transparency
  17794. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17795. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17796. * mesh.visibility * alphaTexture.a
  17797. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17798. */
  17799. enableSoftTransparentShadow: boolean;
  17800. protected _shadowMap: Nullable<RenderTargetTexture>;
  17801. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17802. /**
  17803. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17804. * @returns The render target texture if present otherwise, null
  17805. */
  17806. getShadowMap(): Nullable<RenderTargetTexture>;
  17807. /**
  17808. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17809. * @returns The render target texture if the shadow map is present otherwise, null
  17810. */
  17811. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17812. /**
  17813. * Gets the class name of that object
  17814. * @returns "ShadowGenerator"
  17815. */
  17816. getClassName(): string;
  17817. /**
  17818. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17819. * @param mesh Mesh to add
  17820. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17821. * @returns the Shadow Generator itself
  17822. */
  17823. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17824. /**
  17825. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17826. * @param mesh Mesh to remove
  17827. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17828. * @returns the Shadow Generator itself
  17829. */
  17830. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17831. /**
  17832. * Controls the extent to which the shadows fade out at the edge of the frustum
  17833. */
  17834. frustumEdgeFalloff: number;
  17835. protected _light: IShadowLight;
  17836. /**
  17837. * Returns the associated light object.
  17838. * @returns the light generating the shadow
  17839. */
  17840. getLight(): IShadowLight;
  17841. /**
  17842. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17843. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17844. * It might on the other hand introduce peter panning.
  17845. */
  17846. forceBackFacesOnly: boolean;
  17847. protected _scene: Scene;
  17848. protected _lightDirection: Vector3;
  17849. protected _effect: Effect;
  17850. protected _viewMatrix: Matrix;
  17851. protected _projectionMatrix: Matrix;
  17852. protected _transformMatrix: Matrix;
  17853. protected _cachedPosition: Vector3;
  17854. protected _cachedDirection: Vector3;
  17855. protected _cachedDefines: string;
  17856. protected _currentRenderID: number;
  17857. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17858. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17859. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17860. protected _blurPostProcesses: PostProcess[];
  17861. protected _mapSize: number;
  17862. protected _currentFaceIndex: number;
  17863. protected _currentFaceIndexCache: number;
  17864. protected _textureType: number;
  17865. protected _defaultTextureMatrix: Matrix;
  17866. protected _storedUniqueId: Nullable<number>;
  17867. /** @hidden */
  17868. static _SceneComponentInitialization: (scene: Scene) => void;
  17869. /**
  17870. * Creates a ShadowGenerator object.
  17871. * A ShadowGenerator is the required tool to use the shadows.
  17872. * Each light casting shadows needs to use its own ShadowGenerator.
  17873. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17874. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17875. * @param light The light object generating the shadows.
  17876. * @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.
  17877. */
  17878. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17879. protected _initializeGenerator(): void;
  17880. protected _createTargetRenderTexture(): void;
  17881. protected _initializeShadowMap(): void;
  17882. protected _initializeBlurRTTAndPostProcesses(): void;
  17883. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17884. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17885. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17886. protected _applyFilterValues(): void;
  17887. /**
  17888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17889. * @param onCompiled Callback triggered at the and of the effects compilation
  17890. * @param options Sets of optional options forcing the compilation with different modes
  17891. */
  17892. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17893. useInstances: boolean;
  17894. }>): void;
  17895. /**
  17896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17897. * @param options Sets of optional options forcing the compilation with different modes
  17898. * @returns A promise that resolves when the compilation completes
  17899. */
  17900. forceCompilationAsync(options?: Partial<{
  17901. useInstances: boolean;
  17902. }>): Promise<void>;
  17903. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17904. private _prepareShadowDefines;
  17905. /**
  17906. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17907. * @param subMesh The submesh we want to render in the shadow map
  17908. * @param useInstances Defines wether will draw in the map using instances
  17909. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17910. * @returns true if ready otherwise, false
  17911. */
  17912. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17913. /**
  17914. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17915. * @param defines Defines of the material we want to update
  17916. * @param lightIndex Index of the light in the enabled light list of the material
  17917. */
  17918. prepareDefines(defines: any, lightIndex: number): void;
  17919. /**
  17920. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17921. * defined in the generator but impacting the effect).
  17922. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17923. * @param effect The effect we are binfing the information for
  17924. */
  17925. bindShadowLight(lightIndex: string, effect: Effect): void;
  17926. /**
  17927. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17928. * (eq to shadow prjection matrix * light transform matrix)
  17929. * @returns The transform matrix used to create the shadow map
  17930. */
  17931. getTransformMatrix(): Matrix;
  17932. /**
  17933. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17934. * Cube and 2D textures for instance.
  17935. */
  17936. recreateShadowMap(): void;
  17937. protected _disposeBlurPostProcesses(): void;
  17938. protected _disposeRTTandPostProcesses(): void;
  17939. /**
  17940. * Disposes the ShadowGenerator.
  17941. * Returns nothing.
  17942. */
  17943. dispose(): void;
  17944. /**
  17945. * Serializes the shadow generator setup to a json object.
  17946. * @returns The serialized JSON object
  17947. */
  17948. serialize(): any;
  17949. /**
  17950. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17951. * @param parsedShadowGenerator The JSON object to parse
  17952. * @param scene The scene to create the shadow map for
  17953. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17954. * @returns The parsed shadow generator
  17955. */
  17956. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17957. }
  17958. }
  17959. declare module BABYLON {
  17960. /**
  17961. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17962. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17963. * 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.
  17964. */
  17965. export abstract class Light extends Node {
  17966. /**
  17967. * Falloff Default: light is falling off following the material specification:
  17968. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17969. */
  17970. static readonly FALLOFF_DEFAULT: number;
  17971. /**
  17972. * Falloff Physical: light is falling off following the inverse squared distance law.
  17973. */
  17974. static readonly FALLOFF_PHYSICAL: number;
  17975. /**
  17976. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17977. * to enhance interoperability with other engines.
  17978. */
  17979. static readonly FALLOFF_GLTF: number;
  17980. /**
  17981. * Falloff Standard: light is falling off like in the standard material
  17982. * to enhance interoperability with other materials.
  17983. */
  17984. static readonly FALLOFF_STANDARD: number;
  17985. /**
  17986. * If every light affecting the material is in this lightmapMode,
  17987. * material.lightmapTexture adds or multiplies
  17988. * (depends on material.useLightmapAsShadowmap)
  17989. * after every other light calculations.
  17990. */
  17991. static readonly LIGHTMAP_DEFAULT: number;
  17992. /**
  17993. * material.lightmapTexture as only diffuse lighting from this light
  17994. * adds only specular lighting from this light
  17995. * adds dynamic shadows
  17996. */
  17997. static readonly LIGHTMAP_SPECULAR: number;
  17998. /**
  17999. * material.lightmapTexture as only lighting
  18000. * no light calculation from this light
  18001. * only adds dynamic shadows from this light
  18002. */
  18003. static readonly LIGHTMAP_SHADOWSONLY: number;
  18004. /**
  18005. * Each light type uses the default quantity according to its type:
  18006. * point/spot lights use luminous intensity
  18007. * directional lights use illuminance
  18008. */
  18009. static readonly INTENSITYMODE_AUTOMATIC: number;
  18010. /**
  18011. * lumen (lm)
  18012. */
  18013. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18014. /**
  18015. * candela (lm/sr)
  18016. */
  18017. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18018. /**
  18019. * lux (lm/m^2)
  18020. */
  18021. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18022. /**
  18023. * nit (cd/m^2)
  18024. */
  18025. static readonly INTENSITYMODE_LUMINANCE: number;
  18026. /**
  18027. * Light type const id of the point light.
  18028. */
  18029. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18030. /**
  18031. * Light type const id of the directional light.
  18032. */
  18033. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18034. /**
  18035. * Light type const id of the spot light.
  18036. */
  18037. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18038. /**
  18039. * Light type const id of the hemispheric light.
  18040. */
  18041. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18042. /**
  18043. * Diffuse gives the basic color to an object.
  18044. */
  18045. diffuse: Color3;
  18046. /**
  18047. * Specular produces a highlight color on an object.
  18048. * Note: This is note affecting PBR materials.
  18049. */
  18050. specular: Color3;
  18051. /**
  18052. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18053. * falling off base on range or angle.
  18054. * This can be set to any values in Light.FALLOFF_x.
  18055. *
  18056. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18057. * other types of materials.
  18058. */
  18059. falloffType: number;
  18060. /**
  18061. * Strength of the light.
  18062. * Note: By default it is define in the framework own unit.
  18063. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18064. */
  18065. intensity: number;
  18066. private _range;
  18067. protected _inverseSquaredRange: number;
  18068. /**
  18069. * Defines how far from the source the light is impacting in scene units.
  18070. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18071. */
  18072. get range(): number;
  18073. /**
  18074. * Defines how far from the source the light is impacting in scene units.
  18075. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18076. */
  18077. set range(value: number);
  18078. /**
  18079. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18080. * of light.
  18081. */
  18082. private _photometricScale;
  18083. private _intensityMode;
  18084. /**
  18085. * Gets the photometric scale used to interpret the intensity.
  18086. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18087. */
  18088. get intensityMode(): number;
  18089. /**
  18090. * Sets the photometric scale used to interpret the intensity.
  18091. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18092. */
  18093. set intensityMode(value: number);
  18094. private _radius;
  18095. /**
  18096. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18097. */
  18098. get radius(): number;
  18099. /**
  18100. * sets the light radius used by PBR Materials to simulate soft area lights.
  18101. */
  18102. set radius(value: number);
  18103. private _renderPriority;
  18104. /**
  18105. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18106. * exceeding the number allowed of the materials.
  18107. */
  18108. renderPriority: number;
  18109. private _shadowEnabled;
  18110. /**
  18111. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18112. * the current shadow generator.
  18113. */
  18114. get shadowEnabled(): boolean;
  18115. /**
  18116. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18117. * the current shadow generator.
  18118. */
  18119. set shadowEnabled(value: boolean);
  18120. private _includedOnlyMeshes;
  18121. /**
  18122. * Gets the only meshes impacted by this light.
  18123. */
  18124. get includedOnlyMeshes(): AbstractMesh[];
  18125. /**
  18126. * Sets the only meshes impacted by this light.
  18127. */
  18128. set includedOnlyMeshes(value: AbstractMesh[]);
  18129. private _excludedMeshes;
  18130. /**
  18131. * Gets the meshes not impacted by this light.
  18132. */
  18133. get excludedMeshes(): AbstractMesh[];
  18134. /**
  18135. * Sets the meshes not impacted by this light.
  18136. */
  18137. set excludedMeshes(value: AbstractMesh[]);
  18138. private _excludeWithLayerMask;
  18139. /**
  18140. * Gets the layer id use to find what meshes are not impacted by the light.
  18141. * Inactive if 0
  18142. */
  18143. get excludeWithLayerMask(): number;
  18144. /**
  18145. * Sets the layer id use to find what meshes are not impacted by the light.
  18146. * Inactive if 0
  18147. */
  18148. set excludeWithLayerMask(value: number);
  18149. private _includeOnlyWithLayerMask;
  18150. /**
  18151. * Gets the layer id use to find what meshes are impacted by the light.
  18152. * Inactive if 0
  18153. */
  18154. get includeOnlyWithLayerMask(): number;
  18155. /**
  18156. * Sets the layer id use to find what meshes are impacted by the light.
  18157. * Inactive if 0
  18158. */
  18159. set includeOnlyWithLayerMask(value: number);
  18160. private _lightmapMode;
  18161. /**
  18162. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18163. */
  18164. get lightmapMode(): number;
  18165. /**
  18166. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18167. */
  18168. set lightmapMode(value: number);
  18169. /**
  18170. * Shadow generator associted to the light.
  18171. * @hidden Internal use only.
  18172. */
  18173. _shadowGenerator: Nullable<IShadowGenerator>;
  18174. /**
  18175. * @hidden Internal use only.
  18176. */
  18177. _excludedMeshesIds: string[];
  18178. /**
  18179. * @hidden Internal use only.
  18180. */
  18181. _includedOnlyMeshesIds: string[];
  18182. /**
  18183. * The current light unifom buffer.
  18184. * @hidden Internal use only.
  18185. */
  18186. _uniformBuffer: UniformBuffer;
  18187. /** @hidden */
  18188. _renderId: number;
  18189. /**
  18190. * Creates a Light object in the scene.
  18191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18192. * @param name The firendly name of the light
  18193. * @param scene The scene the light belongs too
  18194. */
  18195. constructor(name: string, scene: Scene);
  18196. protected abstract _buildUniformLayout(): void;
  18197. /**
  18198. * Sets the passed Effect "effect" with the Light information.
  18199. * @param effect The effect to update
  18200. * @param lightIndex The index of the light in the effect to update
  18201. * @returns The light
  18202. */
  18203. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18204. /**
  18205. * Sets the passed Effect "effect" with the Light textures.
  18206. * @param effect The effect to update
  18207. * @param lightIndex The index of the light in the effect to update
  18208. * @returns The light
  18209. */
  18210. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18211. /**
  18212. * Binds the lights information from the scene to the effect for the given mesh.
  18213. * @param lightIndex Light index
  18214. * @param scene The scene where the light belongs to
  18215. * @param effect The effect we are binding the data to
  18216. * @param useSpecular Defines if specular is supported
  18217. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18218. */
  18219. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18220. /**
  18221. * Sets the passed Effect "effect" with the Light information.
  18222. * @param effect The effect to update
  18223. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18224. * @returns The light
  18225. */
  18226. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18227. /**
  18228. * Returns the string "Light".
  18229. * @returns the class name
  18230. */
  18231. getClassName(): string;
  18232. /** @hidden */
  18233. readonly _isLight: boolean;
  18234. /**
  18235. * Converts the light information to a readable string for debug purpose.
  18236. * @param fullDetails Supports for multiple levels of logging within scene loading
  18237. * @returns the human readable light info
  18238. */
  18239. toString(fullDetails?: boolean): string;
  18240. /** @hidden */
  18241. protected _syncParentEnabledState(): void;
  18242. /**
  18243. * Set the enabled state of this node.
  18244. * @param value - the new enabled state
  18245. */
  18246. setEnabled(value: boolean): void;
  18247. /**
  18248. * Returns the Light associated shadow generator if any.
  18249. * @return the associated shadow generator.
  18250. */
  18251. getShadowGenerator(): Nullable<IShadowGenerator>;
  18252. /**
  18253. * Returns a Vector3, the absolute light position in the World.
  18254. * @returns the world space position of the light
  18255. */
  18256. getAbsolutePosition(): Vector3;
  18257. /**
  18258. * Specifies if the light will affect the passed mesh.
  18259. * @param mesh The mesh to test against the light
  18260. * @return true the mesh is affected otherwise, false.
  18261. */
  18262. canAffectMesh(mesh: AbstractMesh): boolean;
  18263. /**
  18264. * Sort function to order lights for rendering.
  18265. * @param a First Light object to compare to second.
  18266. * @param b Second Light object to compare first.
  18267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18268. */
  18269. static CompareLightsPriority(a: Light, b: Light): number;
  18270. /**
  18271. * Releases resources associated with this node.
  18272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18274. */
  18275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18276. /**
  18277. * Returns the light type ID (integer).
  18278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18279. */
  18280. getTypeID(): number;
  18281. /**
  18282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18283. * @returns the scaled intensity in intensity mode unit
  18284. */
  18285. getScaledIntensity(): number;
  18286. /**
  18287. * Returns a new Light object, named "name", from the current one.
  18288. * @param name The name of the cloned light
  18289. * @param newParent The parent of this light, if it has one
  18290. * @returns the new created light
  18291. */
  18292. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18293. /**
  18294. * Serializes the current light into a Serialization object.
  18295. * @returns the serialized object.
  18296. */
  18297. serialize(): any;
  18298. /**
  18299. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18300. * This new light is named "name" and added to the passed scene.
  18301. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18302. * @param name The friendly name of the light
  18303. * @param scene The scene the new light will belong to
  18304. * @returns the constructor function
  18305. */
  18306. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18307. /**
  18308. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18309. * @param parsedLight The JSON representation of the light
  18310. * @param scene The scene to create the parsed light in
  18311. * @returns the created light after parsing
  18312. */
  18313. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18314. private _hookArrayForExcluded;
  18315. private _hookArrayForIncludedOnly;
  18316. private _resyncMeshes;
  18317. /**
  18318. * Forces the meshes to update their light related information in their rendering used effects
  18319. * @hidden Internal Use Only
  18320. */
  18321. _markMeshesAsLightDirty(): void;
  18322. /**
  18323. * Recomputes the cached photometric scale if needed.
  18324. */
  18325. private _computePhotometricScale;
  18326. /**
  18327. * Returns the Photometric Scale according to the light type and intensity mode.
  18328. */
  18329. private _getPhotometricScale;
  18330. /**
  18331. * Reorder the light in the scene according to their defined priority.
  18332. * @hidden Internal Use Only
  18333. */
  18334. _reorderLightsInScene(): void;
  18335. /**
  18336. * Prepares the list of defines specific to the light type.
  18337. * @param defines the list of defines
  18338. * @param lightIndex defines the index of the light for the effect
  18339. */
  18340. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18341. }
  18342. }
  18343. declare module BABYLON {
  18344. /**
  18345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18346. * This is the base of the follow, arc rotate cameras and Free camera
  18347. * @see https://doc.babylonjs.com/features/cameras
  18348. */
  18349. export class TargetCamera extends Camera {
  18350. private static _RigCamTransformMatrix;
  18351. private static _TargetTransformMatrix;
  18352. private static _TargetFocalPoint;
  18353. private _tmpUpVector;
  18354. private _tmpTargetVector;
  18355. /**
  18356. * Define the current direction the camera is moving to
  18357. */
  18358. cameraDirection: Vector3;
  18359. /**
  18360. * Define the current rotation the camera is rotating to
  18361. */
  18362. cameraRotation: Vector2;
  18363. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18364. ignoreParentScaling: boolean;
  18365. /**
  18366. * When set, the up vector of the camera will be updated by the rotation of the camera
  18367. */
  18368. updateUpVectorFromRotation: boolean;
  18369. private _tmpQuaternion;
  18370. /**
  18371. * Define the current rotation of the camera
  18372. */
  18373. rotation: Vector3;
  18374. /**
  18375. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18376. */
  18377. rotationQuaternion: Quaternion;
  18378. /**
  18379. * Define the current speed of the camera
  18380. */
  18381. speed: number;
  18382. /**
  18383. * Add constraint to the camera to prevent it to move freely in all directions and
  18384. * around all axis.
  18385. */
  18386. noRotationConstraint: boolean;
  18387. /**
  18388. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18389. * panning
  18390. */
  18391. invertRotation: boolean;
  18392. /**
  18393. * Speed multiplier for inverse camera panning
  18394. */
  18395. inverseRotationSpeed: number;
  18396. /**
  18397. * Define the current target of the camera as an object or a position.
  18398. */
  18399. lockedTarget: any;
  18400. /** @hidden */
  18401. _currentTarget: Vector3;
  18402. /** @hidden */
  18403. _initialFocalDistance: number;
  18404. /** @hidden */
  18405. _viewMatrix: Matrix;
  18406. /** @hidden */
  18407. _camMatrix: Matrix;
  18408. /** @hidden */
  18409. _cameraTransformMatrix: Matrix;
  18410. /** @hidden */
  18411. _cameraRotationMatrix: Matrix;
  18412. /** @hidden */
  18413. _referencePoint: Vector3;
  18414. /** @hidden */
  18415. _transformedReferencePoint: Vector3;
  18416. /** @hidden */
  18417. _reset: () => void;
  18418. private _defaultUp;
  18419. /**
  18420. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18421. * This is the base of the follow, arc rotate cameras and Free camera
  18422. * @see https://doc.babylonjs.com/features/cameras
  18423. * @param name Defines the name of the camera in the scene
  18424. * @param position Defines the start position of the camera in the scene
  18425. * @param scene Defines the scene the camera belongs to
  18426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18427. */
  18428. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18429. /**
  18430. * Gets the position in front of the camera at a given distance.
  18431. * @param distance The distance from the camera we want the position to be
  18432. * @returns the position
  18433. */
  18434. getFrontPosition(distance: number): Vector3;
  18435. /** @hidden */
  18436. _getLockedTargetPosition(): Nullable<Vector3>;
  18437. private _storedPosition;
  18438. private _storedRotation;
  18439. private _storedRotationQuaternion;
  18440. /**
  18441. * Store current camera state of the camera (fov, position, rotation, etc..)
  18442. * @returns the camera
  18443. */
  18444. storeState(): Camera;
  18445. /**
  18446. * Restored camera state. You must call storeState() first
  18447. * @returns whether it was successful or not
  18448. * @hidden
  18449. */
  18450. _restoreStateValues(): boolean;
  18451. /** @hidden */
  18452. _initCache(): void;
  18453. /** @hidden */
  18454. _updateCache(ignoreParentClass?: boolean): void;
  18455. /** @hidden */
  18456. _isSynchronizedViewMatrix(): boolean;
  18457. /** @hidden */
  18458. _computeLocalCameraSpeed(): number;
  18459. /**
  18460. * Defines the target the camera should look at.
  18461. * @param target Defines the new target as a Vector or a mesh
  18462. */
  18463. setTarget(target: Vector3): void;
  18464. /**
  18465. * Defines the target point of the camera.
  18466. * The camera looks towards it form the radius distance.
  18467. */
  18468. get target(): Vector3;
  18469. set target(value: Vector3);
  18470. /**
  18471. * Return the current target position of the camera. This value is expressed in local space.
  18472. * @returns the target position
  18473. */
  18474. getTarget(): Vector3;
  18475. /** @hidden */
  18476. _decideIfNeedsToMove(): boolean;
  18477. /** @hidden */
  18478. _updatePosition(): void;
  18479. /** @hidden */
  18480. _checkInputs(): void;
  18481. protected _updateCameraRotationMatrix(): void;
  18482. /**
  18483. * 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)
  18484. * @returns the current camera
  18485. */
  18486. private _rotateUpVectorWithCameraRotationMatrix;
  18487. private _cachedRotationZ;
  18488. private _cachedQuaternionRotationZ;
  18489. /** @hidden */
  18490. _getViewMatrix(): Matrix;
  18491. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18492. /**
  18493. * @hidden
  18494. */
  18495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18496. /**
  18497. * @hidden
  18498. */
  18499. _updateRigCameras(): void;
  18500. private _getRigCamPositionAndTarget;
  18501. /**
  18502. * Gets the current object class name.
  18503. * @return the class name
  18504. */
  18505. getClassName(): string;
  18506. }
  18507. }
  18508. declare module BABYLON {
  18509. /**
  18510. * Gather the list of keyboard event types as constants.
  18511. */
  18512. export class KeyboardEventTypes {
  18513. /**
  18514. * The keydown event is fired when a key becomes active (pressed).
  18515. */
  18516. static readonly KEYDOWN: number;
  18517. /**
  18518. * The keyup event is fired when a key has been released.
  18519. */
  18520. static readonly KEYUP: number;
  18521. }
  18522. /**
  18523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18524. */
  18525. export class KeyboardInfo {
  18526. /**
  18527. * Defines the type of event (KeyboardEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: KeyboardEvent;
  18534. /**
  18535. * Instantiates a new keyboard info.
  18536. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18537. * @param type Defines the type of event (KeyboardEventTypes)
  18538. * @param event Defines the related dom event
  18539. */
  18540. constructor(
  18541. /**
  18542. * Defines the type of event (KeyboardEventTypes)
  18543. */
  18544. type: number,
  18545. /**
  18546. * Defines the related dom event
  18547. */
  18548. event: KeyboardEvent);
  18549. }
  18550. /**
  18551. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18552. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18553. */
  18554. export class KeyboardInfoPre extends KeyboardInfo {
  18555. /**
  18556. * Defines the type of event (KeyboardEventTypes)
  18557. */
  18558. type: number;
  18559. /**
  18560. * Defines the related dom event
  18561. */
  18562. event: KeyboardEvent;
  18563. /**
  18564. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18565. */
  18566. skipOnPointerObservable: boolean;
  18567. /**
  18568. * Instantiates a new keyboard pre info.
  18569. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18570. * @param type Defines the type of event (KeyboardEventTypes)
  18571. * @param event Defines the related dom event
  18572. */
  18573. constructor(
  18574. /**
  18575. * Defines the type of event (KeyboardEventTypes)
  18576. */
  18577. type: number,
  18578. /**
  18579. * Defines the related dom event
  18580. */
  18581. event: KeyboardEvent);
  18582. }
  18583. }
  18584. declare module BABYLON {
  18585. /**
  18586. * Manage the keyboard inputs to control the movement of a free camera.
  18587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18588. */
  18589. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18590. /**
  18591. * Defines the camera the input is attached to.
  18592. */
  18593. camera: FreeCamera;
  18594. /**
  18595. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18596. */
  18597. keysUp: number[];
  18598. /**
  18599. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18600. */
  18601. keysUpward: number[];
  18602. /**
  18603. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18604. */
  18605. keysDown: number[];
  18606. /**
  18607. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18608. */
  18609. keysDownward: number[];
  18610. /**
  18611. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18612. */
  18613. keysLeft: number[];
  18614. /**
  18615. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18616. */
  18617. keysRight: number[];
  18618. private _keys;
  18619. private _onCanvasBlurObserver;
  18620. private _onKeyboardObserver;
  18621. private _engine;
  18622. private _scene;
  18623. /**
  18624. * Attach the input controls to a specific dom element to get the input from.
  18625. * @param element Defines the element the controls should be listened from
  18626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18627. */
  18628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18629. /**
  18630. * Detach the current controls from the specified dom element.
  18631. * @param element Defines the element to stop listening the inputs from
  18632. */
  18633. detachControl(element: Nullable<HTMLElement>): void;
  18634. /**
  18635. * Update the current camera state depending on the inputs that have been used this frame.
  18636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18637. */
  18638. checkInputs(): void;
  18639. /**
  18640. * Gets the class name of the current intput.
  18641. * @returns the class name
  18642. */
  18643. getClassName(): string;
  18644. /** @hidden */
  18645. _onLostFocus(): void;
  18646. /**
  18647. * Get the friendly name associated with the input class.
  18648. * @returns the input friendly name
  18649. */
  18650. getSimpleName(): string;
  18651. }
  18652. }
  18653. declare module BABYLON {
  18654. /**
  18655. * Gather the list of pointer event types as constants.
  18656. */
  18657. export class PointerEventTypes {
  18658. /**
  18659. * 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.
  18660. */
  18661. static readonly POINTERDOWN: number;
  18662. /**
  18663. * The pointerup event is fired when a pointer is no longer active.
  18664. */
  18665. static readonly POINTERUP: number;
  18666. /**
  18667. * The pointermove event is fired when a pointer changes coordinates.
  18668. */
  18669. static readonly POINTERMOVE: number;
  18670. /**
  18671. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18672. */
  18673. static readonly POINTERWHEEL: number;
  18674. /**
  18675. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18676. */
  18677. static readonly POINTERPICK: number;
  18678. /**
  18679. * The pointertap event is fired when a the object has been touched and released without drag.
  18680. */
  18681. static readonly POINTERTAP: number;
  18682. /**
  18683. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18684. */
  18685. static readonly POINTERDOUBLETAP: number;
  18686. }
  18687. /**
  18688. * Base class of pointer info types.
  18689. */
  18690. export class PointerInfoBase {
  18691. /**
  18692. * Defines the type of event (PointerEventTypes)
  18693. */
  18694. type: number;
  18695. /**
  18696. * Defines the related dom event
  18697. */
  18698. event: PointerEvent | MouseWheelEvent;
  18699. /**
  18700. * Instantiates the base class of pointers info.
  18701. * @param type Defines the type of event (PointerEventTypes)
  18702. * @param event Defines the related dom event
  18703. */
  18704. constructor(
  18705. /**
  18706. * Defines the type of event (PointerEventTypes)
  18707. */
  18708. type: number,
  18709. /**
  18710. * Defines the related dom event
  18711. */
  18712. event: PointerEvent | MouseWheelEvent);
  18713. }
  18714. /**
  18715. * This class is used to store pointer related info for the onPrePointerObservable event.
  18716. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18717. */
  18718. export class PointerInfoPre extends PointerInfoBase {
  18719. /**
  18720. * Ray from a pointer if availible (eg. 6dof controller)
  18721. */
  18722. ray: Nullable<Ray>;
  18723. /**
  18724. * Defines the local position of the pointer on the canvas.
  18725. */
  18726. localPosition: Vector2;
  18727. /**
  18728. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18729. */
  18730. skipOnPointerObservable: boolean;
  18731. /**
  18732. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18733. * @param type Defines the type of event (PointerEventTypes)
  18734. * @param event Defines the related dom event
  18735. * @param localX Defines the local x coordinates of the pointer when the event occured
  18736. * @param localY Defines the local y coordinates of the pointer when the event occured
  18737. */
  18738. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18739. }
  18740. /**
  18741. * This type contains all the data related to a pointer event in Babylon.js.
  18742. * 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.
  18743. */
  18744. export class PointerInfo extends PointerInfoBase {
  18745. /**
  18746. * Defines the picking info associated to the info (if any)\
  18747. */
  18748. pickInfo: Nullable<PickingInfo>;
  18749. /**
  18750. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18751. * @param type Defines the type of event (PointerEventTypes)
  18752. * @param event Defines the related dom event
  18753. * @param pickInfo Defines the picking info associated to the info (if any)\
  18754. */
  18755. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18756. /**
  18757. * Defines the picking info associated to the info (if any)\
  18758. */
  18759. pickInfo: Nullable<PickingInfo>);
  18760. }
  18761. /**
  18762. * Data relating to a touch event on the screen.
  18763. */
  18764. export interface PointerTouch {
  18765. /**
  18766. * X coordinate of touch.
  18767. */
  18768. x: number;
  18769. /**
  18770. * Y coordinate of touch.
  18771. */
  18772. y: number;
  18773. /**
  18774. * Id of touch. Unique for each finger.
  18775. */
  18776. pointerId: number;
  18777. /**
  18778. * Event type passed from DOM.
  18779. */
  18780. type: any;
  18781. }
  18782. }
  18783. declare module BABYLON {
  18784. /**
  18785. * Manage the mouse inputs to control the movement of a free camera.
  18786. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18787. */
  18788. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18789. /**
  18790. * Define if touch is enabled in the mouse input
  18791. */
  18792. touchEnabled: boolean;
  18793. /**
  18794. * Defines the camera the input is attached to.
  18795. */
  18796. camera: FreeCamera;
  18797. /**
  18798. * Defines the buttons associated with the input to handle camera move.
  18799. */
  18800. buttons: number[];
  18801. /**
  18802. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18803. */
  18804. angularSensibility: number;
  18805. private _pointerInput;
  18806. private _onMouseMove;
  18807. private _observer;
  18808. private previousPosition;
  18809. /**
  18810. * Observable for when a pointer move event occurs containing the move offset
  18811. */
  18812. onPointerMovedObservable: Observable<{
  18813. offsetX: number;
  18814. offsetY: number;
  18815. }>;
  18816. /**
  18817. * @hidden
  18818. * If the camera should be rotated automatically based on pointer movement
  18819. */
  18820. _allowCameraRotation: boolean;
  18821. /**
  18822. * Manage the mouse inputs to control the movement of a free camera.
  18823. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18824. * @param touchEnabled Defines if touch is enabled or not
  18825. */
  18826. constructor(
  18827. /**
  18828. * Define if touch is enabled in the mouse input
  18829. */
  18830. touchEnabled?: boolean);
  18831. /**
  18832. * Attach the input controls to a specific dom element to get the input from.
  18833. * @param element Defines the element the controls should be listened from
  18834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18835. */
  18836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18837. /**
  18838. * Called on JS contextmenu event.
  18839. * Override this method to provide functionality.
  18840. */
  18841. protected onContextMenu(evt: PointerEvent): void;
  18842. /**
  18843. * Detach the current controls from the specified dom element.
  18844. * @param element Defines the element to stop listening the inputs from
  18845. */
  18846. detachControl(element: Nullable<HTMLElement>): void;
  18847. /**
  18848. * Gets the class name of the current intput.
  18849. * @returns the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Get the friendly name associated with the input class.
  18854. * @returns the input friendly name
  18855. */
  18856. getSimpleName(): string;
  18857. }
  18858. }
  18859. declare module BABYLON {
  18860. /**
  18861. * Manage the touch inputs to control the movement of a free camera.
  18862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18863. */
  18864. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18865. /**
  18866. * Define if mouse events can be treated as touch events
  18867. */
  18868. allowMouse: boolean;
  18869. /**
  18870. * Defines the camera the input is attached to.
  18871. */
  18872. camera: FreeCamera;
  18873. /**
  18874. * Defines the touch sensibility for rotation.
  18875. * The higher the faster.
  18876. */
  18877. touchAngularSensibility: number;
  18878. /**
  18879. * Defines the touch sensibility for move.
  18880. * The higher the faster.
  18881. */
  18882. touchMoveSensibility: number;
  18883. private _offsetX;
  18884. private _offsetY;
  18885. private _pointerPressed;
  18886. private _pointerInput;
  18887. private _observer;
  18888. private _onLostFocus;
  18889. /**
  18890. * Manage the touch inputs to control the movement of a free camera.
  18891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18892. * @param allowMouse Defines if mouse events can be treated as touch events
  18893. */
  18894. constructor(
  18895. /**
  18896. * Define if mouse events can be treated as touch events
  18897. */
  18898. allowMouse?: boolean);
  18899. /**
  18900. * Attach the input controls to a specific dom element to get the input from.
  18901. * @param element Defines the element the controls should be listened from
  18902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18903. */
  18904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18905. /**
  18906. * Detach the current controls from the specified dom element.
  18907. * @param element Defines the element to stop listening the inputs from
  18908. */
  18909. detachControl(element: Nullable<HTMLElement>): void;
  18910. /**
  18911. * Update the current camera state depending on the inputs that have been used this frame.
  18912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18913. */
  18914. checkInputs(): void;
  18915. /**
  18916. * Gets the class name of the current intput.
  18917. * @returns the class name
  18918. */
  18919. getClassName(): string;
  18920. /**
  18921. * Get the friendly name associated with the input class.
  18922. * @returns the input friendly name
  18923. */
  18924. getSimpleName(): string;
  18925. }
  18926. }
  18927. declare module BABYLON {
  18928. /**
  18929. * Default Inputs manager for the FreeCamera.
  18930. * It groups all the default supported inputs for ease of use.
  18931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18932. */
  18933. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18934. /**
  18935. * @hidden
  18936. */
  18937. _mouseInput: Nullable<FreeCameraMouseInput>;
  18938. /**
  18939. * Instantiates a new FreeCameraInputsManager.
  18940. * @param camera Defines the camera the inputs belong to
  18941. */
  18942. constructor(camera: FreeCamera);
  18943. /**
  18944. * Add keyboard input support to the input manager.
  18945. * @returns the current input manager
  18946. */
  18947. addKeyboard(): FreeCameraInputsManager;
  18948. /**
  18949. * Add mouse input support to the input manager.
  18950. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18951. * @returns the current input manager
  18952. */
  18953. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18954. /**
  18955. * Removes the mouse input support from the manager
  18956. * @returns the current input manager
  18957. */
  18958. removeMouse(): FreeCameraInputsManager;
  18959. /**
  18960. * Add touch input support to the input manager.
  18961. * @returns the current input manager
  18962. */
  18963. addTouch(): FreeCameraInputsManager;
  18964. /**
  18965. * Remove all attached input methods from a camera
  18966. */
  18967. clear(): void;
  18968. }
  18969. }
  18970. declare module BABYLON {
  18971. /**
  18972. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18973. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18974. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18975. */
  18976. export class FreeCamera extends TargetCamera {
  18977. /**
  18978. * Define the collision ellipsoid of the camera.
  18979. * This is helpful to simulate a camera body like the player body around the camera
  18980. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18981. */
  18982. ellipsoid: Vector3;
  18983. /**
  18984. * Define an offset for the position of the ellipsoid around the camera.
  18985. * This can be helpful to determine the center of the body near the gravity center of the body
  18986. * instead of its head.
  18987. */
  18988. ellipsoidOffset: Vector3;
  18989. /**
  18990. * Enable or disable collisions of the camera with the rest of the scene objects.
  18991. */
  18992. checkCollisions: boolean;
  18993. /**
  18994. * Enable or disable gravity on the camera.
  18995. */
  18996. applyGravity: boolean;
  18997. /**
  18998. * Define the input manager associated to the camera.
  18999. */
  19000. inputs: FreeCameraInputsManager;
  19001. /**
  19002. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19003. * Higher values reduce sensitivity.
  19004. */
  19005. get angularSensibility(): number;
  19006. /**
  19007. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19008. * Higher values reduce sensitivity.
  19009. */
  19010. set angularSensibility(value: number);
  19011. /**
  19012. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19013. */
  19014. get keysUp(): number[];
  19015. set keysUp(value: number[]);
  19016. /**
  19017. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19018. */
  19019. get keysUpward(): number[];
  19020. set keysUpward(value: number[]);
  19021. /**
  19022. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19023. */
  19024. get keysDown(): number[];
  19025. set keysDown(value: number[]);
  19026. /**
  19027. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19028. */
  19029. get keysDownward(): number[];
  19030. set keysDownward(value: number[]);
  19031. /**
  19032. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19033. */
  19034. get keysLeft(): number[];
  19035. set keysLeft(value: number[]);
  19036. /**
  19037. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19038. */
  19039. get keysRight(): number[];
  19040. set keysRight(value: number[]);
  19041. /**
  19042. * Event raised when the camera collide with a mesh in the scene.
  19043. */
  19044. onCollide: (collidedMesh: AbstractMesh) => void;
  19045. private _collider;
  19046. private _needMoveForGravity;
  19047. private _oldPosition;
  19048. private _diffPosition;
  19049. private _newPosition;
  19050. /** @hidden */
  19051. _localDirection: Vector3;
  19052. /** @hidden */
  19053. _transformedDirection: Vector3;
  19054. /**
  19055. * Instantiates a Free Camera.
  19056. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19057. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19058. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19059. * @param name Define the name of the camera in the scene
  19060. * @param position Define the start position of the camera in the scene
  19061. * @param scene Define the scene the camera belongs to
  19062. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19063. */
  19064. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19065. /**
  19066. * Attached controls to the current camera.
  19067. * @param element Defines the element the controls should be listened from
  19068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19069. */
  19070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19071. /**
  19072. * Detach the current controls from the camera.
  19073. * The camera will stop reacting to inputs.
  19074. * @param element Defines the element to stop listening the inputs from
  19075. */
  19076. detachControl(element: HTMLElement): void;
  19077. private _collisionMask;
  19078. /**
  19079. * Define a collision mask to limit the list of object the camera can collide with
  19080. */
  19081. get collisionMask(): number;
  19082. set collisionMask(mask: number);
  19083. /** @hidden */
  19084. _collideWithWorld(displacement: Vector3): void;
  19085. private _onCollisionPositionChange;
  19086. /** @hidden */
  19087. _checkInputs(): void;
  19088. /** @hidden */
  19089. _decideIfNeedsToMove(): boolean;
  19090. /** @hidden */
  19091. _updatePosition(): void;
  19092. /**
  19093. * Destroy the camera and release the current resources hold by it.
  19094. */
  19095. dispose(): void;
  19096. /**
  19097. * Gets the current object class name.
  19098. * @return the class name
  19099. */
  19100. getClassName(): string;
  19101. }
  19102. }
  19103. declare module BABYLON {
  19104. /**
  19105. * Represents a gamepad control stick position
  19106. */
  19107. export class StickValues {
  19108. /**
  19109. * The x component of the control stick
  19110. */
  19111. x: number;
  19112. /**
  19113. * The y component of the control stick
  19114. */
  19115. y: number;
  19116. /**
  19117. * Initializes the gamepad x and y control stick values
  19118. * @param x The x component of the gamepad control stick value
  19119. * @param y The y component of the gamepad control stick value
  19120. */
  19121. constructor(
  19122. /**
  19123. * The x component of the control stick
  19124. */
  19125. x: number,
  19126. /**
  19127. * The y component of the control stick
  19128. */
  19129. y: number);
  19130. }
  19131. /**
  19132. * An interface which manages callbacks for gamepad button changes
  19133. */
  19134. export interface GamepadButtonChanges {
  19135. /**
  19136. * Called when a gamepad has been changed
  19137. */
  19138. changed: boolean;
  19139. /**
  19140. * Called when a gamepad press event has been triggered
  19141. */
  19142. pressChanged: boolean;
  19143. /**
  19144. * Called when a touch event has been triggered
  19145. */
  19146. touchChanged: boolean;
  19147. /**
  19148. * Called when a value has changed
  19149. */
  19150. valueChanged: boolean;
  19151. }
  19152. /**
  19153. * Represents a gamepad
  19154. */
  19155. export class Gamepad {
  19156. /**
  19157. * The id of the gamepad
  19158. */
  19159. id: string;
  19160. /**
  19161. * The index of the gamepad
  19162. */
  19163. index: number;
  19164. /**
  19165. * The browser gamepad
  19166. */
  19167. browserGamepad: any;
  19168. /**
  19169. * Specifies what type of gamepad this represents
  19170. */
  19171. type: number;
  19172. private _leftStick;
  19173. private _rightStick;
  19174. /** @hidden */
  19175. _isConnected: boolean;
  19176. private _leftStickAxisX;
  19177. private _leftStickAxisY;
  19178. private _rightStickAxisX;
  19179. private _rightStickAxisY;
  19180. /**
  19181. * Triggered when the left control stick has been changed
  19182. */
  19183. private _onleftstickchanged;
  19184. /**
  19185. * Triggered when the right control stick has been changed
  19186. */
  19187. private _onrightstickchanged;
  19188. /**
  19189. * Represents a gamepad controller
  19190. */
  19191. static GAMEPAD: number;
  19192. /**
  19193. * Represents a generic controller
  19194. */
  19195. static GENERIC: number;
  19196. /**
  19197. * Represents an XBox controller
  19198. */
  19199. static XBOX: number;
  19200. /**
  19201. * Represents a pose-enabled controller
  19202. */
  19203. static POSE_ENABLED: number;
  19204. /**
  19205. * Represents an Dual Shock controller
  19206. */
  19207. static DUALSHOCK: number;
  19208. /**
  19209. * Specifies whether the left control stick should be Y-inverted
  19210. */
  19211. protected _invertLeftStickY: boolean;
  19212. /**
  19213. * Specifies if the gamepad has been connected
  19214. */
  19215. get isConnected(): boolean;
  19216. /**
  19217. * Initializes the gamepad
  19218. * @param id The id of the gamepad
  19219. * @param index The index of the gamepad
  19220. * @param browserGamepad The browser gamepad
  19221. * @param leftStickX The x component of the left joystick
  19222. * @param leftStickY The y component of the left joystick
  19223. * @param rightStickX The x component of the right joystick
  19224. * @param rightStickY The y component of the right joystick
  19225. */
  19226. constructor(
  19227. /**
  19228. * The id of the gamepad
  19229. */
  19230. id: string,
  19231. /**
  19232. * The index of the gamepad
  19233. */
  19234. index: number,
  19235. /**
  19236. * The browser gamepad
  19237. */
  19238. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19239. /**
  19240. * Callback triggered when the left joystick has changed
  19241. * @param callback
  19242. */
  19243. onleftstickchanged(callback: (values: StickValues) => void): void;
  19244. /**
  19245. * Callback triggered when the right joystick has changed
  19246. * @param callback
  19247. */
  19248. onrightstickchanged(callback: (values: StickValues) => void): void;
  19249. /**
  19250. * Gets the left joystick
  19251. */
  19252. get leftStick(): StickValues;
  19253. /**
  19254. * Sets the left joystick values
  19255. */
  19256. set leftStick(newValues: StickValues);
  19257. /**
  19258. * Gets the right joystick
  19259. */
  19260. get rightStick(): StickValues;
  19261. /**
  19262. * Sets the right joystick value
  19263. */
  19264. set rightStick(newValues: StickValues);
  19265. /**
  19266. * Updates the gamepad joystick positions
  19267. */
  19268. update(): void;
  19269. /**
  19270. * Disposes the gamepad
  19271. */
  19272. dispose(): void;
  19273. }
  19274. /**
  19275. * Represents a generic gamepad
  19276. */
  19277. export class GenericPad extends Gamepad {
  19278. private _buttons;
  19279. private _onbuttondown;
  19280. private _onbuttonup;
  19281. /**
  19282. * Observable triggered when a button has been pressed
  19283. */
  19284. onButtonDownObservable: Observable<number>;
  19285. /**
  19286. * Observable triggered when a button has been released
  19287. */
  19288. onButtonUpObservable: Observable<number>;
  19289. /**
  19290. * Callback triggered when a button has been pressed
  19291. * @param callback Called when a button has been pressed
  19292. */
  19293. onbuttondown(callback: (buttonPressed: number) => void): void;
  19294. /**
  19295. * Callback triggered when a button has been released
  19296. * @param callback Called when a button has been released
  19297. */
  19298. onbuttonup(callback: (buttonReleased: number) => void): void;
  19299. /**
  19300. * Initializes the generic gamepad
  19301. * @param id The id of the generic gamepad
  19302. * @param index The index of the generic gamepad
  19303. * @param browserGamepad The browser gamepad
  19304. */
  19305. constructor(id: string, index: number, browserGamepad: any);
  19306. private _setButtonValue;
  19307. /**
  19308. * Updates the generic gamepad
  19309. */
  19310. update(): void;
  19311. /**
  19312. * Disposes the generic gamepad
  19313. */
  19314. dispose(): void;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * Defines the types of pose enabled controllers that are supported
  19320. */
  19321. export enum PoseEnabledControllerType {
  19322. /**
  19323. * HTC Vive
  19324. */
  19325. VIVE = 0,
  19326. /**
  19327. * Oculus Rift
  19328. */
  19329. OCULUS = 1,
  19330. /**
  19331. * Windows mixed reality
  19332. */
  19333. WINDOWS = 2,
  19334. /**
  19335. * Samsung gear VR
  19336. */
  19337. GEAR_VR = 3,
  19338. /**
  19339. * Google Daydream
  19340. */
  19341. DAYDREAM = 4,
  19342. /**
  19343. * Generic
  19344. */
  19345. GENERIC = 5
  19346. }
  19347. /**
  19348. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19349. */
  19350. export interface MutableGamepadButton {
  19351. /**
  19352. * Value of the button/trigger
  19353. */
  19354. value: number;
  19355. /**
  19356. * If the button/trigger is currently touched
  19357. */
  19358. touched: boolean;
  19359. /**
  19360. * If the button/trigger is currently pressed
  19361. */
  19362. pressed: boolean;
  19363. }
  19364. /**
  19365. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19366. * @hidden
  19367. */
  19368. export interface ExtendedGamepadButton extends GamepadButton {
  19369. /**
  19370. * If the button/trigger is currently pressed
  19371. */
  19372. readonly pressed: boolean;
  19373. /**
  19374. * If the button/trigger is currently touched
  19375. */
  19376. readonly touched: boolean;
  19377. /**
  19378. * Value of the button/trigger
  19379. */
  19380. readonly value: number;
  19381. }
  19382. /** @hidden */
  19383. export interface _GamePadFactory {
  19384. /**
  19385. * Returns whether or not the current gamepad can be created for this type of controller.
  19386. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19387. * @returns true if it can be created, otherwise false
  19388. */
  19389. canCreate(gamepadInfo: any): boolean;
  19390. /**
  19391. * Creates a new instance of the Gamepad.
  19392. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19393. * @returns the new gamepad instance
  19394. */
  19395. create(gamepadInfo: any): Gamepad;
  19396. }
  19397. /**
  19398. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19399. */
  19400. export class PoseEnabledControllerHelper {
  19401. /** @hidden */
  19402. static _ControllerFactories: _GamePadFactory[];
  19403. /** @hidden */
  19404. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19405. /**
  19406. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19407. * @param vrGamepad the gamepad to initialized
  19408. * @returns a vr controller of the type the gamepad identified as
  19409. */
  19410. static InitiateController(vrGamepad: any): Gamepad;
  19411. }
  19412. /**
  19413. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19414. */
  19415. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19416. /**
  19417. * If the controller is used in a webXR session
  19418. */
  19419. isXR: boolean;
  19420. private _deviceRoomPosition;
  19421. private _deviceRoomRotationQuaternion;
  19422. /**
  19423. * The device position in babylon space
  19424. */
  19425. devicePosition: Vector3;
  19426. /**
  19427. * The device rotation in babylon space
  19428. */
  19429. deviceRotationQuaternion: Quaternion;
  19430. /**
  19431. * The scale factor of the device in babylon space
  19432. */
  19433. deviceScaleFactor: number;
  19434. /**
  19435. * (Likely devicePosition should be used instead) The device position in its room space
  19436. */
  19437. position: Vector3;
  19438. /**
  19439. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19440. */
  19441. rotationQuaternion: Quaternion;
  19442. /**
  19443. * The type of controller (Eg. Windows mixed reality)
  19444. */
  19445. controllerType: PoseEnabledControllerType;
  19446. protected _calculatedPosition: Vector3;
  19447. private _calculatedRotation;
  19448. /**
  19449. * The raw pose from the device
  19450. */
  19451. rawPose: DevicePose;
  19452. private _trackPosition;
  19453. private _maxRotationDistFromHeadset;
  19454. private _draggedRoomRotation;
  19455. /**
  19456. * @hidden
  19457. */
  19458. _disableTrackPosition(fixedPosition: Vector3): void;
  19459. /**
  19460. * Internal, the mesh attached to the controller
  19461. * @hidden
  19462. */
  19463. _mesh: Nullable<AbstractMesh>;
  19464. private _poseControlledCamera;
  19465. private _leftHandSystemQuaternion;
  19466. /**
  19467. * Internal, matrix used to convert room space to babylon space
  19468. * @hidden
  19469. */
  19470. _deviceToWorld: Matrix;
  19471. /**
  19472. * Node to be used when casting a ray from the controller
  19473. * @hidden
  19474. */
  19475. _pointingPoseNode: Nullable<TransformNode>;
  19476. /**
  19477. * Name of the child mesh that can be used to cast a ray from the controller
  19478. */
  19479. static readonly POINTING_POSE: string;
  19480. /**
  19481. * Creates a new PoseEnabledController from a gamepad
  19482. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19483. */
  19484. constructor(browserGamepad: any);
  19485. private _workingMatrix;
  19486. /**
  19487. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19488. */
  19489. update(): void;
  19490. /**
  19491. * Updates only the pose device and mesh without doing any button event checking
  19492. */
  19493. protected _updatePoseAndMesh(): void;
  19494. /**
  19495. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19496. * @param poseData raw pose fromthe device
  19497. */
  19498. updateFromDevice(poseData: DevicePose): void;
  19499. /**
  19500. * @hidden
  19501. */
  19502. _meshAttachedObservable: Observable<AbstractMesh>;
  19503. /**
  19504. * Attaches a mesh to the controller
  19505. * @param mesh the mesh to be attached
  19506. */
  19507. attachToMesh(mesh: AbstractMesh): void;
  19508. /**
  19509. * Attaches the controllers mesh to a camera
  19510. * @param camera the camera the mesh should be attached to
  19511. */
  19512. attachToPoseControlledCamera(camera: TargetCamera): void;
  19513. /**
  19514. * Disposes of the controller
  19515. */
  19516. dispose(): void;
  19517. /**
  19518. * The mesh that is attached to the controller
  19519. */
  19520. get mesh(): Nullable<AbstractMesh>;
  19521. /**
  19522. * Gets the ray of the controller in the direction the controller is pointing
  19523. * @param length the length the resulting ray should be
  19524. * @returns a ray in the direction the controller is pointing
  19525. */
  19526. getForwardRay(length?: number): Ray;
  19527. }
  19528. }
  19529. declare module BABYLON {
  19530. /**
  19531. * Defines the WebVRController object that represents controllers tracked in 3D space
  19532. */
  19533. export abstract class WebVRController extends PoseEnabledController {
  19534. /**
  19535. * Internal, the default controller model for the controller
  19536. */
  19537. protected _defaultModel: Nullable<AbstractMesh>;
  19538. /**
  19539. * Fired when the trigger state has changed
  19540. */
  19541. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19542. /**
  19543. * Fired when the main button state has changed
  19544. */
  19545. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19546. /**
  19547. * Fired when the secondary button state has changed
  19548. */
  19549. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19550. /**
  19551. * Fired when the pad state has changed
  19552. */
  19553. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19554. /**
  19555. * Fired when controllers stick values have changed
  19556. */
  19557. onPadValuesChangedObservable: Observable<StickValues>;
  19558. /**
  19559. * Array of button availible on the controller
  19560. */
  19561. protected _buttons: Array<MutableGamepadButton>;
  19562. private _onButtonStateChange;
  19563. /**
  19564. * Fired when a controller button's state has changed
  19565. * @param callback the callback containing the button that was modified
  19566. */
  19567. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19568. /**
  19569. * X and Y axis corresponding to the controllers joystick
  19570. */
  19571. pad: StickValues;
  19572. /**
  19573. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19574. */
  19575. hand: string;
  19576. /**
  19577. * The default controller model for the controller
  19578. */
  19579. get defaultModel(): Nullable<AbstractMesh>;
  19580. /**
  19581. * Creates a new WebVRController from a gamepad
  19582. * @param vrGamepad the gamepad that the WebVRController should be created from
  19583. */
  19584. constructor(vrGamepad: any);
  19585. /**
  19586. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19587. */
  19588. update(): void;
  19589. /**
  19590. * Function to be called when a button is modified
  19591. */
  19592. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19593. /**
  19594. * Loads a mesh and attaches it to the controller
  19595. * @param scene the scene the mesh should be added to
  19596. * @param meshLoaded callback for when the mesh has been loaded
  19597. */
  19598. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19599. private _setButtonValue;
  19600. private _changes;
  19601. private _checkChanges;
  19602. /**
  19603. * Disposes of th webVRCOntroller
  19604. */
  19605. dispose(): void;
  19606. }
  19607. }
  19608. declare module BABYLON {
  19609. /**
  19610. * The HemisphericLight simulates the ambient environment light,
  19611. * so the passed direction is the light reflection direction, not the incoming direction.
  19612. */
  19613. export class HemisphericLight extends Light {
  19614. /**
  19615. * The groundColor is the light in the opposite direction to the one specified during creation.
  19616. * 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.
  19617. */
  19618. groundColor: Color3;
  19619. /**
  19620. * The light reflection direction, not the incoming direction.
  19621. */
  19622. direction: Vector3;
  19623. /**
  19624. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19625. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19626. * The HemisphericLight can't cast shadows.
  19627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19628. * @param name The friendly name of the light
  19629. * @param direction The direction of the light reflection
  19630. * @param scene The scene the light belongs to
  19631. */
  19632. constructor(name: string, direction: Vector3, scene: Scene);
  19633. protected _buildUniformLayout(): void;
  19634. /**
  19635. * Returns the string "HemisphericLight".
  19636. * @return The class name
  19637. */
  19638. getClassName(): string;
  19639. /**
  19640. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19641. * Returns the updated direction.
  19642. * @param target The target the direction should point to
  19643. * @return The computed direction
  19644. */
  19645. setDirectionToTarget(target: Vector3): Vector3;
  19646. /**
  19647. * Returns the shadow generator associated to the light.
  19648. * @returns Always null for hemispheric lights because it does not support shadows.
  19649. */
  19650. getShadowGenerator(): Nullable<IShadowGenerator>;
  19651. /**
  19652. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19653. * @param effect The effect to update
  19654. * @param lightIndex The index of the light in the effect to update
  19655. * @returns The hemispheric light
  19656. */
  19657. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19658. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19659. /**
  19660. * Computes the world matrix of the node
  19661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19662. * @param useWasUpdatedFlag defines a reserved property
  19663. * @returns the world matrix
  19664. */
  19665. computeWorldMatrix(): Matrix;
  19666. /**
  19667. * Returns the integer 3.
  19668. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19669. */
  19670. getTypeID(): number;
  19671. /**
  19672. * Prepares the list of defines specific to the light type.
  19673. * @param defines the list of defines
  19674. * @param lightIndex defines the index of the light for the effect
  19675. */
  19676. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /** @hidden */
  19681. export var vrMultiviewToSingleviewPixelShader: {
  19682. name: string;
  19683. shader: string;
  19684. };
  19685. }
  19686. declare module BABYLON {
  19687. /**
  19688. * Renders to multiple views with a single draw call
  19689. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19690. */
  19691. export class MultiviewRenderTarget extends RenderTargetTexture {
  19692. /**
  19693. * Creates a multiview render target
  19694. * @param scene scene used with the render target
  19695. * @param size the size of the render target (used for each view)
  19696. */
  19697. constructor(scene: Scene, size?: number | {
  19698. width: number;
  19699. height: number;
  19700. } | {
  19701. ratio: number;
  19702. });
  19703. /**
  19704. * @hidden
  19705. * @param faceIndex the face index, if its a cube texture
  19706. */
  19707. _bindFrameBuffer(faceIndex?: number): void;
  19708. /**
  19709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19710. * @returns the view count
  19711. */
  19712. getViewCount(): number;
  19713. }
  19714. }
  19715. declare module BABYLON {
  19716. interface Engine {
  19717. /**
  19718. * Creates a new multiview render target
  19719. * @param width defines the width of the texture
  19720. * @param height defines the height of the texture
  19721. * @returns the created multiview texture
  19722. */
  19723. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19724. /**
  19725. * Binds a multiview framebuffer to be drawn to
  19726. * @param multiviewTexture texture to bind
  19727. */
  19728. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19729. }
  19730. interface Camera {
  19731. /**
  19732. * @hidden
  19733. * 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)
  19734. */
  19735. _useMultiviewToSingleView: boolean;
  19736. /**
  19737. * @hidden
  19738. * 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)
  19739. */
  19740. _multiviewTexture: Nullable<RenderTargetTexture>;
  19741. /**
  19742. * @hidden
  19743. * ensures the multiview texture of the camera exists and has the specified width/height
  19744. * @param width height to set on the multiview texture
  19745. * @param height width to set on the multiview texture
  19746. */
  19747. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19748. }
  19749. interface Scene {
  19750. /** @hidden */
  19751. _transformMatrixR: Matrix;
  19752. /** @hidden */
  19753. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19754. /** @hidden */
  19755. _createMultiviewUbo(): void;
  19756. /** @hidden */
  19757. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19758. /** @hidden */
  19759. _renderMultiviewToSingleView(camera: Camera): void;
  19760. }
  19761. }
  19762. declare module BABYLON {
  19763. /**
  19764. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19765. * This will not be used for webXR as it supports displaying texture arrays directly
  19766. */
  19767. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19768. /**
  19769. * Gets a string identifying the name of the class
  19770. * @returns "VRMultiviewToSingleviewPostProcess" string
  19771. */
  19772. getClassName(): string;
  19773. /**
  19774. * Initializes a VRMultiviewToSingleview
  19775. * @param name name of the post process
  19776. * @param camera camera to be applied to
  19777. * @param scaleFactor scaling factor to the size of the output texture
  19778. */
  19779. constructor(name: string, camera: Camera, scaleFactor: number);
  19780. }
  19781. }
  19782. declare module BABYLON {
  19783. /**
  19784. * Interface used to define additional presentation attributes
  19785. */
  19786. export interface IVRPresentationAttributes {
  19787. /**
  19788. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19789. */
  19790. highRefreshRate: boolean;
  19791. /**
  19792. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19793. */
  19794. foveationLevel: number;
  19795. }
  19796. interface Engine {
  19797. /** @hidden */
  19798. _vrDisplay: any;
  19799. /** @hidden */
  19800. _vrSupported: boolean;
  19801. /** @hidden */
  19802. _oldSize: Size;
  19803. /** @hidden */
  19804. _oldHardwareScaleFactor: number;
  19805. /** @hidden */
  19806. _vrExclusivePointerMode: boolean;
  19807. /** @hidden */
  19808. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19809. /** @hidden */
  19810. _onVRDisplayPointerRestricted: () => void;
  19811. /** @hidden */
  19812. _onVRDisplayPointerUnrestricted: () => void;
  19813. /** @hidden */
  19814. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19815. /** @hidden */
  19816. _onVrDisplayDisconnect: Nullable<() => void>;
  19817. /** @hidden */
  19818. _onVrDisplayPresentChange: Nullable<() => void>;
  19819. /**
  19820. * Observable signaled when VR display mode changes
  19821. */
  19822. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19823. /**
  19824. * Observable signaled when VR request present is complete
  19825. */
  19826. onVRRequestPresentComplete: Observable<boolean>;
  19827. /**
  19828. * Observable signaled when VR request present starts
  19829. */
  19830. onVRRequestPresentStart: Observable<Engine>;
  19831. /**
  19832. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19833. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19834. */
  19835. isInVRExclusivePointerMode: boolean;
  19836. /**
  19837. * Gets a boolean indicating if a webVR device was detected
  19838. * @returns true if a webVR device was detected
  19839. */
  19840. isVRDevicePresent(): boolean;
  19841. /**
  19842. * Gets the current webVR device
  19843. * @returns the current webVR device (or null)
  19844. */
  19845. getVRDevice(): any;
  19846. /**
  19847. * Initializes a webVR display and starts listening to display change events
  19848. * The onVRDisplayChangedObservable will be notified upon these changes
  19849. * @returns A promise containing a VRDisplay and if vr is supported
  19850. */
  19851. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19852. /** @hidden */
  19853. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19854. /**
  19855. * Gets or sets the presentation attributes used to configure VR rendering
  19856. */
  19857. vrPresentationAttributes?: IVRPresentationAttributes;
  19858. /**
  19859. * Call this function to switch to webVR mode
  19860. * Will do nothing if webVR is not supported or if there is no webVR device
  19861. * @param options the webvr options provided to the camera. mainly used for multiview
  19862. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19863. */
  19864. enableVR(options: WebVROptions): void;
  19865. /** @hidden */
  19866. _onVRFullScreenTriggered(): void;
  19867. }
  19868. }
  19869. declare module BABYLON {
  19870. /**
  19871. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19872. * IMPORTANT!! The data is right-hand data.
  19873. * @export
  19874. * @interface DevicePose
  19875. */
  19876. export interface DevicePose {
  19877. /**
  19878. * The position of the device, values in array are [x,y,z].
  19879. */
  19880. readonly position: Nullable<Float32Array>;
  19881. /**
  19882. * The linearVelocity of the device, values in array are [x,y,z].
  19883. */
  19884. readonly linearVelocity: Nullable<Float32Array>;
  19885. /**
  19886. * The linearAcceleration of the device, values in array are [x,y,z].
  19887. */
  19888. readonly linearAcceleration: Nullable<Float32Array>;
  19889. /**
  19890. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19891. */
  19892. readonly orientation: Nullable<Float32Array>;
  19893. /**
  19894. * The angularVelocity of the device, values in array are [x,y,z].
  19895. */
  19896. readonly angularVelocity: Nullable<Float32Array>;
  19897. /**
  19898. * The angularAcceleration of the device, values in array are [x,y,z].
  19899. */
  19900. readonly angularAcceleration: Nullable<Float32Array>;
  19901. }
  19902. /**
  19903. * Interface representing a pose controlled object in Babylon.
  19904. * A pose controlled object has both regular pose values as well as pose values
  19905. * from an external device such as a VR head mounted display
  19906. */
  19907. export interface PoseControlled {
  19908. /**
  19909. * The position of the object in babylon space.
  19910. */
  19911. position: Vector3;
  19912. /**
  19913. * The rotation quaternion of the object in babylon space.
  19914. */
  19915. rotationQuaternion: Quaternion;
  19916. /**
  19917. * The position of the device in babylon space.
  19918. */
  19919. devicePosition?: Vector3;
  19920. /**
  19921. * The rotation quaternion of the device in babylon space.
  19922. */
  19923. deviceRotationQuaternion: Quaternion;
  19924. /**
  19925. * The raw pose coming from the device.
  19926. */
  19927. rawPose: Nullable<DevicePose>;
  19928. /**
  19929. * The scale of the device to be used when translating from device space to babylon space.
  19930. */
  19931. deviceScaleFactor: number;
  19932. /**
  19933. * Updates the poseControlled values based on the input device pose.
  19934. * @param poseData the pose data to update the object with
  19935. */
  19936. updateFromDevice(poseData: DevicePose): void;
  19937. }
  19938. /**
  19939. * Set of options to customize the webVRCamera
  19940. */
  19941. export interface WebVROptions {
  19942. /**
  19943. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19944. */
  19945. trackPosition?: boolean;
  19946. /**
  19947. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19948. */
  19949. positionScale?: number;
  19950. /**
  19951. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19952. */
  19953. displayName?: string;
  19954. /**
  19955. * Should the native controller meshes be initialized. (default: true)
  19956. */
  19957. controllerMeshes?: boolean;
  19958. /**
  19959. * Creating a default HemiLight only on controllers. (default: true)
  19960. */
  19961. defaultLightingOnControllers?: boolean;
  19962. /**
  19963. * If you don't want to use the default VR button of the helper. (default: false)
  19964. */
  19965. useCustomVRButton?: boolean;
  19966. /**
  19967. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19968. */
  19969. customVRButton?: HTMLButtonElement;
  19970. /**
  19971. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19972. */
  19973. rayLength?: number;
  19974. /**
  19975. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19976. */
  19977. defaultHeight?: number;
  19978. /**
  19979. * If multiview should be used if availible (default: false)
  19980. */
  19981. useMultiview?: boolean;
  19982. }
  19983. /**
  19984. * This represents a WebVR camera.
  19985. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19986. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19987. */
  19988. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19989. private webVROptions;
  19990. /**
  19991. * @hidden
  19992. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19993. */
  19994. _vrDevice: any;
  19995. /**
  19996. * The rawPose of the vrDevice.
  19997. */
  19998. rawPose: Nullable<DevicePose>;
  19999. private _onVREnabled;
  20000. private _specsVersion;
  20001. private _attached;
  20002. private _frameData;
  20003. protected _descendants: Array<Node>;
  20004. private _deviceRoomPosition;
  20005. /** @hidden */
  20006. _deviceRoomRotationQuaternion: Quaternion;
  20007. private _standingMatrix;
  20008. /**
  20009. * Represents device position in babylon space.
  20010. */
  20011. devicePosition: Vector3;
  20012. /**
  20013. * Represents device rotation in babylon space.
  20014. */
  20015. deviceRotationQuaternion: Quaternion;
  20016. /**
  20017. * The scale of the device to be used when translating from device space to babylon space.
  20018. */
  20019. deviceScaleFactor: number;
  20020. private _deviceToWorld;
  20021. private _worldToDevice;
  20022. /**
  20023. * References to the webVR controllers for the vrDevice.
  20024. */
  20025. controllers: Array<WebVRController>;
  20026. /**
  20027. * Emits an event when a controller is attached.
  20028. */
  20029. onControllersAttachedObservable: Observable<WebVRController[]>;
  20030. /**
  20031. * Emits an event when a controller's mesh has been loaded;
  20032. */
  20033. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20034. /**
  20035. * Emits an event when the HMD's pose has been updated.
  20036. */
  20037. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20038. private _poseSet;
  20039. /**
  20040. * If the rig cameras be used as parent instead of this camera.
  20041. */
  20042. rigParenting: boolean;
  20043. private _lightOnControllers;
  20044. private _defaultHeight?;
  20045. /**
  20046. * Instantiates a WebVRFreeCamera.
  20047. * @param name The name of the WebVRFreeCamera
  20048. * @param position The starting anchor position for the camera
  20049. * @param scene The scene the camera belongs to
  20050. * @param webVROptions a set of customizable options for the webVRCamera
  20051. */
  20052. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20053. /**
  20054. * Gets the device distance from the ground in meters.
  20055. * @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.
  20056. */
  20057. deviceDistanceToRoomGround(): number;
  20058. /**
  20059. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20060. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20061. */
  20062. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20063. /**
  20064. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20065. * @returns A promise with a boolean set to if the standing matrix is supported.
  20066. */
  20067. useStandingMatrixAsync(): Promise<boolean>;
  20068. /**
  20069. * Disposes the camera
  20070. */
  20071. dispose(): void;
  20072. /**
  20073. * Gets a vrController by name.
  20074. * @param name The name of the controller to retreive
  20075. * @returns the controller matching the name specified or null if not found
  20076. */
  20077. getControllerByName(name: string): Nullable<WebVRController>;
  20078. private _leftController;
  20079. /**
  20080. * The controller corresponding to the users left hand.
  20081. */
  20082. get leftController(): Nullable<WebVRController>;
  20083. private _rightController;
  20084. /**
  20085. * The controller corresponding to the users right hand.
  20086. */
  20087. get rightController(): Nullable<WebVRController>;
  20088. /**
  20089. * Casts a ray forward from the vrCamera's gaze.
  20090. * @param length Length of the ray (default: 100)
  20091. * @returns the ray corresponding to the gaze
  20092. */
  20093. getForwardRay(length?: number): Ray;
  20094. /**
  20095. * @hidden
  20096. * Updates the camera based on device's frame data
  20097. */
  20098. _checkInputs(): void;
  20099. /**
  20100. * Updates the poseControlled values based on the input device pose.
  20101. * @param poseData Pose coming from the device
  20102. */
  20103. updateFromDevice(poseData: DevicePose): void;
  20104. private _htmlElementAttached;
  20105. private _detachIfAttached;
  20106. /**
  20107. * WebVR's attach control will start broadcasting frames to the device.
  20108. * Note that in certain browsers (chrome for example) this function must be called
  20109. * within a user-interaction callback. Example:
  20110. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20111. *
  20112. * @param element html element to attach the vrDevice to
  20113. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20114. */
  20115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20116. /**
  20117. * Detaches the camera from the html element and disables VR
  20118. *
  20119. * @param element html element to detach from
  20120. */
  20121. detachControl(element: HTMLElement): void;
  20122. /**
  20123. * @returns the name of this class
  20124. */
  20125. getClassName(): string;
  20126. /**
  20127. * Calls resetPose on the vrDisplay
  20128. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20129. */
  20130. resetToCurrentRotation(): void;
  20131. /**
  20132. * @hidden
  20133. * Updates the rig cameras (left and right eye)
  20134. */
  20135. _updateRigCameras(): void;
  20136. private _workingVector;
  20137. private _oneVector;
  20138. private _workingMatrix;
  20139. private updateCacheCalled;
  20140. private _correctPositionIfNotTrackPosition;
  20141. /**
  20142. * @hidden
  20143. * Updates the cached values of the camera
  20144. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20145. */
  20146. _updateCache(ignoreParentClass?: boolean): void;
  20147. /**
  20148. * @hidden
  20149. * Get current device position in babylon world
  20150. */
  20151. _computeDevicePosition(): void;
  20152. /**
  20153. * Updates the current device position and rotation in the babylon world
  20154. */
  20155. update(): void;
  20156. /**
  20157. * @hidden
  20158. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20159. * @returns an identity matrix
  20160. */
  20161. _getViewMatrix(): Matrix;
  20162. private _tmpMatrix;
  20163. /**
  20164. * This function is called by the two RIG cameras.
  20165. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20166. * @hidden
  20167. */
  20168. _getWebVRViewMatrix(): Matrix;
  20169. /** @hidden */
  20170. _getWebVRProjectionMatrix(): Matrix;
  20171. private _onGamepadConnectedObserver;
  20172. private _onGamepadDisconnectedObserver;
  20173. private _updateCacheWhenTrackingDisabledObserver;
  20174. /**
  20175. * Initializes the controllers and their meshes
  20176. */
  20177. initControllers(): void;
  20178. }
  20179. }
  20180. declare module BABYLON {
  20181. /**
  20182. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20183. *
  20184. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20185. *
  20186. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20187. */
  20188. export class MaterialHelper {
  20189. /**
  20190. * Bind the current view position to an effect.
  20191. * @param effect The effect to be bound
  20192. * @param scene The scene the eyes position is used from
  20193. * @param variableName name of the shader variable that will hold the eye position
  20194. */
  20195. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20196. /**
  20197. * Helps preparing the defines values about the UVs in used in the effect.
  20198. * UVs are shared as much as we can accross channels in the shaders.
  20199. * @param texture The texture we are preparing the UVs for
  20200. * @param defines The defines to update
  20201. * @param key The channel key "diffuse", "specular"... used in the shader
  20202. */
  20203. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20204. /**
  20205. * Binds a texture matrix value to its corrsponding uniform
  20206. * @param texture The texture to bind the matrix for
  20207. * @param uniformBuffer The uniform buffer receivin the data
  20208. * @param key The channel key "diffuse", "specular"... used in the shader
  20209. */
  20210. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20211. /**
  20212. * Gets the current status of the fog (should it be enabled?)
  20213. * @param mesh defines the mesh to evaluate for fog support
  20214. * @param scene defines the hosting scene
  20215. * @returns true if fog must be enabled
  20216. */
  20217. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20218. /**
  20219. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20220. * @param mesh defines the current mesh
  20221. * @param scene defines the current scene
  20222. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20223. * @param pointsCloud defines if point cloud rendering has to be turned on
  20224. * @param fogEnabled defines if fog has to be turned on
  20225. * @param alphaTest defines if alpha testing has to be turned on
  20226. * @param defines defines the current list of defines
  20227. */
  20228. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20229. /**
  20230. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20231. * @param scene defines the current scene
  20232. * @param engine defines the current engine
  20233. * @param defines specifies the list of active defines
  20234. * @param useInstances defines if instances have to be turned on
  20235. * @param useClipPlane defines if clip plane have to be turned on
  20236. * @param useInstances defines if instances have to be turned on
  20237. * @param useThinInstances defines if thin instances have to be turned on
  20238. */
  20239. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20240. /**
  20241. * Prepares the defines for bones
  20242. * @param mesh The mesh containing the geometry data we will draw
  20243. * @param defines The defines to update
  20244. */
  20245. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20246. /**
  20247. * Prepares the defines for morph targets
  20248. * @param mesh The mesh containing the geometry data we will draw
  20249. * @param defines The defines to update
  20250. */
  20251. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20252. /**
  20253. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20254. * @param mesh The mesh containing the geometry data we will draw
  20255. * @param defines The defines to update
  20256. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20257. * @param useBones Precise whether bones should be used or not (override mesh info)
  20258. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20259. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20260. * @returns false if defines are considered not dirty and have not been checked
  20261. */
  20262. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20263. /**
  20264. * Prepares the defines related to multiview
  20265. * @param scene The scene we are intending to draw
  20266. * @param defines The defines to update
  20267. */
  20268. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20269. /**
  20270. * Prepares the defines related to the prepass
  20271. * @param scene The scene we are intending to draw
  20272. * @param defines The defines to update
  20273. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20274. */
  20275. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20276. /**
  20277. * Prepares the defines related to the light information passed in parameter
  20278. * @param scene The scene we are intending to draw
  20279. * @param mesh The mesh the effect is compiling for
  20280. * @param light The light the effect is compiling for
  20281. * @param lightIndex The index of the light
  20282. * @param defines The defines to update
  20283. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20284. * @param state Defines the current state regarding what is needed (normals, etc...)
  20285. */
  20286. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20287. needNormals: boolean;
  20288. needRebuild: boolean;
  20289. shadowEnabled: boolean;
  20290. specularEnabled: boolean;
  20291. lightmapMode: boolean;
  20292. }): void;
  20293. /**
  20294. * Prepares the defines related to the light information passed in parameter
  20295. * @param scene The scene we are intending to draw
  20296. * @param mesh The mesh the effect is compiling for
  20297. * @param defines The defines to update
  20298. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20299. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20300. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20301. * @returns true if normals will be required for the rest of the effect
  20302. */
  20303. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20304. /**
  20305. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20306. * @param lightIndex defines the light index
  20307. * @param uniformsList The uniform list
  20308. * @param samplersList The sampler list
  20309. * @param projectedLightTexture defines if projected texture must be used
  20310. * @param uniformBuffersList defines an optional list of uniform buffers
  20311. */
  20312. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20313. /**
  20314. * Prepares the uniforms and samplers list to be used in the effect
  20315. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20316. * @param samplersList The sampler list
  20317. * @param defines The defines helping in the list generation
  20318. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20319. */
  20320. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20321. /**
  20322. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20323. * @param defines The defines to update while falling back
  20324. * @param fallbacks The authorized effect fallbacks
  20325. * @param maxSimultaneousLights The maximum number of lights allowed
  20326. * @param rank the current rank of the Effect
  20327. * @returns The newly affected rank
  20328. */
  20329. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20330. private static _TmpMorphInfluencers;
  20331. /**
  20332. * Prepares the list of attributes required for morph targets according to the effect defines.
  20333. * @param attribs The current list of supported attribs
  20334. * @param mesh The mesh to prepare the morph targets attributes for
  20335. * @param influencers The number of influencers
  20336. */
  20337. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20338. /**
  20339. * Prepares the list of attributes required for morph targets according to the effect defines.
  20340. * @param attribs The current list of supported attribs
  20341. * @param mesh The mesh to prepare the morph targets attributes for
  20342. * @param defines The current Defines of the effect
  20343. */
  20344. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20345. /**
  20346. * Prepares the list of attributes required for bones according to the effect defines.
  20347. * @param attribs The current list of supported attribs
  20348. * @param mesh The mesh to prepare the bones attributes for
  20349. * @param defines The current Defines of the effect
  20350. * @param fallbacks The current efffect fallback strategy
  20351. */
  20352. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20353. /**
  20354. * Check and prepare the list of attributes required for instances according to the effect defines.
  20355. * @param attribs The current list of supported attribs
  20356. * @param defines The current MaterialDefines of the effect
  20357. */
  20358. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20359. /**
  20360. * Add the list of attributes required for instances to the attribs array.
  20361. * @param attribs The current list of supported attribs
  20362. */
  20363. static PushAttributesForInstances(attribs: string[]): void;
  20364. /**
  20365. * Binds the light information to the effect.
  20366. * @param light The light containing the generator
  20367. * @param effect The effect we are binding the data to
  20368. * @param lightIndex The light index in the effect used to render
  20369. */
  20370. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20371. /**
  20372. * Binds the lights information from the scene to the effect for the given mesh.
  20373. * @param light Light to bind
  20374. * @param lightIndex Light index
  20375. * @param scene The scene where the light belongs to
  20376. * @param effect The effect we are binding the data to
  20377. * @param useSpecular Defines if specular is supported
  20378. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20379. */
  20380. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20381. /**
  20382. * Binds the lights information from the scene to the effect for the given mesh.
  20383. * @param scene The scene the lights belongs to
  20384. * @param mesh The mesh we are binding the information to render
  20385. * @param effect The effect we are binding the data to
  20386. * @param defines The generated defines for the effect
  20387. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20388. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20389. */
  20390. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20391. private static _tempFogColor;
  20392. /**
  20393. * Binds the fog information from the scene to the effect for the given mesh.
  20394. * @param scene The scene the lights belongs to
  20395. * @param mesh The mesh we are binding the information to render
  20396. * @param effect The effect we are binding the data to
  20397. * @param linearSpace Defines if the fog effect is applied in linear space
  20398. */
  20399. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20400. /**
  20401. * Binds the bones information from the mesh to the effect.
  20402. * @param mesh The mesh we are binding the information to render
  20403. * @param effect The effect we are binding the data to
  20404. */
  20405. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20406. /**
  20407. * Binds the morph targets information from the mesh to the effect.
  20408. * @param abstractMesh The mesh we are binding the information to render
  20409. * @param effect The effect we are binding the data to
  20410. */
  20411. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20412. /**
  20413. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20414. * @param defines The generated defines used in the effect
  20415. * @param effect The effect we are binding the data to
  20416. * @param scene The scene we are willing to render with logarithmic scale for
  20417. */
  20418. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20419. /**
  20420. * Binds the clip plane information from the scene to the effect.
  20421. * @param scene The scene the clip plane information are extracted from
  20422. * @param effect The effect we are binding the data to
  20423. */
  20424. static BindClipPlane(effect: Effect, scene: Scene): void;
  20425. }
  20426. }
  20427. declare module BABYLON {
  20428. /**
  20429. * Block used to expose an input value
  20430. */
  20431. export class InputBlock extends NodeMaterialBlock {
  20432. private _mode;
  20433. private _associatedVariableName;
  20434. private _storedValue;
  20435. private _valueCallback;
  20436. private _type;
  20437. private _animationType;
  20438. /** Gets or set a value used to limit the range of float values */
  20439. min: number;
  20440. /** Gets or set a value used to limit the range of float values */
  20441. max: number;
  20442. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20443. isBoolean: boolean;
  20444. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20445. matrixMode: number;
  20446. /** @hidden */
  20447. _systemValue: Nullable<NodeMaterialSystemValues>;
  20448. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20449. visibleInInspector: boolean;
  20450. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20451. isConstant: boolean;
  20452. /** Gets or sets the group to use to display this block in the Inspector */
  20453. groupInInspector: string;
  20454. /** Gets an observable raised when the value is changed */
  20455. onValueChangedObservable: Observable<InputBlock>;
  20456. /**
  20457. * Gets or sets the connection point type (default is float)
  20458. */
  20459. get type(): NodeMaterialBlockConnectionPointTypes;
  20460. /**
  20461. * Creates a new InputBlock
  20462. * @param name defines the block name
  20463. * @param target defines the target of that block (Vertex by default)
  20464. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20465. */
  20466. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20467. /**
  20468. * Validates if a name is a reserve word.
  20469. * @param newName the new name to be given to the node.
  20470. * @returns false if the name is a reserve word, else true.
  20471. */
  20472. validateBlockName(newName: string): boolean;
  20473. /**
  20474. * Gets the output component
  20475. */
  20476. get output(): NodeMaterialConnectionPoint;
  20477. /**
  20478. * Set the source of this connection point to a vertex attribute
  20479. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20480. * @returns the current connection point
  20481. */
  20482. setAsAttribute(attributeName?: string): InputBlock;
  20483. /**
  20484. * Set the source of this connection point to a system value
  20485. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20486. * @returns the current connection point
  20487. */
  20488. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20489. /**
  20490. * Gets or sets the value of that point.
  20491. * Please note that this value will be ignored if valueCallback is defined
  20492. */
  20493. get value(): any;
  20494. set value(value: any);
  20495. /**
  20496. * Gets or sets a callback used to get the value of that point.
  20497. * Please note that setting this value will force the connection point to ignore the value property
  20498. */
  20499. get valueCallback(): () => any;
  20500. set valueCallback(value: () => any);
  20501. /**
  20502. * Gets or sets the associated variable name in the shader
  20503. */
  20504. get associatedVariableName(): string;
  20505. set associatedVariableName(value: string);
  20506. /** Gets or sets the type of animation applied to the input */
  20507. get animationType(): AnimatedInputBlockTypes;
  20508. set animationType(value: AnimatedInputBlockTypes);
  20509. /**
  20510. * Gets a boolean indicating that this connection point not defined yet
  20511. */
  20512. get isUndefined(): boolean;
  20513. /**
  20514. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20515. * In this case the connection point name must be the name of the uniform to use.
  20516. * Can only be set on inputs
  20517. */
  20518. get isUniform(): boolean;
  20519. set isUniform(value: boolean);
  20520. /**
  20521. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20522. * In this case the connection point name must be the name of the attribute to use
  20523. * Can only be set on inputs
  20524. */
  20525. get isAttribute(): boolean;
  20526. set isAttribute(value: boolean);
  20527. /**
  20528. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20529. * Can only be set on exit points
  20530. */
  20531. get isVarying(): boolean;
  20532. set isVarying(value: boolean);
  20533. /**
  20534. * Gets a boolean indicating that the current connection point is a system value
  20535. */
  20536. get isSystemValue(): boolean;
  20537. /**
  20538. * Gets or sets the current well known value or null if not defined as a system value
  20539. */
  20540. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20541. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20542. /**
  20543. * Gets the current class name
  20544. * @returns the class name
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Animate the input if animationType !== None
  20549. * @param scene defines the rendering scene
  20550. */
  20551. animate(scene: Scene): void;
  20552. private _emitDefine;
  20553. initialize(state: NodeMaterialBuildState): void;
  20554. /**
  20555. * Set the input block to its default value (based on its type)
  20556. */
  20557. setDefaultValue(): void;
  20558. private _emitConstant;
  20559. /** @hidden */
  20560. get _noContextSwitch(): boolean;
  20561. private _emit;
  20562. /** @hidden */
  20563. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20564. /** @hidden */
  20565. _transmit(effect: Effect, scene: Scene): void;
  20566. protected _buildBlock(state: NodeMaterialBuildState): void;
  20567. protected _dumpPropertiesCode(): string;
  20568. dispose(): void;
  20569. serialize(): any;
  20570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20571. }
  20572. }
  20573. declare module BABYLON {
  20574. /**
  20575. * Enum used to define the compatibility state between two connection points
  20576. */
  20577. export enum NodeMaterialConnectionPointCompatibilityStates {
  20578. /** Points are compatibles */
  20579. Compatible = 0,
  20580. /** Points are incompatible because of their types */
  20581. TypeIncompatible = 1,
  20582. /** Points are incompatible because of their targets (vertex vs fragment) */
  20583. TargetIncompatible = 2
  20584. }
  20585. /**
  20586. * Defines the direction of a connection point
  20587. */
  20588. export enum NodeMaterialConnectionPointDirection {
  20589. /** Input */
  20590. Input = 0,
  20591. /** Output */
  20592. Output = 1
  20593. }
  20594. /**
  20595. * Defines a connection point for a block
  20596. */
  20597. export class NodeMaterialConnectionPoint {
  20598. /** @hidden */
  20599. _ownerBlock: NodeMaterialBlock;
  20600. /** @hidden */
  20601. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20602. private _endpoints;
  20603. private _associatedVariableName;
  20604. private _direction;
  20605. /** @hidden */
  20606. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20607. /** @hidden */
  20608. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20609. private _type;
  20610. /** @hidden */
  20611. _enforceAssociatedVariableName: boolean;
  20612. /** Gets the direction of the point */
  20613. get direction(): NodeMaterialConnectionPointDirection;
  20614. /** Indicates that this connection point needs dual validation before being connected to another point */
  20615. needDualDirectionValidation: boolean;
  20616. /**
  20617. * Gets or sets the additional types supported by this connection point
  20618. */
  20619. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20620. /**
  20621. * Gets or sets the additional types excluded by this connection point
  20622. */
  20623. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20624. /**
  20625. * Observable triggered when this point is connected
  20626. */
  20627. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20628. /**
  20629. * Gets or sets the associated variable name in the shader
  20630. */
  20631. get associatedVariableName(): string;
  20632. set associatedVariableName(value: string);
  20633. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20634. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20635. /**
  20636. * Gets or sets the connection point type (default is float)
  20637. */
  20638. get type(): NodeMaterialBlockConnectionPointTypes;
  20639. set type(value: NodeMaterialBlockConnectionPointTypes);
  20640. /**
  20641. * Gets or sets the connection point name
  20642. */
  20643. name: string;
  20644. /**
  20645. * Gets or sets the connection point name
  20646. */
  20647. displayName: string;
  20648. /**
  20649. * Gets or sets a boolean indicating that this connection point can be omitted
  20650. */
  20651. isOptional: boolean;
  20652. /**
  20653. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20654. */
  20655. isExposedOnFrame: boolean;
  20656. /**
  20657. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20658. */
  20659. define: string;
  20660. /** @hidden */
  20661. _prioritizeVertex: boolean;
  20662. private _target;
  20663. /** Gets or sets the target of that connection point */
  20664. get target(): NodeMaterialBlockTargets;
  20665. set target(value: NodeMaterialBlockTargets);
  20666. /**
  20667. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20668. */
  20669. get isConnected(): boolean;
  20670. /**
  20671. * Gets a boolean indicating that the current point is connected to an input block
  20672. */
  20673. get isConnectedToInputBlock(): boolean;
  20674. /**
  20675. * Gets a the connected input block (if any)
  20676. */
  20677. get connectInputBlock(): Nullable<InputBlock>;
  20678. /** Get the other side of the connection (if any) */
  20679. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20680. /** Get the block that owns this connection point */
  20681. get ownerBlock(): NodeMaterialBlock;
  20682. /** Get the block connected on the other side of this connection (if any) */
  20683. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20684. /** Get the block connected on the endpoints of this connection (if any) */
  20685. get connectedBlocks(): Array<NodeMaterialBlock>;
  20686. /** Gets the list of connected endpoints */
  20687. get endpoints(): NodeMaterialConnectionPoint[];
  20688. /** Gets a boolean indicating if that output point is connected to at least one input */
  20689. get hasEndpoints(): boolean;
  20690. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20691. get isConnectedInVertexShader(): boolean;
  20692. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20693. get isConnectedInFragmentShader(): boolean;
  20694. /**
  20695. * Creates a block suitable to be used as an input for this input point.
  20696. * If null is returned, a block based on the point type will be created.
  20697. * @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
  20698. */
  20699. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20700. /**
  20701. * Creates a new connection point
  20702. * @param name defines the connection point name
  20703. * @param ownerBlock defines the block hosting this connection point
  20704. * @param direction defines the direction of the connection point
  20705. */
  20706. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20707. /**
  20708. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20709. * @returns the class name
  20710. */
  20711. getClassName(): string;
  20712. /**
  20713. * Gets a boolean indicating if the current point can be connected to another point
  20714. * @param connectionPoint defines the other connection point
  20715. * @returns a boolean
  20716. */
  20717. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20718. /**
  20719. * Gets a number indicating if the current point can be connected to another point
  20720. * @param connectionPoint defines the other connection point
  20721. * @returns a number defining the compatibility state
  20722. */
  20723. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20724. /**
  20725. * Connect this point to another connection point
  20726. * @param connectionPoint defines the other connection point
  20727. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20728. * @returns the current connection point
  20729. */
  20730. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20731. /**
  20732. * Disconnect this point from one of his endpoint
  20733. * @param endpoint defines the other connection point
  20734. * @returns the current connection point
  20735. */
  20736. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20737. /**
  20738. * Serializes this point in a JSON representation
  20739. * @param isInput defines if the connection point is an input (default is true)
  20740. * @returns the serialized point object
  20741. */
  20742. serialize(isInput?: boolean): any;
  20743. /**
  20744. * Release resources
  20745. */
  20746. dispose(): void;
  20747. }
  20748. }
  20749. declare module BABYLON {
  20750. /**
  20751. * Enum used to define the material modes
  20752. */
  20753. export enum NodeMaterialModes {
  20754. /** Regular material */
  20755. Material = 0,
  20756. /** For post process */
  20757. PostProcess = 1,
  20758. /** For particle system */
  20759. Particle = 2
  20760. }
  20761. }
  20762. declare module BABYLON {
  20763. /**
  20764. * Block used to read a texture from a sampler
  20765. */
  20766. export class TextureBlock extends NodeMaterialBlock {
  20767. private _defineName;
  20768. private _linearDefineName;
  20769. private _gammaDefineName;
  20770. private _tempTextureRead;
  20771. private _samplerName;
  20772. private _transformedUVName;
  20773. private _textureTransformName;
  20774. private _textureInfoName;
  20775. private _mainUVName;
  20776. private _mainUVDefineName;
  20777. private _fragmentOnly;
  20778. /**
  20779. * Gets or sets the texture associated with the node
  20780. */
  20781. texture: Nullable<Texture>;
  20782. /**
  20783. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20784. */
  20785. convertToGammaSpace: boolean;
  20786. /**
  20787. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20788. */
  20789. convertToLinearSpace: boolean;
  20790. /**
  20791. * Create a new TextureBlock
  20792. * @param name defines the block name
  20793. */
  20794. constructor(name: string, fragmentOnly?: boolean);
  20795. /**
  20796. * Gets the current class name
  20797. * @returns the class name
  20798. */
  20799. getClassName(): string;
  20800. /**
  20801. * Gets the uv input component
  20802. */
  20803. get uv(): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Gets the rgba output component
  20806. */
  20807. get rgba(): NodeMaterialConnectionPoint;
  20808. /**
  20809. * Gets the rgb output component
  20810. */
  20811. get rgb(): NodeMaterialConnectionPoint;
  20812. /**
  20813. * Gets the r output component
  20814. */
  20815. get r(): NodeMaterialConnectionPoint;
  20816. /**
  20817. * Gets the g output component
  20818. */
  20819. get g(): NodeMaterialConnectionPoint;
  20820. /**
  20821. * Gets the b output component
  20822. */
  20823. get b(): NodeMaterialConnectionPoint;
  20824. /**
  20825. * Gets the a output component
  20826. */
  20827. get a(): NodeMaterialConnectionPoint;
  20828. get target(): NodeMaterialBlockTargets;
  20829. autoConfigure(material: NodeMaterial): void;
  20830. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20832. isReady(): boolean;
  20833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20834. private get _isMixed();
  20835. private _injectVertexCode;
  20836. private _writeTextureRead;
  20837. private _writeOutput;
  20838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20839. protected _dumpPropertiesCode(): string;
  20840. serialize(): any;
  20841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20842. }
  20843. }
  20844. declare module BABYLON {
  20845. /** @hidden */
  20846. export var reflectionFunction: {
  20847. name: string;
  20848. shader: string;
  20849. };
  20850. }
  20851. declare module BABYLON {
  20852. /**
  20853. * Base block used to read a reflection texture from a sampler
  20854. */
  20855. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20856. /** @hidden */
  20857. _define3DName: string;
  20858. /** @hidden */
  20859. _defineCubicName: string;
  20860. /** @hidden */
  20861. _defineExplicitName: string;
  20862. /** @hidden */
  20863. _defineProjectionName: string;
  20864. /** @hidden */
  20865. _defineLocalCubicName: string;
  20866. /** @hidden */
  20867. _defineSphericalName: string;
  20868. /** @hidden */
  20869. _definePlanarName: string;
  20870. /** @hidden */
  20871. _defineEquirectangularName: string;
  20872. /** @hidden */
  20873. _defineMirroredEquirectangularFixedName: string;
  20874. /** @hidden */
  20875. _defineEquirectangularFixedName: string;
  20876. /** @hidden */
  20877. _defineSkyboxName: string;
  20878. /** @hidden */
  20879. _defineOppositeZ: string;
  20880. /** @hidden */
  20881. _cubeSamplerName: string;
  20882. /** @hidden */
  20883. _2DSamplerName: string;
  20884. protected _positionUVWName: string;
  20885. protected _directionWName: string;
  20886. protected _reflectionVectorName: string;
  20887. /** @hidden */
  20888. _reflectionCoordsName: string;
  20889. /** @hidden */
  20890. _reflectionMatrixName: string;
  20891. protected _reflectionColorName: string;
  20892. /**
  20893. * Gets or sets the texture associated with the node
  20894. */
  20895. texture: Nullable<BaseTexture>;
  20896. /**
  20897. * Create a new ReflectionTextureBaseBlock
  20898. * @param name defines the block name
  20899. */
  20900. constructor(name: string);
  20901. /**
  20902. * Gets the current class name
  20903. * @returns the class name
  20904. */
  20905. getClassName(): string;
  20906. /**
  20907. * Gets the world position input component
  20908. */
  20909. abstract get position(): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Gets the world position input component
  20912. */
  20913. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20914. /**
  20915. * Gets the world normal input component
  20916. */
  20917. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20918. /**
  20919. * Gets the world input component
  20920. */
  20921. abstract get world(): NodeMaterialConnectionPoint;
  20922. /**
  20923. * Gets the camera (or eye) position component
  20924. */
  20925. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20926. /**
  20927. * Gets the view input component
  20928. */
  20929. abstract get view(): NodeMaterialConnectionPoint;
  20930. protected _getTexture(): Nullable<BaseTexture>;
  20931. autoConfigure(material: NodeMaterial): void;
  20932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20933. isReady(): boolean;
  20934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20935. /**
  20936. * Gets the code to inject in the vertex shader
  20937. * @param state current state of the node material building
  20938. * @returns the shader code
  20939. */
  20940. handleVertexSide(state: NodeMaterialBuildState): string;
  20941. /**
  20942. * Handles the inits for the fragment code path
  20943. * @param state node material build state
  20944. */
  20945. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20946. /**
  20947. * Generates the reflection coords code for the fragment code path
  20948. * @param worldNormalVarName name of the world normal variable
  20949. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20950. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20951. * @returns the shader code
  20952. */
  20953. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20954. /**
  20955. * Generates the reflection color code for the fragment code path
  20956. * @param lodVarName name of the lod variable
  20957. * @param swizzleLookupTexture swizzle to use for the final color variable
  20958. * @returns the shader code
  20959. */
  20960. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20961. /**
  20962. * Generates the code corresponding to the connected output points
  20963. * @param state node material build state
  20964. * @param varName name of the variable to output
  20965. * @returns the shader code
  20966. */
  20967. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20968. protected _buildBlock(state: NodeMaterialBuildState): this;
  20969. protected _dumpPropertiesCode(): string;
  20970. serialize(): any;
  20971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20972. }
  20973. }
  20974. declare module BABYLON {
  20975. /**
  20976. * Defines a connection point to be used for points with a custom object type
  20977. */
  20978. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20979. private _blockType;
  20980. private _blockName;
  20981. private _nameForCheking?;
  20982. /**
  20983. * Creates a new connection point
  20984. * @param name defines the connection point name
  20985. * @param ownerBlock defines the block hosting this connection point
  20986. * @param direction defines the direction of the connection point
  20987. */
  20988. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20989. /**
  20990. * Gets a number indicating if the current point can be connected to another point
  20991. * @param connectionPoint defines the other connection point
  20992. * @returns a number defining the compatibility state
  20993. */
  20994. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20995. /**
  20996. * Creates a block suitable to be used as an input for this input point.
  20997. * If null is returned, a block based on the point type will be created.
  20998. * @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
  20999. */
  21000. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /**
  21005. * Enum defining the type of properties that can be edited in the property pages in the NME
  21006. */
  21007. export enum PropertyTypeForEdition {
  21008. /** property is a boolean */
  21009. Boolean = 0,
  21010. /** property is a float */
  21011. Float = 1,
  21012. /** property is a Vector2 */
  21013. Vector2 = 2,
  21014. /** property is a list of values */
  21015. List = 3
  21016. }
  21017. /**
  21018. * Interface that defines an option in a variable of type list
  21019. */
  21020. export interface IEditablePropertyListOption {
  21021. /** label of the option */
  21022. "label": string;
  21023. /** value of the option */
  21024. "value": number;
  21025. }
  21026. /**
  21027. * Interface that defines the options available for an editable property
  21028. */
  21029. export interface IEditablePropertyOption {
  21030. /** min value */
  21031. "min"?: number;
  21032. /** max value */
  21033. "max"?: number;
  21034. /** notifiers: indicates which actions to take when the property is changed */
  21035. "notifiers"?: {
  21036. /** the material should be rebuilt */
  21037. "rebuild"?: boolean;
  21038. /** the preview should be updated */
  21039. "update"?: boolean;
  21040. };
  21041. /** list of the options for a variable of type list */
  21042. "options"?: IEditablePropertyListOption[];
  21043. }
  21044. /**
  21045. * Interface that describes an editable property
  21046. */
  21047. export interface IPropertyDescriptionForEdition {
  21048. /** name of the property */
  21049. "propertyName": string;
  21050. /** display name of the property */
  21051. "displayName": string;
  21052. /** type of the property */
  21053. "type": PropertyTypeForEdition;
  21054. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21055. "groupName": string;
  21056. /** options for the property */
  21057. "options": IEditablePropertyOption;
  21058. }
  21059. /**
  21060. * Decorator that flags a property in a node material block as being editable
  21061. */
  21062. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21063. }
  21064. declare module BABYLON {
  21065. /**
  21066. * Block used to implement the refraction part of the sub surface module of the PBR material
  21067. */
  21068. export class RefractionBlock extends NodeMaterialBlock {
  21069. /** @hidden */
  21070. _define3DName: string;
  21071. /** @hidden */
  21072. _refractionMatrixName: string;
  21073. /** @hidden */
  21074. _defineLODRefractionAlpha: string;
  21075. /** @hidden */
  21076. _defineLinearSpecularRefraction: string;
  21077. /** @hidden */
  21078. _defineOppositeZ: string;
  21079. /** @hidden */
  21080. _cubeSamplerName: string;
  21081. /** @hidden */
  21082. _2DSamplerName: string;
  21083. /** @hidden */
  21084. _vRefractionMicrosurfaceInfosName: string;
  21085. /** @hidden */
  21086. _vRefractionInfosName: string;
  21087. private _scene;
  21088. /**
  21089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21090. * Materials half opaque for instance using refraction could benefit from this control.
  21091. */
  21092. linkRefractionWithTransparency: boolean;
  21093. /**
  21094. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21095. */
  21096. invertRefractionY: boolean;
  21097. /**
  21098. * Gets or sets the texture associated with the node
  21099. */
  21100. texture: Nullable<BaseTexture>;
  21101. /**
  21102. * Create a new RefractionBlock
  21103. * @param name defines the block name
  21104. */
  21105. constructor(name: string);
  21106. /**
  21107. * Gets the current class name
  21108. * @returns the class name
  21109. */
  21110. getClassName(): string;
  21111. /**
  21112. * Gets the intensity input component
  21113. */
  21114. get intensity(): NodeMaterialConnectionPoint;
  21115. /**
  21116. * Gets the index of refraction input component
  21117. */
  21118. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21119. /**
  21120. * Gets the tint at distance input component
  21121. */
  21122. get tintAtDistance(): NodeMaterialConnectionPoint;
  21123. /**
  21124. * Gets the view input component
  21125. */
  21126. get view(): NodeMaterialConnectionPoint;
  21127. /**
  21128. * Gets the refraction object output component
  21129. */
  21130. get refraction(): NodeMaterialConnectionPoint;
  21131. /**
  21132. * Returns true if the block has a texture
  21133. */
  21134. get hasTexture(): boolean;
  21135. protected _getTexture(): Nullable<BaseTexture>;
  21136. autoConfigure(material: NodeMaterial): void;
  21137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21138. isReady(): boolean;
  21139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21140. /**
  21141. * Gets the main code of the block (fragment side)
  21142. * @param state current state of the node material building
  21143. * @returns the shader code
  21144. */
  21145. getCode(state: NodeMaterialBuildState): string;
  21146. protected _buildBlock(state: NodeMaterialBuildState): this;
  21147. protected _dumpPropertiesCode(): string;
  21148. serialize(): any;
  21149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21150. }
  21151. }
  21152. declare module BABYLON {
  21153. /**
  21154. * Base block used as input for post process
  21155. */
  21156. export class CurrentScreenBlock extends NodeMaterialBlock {
  21157. private _samplerName;
  21158. private _linearDefineName;
  21159. private _gammaDefineName;
  21160. private _mainUVName;
  21161. private _tempTextureRead;
  21162. /**
  21163. * Gets or sets the texture associated with the node
  21164. */
  21165. texture: Nullable<BaseTexture>;
  21166. /**
  21167. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21168. */
  21169. convertToGammaSpace: boolean;
  21170. /**
  21171. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21172. */
  21173. convertToLinearSpace: boolean;
  21174. /**
  21175. * Create a new CurrentScreenBlock
  21176. * @param name defines the block name
  21177. */
  21178. constructor(name: string);
  21179. /**
  21180. * Gets the current class name
  21181. * @returns the class name
  21182. */
  21183. getClassName(): string;
  21184. /**
  21185. * Gets the uv input component
  21186. */
  21187. get uv(): NodeMaterialConnectionPoint;
  21188. /**
  21189. * Gets the rgba output component
  21190. */
  21191. get rgba(): NodeMaterialConnectionPoint;
  21192. /**
  21193. * Gets the rgb output component
  21194. */
  21195. get rgb(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the r output component
  21198. */
  21199. get r(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the g output component
  21202. */
  21203. get g(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the b output component
  21206. */
  21207. get b(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the a output component
  21210. */
  21211. get a(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Initialize the block and prepare the context for build
  21214. * @param state defines the state that will be used for the build
  21215. */
  21216. initialize(state: NodeMaterialBuildState): void;
  21217. get target(): NodeMaterialBlockTargets;
  21218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21219. isReady(): boolean;
  21220. private _injectVertexCode;
  21221. private _writeTextureRead;
  21222. private _writeOutput;
  21223. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21224. serialize(): any;
  21225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21226. }
  21227. }
  21228. declare module BABYLON {
  21229. /**
  21230. * Base block used for the particle texture
  21231. */
  21232. export class ParticleTextureBlock extends NodeMaterialBlock {
  21233. private _samplerName;
  21234. private _linearDefineName;
  21235. private _gammaDefineName;
  21236. private _tempTextureRead;
  21237. /**
  21238. * Gets or sets the texture associated with the node
  21239. */
  21240. texture: Nullable<BaseTexture>;
  21241. /**
  21242. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21243. */
  21244. convertToGammaSpace: boolean;
  21245. /**
  21246. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21247. */
  21248. convertToLinearSpace: boolean;
  21249. /**
  21250. * Create a new ParticleTextureBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the uv input component
  21261. */
  21262. get uv(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the rgba output component
  21265. */
  21266. get rgba(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the rgb output component
  21269. */
  21270. get rgb(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the r output component
  21273. */
  21274. get r(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the g output component
  21277. */
  21278. get g(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the b output component
  21281. */
  21282. get b(): NodeMaterialConnectionPoint;
  21283. /**
  21284. * Gets the a output component
  21285. */
  21286. get a(): NodeMaterialConnectionPoint;
  21287. /**
  21288. * Initialize the block and prepare the context for build
  21289. * @param state defines the state that will be used for the build
  21290. */
  21291. initialize(state: NodeMaterialBuildState): void;
  21292. autoConfigure(material: NodeMaterial): void;
  21293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21294. isReady(): boolean;
  21295. private _writeOutput;
  21296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21297. serialize(): any;
  21298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21299. }
  21300. }
  21301. declare module BABYLON {
  21302. /**
  21303. * Class used to store shared data between 2 NodeMaterialBuildState
  21304. */
  21305. export class NodeMaterialBuildStateSharedData {
  21306. /**
  21307. * Gets the list of emitted varyings
  21308. */
  21309. temps: string[];
  21310. /**
  21311. * Gets the list of emitted varyings
  21312. */
  21313. varyings: string[];
  21314. /**
  21315. * Gets the varying declaration string
  21316. */
  21317. varyingDeclaration: string;
  21318. /**
  21319. * Input blocks
  21320. */
  21321. inputBlocks: InputBlock[];
  21322. /**
  21323. * Input blocks
  21324. */
  21325. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21326. /**
  21327. * Bindable blocks (Blocks that need to set data to the effect)
  21328. */
  21329. bindableBlocks: NodeMaterialBlock[];
  21330. /**
  21331. * List of blocks that can provide a compilation fallback
  21332. */
  21333. blocksWithFallbacks: NodeMaterialBlock[];
  21334. /**
  21335. * List of blocks that can provide a define update
  21336. */
  21337. blocksWithDefines: NodeMaterialBlock[];
  21338. /**
  21339. * List of blocks that can provide a repeatable content
  21340. */
  21341. repeatableContentBlocks: NodeMaterialBlock[];
  21342. /**
  21343. * List of blocks that can provide a dynamic list of uniforms
  21344. */
  21345. dynamicUniformBlocks: NodeMaterialBlock[];
  21346. /**
  21347. * List of blocks that can block the isReady function for the material
  21348. */
  21349. blockingBlocks: NodeMaterialBlock[];
  21350. /**
  21351. * Gets the list of animated inputs
  21352. */
  21353. animatedInputs: InputBlock[];
  21354. /**
  21355. * Build Id used to avoid multiple recompilations
  21356. */
  21357. buildId: number;
  21358. /** List of emitted variables */
  21359. variableNames: {
  21360. [key: string]: number;
  21361. };
  21362. /** List of emitted defines */
  21363. defineNames: {
  21364. [key: string]: number;
  21365. };
  21366. /** Should emit comments? */
  21367. emitComments: boolean;
  21368. /** Emit build activity */
  21369. verbose: boolean;
  21370. /** Gets or sets the hosting scene */
  21371. scene: Scene;
  21372. /**
  21373. * Gets the compilation hints emitted at compilation time
  21374. */
  21375. hints: {
  21376. needWorldViewMatrix: boolean;
  21377. needWorldViewProjectionMatrix: boolean;
  21378. needAlphaBlending: boolean;
  21379. needAlphaTesting: boolean;
  21380. };
  21381. /**
  21382. * List of compilation checks
  21383. */
  21384. checks: {
  21385. emitVertex: boolean;
  21386. emitFragment: boolean;
  21387. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21388. };
  21389. /**
  21390. * Is vertex program allowed to be empty?
  21391. */
  21392. allowEmptyVertexProgram: boolean;
  21393. /** Creates a new shared data */
  21394. constructor();
  21395. /**
  21396. * Emits console errors and exceptions if there is a failing check
  21397. */
  21398. emitErrors(): void;
  21399. }
  21400. }
  21401. declare module BABYLON {
  21402. /**
  21403. * Class used to store node based material build state
  21404. */
  21405. export class NodeMaterialBuildState {
  21406. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21407. supportUniformBuffers: boolean;
  21408. /**
  21409. * Gets the list of emitted attributes
  21410. */
  21411. attributes: string[];
  21412. /**
  21413. * Gets the list of emitted uniforms
  21414. */
  21415. uniforms: string[];
  21416. /**
  21417. * Gets the list of emitted constants
  21418. */
  21419. constants: string[];
  21420. /**
  21421. * Gets the list of emitted samplers
  21422. */
  21423. samplers: string[];
  21424. /**
  21425. * Gets the list of emitted functions
  21426. */
  21427. functions: {
  21428. [key: string]: string;
  21429. };
  21430. /**
  21431. * Gets the list of emitted extensions
  21432. */
  21433. extensions: {
  21434. [key: string]: string;
  21435. };
  21436. /**
  21437. * Gets the target of the compilation state
  21438. */
  21439. target: NodeMaterialBlockTargets;
  21440. /**
  21441. * Gets the list of emitted counters
  21442. */
  21443. counters: {
  21444. [key: string]: number;
  21445. };
  21446. /**
  21447. * Shared data between multiple NodeMaterialBuildState instances
  21448. */
  21449. sharedData: NodeMaterialBuildStateSharedData;
  21450. /** @hidden */
  21451. _vertexState: NodeMaterialBuildState;
  21452. /** @hidden */
  21453. _attributeDeclaration: string;
  21454. /** @hidden */
  21455. _uniformDeclaration: string;
  21456. /** @hidden */
  21457. _constantDeclaration: string;
  21458. /** @hidden */
  21459. _samplerDeclaration: string;
  21460. /** @hidden */
  21461. _varyingTransfer: string;
  21462. /** @hidden */
  21463. _injectAtEnd: string;
  21464. private _repeatableContentAnchorIndex;
  21465. /** @hidden */
  21466. _builtCompilationString: string;
  21467. /**
  21468. * Gets the emitted compilation strings
  21469. */
  21470. compilationString: string;
  21471. /**
  21472. * Finalize the compilation strings
  21473. * @param state defines the current compilation state
  21474. */
  21475. finalize(state: NodeMaterialBuildState): void;
  21476. /** @hidden */
  21477. get _repeatableContentAnchor(): string;
  21478. /** @hidden */
  21479. _getFreeVariableName(prefix: string): string;
  21480. /** @hidden */
  21481. _getFreeDefineName(prefix: string): string;
  21482. /** @hidden */
  21483. _excludeVariableName(name: string): void;
  21484. /** @hidden */
  21485. _emit2DSampler(name: string): void;
  21486. /** @hidden */
  21487. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21488. /** @hidden */
  21489. _emitExtension(name: string, extension: string, define?: string): void;
  21490. /** @hidden */
  21491. _emitFunction(name: string, code: string, comments: string): void;
  21492. /** @hidden */
  21493. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21494. replaceStrings?: {
  21495. search: RegExp;
  21496. replace: string;
  21497. }[];
  21498. repeatKey?: string;
  21499. }): string;
  21500. /** @hidden */
  21501. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21502. repeatKey?: string;
  21503. removeAttributes?: boolean;
  21504. removeUniforms?: boolean;
  21505. removeVaryings?: boolean;
  21506. removeIfDef?: boolean;
  21507. replaceStrings?: {
  21508. search: RegExp;
  21509. replace: string;
  21510. }[];
  21511. }, storeKey?: string): void;
  21512. /** @hidden */
  21513. _registerTempVariable(name: string): boolean;
  21514. /** @hidden */
  21515. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21516. /** @hidden */
  21517. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21518. /** @hidden */
  21519. _emitFloat(value: number): string;
  21520. }
  21521. }
  21522. declare module BABYLON {
  21523. /**
  21524. * Helper class used to generate session unique ID
  21525. */
  21526. export class UniqueIdGenerator {
  21527. private static _UniqueIdCounter;
  21528. /**
  21529. * Gets an unique (relatively to the current scene) Id
  21530. */
  21531. static get UniqueId(): number;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Defines a block that can be used inside a node based material
  21537. */
  21538. export class NodeMaterialBlock {
  21539. private _buildId;
  21540. private _buildTarget;
  21541. private _target;
  21542. private _isFinalMerger;
  21543. private _isInput;
  21544. private _name;
  21545. protected _isUnique: boolean;
  21546. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21547. inputsAreExclusive: boolean;
  21548. /** @hidden */
  21549. _codeVariableName: string;
  21550. /** @hidden */
  21551. _inputs: NodeMaterialConnectionPoint[];
  21552. /** @hidden */
  21553. _outputs: NodeMaterialConnectionPoint[];
  21554. /** @hidden */
  21555. _preparationId: number;
  21556. /**
  21557. * Gets the name of the block
  21558. */
  21559. get name(): string;
  21560. /**
  21561. * Sets the name of the block. Will check if the name is valid.
  21562. */
  21563. set name(newName: string);
  21564. /**
  21565. * Gets or sets the unique id of the node
  21566. */
  21567. uniqueId: number;
  21568. /**
  21569. * Gets or sets the comments associated with this block
  21570. */
  21571. comments: string;
  21572. /**
  21573. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21574. */
  21575. get isUnique(): boolean;
  21576. /**
  21577. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21578. */
  21579. get isFinalMerger(): boolean;
  21580. /**
  21581. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21582. */
  21583. get isInput(): boolean;
  21584. /**
  21585. * Gets or sets the build Id
  21586. */
  21587. get buildId(): number;
  21588. set buildId(value: number);
  21589. /**
  21590. * Gets or sets the target of the block
  21591. */
  21592. get target(): NodeMaterialBlockTargets;
  21593. set target(value: NodeMaterialBlockTargets);
  21594. /**
  21595. * Gets the list of input points
  21596. */
  21597. get inputs(): NodeMaterialConnectionPoint[];
  21598. /** Gets the list of output points */
  21599. get outputs(): NodeMaterialConnectionPoint[];
  21600. /**
  21601. * Find an input by its name
  21602. * @param name defines the name of the input to look for
  21603. * @returns the input or null if not found
  21604. */
  21605. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21606. /**
  21607. * Find an output by its name
  21608. * @param name defines the name of the outputto look for
  21609. * @returns the output or null if not found
  21610. */
  21611. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21612. /**
  21613. * Creates a new NodeMaterialBlock
  21614. * @param name defines the block name
  21615. * @param target defines the target of that block (Vertex by default)
  21616. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21617. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21618. */
  21619. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21620. /**
  21621. * Initialize the block and prepare the context for build
  21622. * @param state defines the state that will be used for the build
  21623. */
  21624. initialize(state: NodeMaterialBuildState): void;
  21625. /**
  21626. * Bind data to effect. Will only be called for blocks with isBindable === true
  21627. * @param effect defines the effect to bind data to
  21628. * @param nodeMaterial defines the hosting NodeMaterial
  21629. * @param mesh defines the mesh that will be rendered
  21630. * @param subMesh defines the submesh that will be rendered
  21631. */
  21632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21633. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21634. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21635. protected _writeFloat(value: number): string;
  21636. /**
  21637. * Gets the current class name e.g. "NodeMaterialBlock"
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Register a new input. Must be called inside a block constructor
  21643. * @param name defines the connection point name
  21644. * @param type defines the connection point type
  21645. * @param isOptional defines a boolean indicating that this input can be omitted
  21646. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21647. * @param point an already created connection point. If not provided, create a new one
  21648. * @returns the current block
  21649. */
  21650. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21651. /**
  21652. * Register a new output. Must be called inside a block constructor
  21653. * @param name defines the connection point name
  21654. * @param type defines the connection point type
  21655. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21656. * @param point an already created connection point. If not provided, create a new one
  21657. * @returns the current block
  21658. */
  21659. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21660. /**
  21661. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21662. * @param forOutput defines an optional connection point to check compatibility with
  21663. * @returns the first available input or null
  21664. */
  21665. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21666. /**
  21667. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21668. * @param forBlock defines an optional block to check compatibility with
  21669. * @returns the first available input or null
  21670. */
  21671. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21672. /**
  21673. * Gets the sibling of the given output
  21674. * @param current defines the current output
  21675. * @returns the next output in the list or null
  21676. */
  21677. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21678. /**
  21679. * Connect current block with another block
  21680. * @param other defines the block to connect with
  21681. * @param options define the various options to help pick the right connections
  21682. * @returns the current block
  21683. */
  21684. connectTo(other: NodeMaterialBlock, options?: {
  21685. input?: string;
  21686. output?: string;
  21687. outputSwizzle?: string;
  21688. }): this | undefined;
  21689. protected _buildBlock(state: NodeMaterialBuildState): void;
  21690. /**
  21691. * Add uniforms, samplers and uniform buffers at compilation time
  21692. * @param state defines the state to update
  21693. * @param nodeMaterial defines the node material requesting the update
  21694. * @param defines defines the material defines to update
  21695. * @param uniformBuffers defines the list of uniform buffer names
  21696. */
  21697. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21698. /**
  21699. * Add potential fallbacks if shader compilation fails
  21700. * @param mesh defines the mesh to be rendered
  21701. * @param fallbacks defines the current prioritized list of fallbacks
  21702. */
  21703. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21704. /**
  21705. * Initialize defines for shader compilation
  21706. * @param mesh defines the mesh to be rendered
  21707. * @param nodeMaterial defines the node material requesting the update
  21708. * @param defines defines the material defines to update
  21709. * @param useInstances specifies that instances should be used
  21710. */
  21711. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21712. /**
  21713. * Update defines for shader compilation
  21714. * @param mesh defines the mesh to be rendered
  21715. * @param nodeMaterial defines the node material requesting the update
  21716. * @param defines defines the material defines to update
  21717. * @param useInstances specifies that instances should be used
  21718. * @param subMesh defines which submesh to render
  21719. */
  21720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21721. /**
  21722. * Lets the block try to connect some inputs automatically
  21723. * @param material defines the hosting NodeMaterial
  21724. */
  21725. autoConfigure(material: NodeMaterial): void;
  21726. /**
  21727. * Function called when a block is declared as repeatable content generator
  21728. * @param vertexShaderState defines the current compilation state for the vertex shader
  21729. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21730. * @param mesh defines the mesh to be rendered
  21731. * @param defines defines the material defines to update
  21732. */
  21733. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21734. /**
  21735. * Checks if the block is ready
  21736. * @param mesh defines the mesh to be rendered
  21737. * @param nodeMaterial defines the node material requesting the update
  21738. * @param defines defines the material defines to update
  21739. * @param useInstances specifies that instances should be used
  21740. * @returns true if the block is ready
  21741. */
  21742. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21743. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21744. private _processBuild;
  21745. /**
  21746. * Validates the new name for the block node.
  21747. * @param newName the new name to be given to the node.
  21748. * @returns false if the name is a reserve word, else true.
  21749. */
  21750. validateBlockName(newName: string): boolean;
  21751. /**
  21752. * Compile the current node and generate the shader code
  21753. * @param state defines the current compilation state (uniforms, samplers, current string)
  21754. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21755. * @returns true if already built
  21756. */
  21757. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21758. protected _inputRename(name: string): string;
  21759. protected _outputRename(name: string): string;
  21760. protected _dumpPropertiesCode(): string;
  21761. /** @hidden */
  21762. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21763. /** @hidden */
  21764. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21765. /**
  21766. * Clone the current block to a new identical block
  21767. * @param scene defines the hosting scene
  21768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21769. * @returns a copy of the current block
  21770. */
  21771. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21772. /**
  21773. * Serializes this block in a JSON representation
  21774. * @returns the serialized block object
  21775. */
  21776. serialize(): any;
  21777. /** @hidden */
  21778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21779. private _deserializePortDisplayNamesAndExposedOnFrame;
  21780. /**
  21781. * Release resources
  21782. */
  21783. dispose(): void;
  21784. }
  21785. }
  21786. declare module BABYLON {
  21787. /**
  21788. * Base class of materials working in push mode in babylon JS
  21789. * @hidden
  21790. */
  21791. export class PushMaterial extends Material {
  21792. protected _activeEffect: Effect;
  21793. protected _normalMatrix: Matrix;
  21794. constructor(name: string, scene: Scene);
  21795. getEffect(): Effect;
  21796. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21797. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21798. /**
  21799. * Binds the given world matrix to the active effect
  21800. *
  21801. * @param world the matrix to bind
  21802. */
  21803. bindOnlyWorldMatrix(world: Matrix): void;
  21804. /**
  21805. * Binds the given normal matrix to the active effect
  21806. *
  21807. * @param normalMatrix the matrix to bind
  21808. */
  21809. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21810. bind(world: Matrix, mesh?: Mesh): void;
  21811. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21812. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21813. }
  21814. }
  21815. declare module BABYLON {
  21816. /**
  21817. * Root class for all node material optimizers
  21818. */
  21819. export class NodeMaterialOptimizer {
  21820. /**
  21821. * Function used to optimize a NodeMaterial graph
  21822. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21823. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21824. */
  21825. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21826. }
  21827. }
  21828. declare module BABYLON {
  21829. /**
  21830. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21831. */
  21832. export class TransformBlock extends NodeMaterialBlock {
  21833. /**
  21834. * Defines the value to use to complement W value to transform it to a Vector4
  21835. */
  21836. complementW: number;
  21837. /**
  21838. * Defines the value to use to complement z value to transform it to a Vector4
  21839. */
  21840. complementZ: number;
  21841. /**
  21842. * Creates a new TransformBlock
  21843. * @param name defines the block name
  21844. */
  21845. constructor(name: string);
  21846. /**
  21847. * Gets the current class name
  21848. * @returns the class name
  21849. */
  21850. getClassName(): string;
  21851. /**
  21852. * Gets the vector input
  21853. */
  21854. get vector(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the output component
  21857. */
  21858. get output(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Gets the xyz output component
  21861. */
  21862. get xyz(): NodeMaterialConnectionPoint;
  21863. /**
  21864. * Gets the matrix transform input
  21865. */
  21866. get transform(): NodeMaterialConnectionPoint;
  21867. protected _buildBlock(state: NodeMaterialBuildState): this;
  21868. /**
  21869. * Update defines for shader compilation
  21870. * @param mesh defines the mesh to be rendered
  21871. * @param nodeMaterial defines the node material requesting the update
  21872. * @param defines defines the material defines to update
  21873. * @param useInstances specifies that instances should be used
  21874. * @param subMesh defines which submesh to render
  21875. */
  21876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21877. serialize(): any;
  21878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21879. protected _dumpPropertiesCode(): string;
  21880. }
  21881. }
  21882. declare module BABYLON {
  21883. /**
  21884. * Block used to output the vertex position
  21885. */
  21886. export class VertexOutputBlock extends NodeMaterialBlock {
  21887. /**
  21888. * Creates a new VertexOutputBlock
  21889. * @param name defines the block name
  21890. */
  21891. constructor(name: string);
  21892. /**
  21893. * Gets the current class name
  21894. * @returns the class name
  21895. */
  21896. getClassName(): string;
  21897. /**
  21898. * Gets the vector input component
  21899. */
  21900. get vector(): NodeMaterialConnectionPoint;
  21901. protected _buildBlock(state: NodeMaterialBuildState): this;
  21902. }
  21903. }
  21904. declare module BABYLON {
  21905. /**
  21906. * Block used to output the final color
  21907. */
  21908. export class FragmentOutputBlock extends NodeMaterialBlock {
  21909. /**
  21910. * Create a new FragmentOutputBlock
  21911. * @param name defines the block name
  21912. */
  21913. constructor(name: string);
  21914. /**
  21915. * Gets the current class name
  21916. * @returns the class name
  21917. */
  21918. getClassName(): string;
  21919. /**
  21920. * Gets the rgba input component
  21921. */
  21922. get rgba(): NodeMaterialConnectionPoint;
  21923. /**
  21924. * Gets the rgb input component
  21925. */
  21926. get rgb(): NodeMaterialConnectionPoint;
  21927. /**
  21928. * Gets the a input component
  21929. */
  21930. get a(): NodeMaterialConnectionPoint;
  21931. protected _buildBlock(state: NodeMaterialBuildState): this;
  21932. }
  21933. }
  21934. declare module BABYLON {
  21935. /**
  21936. * Block used for the particle ramp gradient section
  21937. */
  21938. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21939. /**
  21940. * Create a new ParticleRampGradientBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the color input component
  21951. */
  21952. get color(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the rampColor output component
  21955. */
  21956. get rampColor(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Initialize the block and prepare the context for build
  21959. * @param state defines the state that will be used for the build
  21960. */
  21961. initialize(state: NodeMaterialBuildState): void;
  21962. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21963. }
  21964. }
  21965. declare module BABYLON {
  21966. /**
  21967. * Block used for the particle blend multiply section
  21968. */
  21969. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21970. /**
  21971. * Create a new ParticleBlendMultiplyBlock
  21972. * @param name defines the block name
  21973. */
  21974. constructor(name: string);
  21975. /**
  21976. * Gets the current class name
  21977. * @returns the class name
  21978. */
  21979. getClassName(): string;
  21980. /**
  21981. * Gets the color input component
  21982. */
  21983. get color(): NodeMaterialConnectionPoint;
  21984. /**
  21985. * Gets the alphaTexture input component
  21986. */
  21987. get alphaTexture(): NodeMaterialConnectionPoint;
  21988. /**
  21989. * Gets the alphaColor input component
  21990. */
  21991. get alphaColor(): NodeMaterialConnectionPoint;
  21992. /**
  21993. * Gets the blendColor output component
  21994. */
  21995. get blendColor(): NodeMaterialConnectionPoint;
  21996. /**
  21997. * Initialize the block and prepare the context for build
  21998. * @param state defines the state that will be used for the build
  21999. */
  22000. initialize(state: NodeMaterialBuildState): void;
  22001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22002. }
  22003. }
  22004. declare module BABYLON {
  22005. /**
  22006. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22007. */
  22008. export class VectorMergerBlock extends NodeMaterialBlock {
  22009. /**
  22010. * Create a new VectorMergerBlock
  22011. * @param name defines the block name
  22012. */
  22013. constructor(name: string);
  22014. /**
  22015. * Gets the current class name
  22016. * @returns the class name
  22017. */
  22018. getClassName(): string;
  22019. /**
  22020. * Gets the xyz component (input)
  22021. */
  22022. get xyzIn(): NodeMaterialConnectionPoint;
  22023. /**
  22024. * Gets the xy component (input)
  22025. */
  22026. get xyIn(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the x component (input)
  22029. */
  22030. get x(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Gets the y component (input)
  22033. */
  22034. get y(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the z component (input)
  22037. */
  22038. get z(): NodeMaterialConnectionPoint;
  22039. /**
  22040. * Gets the w component (input)
  22041. */
  22042. get w(): NodeMaterialConnectionPoint;
  22043. /**
  22044. * Gets the xyzw component (output)
  22045. */
  22046. get xyzw(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the xyz component (output)
  22049. */
  22050. get xyzOut(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the xy component (output)
  22053. */
  22054. get xyOut(): NodeMaterialConnectionPoint;
  22055. /**
  22056. * Gets the xy component (output)
  22057. * @deprecated Please use xyOut instead.
  22058. */
  22059. get xy(): NodeMaterialConnectionPoint;
  22060. /**
  22061. * Gets the xyz component (output)
  22062. * @deprecated Please use xyzOut instead.
  22063. */
  22064. get xyz(): NodeMaterialConnectionPoint;
  22065. protected _buildBlock(state: NodeMaterialBuildState): this;
  22066. }
  22067. }
  22068. declare module BABYLON {
  22069. /**
  22070. * Block used to remap a float from a range to a new one
  22071. */
  22072. export class RemapBlock extends NodeMaterialBlock {
  22073. /**
  22074. * Gets or sets the source range
  22075. */
  22076. sourceRange: Vector2;
  22077. /**
  22078. * Gets or sets the target range
  22079. */
  22080. targetRange: Vector2;
  22081. /**
  22082. * Creates a new RemapBlock
  22083. * @param name defines the block name
  22084. */
  22085. constructor(name: string);
  22086. /**
  22087. * Gets the current class name
  22088. * @returns the class name
  22089. */
  22090. getClassName(): string;
  22091. /**
  22092. * Gets the input component
  22093. */
  22094. get input(): NodeMaterialConnectionPoint;
  22095. /**
  22096. * Gets the source min input component
  22097. */
  22098. get sourceMin(): NodeMaterialConnectionPoint;
  22099. /**
  22100. * Gets the source max input component
  22101. */
  22102. get sourceMax(): NodeMaterialConnectionPoint;
  22103. /**
  22104. * Gets the target min input component
  22105. */
  22106. get targetMin(): NodeMaterialConnectionPoint;
  22107. /**
  22108. * Gets the target max input component
  22109. */
  22110. get targetMax(): NodeMaterialConnectionPoint;
  22111. /**
  22112. * Gets the output component
  22113. */
  22114. get output(): NodeMaterialConnectionPoint;
  22115. protected _buildBlock(state: NodeMaterialBuildState): this;
  22116. protected _dumpPropertiesCode(): string;
  22117. serialize(): any;
  22118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22119. }
  22120. }
  22121. declare module BABYLON {
  22122. /**
  22123. * Block used to multiply 2 values
  22124. */
  22125. export class MultiplyBlock extends NodeMaterialBlock {
  22126. /**
  22127. * Creates a new MultiplyBlock
  22128. * @param name defines the block name
  22129. */
  22130. constructor(name: string);
  22131. /**
  22132. * Gets the current class name
  22133. * @returns the class name
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Gets the left operand input component
  22138. */
  22139. get left(): NodeMaterialConnectionPoint;
  22140. /**
  22141. * Gets the right operand input component
  22142. */
  22143. get right(): NodeMaterialConnectionPoint;
  22144. /**
  22145. * Gets the output component
  22146. */
  22147. get output(): NodeMaterialConnectionPoint;
  22148. protected _buildBlock(state: NodeMaterialBuildState): this;
  22149. }
  22150. }
  22151. declare module BABYLON {
  22152. /**
  22153. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22154. */
  22155. export class ColorSplitterBlock extends NodeMaterialBlock {
  22156. /**
  22157. * Create a new ColorSplitterBlock
  22158. * @param name defines the block name
  22159. */
  22160. constructor(name: string);
  22161. /**
  22162. * Gets the current class name
  22163. * @returns the class name
  22164. */
  22165. getClassName(): string;
  22166. /**
  22167. * Gets the rgba component (input)
  22168. */
  22169. get rgba(): NodeMaterialConnectionPoint;
  22170. /**
  22171. * Gets the rgb component (input)
  22172. */
  22173. get rgbIn(): NodeMaterialConnectionPoint;
  22174. /**
  22175. * Gets the rgb component (output)
  22176. */
  22177. get rgbOut(): NodeMaterialConnectionPoint;
  22178. /**
  22179. * Gets the r component (output)
  22180. */
  22181. get r(): NodeMaterialConnectionPoint;
  22182. /**
  22183. * Gets the g component (output)
  22184. */
  22185. get g(): NodeMaterialConnectionPoint;
  22186. /**
  22187. * Gets the b component (output)
  22188. */
  22189. get b(): NodeMaterialConnectionPoint;
  22190. /**
  22191. * Gets the a component (output)
  22192. */
  22193. get a(): NodeMaterialConnectionPoint;
  22194. protected _inputRename(name: string): string;
  22195. protected _outputRename(name: string): string;
  22196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22197. }
  22198. }
  22199. declare module BABYLON {
  22200. /**
  22201. * Interface used to configure the node material editor
  22202. */
  22203. export interface INodeMaterialEditorOptions {
  22204. /** Define the URl to load node editor script */
  22205. editorURL?: string;
  22206. }
  22207. /** @hidden */
  22208. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22209. NORMAL: boolean;
  22210. TANGENT: boolean;
  22211. UV1: boolean;
  22212. /** BONES */
  22213. NUM_BONE_INFLUENCERS: number;
  22214. BonesPerMesh: number;
  22215. BONETEXTURE: boolean;
  22216. /** MORPH TARGETS */
  22217. MORPHTARGETS: boolean;
  22218. MORPHTARGETS_NORMAL: boolean;
  22219. MORPHTARGETS_TANGENT: boolean;
  22220. MORPHTARGETS_UV: boolean;
  22221. NUM_MORPH_INFLUENCERS: number;
  22222. /** IMAGE PROCESSING */
  22223. IMAGEPROCESSING: boolean;
  22224. VIGNETTE: boolean;
  22225. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22226. VIGNETTEBLENDMODEOPAQUE: boolean;
  22227. TONEMAPPING: boolean;
  22228. TONEMAPPING_ACES: boolean;
  22229. CONTRAST: boolean;
  22230. EXPOSURE: boolean;
  22231. COLORCURVES: boolean;
  22232. COLORGRADING: boolean;
  22233. COLORGRADING3D: boolean;
  22234. SAMPLER3DGREENDEPTH: boolean;
  22235. SAMPLER3DBGRMAP: boolean;
  22236. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22237. /** MISC. */
  22238. BUMPDIRECTUV: number;
  22239. constructor();
  22240. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22241. }
  22242. /**
  22243. * Class used to configure NodeMaterial
  22244. */
  22245. export interface INodeMaterialOptions {
  22246. /**
  22247. * Defines if blocks should emit comments
  22248. */
  22249. emitComments: boolean;
  22250. }
  22251. /**
  22252. * Class used to create a node based material built by assembling shader blocks
  22253. */
  22254. export class NodeMaterial extends PushMaterial {
  22255. private static _BuildIdGenerator;
  22256. private _options;
  22257. private _vertexCompilationState;
  22258. private _fragmentCompilationState;
  22259. private _sharedData;
  22260. private _buildId;
  22261. private _buildWasSuccessful;
  22262. private _cachedWorldViewMatrix;
  22263. private _cachedWorldViewProjectionMatrix;
  22264. private _optimizers;
  22265. private _animationFrame;
  22266. /** Define the Url to load node editor script */
  22267. static EditorURL: string;
  22268. /** Define the Url to load snippets */
  22269. static SnippetUrl: string;
  22270. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22271. static IgnoreTexturesAtLoadTime: boolean;
  22272. private BJSNODEMATERIALEDITOR;
  22273. /** Get the inspector from bundle or global */
  22274. private _getGlobalNodeMaterialEditor;
  22275. /**
  22276. * Snippet ID if the material was created from the snippet server
  22277. */
  22278. snippetId: string;
  22279. /**
  22280. * Gets or sets data used by visual editor
  22281. * @see https://nme.babylonjs.com
  22282. */
  22283. editorData: any;
  22284. /**
  22285. * 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)
  22286. */
  22287. ignoreAlpha: boolean;
  22288. /**
  22289. * Defines the maximum number of lights that can be used in the material
  22290. */
  22291. maxSimultaneousLights: number;
  22292. /**
  22293. * Observable raised when the material is built
  22294. */
  22295. onBuildObservable: Observable<NodeMaterial>;
  22296. /**
  22297. * Gets or sets the root nodes of the material vertex shader
  22298. */
  22299. _vertexOutputNodes: NodeMaterialBlock[];
  22300. /**
  22301. * Gets or sets the root nodes of the material fragment (pixel) shader
  22302. */
  22303. _fragmentOutputNodes: NodeMaterialBlock[];
  22304. /** Gets or sets options to control the node material overall behavior */
  22305. get options(): INodeMaterialOptions;
  22306. set options(options: INodeMaterialOptions);
  22307. /**
  22308. * Default configuration related to image processing available in the standard Material.
  22309. */
  22310. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22311. /**
  22312. * Gets the image processing configuration used either in this material.
  22313. */
  22314. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22315. /**
  22316. * Sets the Default image processing configuration used either in the this material.
  22317. *
  22318. * If sets to null, the scene one is in use.
  22319. */
  22320. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22321. /**
  22322. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22323. */
  22324. attachedBlocks: NodeMaterialBlock[];
  22325. /**
  22326. * Specifies the mode of the node material
  22327. * @hidden
  22328. */
  22329. _mode: NodeMaterialModes;
  22330. /**
  22331. * Gets the mode property
  22332. */
  22333. get mode(): NodeMaterialModes;
  22334. /**
  22335. * Create a new node based material
  22336. * @param name defines the material name
  22337. * @param scene defines the hosting scene
  22338. * @param options defines creation option
  22339. */
  22340. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22341. /**
  22342. * Gets the current class name of the material e.g. "NodeMaterial"
  22343. * @returns the class name
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * Keep track of the image processing observer to allow dispose and replace.
  22348. */
  22349. private _imageProcessingObserver;
  22350. /**
  22351. * Attaches a new image processing configuration to the Standard Material.
  22352. * @param configuration
  22353. */
  22354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22355. /**
  22356. * Get a block by its name
  22357. * @param name defines the name of the block to retrieve
  22358. * @returns the required block or null if not found
  22359. */
  22360. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22361. /**
  22362. * Get a block by its name
  22363. * @param predicate defines the predicate used to find the good candidate
  22364. * @returns the required block or null if not found
  22365. */
  22366. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22367. /**
  22368. * Get an input block by its name
  22369. * @param predicate defines the predicate used to find the good candidate
  22370. * @returns the required input block or null if not found
  22371. */
  22372. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22373. /**
  22374. * Gets the list of input blocks attached to this material
  22375. * @returns an array of InputBlocks
  22376. */
  22377. getInputBlocks(): InputBlock[];
  22378. /**
  22379. * Adds a new optimizer to the list of optimizers
  22380. * @param optimizer defines the optimizers to add
  22381. * @returns the current material
  22382. */
  22383. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22384. /**
  22385. * Remove an optimizer from the list of optimizers
  22386. * @param optimizer defines the optimizers to remove
  22387. * @returns the current material
  22388. */
  22389. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22390. /**
  22391. * Add a new block to the list of output nodes
  22392. * @param node defines the node to add
  22393. * @returns the current material
  22394. */
  22395. addOutputNode(node: NodeMaterialBlock): this;
  22396. /**
  22397. * Remove a block from the list of root nodes
  22398. * @param node defines the node to remove
  22399. * @returns the current material
  22400. */
  22401. removeOutputNode(node: NodeMaterialBlock): this;
  22402. private _addVertexOutputNode;
  22403. private _removeVertexOutputNode;
  22404. private _addFragmentOutputNode;
  22405. private _removeFragmentOutputNode;
  22406. /**
  22407. * Specifies if the material will require alpha blending
  22408. * @returns a boolean specifying if alpha blending is needed
  22409. */
  22410. needAlphaBlending(): boolean;
  22411. /**
  22412. * Specifies if this material should be rendered in alpha test mode
  22413. * @returns a boolean specifying if an alpha test is needed.
  22414. */
  22415. needAlphaTesting(): boolean;
  22416. private _initializeBlock;
  22417. private _resetDualBlocks;
  22418. /**
  22419. * Remove a block from the current node material
  22420. * @param block defines the block to remove
  22421. */
  22422. removeBlock(block: NodeMaterialBlock): void;
  22423. /**
  22424. * Build the material and generates the inner effect
  22425. * @param verbose defines if the build should log activity
  22426. */
  22427. build(verbose?: boolean): void;
  22428. /**
  22429. * Runs an otpimization phase to try to improve the shader code
  22430. */
  22431. optimize(): void;
  22432. private _prepareDefinesForAttributes;
  22433. /**
  22434. * Create a post process from the material
  22435. * @param camera The camera to apply the render pass to.
  22436. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22438. * @param engine The engine which the post process will be applied. (default: current engine)
  22439. * @param reusable If the post process can be reused on the same frame. (default: false)
  22440. * @param textureType Type of textures used when performing the post process. (default: 0)
  22441. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22442. * @returns the post process created
  22443. */
  22444. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22445. /**
  22446. * Create the post process effect from the material
  22447. * @param postProcess The post process to create the effect for
  22448. */
  22449. createEffectForPostProcess(postProcess: PostProcess): void;
  22450. private _createEffectOrPostProcess;
  22451. private _createEffectForParticles;
  22452. /**
  22453. * Create the effect to be used as the custom effect for a particle system
  22454. * @param particleSystem Particle system to create the effect for
  22455. * @param onCompiled defines a function to call when the effect creation is successful
  22456. * @param onError defines a function to call when the effect creation has failed
  22457. */
  22458. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22459. private _processDefines;
  22460. /**
  22461. * Get if the submesh is ready to be used and all its information available.
  22462. * Child classes can use it to update shaders
  22463. * @param mesh defines the mesh to check
  22464. * @param subMesh defines which submesh to check
  22465. * @param useInstances specifies that instances should be used
  22466. * @returns a boolean indicating that the submesh is ready or not
  22467. */
  22468. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22469. /**
  22470. * Get a string representing the shaders built by the current node graph
  22471. */
  22472. get compiledShaders(): string;
  22473. /**
  22474. * Binds the world matrix to the material
  22475. * @param world defines the world transformation matrix
  22476. */
  22477. bindOnlyWorldMatrix(world: Matrix): void;
  22478. /**
  22479. * Binds the submesh to this material by preparing the effect and shader to draw
  22480. * @param world defines the world transformation matrix
  22481. * @param mesh defines the mesh containing the submesh
  22482. * @param subMesh defines the submesh to bind the material to
  22483. */
  22484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22485. /**
  22486. * Gets the active textures from the material
  22487. * @returns an array of textures
  22488. */
  22489. getActiveTextures(): BaseTexture[];
  22490. /**
  22491. * Gets the list of texture blocks
  22492. * @returns an array of texture blocks
  22493. */
  22494. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22495. /**
  22496. * Specifies if the material uses a texture
  22497. * @param texture defines the texture to check against the material
  22498. * @returns a boolean specifying if the material uses the texture
  22499. */
  22500. hasTexture(texture: BaseTexture): boolean;
  22501. /**
  22502. * Disposes the material
  22503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22506. */
  22507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22508. /** Creates the node editor window. */
  22509. private _createNodeEditor;
  22510. /**
  22511. * Launch the node material editor
  22512. * @param config Define the configuration of the editor
  22513. * @return a promise fulfilled when the node editor is visible
  22514. */
  22515. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22516. /**
  22517. * Clear the current material
  22518. */
  22519. clear(): void;
  22520. /**
  22521. * Clear the current material and set it to a default state
  22522. */
  22523. setToDefault(): void;
  22524. /**
  22525. * Clear the current material and set it to a default state for post process
  22526. */
  22527. setToDefaultPostProcess(): void;
  22528. /**
  22529. * Clear the current material and set it to a default state for particle
  22530. */
  22531. setToDefaultParticle(): void;
  22532. /**
  22533. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22534. * @param url defines the url to load from
  22535. * @returns a promise that will fullfil when the material is fully loaded
  22536. */
  22537. loadAsync(url: string): Promise<void>;
  22538. private _gatherBlocks;
  22539. /**
  22540. * Generate a string containing the code declaration required to create an equivalent of this material
  22541. * @returns a string
  22542. */
  22543. generateCode(): string;
  22544. /**
  22545. * Serializes this material in a JSON representation
  22546. * @returns the serialized material object
  22547. */
  22548. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22549. private _restoreConnections;
  22550. /**
  22551. * Clear the current graph and load a new one from a serialization object
  22552. * @param source defines the JSON representation of the material
  22553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22554. * @param merge defines whether or not the source must be merged or replace the current content
  22555. */
  22556. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22557. /**
  22558. * Makes a duplicate of the current material.
  22559. * @param name - name to use for the new material.
  22560. */
  22561. clone(name: string): NodeMaterial;
  22562. /**
  22563. * Creates a node material from parsed material data
  22564. * @param source defines the JSON representation of the material
  22565. * @param scene defines the hosting scene
  22566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22567. * @returns a new node material
  22568. */
  22569. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22570. /**
  22571. * Creates a node material from a snippet saved in a remote file
  22572. * @param name defines the name of the material to create
  22573. * @param url defines the url to load from
  22574. * @param scene defines the hosting scene
  22575. * @returns a promise that will resolve to the new node material
  22576. */
  22577. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22578. /**
  22579. * Creates a node material from a snippet saved by the node material editor
  22580. * @param snippetId defines the snippet to load
  22581. * @param scene defines the hosting scene
  22582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22583. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22584. * @returns a promise that will resolve to the new node material
  22585. */
  22586. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22587. /**
  22588. * Creates a new node material set to default basic configuration
  22589. * @param name defines the name of the material
  22590. * @param scene defines the hosting scene
  22591. * @returns a new NodeMaterial
  22592. */
  22593. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22594. }
  22595. }
  22596. declare module BABYLON {
  22597. /**
  22598. * Size options for a post process
  22599. */
  22600. export type PostProcessOptions = {
  22601. width: number;
  22602. height: number;
  22603. };
  22604. /**
  22605. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22606. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22607. */
  22608. export class PostProcess {
  22609. /**
  22610. * Gets or sets the unique id of the post process
  22611. */
  22612. uniqueId: number;
  22613. /** Name of the PostProcess. */
  22614. name: string;
  22615. /**
  22616. * Width of the texture to apply the post process on
  22617. */
  22618. width: number;
  22619. /**
  22620. * Height of the texture to apply the post process on
  22621. */
  22622. height: number;
  22623. /**
  22624. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22625. */
  22626. nodeMaterialSource: Nullable<NodeMaterial>;
  22627. /**
  22628. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22629. * @hidden
  22630. */
  22631. _outputTexture: Nullable<InternalTexture>;
  22632. /**
  22633. * Sampling mode used by the shader
  22634. * See https://doc.babylonjs.com/classes/3.1/texture
  22635. */
  22636. renderTargetSamplingMode: number;
  22637. /**
  22638. * Clear color to use when screen clearing
  22639. */
  22640. clearColor: Color4;
  22641. /**
  22642. * If the buffer needs to be cleared before applying the post process. (default: true)
  22643. * Should be set to false if shader will overwrite all previous pixels.
  22644. */
  22645. autoClear: boolean;
  22646. /**
  22647. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22648. */
  22649. alphaMode: number;
  22650. /**
  22651. * Sets the setAlphaBlendConstants of the babylon engine
  22652. */
  22653. alphaConstants: Color4;
  22654. /**
  22655. * Animations to be used for the post processing
  22656. */
  22657. animations: Animation[];
  22658. /**
  22659. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22660. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22661. */
  22662. enablePixelPerfectMode: boolean;
  22663. /**
  22664. * Force the postprocess to be applied without taking in account viewport
  22665. */
  22666. forceFullscreenViewport: boolean;
  22667. /**
  22668. * List of inspectable custom properties (used by the Inspector)
  22669. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22670. */
  22671. inspectableCustomProperties: IInspectable[];
  22672. /**
  22673. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22674. *
  22675. * | Value | Type | Description |
  22676. * | ----- | ----------------------------------- | ----------- |
  22677. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22678. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22679. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22680. *
  22681. */
  22682. scaleMode: number;
  22683. /**
  22684. * Force textures to be a power of two (default: false)
  22685. */
  22686. alwaysForcePOT: boolean;
  22687. private _samples;
  22688. /**
  22689. * Number of sample textures (default: 1)
  22690. */
  22691. get samples(): number;
  22692. set samples(n: number);
  22693. /**
  22694. * Modify the scale of the post process to be the same as the viewport (default: false)
  22695. */
  22696. adaptScaleToCurrentViewport: boolean;
  22697. private _camera;
  22698. protected _scene: Scene;
  22699. private _engine;
  22700. private _options;
  22701. private _reusable;
  22702. private _textureType;
  22703. private _textureFormat;
  22704. /**
  22705. * Smart array of input and output textures for the post process.
  22706. * @hidden
  22707. */
  22708. _textures: SmartArray<InternalTexture>;
  22709. /**
  22710. * The index in _textures that corresponds to the output texture.
  22711. * @hidden
  22712. */
  22713. _currentRenderTextureInd: number;
  22714. private _effect;
  22715. private _samplers;
  22716. private _fragmentUrl;
  22717. private _vertexUrl;
  22718. private _parameters;
  22719. private _scaleRatio;
  22720. protected _indexParameters: any;
  22721. private _shareOutputWithPostProcess;
  22722. private _texelSize;
  22723. private _forcedOutputTexture;
  22724. /**
  22725. * Returns the fragment url or shader name used in the post process.
  22726. * @returns the fragment url or name in the shader store.
  22727. */
  22728. getEffectName(): string;
  22729. /**
  22730. * An event triggered when the postprocess is activated.
  22731. */
  22732. onActivateObservable: Observable<Camera>;
  22733. private _onActivateObserver;
  22734. /**
  22735. * A function that is added to the onActivateObservable
  22736. */
  22737. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22738. /**
  22739. * An event triggered when the postprocess changes its size.
  22740. */
  22741. onSizeChangedObservable: Observable<PostProcess>;
  22742. private _onSizeChangedObserver;
  22743. /**
  22744. * A function that is added to the onSizeChangedObservable
  22745. */
  22746. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22747. /**
  22748. * An event triggered when the postprocess applies its effect.
  22749. */
  22750. onApplyObservable: Observable<Effect>;
  22751. private _onApplyObserver;
  22752. /**
  22753. * A function that is added to the onApplyObservable
  22754. */
  22755. set onApply(callback: (effect: Effect) => void);
  22756. /**
  22757. * An event triggered before rendering the postprocess
  22758. */
  22759. onBeforeRenderObservable: Observable<Effect>;
  22760. private _onBeforeRenderObserver;
  22761. /**
  22762. * A function that is added to the onBeforeRenderObservable
  22763. */
  22764. set onBeforeRender(callback: (effect: Effect) => void);
  22765. /**
  22766. * An event triggered after rendering the postprocess
  22767. */
  22768. onAfterRenderObservable: Observable<Effect>;
  22769. private _onAfterRenderObserver;
  22770. /**
  22771. * A function that is added to the onAfterRenderObservable
  22772. */
  22773. set onAfterRender(callback: (efect: Effect) => void);
  22774. /**
  22775. * 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
  22776. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22777. */
  22778. get inputTexture(): InternalTexture;
  22779. set inputTexture(value: InternalTexture);
  22780. /**
  22781. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22782. * the only way to unset it is to use this function to restore its internal state
  22783. */
  22784. restoreDefaultInputTexture(): void;
  22785. /**
  22786. * Gets the camera which post process is applied to.
  22787. * @returns The camera the post process is applied to.
  22788. */
  22789. getCamera(): Camera;
  22790. /**
  22791. * Gets the texel size of the postprocess.
  22792. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22793. */
  22794. get texelSize(): Vector2;
  22795. /**
  22796. * Creates a new instance PostProcess
  22797. * @param name The name of the PostProcess.
  22798. * @param fragmentUrl The url of the fragment shader to be used.
  22799. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22800. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22801. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22802. * @param camera The camera to apply the render pass to.
  22803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22804. * @param engine The engine which the post process will be applied. (default: current engine)
  22805. * @param reusable If the post process can be reused on the same frame. (default: false)
  22806. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22807. * @param textureType Type of textures used when performing the post process. (default: 0)
  22808. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22809. * @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
  22810. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22811. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22812. */
  22813. 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);
  22814. /**
  22815. * Gets a string identifying the name of the class
  22816. * @returns "PostProcess" string
  22817. */
  22818. getClassName(): string;
  22819. /**
  22820. * Gets the engine which this post process belongs to.
  22821. * @returns The engine the post process was enabled with.
  22822. */
  22823. getEngine(): Engine;
  22824. /**
  22825. * The effect that is created when initializing the post process.
  22826. * @returns The created effect corresponding the the postprocess.
  22827. */
  22828. getEffect(): Effect;
  22829. /**
  22830. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22831. * @param postProcess The post process to share the output with.
  22832. * @returns This post process.
  22833. */
  22834. shareOutputWith(postProcess: PostProcess): PostProcess;
  22835. /**
  22836. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22837. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22838. */
  22839. useOwnOutput(): void;
  22840. /**
  22841. * Updates the effect with the current post process compile time values and recompiles the shader.
  22842. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22843. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22844. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22845. * @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
  22846. * @param onCompiled Called when the shader has been compiled.
  22847. * @param onError Called if there is an error when compiling a shader.
  22848. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22849. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22850. */
  22851. 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;
  22852. /**
  22853. * The post process is reusable if it can be used multiple times within one frame.
  22854. * @returns If the post process is reusable
  22855. */
  22856. isReusable(): boolean;
  22857. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22858. markTextureDirty(): void;
  22859. /**
  22860. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22861. * 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.
  22862. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22863. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22864. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22865. * @returns The target texture that was bound to be written to.
  22866. */
  22867. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22868. /**
  22869. * If the post process is supported.
  22870. */
  22871. get isSupported(): boolean;
  22872. /**
  22873. * The aspect ratio of the output texture.
  22874. */
  22875. get aspectRatio(): number;
  22876. /**
  22877. * Get a value indicating if the post-process is ready to be used
  22878. * @returns true if the post-process is ready (shader is compiled)
  22879. */
  22880. isReady(): boolean;
  22881. /**
  22882. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22883. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22884. */
  22885. apply(): Nullable<Effect>;
  22886. private _disposeTextures;
  22887. /**
  22888. * Disposes the post process.
  22889. * @param camera The camera to dispose the post process on.
  22890. */
  22891. dispose(camera?: Camera): void;
  22892. /**
  22893. * Serializes the particle system to a JSON object
  22894. * @returns the JSON object
  22895. */
  22896. serialize(): any;
  22897. /**
  22898. * Creates a material from parsed material data
  22899. * @param parsedPostProcess defines parsed post process data
  22900. * @param scene defines the hosting scene
  22901. * @param rootUrl defines the root URL to use to load textures
  22902. * @returns a new post process
  22903. */
  22904. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22905. }
  22906. }
  22907. declare module BABYLON {
  22908. /** @hidden */
  22909. export var kernelBlurVaryingDeclaration: {
  22910. name: string;
  22911. shader: string;
  22912. };
  22913. }
  22914. declare module BABYLON {
  22915. /** @hidden */
  22916. export var kernelBlurFragment: {
  22917. name: string;
  22918. shader: string;
  22919. };
  22920. }
  22921. declare module BABYLON {
  22922. /** @hidden */
  22923. export var kernelBlurFragment2: {
  22924. name: string;
  22925. shader: string;
  22926. };
  22927. }
  22928. declare module BABYLON {
  22929. /** @hidden */
  22930. export var kernelBlurPixelShader: {
  22931. name: string;
  22932. shader: string;
  22933. };
  22934. }
  22935. declare module BABYLON {
  22936. /** @hidden */
  22937. export var kernelBlurVertex: {
  22938. name: string;
  22939. shader: string;
  22940. };
  22941. }
  22942. declare module BABYLON {
  22943. /** @hidden */
  22944. export var kernelBlurVertexShader: {
  22945. name: string;
  22946. shader: string;
  22947. };
  22948. }
  22949. declare module BABYLON {
  22950. /**
  22951. * The Blur Post Process which blurs an image based on a kernel and direction.
  22952. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22953. */
  22954. export class BlurPostProcess extends PostProcess {
  22955. private blockCompilation;
  22956. protected _kernel: number;
  22957. protected _idealKernel: number;
  22958. protected _packedFloat: boolean;
  22959. private _staticDefines;
  22960. /** The direction in which to blur the image. */
  22961. direction: Vector2;
  22962. /**
  22963. * Sets the length in pixels of the blur sample region
  22964. */
  22965. set kernel(v: number);
  22966. /**
  22967. * Gets the length in pixels of the blur sample region
  22968. */
  22969. get kernel(): number;
  22970. /**
  22971. * Sets wether or not the blur needs to unpack/repack floats
  22972. */
  22973. set packedFloat(v: boolean);
  22974. /**
  22975. * Gets wether or not the blur is unpacking/repacking floats
  22976. */
  22977. get packedFloat(): boolean;
  22978. /**
  22979. * Gets a string identifying the name of the class
  22980. * @returns "BlurPostProcess" string
  22981. */
  22982. getClassName(): string;
  22983. /**
  22984. * Creates a new instance BlurPostProcess
  22985. * @param name The name of the effect.
  22986. * @param direction The direction in which to blur the image.
  22987. * @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.
  22988. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22989. * @param camera The camera to apply the render pass to.
  22990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22991. * @param engine The engine which the post process will be applied. (default: current engine)
  22992. * @param reusable If the post process can be reused on the same frame. (default: false)
  22993. * @param textureType Type of textures used when performing the post process. (default: 0)
  22994. * @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)
  22995. */
  22996. 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);
  22997. /**
  22998. * Updates the effect with the current post process compile time values and recompiles the shader.
  22999. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23000. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23001. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23002. * @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
  23003. * @param onCompiled Called when the shader has been compiled.
  23004. * @param onError Called if there is an error when compiling a shader.
  23005. */
  23006. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23007. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23008. /**
  23009. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23010. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23011. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23012. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23013. * The gaps between physical kernels are compensated for in the weighting of the samples
  23014. * @param idealKernel Ideal blur kernel.
  23015. * @return Nearest best kernel.
  23016. */
  23017. protected _nearestBestKernel(idealKernel: number): number;
  23018. /**
  23019. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23020. * @param x The point on the Gaussian distribution to sample.
  23021. * @return the value of the Gaussian function at x.
  23022. */
  23023. protected _gaussianWeight(x: number): number;
  23024. /**
  23025. * Generates a string that can be used as a floating point number in GLSL.
  23026. * @param x Value to print.
  23027. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23028. * @return GLSL float string.
  23029. */
  23030. protected _glslFloat(x: number, decimalFigures?: number): string;
  23031. /** @hidden */
  23032. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23033. }
  23034. }
  23035. declare module BABYLON {
  23036. /**
  23037. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23038. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23039. * You can then easily use it as a reflectionTexture on a flat surface.
  23040. * In case the surface is not a plane, please consider relying on reflection probes.
  23041. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23042. */
  23043. export class MirrorTexture extends RenderTargetTexture {
  23044. private scene;
  23045. /**
  23046. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23047. * 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.
  23048. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23049. */
  23050. mirrorPlane: Plane;
  23051. /**
  23052. * Define the blur ratio used to blur the reflection if needed.
  23053. */
  23054. set blurRatio(value: number);
  23055. get blurRatio(): number;
  23056. /**
  23057. * Define the adaptive blur kernel used to blur the reflection if needed.
  23058. * This will autocompute the closest best match for the `blurKernel`
  23059. */
  23060. set adaptiveBlurKernel(value: number);
  23061. /**
  23062. * Define the blur kernel used to blur the reflection if needed.
  23063. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23064. */
  23065. set blurKernel(value: number);
  23066. /**
  23067. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23069. */
  23070. set blurKernelX(value: number);
  23071. get blurKernelX(): number;
  23072. /**
  23073. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23074. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23075. */
  23076. set blurKernelY(value: number);
  23077. get blurKernelY(): number;
  23078. private _autoComputeBlurKernel;
  23079. protected _onRatioRescale(): void;
  23080. private _updateGammaSpace;
  23081. private _imageProcessingConfigChangeObserver;
  23082. private _transformMatrix;
  23083. private _mirrorMatrix;
  23084. private _savedViewMatrix;
  23085. private _blurX;
  23086. private _blurY;
  23087. private _adaptiveBlurKernel;
  23088. private _blurKernelX;
  23089. private _blurKernelY;
  23090. private _blurRatio;
  23091. /**
  23092. * Instantiates a Mirror Texture.
  23093. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23094. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23095. * You can then easily use it as a reflectionTexture on a flat surface.
  23096. * In case the surface is not a plane, please consider relying on reflection probes.
  23097. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23098. * @param name
  23099. * @param size
  23100. * @param scene
  23101. * @param generateMipMaps
  23102. * @param type
  23103. * @param samplingMode
  23104. * @param generateDepthBuffer
  23105. */
  23106. constructor(name: string, size: number | {
  23107. width: number;
  23108. height: number;
  23109. } | {
  23110. ratio: number;
  23111. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23112. private _preparePostProcesses;
  23113. /**
  23114. * Clone the mirror texture.
  23115. * @returns the cloned texture
  23116. */
  23117. clone(): MirrorTexture;
  23118. /**
  23119. * Serialize the texture to a JSON representation you could use in Parse later on
  23120. * @returns the serialized JSON representation
  23121. */
  23122. serialize(): any;
  23123. /**
  23124. * Dispose the texture and release its associated resources.
  23125. */
  23126. dispose(): void;
  23127. }
  23128. }
  23129. declare module BABYLON {
  23130. /**
  23131. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23132. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23133. */
  23134. export class Texture extends BaseTexture {
  23135. /**
  23136. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23137. */
  23138. static SerializeBuffers: boolean;
  23139. /** @hidden */
  23140. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23141. /** @hidden */
  23142. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23143. /** @hidden */
  23144. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23145. /** nearest is mag = nearest and min = nearest and mip = linear */
  23146. static readonly NEAREST_SAMPLINGMODE: number;
  23147. /** nearest is mag = nearest and min = nearest and mip = linear */
  23148. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23149. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23150. static readonly BILINEAR_SAMPLINGMODE: number;
  23151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23152. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23153. /** Trilinear is mag = linear and min = linear and mip = linear */
  23154. static readonly TRILINEAR_SAMPLINGMODE: number;
  23155. /** Trilinear is mag = linear and min = linear and mip = linear */
  23156. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23157. /** mag = nearest and min = nearest and mip = nearest */
  23158. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23159. /** mag = nearest and min = linear and mip = nearest */
  23160. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23161. /** mag = nearest and min = linear and mip = linear */
  23162. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23163. /** mag = nearest and min = linear and mip = none */
  23164. static readonly NEAREST_LINEAR: number;
  23165. /** mag = nearest and min = nearest and mip = none */
  23166. static readonly NEAREST_NEAREST: number;
  23167. /** mag = linear and min = nearest and mip = nearest */
  23168. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23169. /** mag = linear and min = nearest and mip = linear */
  23170. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23171. /** mag = linear and min = linear and mip = none */
  23172. static readonly LINEAR_LINEAR: number;
  23173. /** mag = linear and min = nearest and mip = none */
  23174. static readonly LINEAR_NEAREST: number;
  23175. /** Explicit coordinates mode */
  23176. static readonly EXPLICIT_MODE: number;
  23177. /** Spherical coordinates mode */
  23178. static readonly SPHERICAL_MODE: number;
  23179. /** Planar coordinates mode */
  23180. static readonly PLANAR_MODE: number;
  23181. /** Cubic coordinates mode */
  23182. static readonly CUBIC_MODE: number;
  23183. /** Projection coordinates mode */
  23184. static readonly PROJECTION_MODE: number;
  23185. /** Inverse Cubic coordinates mode */
  23186. static readonly SKYBOX_MODE: number;
  23187. /** Inverse Cubic coordinates mode */
  23188. static readonly INVCUBIC_MODE: number;
  23189. /** Equirectangular coordinates mode */
  23190. static readonly EQUIRECTANGULAR_MODE: number;
  23191. /** Equirectangular Fixed coordinates mode */
  23192. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23193. /** Equirectangular Fixed Mirrored coordinates mode */
  23194. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23195. /** Texture is not repeating outside of 0..1 UVs */
  23196. static readonly CLAMP_ADDRESSMODE: number;
  23197. /** Texture is repeating outside of 0..1 UVs */
  23198. static readonly WRAP_ADDRESSMODE: number;
  23199. /** Texture is repeating and mirrored */
  23200. static readonly MIRROR_ADDRESSMODE: number;
  23201. /**
  23202. * 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
  23203. */
  23204. static UseSerializedUrlIfAny: boolean;
  23205. /**
  23206. * Define the url of the texture.
  23207. */
  23208. url: Nullable<string>;
  23209. /**
  23210. * Define an offset on the texture to offset the u coordinates of the UVs
  23211. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23212. */
  23213. uOffset: number;
  23214. /**
  23215. * Define an offset on the texture to offset the v coordinates of the UVs
  23216. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23217. */
  23218. vOffset: number;
  23219. /**
  23220. * Define an offset on the texture to scale the u coordinates of the UVs
  23221. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23222. */
  23223. uScale: number;
  23224. /**
  23225. * Define an offset on the texture to scale the v coordinates of the UVs
  23226. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23227. */
  23228. vScale: number;
  23229. /**
  23230. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23231. * @see https://doc.babylonjs.com/how_to/more_materials
  23232. */
  23233. uAng: number;
  23234. /**
  23235. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23236. * @see https://doc.babylonjs.com/how_to/more_materials
  23237. */
  23238. vAng: number;
  23239. /**
  23240. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23241. * @see https://doc.babylonjs.com/how_to/more_materials
  23242. */
  23243. wAng: number;
  23244. /**
  23245. * Defines the center of rotation (U)
  23246. */
  23247. uRotationCenter: number;
  23248. /**
  23249. * Defines the center of rotation (V)
  23250. */
  23251. vRotationCenter: number;
  23252. /**
  23253. * Defines the center of rotation (W)
  23254. */
  23255. wRotationCenter: number;
  23256. /**
  23257. * Are mip maps generated for this texture or not.
  23258. */
  23259. get noMipmap(): boolean;
  23260. /**
  23261. * List of inspectable custom properties (used by the Inspector)
  23262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23263. */
  23264. inspectableCustomProperties: Nullable<IInspectable[]>;
  23265. private _noMipmap;
  23266. /** @hidden */
  23267. _invertY: boolean;
  23268. private _rowGenerationMatrix;
  23269. private _cachedTextureMatrix;
  23270. private _projectionModeMatrix;
  23271. private _t0;
  23272. private _t1;
  23273. private _t2;
  23274. private _cachedUOffset;
  23275. private _cachedVOffset;
  23276. private _cachedUScale;
  23277. private _cachedVScale;
  23278. private _cachedUAng;
  23279. private _cachedVAng;
  23280. private _cachedWAng;
  23281. private _cachedProjectionMatrixId;
  23282. private _cachedCoordinatesMode;
  23283. /** @hidden */
  23284. protected _initialSamplingMode: number;
  23285. /** @hidden */
  23286. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23287. private _deleteBuffer;
  23288. protected _format: Nullable<number>;
  23289. private _delayedOnLoad;
  23290. private _delayedOnError;
  23291. private _mimeType?;
  23292. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23293. get mimeType(): string | undefined;
  23294. /**
  23295. * Observable triggered once the texture has been loaded.
  23296. */
  23297. onLoadObservable: Observable<Texture>;
  23298. protected _isBlocking: boolean;
  23299. /**
  23300. * Is the texture preventing material to render while loading.
  23301. * If false, a default texture will be used instead of the loading one during the preparation step.
  23302. */
  23303. set isBlocking(value: boolean);
  23304. get isBlocking(): boolean;
  23305. /**
  23306. * Get the current sampling mode associated with the texture.
  23307. */
  23308. get samplingMode(): number;
  23309. /**
  23310. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23311. */
  23312. get invertY(): boolean;
  23313. /**
  23314. * Instantiates a new texture.
  23315. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23316. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23317. * @param url defines the url of the picture to load as a texture
  23318. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23319. * @param noMipmap defines if the texture will require mip maps or not
  23320. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23321. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23322. * @param onLoad defines a callback triggered when the texture has been loaded
  23323. * @param onError defines a callback triggered when an error occurred during the loading session
  23324. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23325. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23326. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23327. * @param mimeType defines an optional mime type information
  23328. */
  23329. 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);
  23330. /**
  23331. * Update the url (and optional buffer) of this texture if url was null during construction.
  23332. * @param url the url of the texture
  23333. * @param buffer the buffer of the texture (defaults to null)
  23334. * @param onLoad callback called when the texture is loaded (defaults to null)
  23335. */
  23336. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23337. /**
  23338. * Finish the loading sequence of a texture flagged as delayed load.
  23339. * @hidden
  23340. */
  23341. delayLoad(): void;
  23342. private _prepareRowForTextureGeneration;
  23343. /**
  23344. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23345. * @returns the transform matrix of the texture.
  23346. */
  23347. getTextureMatrix(uBase?: number): Matrix;
  23348. /**
  23349. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23350. * @returns The reflection texture transform
  23351. */
  23352. getReflectionTextureMatrix(): Matrix;
  23353. /**
  23354. * Clones the texture.
  23355. * @returns the cloned texture
  23356. */
  23357. clone(): Texture;
  23358. /**
  23359. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23360. * @returns The JSON representation of the texture
  23361. */
  23362. serialize(): any;
  23363. /**
  23364. * Get the current class name of the texture useful for serialization or dynamic coding.
  23365. * @returns "Texture"
  23366. */
  23367. getClassName(): string;
  23368. /**
  23369. * Dispose the texture and release its associated resources.
  23370. */
  23371. dispose(): void;
  23372. /**
  23373. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23374. * @param parsedTexture Define the JSON representation of the texture
  23375. * @param scene Define the scene the parsed texture should be instantiated in
  23376. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23377. * @returns The parsed texture if successful
  23378. */
  23379. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23380. /**
  23381. * Creates a texture from its base 64 representation.
  23382. * @param data Define the base64 payload without the data: prefix
  23383. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23384. * @param scene Define the scene the texture should belong to
  23385. * @param noMipmap Forces the texture to not create mip map information if true
  23386. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23387. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23388. * @param onLoad define a callback triggered when the texture has been loaded
  23389. * @param onError define a callback triggered when an error occurred during the loading session
  23390. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23391. * @returns the created texture
  23392. */
  23393. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23394. /**
  23395. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23396. * @param data Define the base64 payload without the data: prefix
  23397. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23398. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23399. * @param scene Define the scene the texture should belong to
  23400. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23401. * @param noMipmap Forces the texture to not create mip map information if true
  23402. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23403. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23404. * @param onLoad define a callback triggered when the texture has been loaded
  23405. * @param onError define a callback triggered when an error occurred during the loading session
  23406. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23407. * @returns the created texture
  23408. */
  23409. 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;
  23410. }
  23411. }
  23412. declare module BABYLON {
  23413. /**
  23414. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23415. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23416. */
  23417. export class PostProcessManager {
  23418. private _scene;
  23419. private _indexBuffer;
  23420. private _vertexBuffers;
  23421. /**
  23422. * Creates a new instance PostProcess
  23423. * @param scene The scene that the post process is associated with.
  23424. */
  23425. constructor(scene: Scene);
  23426. private _prepareBuffers;
  23427. private _buildIndexBuffer;
  23428. /**
  23429. * Rebuilds the vertex buffers of the manager.
  23430. * @hidden
  23431. */
  23432. _rebuild(): void;
  23433. /**
  23434. * Prepares a frame to be run through a post process.
  23435. * @param sourceTexture The input texture to the post procesess. (default: null)
  23436. * @param postProcesses An array of post processes to be run. (default: null)
  23437. * @returns True if the post processes were able to be run.
  23438. * @hidden
  23439. */
  23440. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23441. /**
  23442. * Manually render a set of post processes to a texture.
  23443. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23444. * @param postProcesses An array of post processes to be run.
  23445. * @param targetTexture The target texture to render to.
  23446. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23447. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23448. * @param lodLevel defines which lod of the texture to render to
  23449. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23450. */
  23451. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23452. /**
  23453. * Finalize the result of the output of the postprocesses.
  23454. * @param doNotPresent If true the result will not be displayed to the screen.
  23455. * @param targetTexture The target texture to render to.
  23456. * @param faceIndex The index of the face to bind the target texture to.
  23457. * @param postProcesses The array of post processes to render.
  23458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23459. * @hidden
  23460. */
  23461. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23462. /**
  23463. * Disposes of the post process manager.
  23464. */
  23465. dispose(): void;
  23466. }
  23467. }
  23468. declare module BABYLON {
  23469. /**
  23470. * This Helps creating a texture that will be created from a camera in your scene.
  23471. * It is basically a dynamic texture that could be used to create special effects for instance.
  23472. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23473. */
  23474. export class RenderTargetTexture extends Texture {
  23475. /**
  23476. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23477. */
  23478. static readonly REFRESHRATE_RENDER_ONCE: number;
  23479. /**
  23480. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23481. */
  23482. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23483. /**
  23484. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23485. * the central point of your effect and can save a lot of performances.
  23486. */
  23487. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23488. /**
  23489. * Use this predicate to dynamically define the list of mesh you want to render.
  23490. * If set, the renderList property will be overwritten.
  23491. */
  23492. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23493. private _renderList;
  23494. /**
  23495. * Use this list to define the list of mesh you want to render.
  23496. */
  23497. get renderList(): Nullable<Array<AbstractMesh>>;
  23498. set renderList(value: Nullable<Array<AbstractMesh>>);
  23499. /**
  23500. * Use this function to overload the renderList array at rendering time.
  23501. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23502. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23503. * the cube (if the RTT is a cube, else layerOrFace=0).
  23504. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23505. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23506. * hold dummy elements!
  23507. */
  23508. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23509. private _hookArray;
  23510. /**
  23511. * Define if particles should be rendered in your texture.
  23512. */
  23513. renderParticles: boolean;
  23514. /**
  23515. * Define if sprites should be rendered in your texture.
  23516. */
  23517. renderSprites: boolean;
  23518. /**
  23519. * Define the camera used to render the texture.
  23520. */
  23521. activeCamera: Nullable<Camera>;
  23522. /**
  23523. * Override the mesh isReady function with your own one.
  23524. */
  23525. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23526. /**
  23527. * Override the render function of the texture with your own one.
  23528. */
  23529. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23530. /**
  23531. * Define if camera post processes should be use while rendering the texture.
  23532. */
  23533. useCameraPostProcesses: boolean;
  23534. /**
  23535. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23536. */
  23537. ignoreCameraViewport: boolean;
  23538. private _postProcessManager;
  23539. private _postProcesses;
  23540. private _resizeObserver;
  23541. /**
  23542. * An event triggered when the texture is unbind.
  23543. */
  23544. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23545. /**
  23546. * An event triggered when the texture is unbind.
  23547. */
  23548. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23549. private _onAfterUnbindObserver;
  23550. /**
  23551. * Set a after unbind callback in the texture.
  23552. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23553. */
  23554. set onAfterUnbind(callback: () => void);
  23555. /**
  23556. * An event triggered before rendering the texture
  23557. */
  23558. onBeforeRenderObservable: Observable<number>;
  23559. private _onBeforeRenderObserver;
  23560. /**
  23561. * Set a before render callback in the texture.
  23562. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23563. */
  23564. set onBeforeRender(callback: (faceIndex: number) => void);
  23565. /**
  23566. * An event triggered after rendering the texture
  23567. */
  23568. onAfterRenderObservable: Observable<number>;
  23569. private _onAfterRenderObserver;
  23570. /**
  23571. * Set a after render callback in the texture.
  23572. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23573. */
  23574. set onAfterRender(callback: (faceIndex: number) => void);
  23575. /**
  23576. * An event triggered after the texture clear
  23577. */
  23578. onClearObservable: Observable<Engine>;
  23579. private _onClearObserver;
  23580. /**
  23581. * Set a clear callback in the texture.
  23582. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23583. */
  23584. set onClear(callback: (Engine: Engine) => void);
  23585. /**
  23586. * An event triggered when the texture is resized.
  23587. */
  23588. onResizeObservable: Observable<RenderTargetTexture>;
  23589. /**
  23590. * Define the clear color of the Render Target if it should be different from the scene.
  23591. */
  23592. clearColor: Color4;
  23593. protected _size: number | {
  23594. width: number;
  23595. height: number;
  23596. layers?: number;
  23597. };
  23598. protected _initialSizeParameter: number | {
  23599. width: number;
  23600. height: number;
  23601. } | {
  23602. ratio: number;
  23603. };
  23604. protected _sizeRatio: Nullable<number>;
  23605. /** @hidden */
  23606. _generateMipMaps: boolean;
  23607. protected _renderingManager: RenderingManager;
  23608. /** @hidden */
  23609. _waitingRenderList?: string[];
  23610. protected _doNotChangeAspectRatio: boolean;
  23611. protected _currentRefreshId: number;
  23612. protected _refreshRate: number;
  23613. protected _textureMatrix: Matrix;
  23614. protected _samples: number;
  23615. protected _renderTargetOptions: RenderTargetCreationOptions;
  23616. /**
  23617. * Gets render target creation options that were used.
  23618. */
  23619. get renderTargetOptions(): RenderTargetCreationOptions;
  23620. protected _onRatioRescale(): void;
  23621. /**
  23622. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23623. * It must define where the camera used to render the texture is set
  23624. */
  23625. boundingBoxPosition: Vector3;
  23626. private _boundingBoxSize;
  23627. /**
  23628. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23629. * When defined, the cubemap will switch to local mode
  23630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23631. * @example https://www.babylonjs-playground.com/#RNASML
  23632. */
  23633. set boundingBoxSize(value: Vector3);
  23634. get boundingBoxSize(): Vector3;
  23635. /**
  23636. * In case the RTT has been created with a depth texture, get the associated
  23637. * depth texture.
  23638. * Otherwise, return null.
  23639. */
  23640. get depthStencilTexture(): Nullable<InternalTexture>;
  23641. /**
  23642. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23643. * or used a shadow, depth texture...
  23644. * @param name The friendly name of the texture
  23645. * @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)
  23646. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23647. * @param generateMipMaps True if mip maps need to be generated after render.
  23648. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23649. * @param type The type of the buffer in the RTT (int, half float, float...)
  23650. * @param isCube True if a cube texture needs to be created
  23651. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23652. * @param generateDepthBuffer True to generate a depth buffer
  23653. * @param generateStencilBuffer True to generate a stencil buffer
  23654. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23655. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23656. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23657. */
  23658. constructor(name: string, size: number | {
  23659. width: number;
  23660. height: number;
  23661. layers?: number;
  23662. } | {
  23663. ratio: number;
  23664. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23665. /**
  23666. * Creates a depth stencil texture.
  23667. * This is only available in WebGL 2 or with the depth texture extension available.
  23668. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23669. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23670. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23671. */
  23672. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23673. private _processSizeParameter;
  23674. /**
  23675. * Define the number of samples to use in case of MSAA.
  23676. * It defaults to one meaning no MSAA has been enabled.
  23677. */
  23678. get samples(): number;
  23679. set samples(value: number);
  23680. /**
  23681. * Resets the refresh counter of the texture and start bak from scratch.
  23682. * Could be useful to regenerate the texture if it is setup to render only once.
  23683. */
  23684. resetRefreshCounter(): void;
  23685. /**
  23686. * Define the refresh rate of the texture or the rendering frequency.
  23687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23688. */
  23689. get refreshRate(): number;
  23690. set refreshRate(value: number);
  23691. /**
  23692. * Adds a post process to the render target rendering passes.
  23693. * @param postProcess define the post process to add
  23694. */
  23695. addPostProcess(postProcess: PostProcess): void;
  23696. /**
  23697. * Clear all the post processes attached to the render target
  23698. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23699. */
  23700. clearPostProcesses(dispose?: boolean): void;
  23701. /**
  23702. * Remove one of the post process from the list of attached post processes to the texture
  23703. * @param postProcess define the post process to remove from the list
  23704. */
  23705. removePostProcess(postProcess: PostProcess): void;
  23706. /** @hidden */
  23707. _shouldRender(): boolean;
  23708. /**
  23709. * Gets the actual render size of the texture.
  23710. * @returns the width of the render size
  23711. */
  23712. getRenderSize(): number;
  23713. /**
  23714. * Gets the actual render width of the texture.
  23715. * @returns the width of the render size
  23716. */
  23717. getRenderWidth(): number;
  23718. /**
  23719. * Gets the actual render height of the texture.
  23720. * @returns the height of the render size
  23721. */
  23722. getRenderHeight(): number;
  23723. /**
  23724. * Gets the actual number of layers of the texture.
  23725. * @returns the number of layers
  23726. */
  23727. getRenderLayers(): number;
  23728. /**
  23729. * Get if the texture can be rescaled or not.
  23730. */
  23731. get canRescale(): boolean;
  23732. /**
  23733. * Resize the texture using a ratio.
  23734. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23735. */
  23736. scale(ratio: number): void;
  23737. /**
  23738. * Get the texture reflection matrix used to rotate/transform the reflection.
  23739. * @returns the reflection matrix
  23740. */
  23741. getReflectionTextureMatrix(): Matrix;
  23742. /**
  23743. * Resize the texture to a new desired size.
  23744. * Be carrefull as it will recreate all the data in the new texture.
  23745. * @param size Define the new size. It can be:
  23746. * - a number for squared texture,
  23747. * - an object containing { width: number, height: number }
  23748. * - or an object containing a ratio { ratio: number }
  23749. */
  23750. resize(size: number | {
  23751. width: number;
  23752. height: number;
  23753. } | {
  23754. ratio: number;
  23755. }): void;
  23756. private _defaultRenderListPrepared;
  23757. /**
  23758. * Renders all the objects from the render list into the texture.
  23759. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23760. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23761. */
  23762. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23763. private _bestReflectionRenderTargetDimension;
  23764. private _prepareRenderingManager;
  23765. /**
  23766. * @hidden
  23767. * @param faceIndex face index to bind to if this is a cubetexture
  23768. * @param layer defines the index of the texture to bind in the array
  23769. */
  23770. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23772. private renderToTarget;
  23773. /**
  23774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23775. * This allowed control for front to back rendering or reversly depending of the special needs.
  23776. *
  23777. * @param renderingGroupId The rendering group id corresponding to its index
  23778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23781. */
  23782. 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;
  23783. /**
  23784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23785. *
  23786. * @param renderingGroupId The rendering group id corresponding to its index
  23787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23788. */
  23789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23790. /**
  23791. * Clones the texture.
  23792. * @returns the cloned texture
  23793. */
  23794. clone(): RenderTargetTexture;
  23795. /**
  23796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23797. * @returns The JSON representation of the texture
  23798. */
  23799. serialize(): any;
  23800. /**
  23801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23802. */
  23803. disposeFramebufferObjects(): void;
  23804. /**
  23805. * Dispose the texture and release its associated resources.
  23806. */
  23807. dispose(): void;
  23808. /** @hidden */
  23809. _rebuild(): void;
  23810. /**
  23811. * Clear the info related to rendering groups preventing retention point in material dispose.
  23812. */
  23813. freeRenderingGroups(): void;
  23814. /**
  23815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23816. * @returns the view count
  23817. */
  23818. getViewCount(): number;
  23819. }
  23820. }
  23821. declare module BABYLON {
  23822. /**
  23823. * Class used to manipulate GUIDs
  23824. */
  23825. export class GUID {
  23826. /**
  23827. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23828. * Be aware Math.random() could cause collisions, but:
  23829. * "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"
  23830. * @returns a pseudo random id
  23831. */
  23832. static RandomId(): string;
  23833. }
  23834. }
  23835. declare module BABYLON {
  23836. /**
  23837. * Options to be used when creating a shadow depth material
  23838. */
  23839. export interface IIOptionShadowDepthMaterial {
  23840. /** Variables in the vertex shader code that need to have their names remapped.
  23841. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23842. * "var_name" should be either: worldPos or vNormalW
  23843. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23844. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23845. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23846. */
  23847. remappedVariables?: string[];
  23848. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23849. standalone?: boolean;
  23850. }
  23851. /**
  23852. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23853. */
  23854. export class ShadowDepthWrapper {
  23855. private _scene;
  23856. private _options?;
  23857. private _baseMaterial;
  23858. private _onEffectCreatedObserver;
  23859. private _subMeshToEffect;
  23860. private _subMeshToDepthEffect;
  23861. private _meshes;
  23862. /** @hidden */
  23863. _matriceNames: any;
  23864. /** Gets the standalone status of the wrapper */
  23865. get standalone(): boolean;
  23866. /** Gets the base material the wrapper is built upon */
  23867. get baseMaterial(): Material;
  23868. /**
  23869. * Instantiate a new shadow depth wrapper.
  23870. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23871. * generate the shadow depth map. For more information, please refer to the documentation:
  23872. * https://doc.babylonjs.com/babylon101/shadows
  23873. * @param baseMaterial Material to wrap
  23874. * @param scene Define the scene the material belongs to
  23875. * @param options Options used to create the wrapper
  23876. */
  23877. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23878. /**
  23879. * Gets the effect to use to generate the depth map
  23880. * @param subMesh subMesh to get the effect for
  23881. * @param shadowGenerator shadow generator to get the effect for
  23882. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23883. */
  23884. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23885. /**
  23886. * Specifies that the submesh is ready to be used for depth rendering
  23887. * @param subMesh submesh to check
  23888. * @param defines the list of defines to take into account when checking the effect
  23889. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23890. * @param useInstances specifies that instances should be used
  23891. * @returns a boolean indicating that the submesh is ready or not
  23892. */
  23893. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23894. /**
  23895. * Disposes the resources
  23896. */
  23897. dispose(): void;
  23898. private _makeEffect;
  23899. }
  23900. }
  23901. declare module BABYLON {
  23902. interface ThinEngine {
  23903. /**
  23904. * Unbind a list of render target textures from the webGL context
  23905. * This is used only when drawBuffer extension or webGL2 are active
  23906. * @param textures defines the render target textures to unbind
  23907. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23908. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23909. */
  23910. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23911. /**
  23912. * Create a multi render target texture
  23913. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23914. * @param size defines the size of the texture
  23915. * @param options defines the creation options
  23916. * @returns the cube texture as an InternalTexture
  23917. */
  23918. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23919. /**
  23920. * Update the sample count for a given multiple render target texture
  23921. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23922. * @param textures defines the textures to update
  23923. * @param samples defines the sample count to set
  23924. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23925. */
  23926. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23927. /**
  23928. * Select a subsets of attachments to draw to.
  23929. * @param attachments gl attachments
  23930. */
  23931. bindAttachments(attachments: number[]): void;
  23932. }
  23933. }
  23934. declare module BABYLON {
  23935. /**
  23936. * Creation options of the multi render target texture.
  23937. */
  23938. export interface IMultiRenderTargetOptions {
  23939. /**
  23940. * Define if the texture needs to create mip maps after render.
  23941. */
  23942. generateMipMaps?: boolean;
  23943. /**
  23944. * Define the types of all the draw buffers we want to create
  23945. */
  23946. types?: number[];
  23947. /**
  23948. * Define the sampling modes of all the draw buffers we want to create
  23949. */
  23950. samplingModes?: number[];
  23951. /**
  23952. * Define if a depth buffer is required
  23953. */
  23954. generateDepthBuffer?: boolean;
  23955. /**
  23956. * Define if a stencil buffer is required
  23957. */
  23958. generateStencilBuffer?: boolean;
  23959. /**
  23960. * Define if a depth texture is required instead of a depth buffer
  23961. */
  23962. generateDepthTexture?: boolean;
  23963. /**
  23964. * Define the number of desired draw buffers
  23965. */
  23966. textureCount?: number;
  23967. /**
  23968. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23969. */
  23970. doNotChangeAspectRatio?: boolean;
  23971. /**
  23972. * Define the default type of the buffers we are creating
  23973. */
  23974. defaultType?: number;
  23975. }
  23976. /**
  23977. * A multi render target, like a render target provides the ability to render to a texture.
  23978. * Unlike the render target, it can render to several draw buffers in one draw.
  23979. * This is specially interesting in deferred rendering or for any effects requiring more than
  23980. * just one color from a single pass.
  23981. */
  23982. export class MultiRenderTarget extends RenderTargetTexture {
  23983. private _internalTextures;
  23984. private _textures;
  23985. private _multiRenderTargetOptions;
  23986. private _count;
  23987. /**
  23988. * Get if draw buffers are currently supported by the used hardware and browser.
  23989. */
  23990. get isSupported(): boolean;
  23991. /**
  23992. * Get the list of textures generated by the multi render target.
  23993. */
  23994. get textures(): Texture[];
  23995. /**
  23996. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23997. */
  23998. get count(): number;
  23999. /**
  24000. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24001. */
  24002. get depthTexture(): Texture;
  24003. /**
  24004. * Set the wrapping mode on U of all the textures we are rendering to.
  24005. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24006. */
  24007. set wrapU(wrap: number);
  24008. /**
  24009. * Set the wrapping mode on V of all the textures we are rendering to.
  24010. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24011. */
  24012. set wrapV(wrap: number);
  24013. /**
  24014. * Instantiate a new multi render target texture.
  24015. * A multi render target, like a render target provides the ability to render to a texture.
  24016. * Unlike the render target, it can render to several draw buffers in one draw.
  24017. * This is specially interesting in deferred rendering or for any effects requiring more than
  24018. * just one color from a single pass.
  24019. * @param name Define the name of the texture
  24020. * @param size Define the size of the buffers to render to
  24021. * @param count Define the number of target we are rendering into
  24022. * @param scene Define the scene the texture belongs to
  24023. * @param options Define the options used to create the multi render target
  24024. */
  24025. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24026. /** @hidden */
  24027. _rebuild(): void;
  24028. private _createInternalTextures;
  24029. private _createTextures;
  24030. /**
  24031. * Define the number of samples used if MSAA is enabled.
  24032. */
  24033. get samples(): number;
  24034. set samples(value: number);
  24035. /**
  24036. * Resize all the textures in the multi render target.
  24037. * Be carrefull as it will recreate all the data in the new texture.
  24038. * @param size Define the new size
  24039. */
  24040. resize(size: any): void;
  24041. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24042. /**
  24043. * Dispose the render targets and their associated resources
  24044. */
  24045. dispose(): void;
  24046. /**
  24047. * Release all the underlying texture used as draw buffers.
  24048. */
  24049. releaseInternalTextures(): void;
  24050. }
  24051. }
  24052. declare module BABYLON {
  24053. /** @hidden */
  24054. export var imageProcessingPixelShader: {
  24055. name: string;
  24056. shader: string;
  24057. };
  24058. }
  24059. declare module BABYLON {
  24060. /**
  24061. * ImageProcessingPostProcess
  24062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24063. */
  24064. export class ImageProcessingPostProcess extends PostProcess {
  24065. /**
  24066. * Default configuration related to image processing available in the PBR Material.
  24067. */
  24068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24069. /**
  24070. * Gets the image processing configuration used either in this material.
  24071. */
  24072. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24073. /**
  24074. * Sets the Default image processing configuration used either in the this material.
  24075. *
  24076. * If sets to null, the scene one is in use.
  24077. */
  24078. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24079. /**
  24080. * Keep track of the image processing observer to allow dispose and replace.
  24081. */
  24082. private _imageProcessingObserver;
  24083. /**
  24084. * Attaches a new image processing configuration to the PBR Material.
  24085. * @param configuration
  24086. */
  24087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24088. /**
  24089. * If the post process is supported.
  24090. */
  24091. get isSupported(): boolean;
  24092. /**
  24093. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24094. */
  24095. get colorCurves(): Nullable<ColorCurves>;
  24096. /**
  24097. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24098. */
  24099. set colorCurves(value: Nullable<ColorCurves>);
  24100. /**
  24101. * Gets wether the color curves effect is enabled.
  24102. */
  24103. get colorCurvesEnabled(): boolean;
  24104. /**
  24105. * Sets wether the color curves effect is enabled.
  24106. */
  24107. set colorCurvesEnabled(value: boolean);
  24108. /**
  24109. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24110. */
  24111. get colorGradingTexture(): Nullable<BaseTexture>;
  24112. /**
  24113. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24114. */
  24115. set colorGradingTexture(value: Nullable<BaseTexture>);
  24116. /**
  24117. * Gets wether the color grading effect is enabled.
  24118. */
  24119. get colorGradingEnabled(): boolean;
  24120. /**
  24121. * Gets wether the color grading effect is enabled.
  24122. */
  24123. set colorGradingEnabled(value: boolean);
  24124. /**
  24125. * Gets exposure used in the effect.
  24126. */
  24127. get exposure(): number;
  24128. /**
  24129. * Sets exposure used in the effect.
  24130. */
  24131. set exposure(value: number);
  24132. /**
  24133. * Gets wether tonemapping is enabled or not.
  24134. */
  24135. get toneMappingEnabled(): boolean;
  24136. /**
  24137. * Sets wether tonemapping is enabled or not
  24138. */
  24139. set toneMappingEnabled(value: boolean);
  24140. /**
  24141. * Gets the type of tone mapping effect.
  24142. */
  24143. get toneMappingType(): number;
  24144. /**
  24145. * Sets the type of tone mapping effect.
  24146. */
  24147. set toneMappingType(value: number);
  24148. /**
  24149. * Gets contrast used in the effect.
  24150. */
  24151. get contrast(): number;
  24152. /**
  24153. * Sets contrast used in the effect.
  24154. */
  24155. set contrast(value: number);
  24156. /**
  24157. * Gets Vignette stretch size.
  24158. */
  24159. get vignetteStretch(): number;
  24160. /**
  24161. * Sets Vignette stretch size.
  24162. */
  24163. set vignetteStretch(value: number);
  24164. /**
  24165. * Gets Vignette centre X Offset.
  24166. */
  24167. get vignetteCentreX(): number;
  24168. /**
  24169. * Sets Vignette centre X Offset.
  24170. */
  24171. set vignetteCentreX(value: number);
  24172. /**
  24173. * Gets Vignette centre Y Offset.
  24174. */
  24175. get vignetteCentreY(): number;
  24176. /**
  24177. * Sets Vignette centre Y Offset.
  24178. */
  24179. set vignetteCentreY(value: number);
  24180. /**
  24181. * Gets Vignette weight or intensity of the vignette effect.
  24182. */
  24183. get vignetteWeight(): number;
  24184. /**
  24185. * Sets Vignette weight or intensity of the vignette effect.
  24186. */
  24187. set vignetteWeight(value: number);
  24188. /**
  24189. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24190. * if vignetteEnabled is set to true.
  24191. */
  24192. get vignetteColor(): Color4;
  24193. /**
  24194. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24195. * if vignetteEnabled is set to true.
  24196. */
  24197. set vignetteColor(value: Color4);
  24198. /**
  24199. * Gets Camera field of view used by the Vignette effect.
  24200. */
  24201. get vignetteCameraFov(): number;
  24202. /**
  24203. * Sets Camera field of view used by the Vignette effect.
  24204. */
  24205. set vignetteCameraFov(value: number);
  24206. /**
  24207. * Gets the vignette blend mode allowing different kind of effect.
  24208. */
  24209. get vignetteBlendMode(): number;
  24210. /**
  24211. * Sets the vignette blend mode allowing different kind of effect.
  24212. */
  24213. set vignetteBlendMode(value: number);
  24214. /**
  24215. * Gets wether the vignette effect is enabled.
  24216. */
  24217. get vignetteEnabled(): boolean;
  24218. /**
  24219. * Sets wether the vignette effect is enabled.
  24220. */
  24221. set vignetteEnabled(value: boolean);
  24222. private _fromLinearSpace;
  24223. /**
  24224. * Gets wether the input of the processing is in Gamma or Linear Space.
  24225. */
  24226. get fromLinearSpace(): boolean;
  24227. /**
  24228. * Sets wether the input of the processing is in Gamma or Linear Space.
  24229. */
  24230. set fromLinearSpace(value: boolean);
  24231. /**
  24232. * Defines cache preventing GC.
  24233. */
  24234. private _defines;
  24235. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24236. /**
  24237. * "ImageProcessingPostProcess"
  24238. * @returns "ImageProcessingPostProcess"
  24239. */
  24240. getClassName(): string;
  24241. /**
  24242. * @hidden
  24243. */
  24244. _updateParameters(): void;
  24245. dispose(camera?: Camera): void;
  24246. }
  24247. }
  24248. declare module BABYLON {
  24249. /** @hidden */
  24250. export var fibonacci: {
  24251. name: string;
  24252. shader: string;
  24253. };
  24254. }
  24255. declare module BABYLON {
  24256. /** @hidden */
  24257. export var subSurfaceScatteringFunctions: {
  24258. name: string;
  24259. shader: string;
  24260. };
  24261. }
  24262. declare module BABYLON {
  24263. /** @hidden */
  24264. export var diffusionProfile: {
  24265. name: string;
  24266. shader: string;
  24267. };
  24268. }
  24269. declare module BABYLON {
  24270. /** @hidden */
  24271. export var subSurfaceScatteringPixelShader: {
  24272. name: string;
  24273. shader: string;
  24274. };
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * Sub surface scattering post process
  24279. */
  24280. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24281. /**
  24282. * Gets a string identifying the name of the class
  24283. * @returns "SubSurfaceScatteringPostProcess" string
  24284. */
  24285. getClassName(): string;
  24286. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24287. }
  24288. }
  24289. declare module BABYLON {
  24290. /**
  24291. * Interface for defining prepass effects in the prepass post-process pipeline
  24292. */
  24293. export interface PrePassEffectConfiguration {
  24294. /**
  24295. * Post process to attach for this effect
  24296. */
  24297. postProcess: PostProcess;
  24298. /**
  24299. * Is the effect enabled
  24300. */
  24301. enabled: boolean;
  24302. /**
  24303. * Disposes the effect configuration
  24304. */
  24305. dispose(): void;
  24306. /**
  24307. * Disposes the effect configuration
  24308. */
  24309. createPostProcess: () => PostProcess;
  24310. }
  24311. }
  24312. declare module BABYLON {
  24313. /**
  24314. * Contains all parameters needed for the prepass to perform
  24315. * screen space subsurface scattering
  24316. */
  24317. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24318. private _ssDiffusionS;
  24319. private _ssFilterRadii;
  24320. private _ssDiffusionD;
  24321. /**
  24322. * Post process to attach for screen space subsurface scattering
  24323. */
  24324. postProcess: SubSurfaceScatteringPostProcess;
  24325. /**
  24326. * Diffusion profile color for subsurface scattering
  24327. */
  24328. get ssDiffusionS(): number[];
  24329. /**
  24330. * Diffusion profile max color channel value for subsurface scattering
  24331. */
  24332. get ssDiffusionD(): number[];
  24333. /**
  24334. * Diffusion profile filter radius for subsurface scattering
  24335. */
  24336. get ssFilterRadii(): number[];
  24337. /**
  24338. * Is subsurface enabled
  24339. */
  24340. enabled: boolean;
  24341. /**
  24342. * Diffusion profile colors for subsurface scattering
  24343. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24344. * See ...
  24345. * Note that you can only store up to 5 of them
  24346. */
  24347. ssDiffusionProfileColors: Color3[];
  24348. /**
  24349. * Defines the ratio real world => scene units.
  24350. * Used for subsurface scattering
  24351. */
  24352. metersPerUnit: number;
  24353. private _scene;
  24354. /**
  24355. * Builds a subsurface configuration object
  24356. * @param scene The scene
  24357. */
  24358. constructor(scene: Scene);
  24359. /**
  24360. * Adds a new diffusion profile.
  24361. * Useful for more realistic subsurface scattering on diverse materials.
  24362. * @param color The color of the diffusion profile. Should be the average color of the material.
  24363. * @return The index of the diffusion profile for the material subsurface configuration
  24364. */
  24365. addDiffusionProfile(color: Color3): number;
  24366. /**
  24367. * Creates the sss post process
  24368. * @return The created post process
  24369. */
  24370. createPostProcess(): SubSurfaceScatteringPostProcess;
  24371. /**
  24372. * Deletes all diffusion profiles.
  24373. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24374. */
  24375. clearAllDiffusionProfiles(): void;
  24376. /**
  24377. * Disposes this object
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * @hidden
  24382. * https://zero-radiance.github.io/post/sampling-diffusion/
  24383. *
  24384. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24385. * ------------------------------------------------------------------------------------
  24386. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24387. * PDF[r, phi, s] = r * R[r, phi, s]
  24388. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24389. * ------------------------------------------------------------------------------------
  24390. * We importance sample the color channel with the widest scattering distance.
  24391. */
  24392. getDiffusionProfileParameters(color: Color3): number;
  24393. /**
  24394. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24395. * 'u' is the random number (the value of the CDF): [0, 1).
  24396. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24397. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24398. */
  24399. private _sampleBurleyDiffusionProfile;
  24400. }
  24401. }
  24402. declare module BABYLON {
  24403. /**
  24404. * Renders a pre pass of the scene
  24405. * This means every mesh in the scene will be rendered to a render target texture
  24406. * And then this texture will be composited to the rendering canvas with post processes
  24407. * It is necessary for effects like subsurface scattering or deferred shading
  24408. */
  24409. export class PrePassRenderer {
  24410. /** @hidden */
  24411. static _SceneComponentInitialization: (scene: Scene) => void;
  24412. private _scene;
  24413. private _engine;
  24414. private _isDirty;
  24415. /**
  24416. * Number of textures in the multi render target texture where the scene is directly rendered
  24417. */
  24418. readonly mrtCount: number;
  24419. /**
  24420. * The render target where the scene is directly rendered
  24421. */
  24422. prePassRT: MultiRenderTarget;
  24423. private _mrtTypes;
  24424. private _multiRenderAttachments;
  24425. private _defaultAttachments;
  24426. private _clearAttachments;
  24427. private _postProcesses;
  24428. private readonly _clearColor;
  24429. /**
  24430. * Image processing post process for composition
  24431. */
  24432. imageProcessingPostProcess: ImageProcessingPostProcess;
  24433. /**
  24434. * Configuration for sub surface scattering post process
  24435. */
  24436. subSurfaceConfiguration: SubSurfaceConfiguration;
  24437. /**
  24438. * Should materials render their geometry on the MRT
  24439. */
  24440. materialsShouldRenderGeometry: boolean;
  24441. /**
  24442. * Should materials render the irradiance information on the MRT
  24443. */
  24444. materialsShouldRenderIrradiance: boolean;
  24445. private _enabled;
  24446. /**
  24447. * Indicates if the prepass is enabled
  24448. */
  24449. get enabled(): boolean;
  24450. /**
  24451. * How many samples are used for MSAA of the scene render target
  24452. */
  24453. get samples(): number;
  24454. set samples(n: number);
  24455. /**
  24456. * Instanciates a prepass renderer
  24457. * @param scene The scene
  24458. */
  24459. constructor(scene: Scene);
  24460. private _initializeAttachments;
  24461. private _createCompositionEffect;
  24462. /**
  24463. * Indicates if rendering a prepass is supported
  24464. */
  24465. get isSupported(): boolean;
  24466. /**
  24467. * Sets the proper output textures to draw in the engine.
  24468. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24469. */
  24470. bindAttachmentsForEffect(effect: Effect): void;
  24471. /**
  24472. * @hidden
  24473. */
  24474. _beforeCameraDraw(): void;
  24475. /**
  24476. * @hidden
  24477. */
  24478. _afterCameraDraw(): void;
  24479. private _checkRTSize;
  24480. private _bindFrameBuffer;
  24481. /**
  24482. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24483. */
  24484. clear(): void;
  24485. private _setState;
  24486. private _enable;
  24487. private _disable;
  24488. private _resetPostProcessChain;
  24489. private _bindPostProcessChain;
  24490. /**
  24491. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24492. */
  24493. markAsDirty(): void;
  24494. private _update;
  24495. /**
  24496. * Disposes the prepass renderer.
  24497. */
  24498. dispose(): void;
  24499. }
  24500. }
  24501. declare module BABYLON {
  24502. /**
  24503. * Options for compiling materials.
  24504. */
  24505. export interface IMaterialCompilationOptions {
  24506. /**
  24507. * Defines whether clip planes are enabled.
  24508. */
  24509. clipPlane: boolean;
  24510. /**
  24511. * Defines whether instances are enabled.
  24512. */
  24513. useInstances: boolean;
  24514. }
  24515. /**
  24516. * Options passed when calling customShaderNameResolve
  24517. */
  24518. export interface ICustomShaderNameResolveOptions {
  24519. /**
  24520. * 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
  24521. */
  24522. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24523. }
  24524. /**
  24525. * Base class for the main features of a material in Babylon.js
  24526. */
  24527. export class Material implements IAnimatable {
  24528. /**
  24529. * Returns the triangle fill mode
  24530. */
  24531. static readonly TriangleFillMode: number;
  24532. /**
  24533. * Returns the wireframe mode
  24534. */
  24535. static readonly WireFrameFillMode: number;
  24536. /**
  24537. * Returns the point fill mode
  24538. */
  24539. static readonly PointFillMode: number;
  24540. /**
  24541. * Returns the point list draw mode
  24542. */
  24543. static readonly PointListDrawMode: number;
  24544. /**
  24545. * Returns the line list draw mode
  24546. */
  24547. static readonly LineListDrawMode: number;
  24548. /**
  24549. * Returns the line loop draw mode
  24550. */
  24551. static readonly LineLoopDrawMode: number;
  24552. /**
  24553. * Returns the line strip draw mode
  24554. */
  24555. static readonly LineStripDrawMode: number;
  24556. /**
  24557. * Returns the triangle strip draw mode
  24558. */
  24559. static readonly TriangleStripDrawMode: number;
  24560. /**
  24561. * Returns the triangle fan draw mode
  24562. */
  24563. static readonly TriangleFanDrawMode: number;
  24564. /**
  24565. * Stores the clock-wise side orientation
  24566. */
  24567. static readonly ClockWiseSideOrientation: number;
  24568. /**
  24569. * Stores the counter clock-wise side orientation
  24570. */
  24571. static readonly CounterClockWiseSideOrientation: number;
  24572. /**
  24573. * The dirty texture flag value
  24574. */
  24575. static readonly TextureDirtyFlag: number;
  24576. /**
  24577. * The dirty light flag value
  24578. */
  24579. static readonly LightDirtyFlag: number;
  24580. /**
  24581. * The dirty fresnel flag value
  24582. */
  24583. static readonly FresnelDirtyFlag: number;
  24584. /**
  24585. * The dirty attribute flag value
  24586. */
  24587. static readonly AttributesDirtyFlag: number;
  24588. /**
  24589. * The dirty misc flag value
  24590. */
  24591. static readonly MiscDirtyFlag: number;
  24592. /**
  24593. * The all dirty flag value
  24594. */
  24595. static readonly AllDirtyFlag: number;
  24596. /**
  24597. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24598. */
  24599. static readonly MATERIAL_OPAQUE: number;
  24600. /**
  24601. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24602. */
  24603. static readonly MATERIAL_ALPHATEST: number;
  24604. /**
  24605. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24606. */
  24607. static readonly MATERIAL_ALPHABLEND: number;
  24608. /**
  24609. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24610. * They are also discarded below the alpha cutoff threshold to improve performances.
  24611. */
  24612. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24613. /**
  24614. * The Whiteout method is used to blend normals.
  24615. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24616. */
  24617. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24618. /**
  24619. * The Reoriented Normal Mapping method is used to blend normals.
  24620. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24621. */
  24622. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24623. /**
  24624. * Custom callback helping to override the default shader used in the material.
  24625. */
  24626. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24627. /**
  24628. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24629. */
  24630. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24631. /**
  24632. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24633. * This means that the material can keep using a previous shader while a new one is being compiled.
  24634. * This is mostly used when shader parallel compilation is supported (true by default)
  24635. */
  24636. allowShaderHotSwapping: boolean;
  24637. /**
  24638. * The ID of the material
  24639. */
  24640. id: string;
  24641. /**
  24642. * Gets or sets the unique id of the material
  24643. */
  24644. uniqueId: number;
  24645. /**
  24646. * The name of the material
  24647. */
  24648. name: string;
  24649. /**
  24650. * Gets or sets user defined metadata
  24651. */
  24652. metadata: any;
  24653. /**
  24654. * For internal use only. Please do not use.
  24655. */
  24656. reservedDataStore: any;
  24657. /**
  24658. * Specifies if the ready state should be checked on each call
  24659. */
  24660. checkReadyOnEveryCall: boolean;
  24661. /**
  24662. * Specifies if the ready state should be checked once
  24663. */
  24664. checkReadyOnlyOnce: boolean;
  24665. /**
  24666. * The state of the material
  24667. */
  24668. state: string;
  24669. /**
  24670. * If the material can be rendered to several textures with MRT extension
  24671. */
  24672. get canRenderToMRT(): boolean;
  24673. /**
  24674. * The alpha value of the material
  24675. */
  24676. protected _alpha: number;
  24677. /**
  24678. * List of inspectable custom properties (used by the Inspector)
  24679. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24680. */
  24681. inspectableCustomProperties: IInspectable[];
  24682. /**
  24683. * Sets the alpha value of the material
  24684. */
  24685. set alpha(value: number);
  24686. /**
  24687. * Gets the alpha value of the material
  24688. */
  24689. get alpha(): number;
  24690. /**
  24691. * Specifies if back face culling is enabled
  24692. */
  24693. protected _backFaceCulling: boolean;
  24694. /**
  24695. * Sets the back-face culling state
  24696. */
  24697. set backFaceCulling(value: boolean);
  24698. /**
  24699. * Gets the back-face culling state
  24700. */
  24701. get backFaceCulling(): boolean;
  24702. /**
  24703. * Stores the value for side orientation
  24704. */
  24705. sideOrientation: number;
  24706. /**
  24707. * Callback triggered when the material is compiled
  24708. */
  24709. onCompiled: Nullable<(effect: Effect) => void>;
  24710. /**
  24711. * Callback triggered when an error occurs
  24712. */
  24713. onError: Nullable<(effect: Effect, errors: string) => void>;
  24714. /**
  24715. * Callback triggered to get the render target textures
  24716. */
  24717. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24718. /**
  24719. * Gets a boolean indicating that current material needs to register RTT
  24720. */
  24721. get hasRenderTargetTextures(): boolean;
  24722. /**
  24723. * Specifies if the material should be serialized
  24724. */
  24725. doNotSerialize: boolean;
  24726. /**
  24727. * @hidden
  24728. */
  24729. _storeEffectOnSubMeshes: boolean;
  24730. /**
  24731. * Stores the animations for the material
  24732. */
  24733. animations: Nullable<Array<Animation>>;
  24734. /**
  24735. * An event triggered when the material is disposed
  24736. */
  24737. onDisposeObservable: Observable<Material>;
  24738. /**
  24739. * An observer which watches for dispose events
  24740. */
  24741. private _onDisposeObserver;
  24742. private _onUnBindObservable;
  24743. /**
  24744. * Called during a dispose event
  24745. */
  24746. set onDispose(callback: () => void);
  24747. private _onBindObservable;
  24748. /**
  24749. * An event triggered when the material is bound
  24750. */
  24751. get onBindObservable(): Observable<AbstractMesh>;
  24752. /**
  24753. * An observer which watches for bind events
  24754. */
  24755. private _onBindObserver;
  24756. /**
  24757. * Called during a bind event
  24758. */
  24759. set onBind(callback: (Mesh: AbstractMesh) => void);
  24760. /**
  24761. * An event triggered when the material is unbound
  24762. */
  24763. get onUnBindObservable(): Observable<Material>;
  24764. protected _onEffectCreatedObservable: Nullable<Observable<{
  24765. effect: Effect;
  24766. subMesh: Nullable<SubMesh>;
  24767. }>>;
  24768. /**
  24769. * An event triggered when the effect is (re)created
  24770. */
  24771. get onEffectCreatedObservable(): Observable<{
  24772. effect: Effect;
  24773. subMesh: Nullable<SubMesh>;
  24774. }>;
  24775. /**
  24776. * Stores the value of the alpha mode
  24777. */
  24778. private _alphaMode;
  24779. /**
  24780. * Sets the value of the alpha mode.
  24781. *
  24782. * | Value | Type | Description |
  24783. * | --- | --- | --- |
  24784. * | 0 | ALPHA_DISABLE | |
  24785. * | 1 | ALPHA_ADD | |
  24786. * | 2 | ALPHA_COMBINE | |
  24787. * | 3 | ALPHA_SUBTRACT | |
  24788. * | 4 | ALPHA_MULTIPLY | |
  24789. * | 5 | ALPHA_MAXIMIZED | |
  24790. * | 6 | ALPHA_ONEONE | |
  24791. * | 7 | ALPHA_PREMULTIPLIED | |
  24792. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24793. * | 9 | ALPHA_INTERPOLATE | |
  24794. * | 10 | ALPHA_SCREENMODE | |
  24795. *
  24796. */
  24797. set alphaMode(value: number);
  24798. /**
  24799. * Gets the value of the alpha mode
  24800. */
  24801. get alphaMode(): number;
  24802. /**
  24803. * Stores the state of the need depth pre-pass value
  24804. */
  24805. private _needDepthPrePass;
  24806. /**
  24807. * Sets the need depth pre-pass value
  24808. */
  24809. set needDepthPrePass(value: boolean);
  24810. /**
  24811. * Gets the depth pre-pass value
  24812. */
  24813. get needDepthPrePass(): boolean;
  24814. /**
  24815. * Specifies if depth writing should be disabled
  24816. */
  24817. disableDepthWrite: boolean;
  24818. /**
  24819. * Specifies if color writing should be disabled
  24820. */
  24821. disableColorWrite: boolean;
  24822. /**
  24823. * Specifies if depth writing should be forced
  24824. */
  24825. forceDepthWrite: boolean;
  24826. /**
  24827. * Specifies the depth function that should be used. 0 means the default engine function
  24828. */
  24829. depthFunction: number;
  24830. /**
  24831. * Specifies if there should be a separate pass for culling
  24832. */
  24833. separateCullingPass: boolean;
  24834. /**
  24835. * Stores the state specifing if fog should be enabled
  24836. */
  24837. private _fogEnabled;
  24838. /**
  24839. * Sets the state for enabling fog
  24840. */
  24841. set fogEnabled(value: boolean);
  24842. /**
  24843. * Gets the value of the fog enabled state
  24844. */
  24845. get fogEnabled(): boolean;
  24846. /**
  24847. * Stores the size of points
  24848. */
  24849. pointSize: number;
  24850. /**
  24851. * Stores the z offset value
  24852. */
  24853. zOffset: number;
  24854. get wireframe(): boolean;
  24855. /**
  24856. * Sets the state of wireframe mode
  24857. */
  24858. set wireframe(value: boolean);
  24859. /**
  24860. * Gets the value specifying if point clouds are enabled
  24861. */
  24862. get pointsCloud(): boolean;
  24863. /**
  24864. * Sets the state of point cloud mode
  24865. */
  24866. set pointsCloud(value: boolean);
  24867. /**
  24868. * Gets the material fill mode
  24869. */
  24870. get fillMode(): number;
  24871. /**
  24872. * Sets the material fill mode
  24873. */
  24874. set fillMode(value: number);
  24875. /**
  24876. * @hidden
  24877. * Stores the effects for the material
  24878. */
  24879. _effect: Nullable<Effect>;
  24880. /**
  24881. * Specifies if uniform buffers should be used
  24882. */
  24883. private _useUBO;
  24884. /**
  24885. * Stores a reference to the scene
  24886. */
  24887. private _scene;
  24888. /**
  24889. * Stores the fill mode state
  24890. */
  24891. private _fillMode;
  24892. /**
  24893. * Specifies if the depth write state should be cached
  24894. */
  24895. private _cachedDepthWriteState;
  24896. /**
  24897. * Specifies if the color write state should be cached
  24898. */
  24899. private _cachedColorWriteState;
  24900. /**
  24901. * Specifies if the depth function state should be cached
  24902. */
  24903. private _cachedDepthFunctionState;
  24904. /**
  24905. * Stores the uniform buffer
  24906. */
  24907. protected _uniformBuffer: UniformBuffer;
  24908. /** @hidden */
  24909. _indexInSceneMaterialArray: number;
  24910. /** @hidden */
  24911. meshMap: Nullable<{
  24912. [id: string]: AbstractMesh | undefined;
  24913. }>;
  24914. /**
  24915. * Creates a material instance
  24916. * @param name defines the name of the material
  24917. * @param scene defines the scene to reference
  24918. * @param doNotAdd specifies if the material should be added to the scene
  24919. */
  24920. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24921. /**
  24922. * Returns a string representation of the current material
  24923. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24924. * @returns a string with material information
  24925. */
  24926. toString(fullDetails?: boolean): string;
  24927. /**
  24928. * Gets the class name of the material
  24929. * @returns a string with the class name of the material
  24930. */
  24931. getClassName(): string;
  24932. /**
  24933. * Specifies if updates for the material been locked
  24934. */
  24935. get isFrozen(): boolean;
  24936. /**
  24937. * Locks updates for the material
  24938. */
  24939. freeze(): void;
  24940. /**
  24941. * Unlocks updates for the material
  24942. */
  24943. unfreeze(): void;
  24944. /**
  24945. * Specifies if the material is ready to be used
  24946. * @param mesh defines the mesh to check
  24947. * @param useInstances specifies if instances should be used
  24948. * @returns a boolean indicating if the material is ready to be used
  24949. */
  24950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24951. /**
  24952. * Specifies that the submesh is ready to be used
  24953. * @param mesh defines the mesh to check
  24954. * @param subMesh defines which submesh to check
  24955. * @param useInstances specifies that instances should be used
  24956. * @returns a boolean indicating that the submesh is ready or not
  24957. */
  24958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24959. /**
  24960. * Returns the material effect
  24961. * @returns the effect associated with the material
  24962. */
  24963. getEffect(): Nullable<Effect>;
  24964. /**
  24965. * Returns the current scene
  24966. * @returns a Scene
  24967. */
  24968. getScene(): Scene;
  24969. /**
  24970. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24971. */
  24972. protected _forceAlphaTest: boolean;
  24973. /**
  24974. * The transparency mode of the material.
  24975. */
  24976. protected _transparencyMode: Nullable<number>;
  24977. /**
  24978. * Gets the current transparency mode.
  24979. */
  24980. get transparencyMode(): Nullable<number>;
  24981. /**
  24982. * Sets the transparency mode of the material.
  24983. *
  24984. * | Value | Type | Description |
  24985. * | ----- | ----------------------------------- | ----------- |
  24986. * | 0 | OPAQUE | |
  24987. * | 1 | ALPHATEST | |
  24988. * | 2 | ALPHABLEND | |
  24989. * | 3 | ALPHATESTANDBLEND | |
  24990. *
  24991. */
  24992. set transparencyMode(value: Nullable<number>);
  24993. /**
  24994. * Returns true if alpha blending should be disabled.
  24995. */
  24996. protected get _disableAlphaBlending(): boolean;
  24997. /**
  24998. * Specifies whether or not this material should be rendered in alpha blend mode.
  24999. * @returns a boolean specifying if alpha blending is needed
  25000. */
  25001. needAlphaBlending(): boolean;
  25002. /**
  25003. * Specifies if the mesh will require alpha blending
  25004. * @param mesh defines the mesh to check
  25005. * @returns a boolean specifying if alpha blending is needed for the mesh
  25006. */
  25007. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25008. /**
  25009. * Specifies whether or not this material should be rendered in alpha test mode.
  25010. * @returns a boolean specifying if an alpha test is needed.
  25011. */
  25012. needAlphaTesting(): boolean;
  25013. /**
  25014. * Specifies if material alpha testing should be turned on for the mesh
  25015. * @param mesh defines the mesh to check
  25016. */
  25017. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25018. /**
  25019. * Gets the texture used for the alpha test
  25020. * @returns the texture to use for alpha testing
  25021. */
  25022. getAlphaTestTexture(): Nullable<BaseTexture>;
  25023. /**
  25024. * Marks the material to indicate that it needs to be re-calculated
  25025. */
  25026. markDirty(): void;
  25027. /** @hidden */
  25028. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25029. /**
  25030. * Binds the material to the mesh
  25031. * @param world defines the world transformation matrix
  25032. * @param mesh defines the mesh to bind the material to
  25033. */
  25034. bind(world: Matrix, mesh?: Mesh): void;
  25035. /**
  25036. * Binds the submesh to the material
  25037. * @param world defines the world transformation matrix
  25038. * @param mesh defines the mesh containing the submesh
  25039. * @param subMesh defines the submesh to bind the material to
  25040. */
  25041. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25042. /**
  25043. * Binds the world matrix to the material
  25044. * @param world defines the world transformation matrix
  25045. */
  25046. bindOnlyWorldMatrix(world: Matrix): void;
  25047. /**
  25048. * Binds the scene's uniform buffer to the effect.
  25049. * @param effect defines the effect to bind to the scene uniform buffer
  25050. * @param sceneUbo defines the uniform buffer storing scene data
  25051. */
  25052. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25053. /**
  25054. * Binds the view matrix to the effect
  25055. * @param effect defines the effect to bind the view matrix to
  25056. */
  25057. bindView(effect: Effect): void;
  25058. /**
  25059. * Binds the view projection matrix to the effect
  25060. * @param effect defines the effect to bind the view projection matrix to
  25061. */
  25062. bindViewProjection(effect: Effect): void;
  25063. /**
  25064. * Processes to execute after binding the material to a mesh
  25065. * @param mesh defines the rendered mesh
  25066. */
  25067. protected _afterBind(mesh?: Mesh): void;
  25068. /**
  25069. * Unbinds the material from the mesh
  25070. */
  25071. unbind(): void;
  25072. /**
  25073. * Gets the active textures from the material
  25074. * @returns an array of textures
  25075. */
  25076. getActiveTextures(): BaseTexture[];
  25077. /**
  25078. * Specifies if the material uses a texture
  25079. * @param texture defines the texture to check against the material
  25080. * @returns a boolean specifying if the material uses the texture
  25081. */
  25082. hasTexture(texture: BaseTexture): boolean;
  25083. /**
  25084. * Makes a duplicate of the material, and gives it a new name
  25085. * @param name defines the new name for the duplicated material
  25086. * @returns the cloned material
  25087. */
  25088. clone(name: string): Nullable<Material>;
  25089. /**
  25090. * Gets the meshes bound to the material
  25091. * @returns an array of meshes bound to the material
  25092. */
  25093. getBindedMeshes(): AbstractMesh[];
  25094. /**
  25095. * Force shader compilation
  25096. * @param mesh defines the mesh associated with this material
  25097. * @param onCompiled defines a function to execute once the material is compiled
  25098. * @param options defines the options to configure the compilation
  25099. * @param onError defines a function to execute if the material fails compiling
  25100. */
  25101. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25102. /**
  25103. * Force shader compilation
  25104. * @param mesh defines the mesh that will use this material
  25105. * @param options defines additional options for compiling the shaders
  25106. * @returns a promise that resolves when the compilation completes
  25107. */
  25108. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25109. private static readonly _AllDirtyCallBack;
  25110. private static readonly _ImageProcessingDirtyCallBack;
  25111. private static readonly _TextureDirtyCallBack;
  25112. private static readonly _FresnelDirtyCallBack;
  25113. private static readonly _MiscDirtyCallBack;
  25114. private static readonly _LightsDirtyCallBack;
  25115. private static readonly _AttributeDirtyCallBack;
  25116. private static _FresnelAndMiscDirtyCallBack;
  25117. private static _TextureAndMiscDirtyCallBack;
  25118. private static readonly _DirtyCallbackArray;
  25119. private static readonly _RunDirtyCallBacks;
  25120. /**
  25121. * Marks a define in the material to indicate that it needs to be re-computed
  25122. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25123. */
  25124. markAsDirty(flag: number): void;
  25125. /**
  25126. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25127. * @param func defines a function which checks material defines against the submeshes
  25128. */
  25129. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25130. /**
  25131. * Indicates that the scene should check if the rendering now needs a prepass
  25132. */
  25133. protected _markScenePrePassDirty(): void;
  25134. /**
  25135. * Indicates that we need to re-calculated for all submeshes
  25136. */
  25137. protected _markAllSubMeshesAsAllDirty(): void;
  25138. /**
  25139. * Indicates that image processing needs to be re-calculated for all submeshes
  25140. */
  25141. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25142. /**
  25143. * Indicates that textures need to be re-calculated for all submeshes
  25144. */
  25145. protected _markAllSubMeshesAsTexturesDirty(): void;
  25146. /**
  25147. * Indicates that fresnel needs to be re-calculated for all submeshes
  25148. */
  25149. protected _markAllSubMeshesAsFresnelDirty(): void;
  25150. /**
  25151. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25152. */
  25153. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25154. /**
  25155. * Indicates that lights need to be re-calculated for all submeshes
  25156. */
  25157. protected _markAllSubMeshesAsLightsDirty(): void;
  25158. /**
  25159. * Indicates that attributes need to be re-calculated for all submeshes
  25160. */
  25161. protected _markAllSubMeshesAsAttributesDirty(): void;
  25162. /**
  25163. * Indicates that misc needs to be re-calculated for all submeshes
  25164. */
  25165. protected _markAllSubMeshesAsMiscDirty(): void;
  25166. /**
  25167. * Indicates that textures and misc need to be re-calculated for all submeshes
  25168. */
  25169. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25170. /**
  25171. * Sets the required values to the prepass renderer.
  25172. * @param prePassRenderer defines the prepass renderer to setup.
  25173. * @returns true if the pre pass is needed.
  25174. */
  25175. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25176. /**
  25177. * Disposes the material
  25178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25180. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25181. */
  25182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25183. /** @hidden */
  25184. private releaseVertexArrayObject;
  25185. /**
  25186. * Serializes this material
  25187. * @returns the serialized material object
  25188. */
  25189. serialize(): any;
  25190. /**
  25191. * Creates a material from parsed material data
  25192. * @param parsedMaterial defines parsed material data
  25193. * @param scene defines the hosting scene
  25194. * @param rootUrl defines the root URL to use to load textures
  25195. * @returns a new material
  25196. */
  25197. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25198. }
  25199. }
  25200. declare module BABYLON {
  25201. /**
  25202. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25203. * separate meshes. This can be use to improve performances.
  25204. * @see https://doc.babylonjs.com/how_to/multi_materials
  25205. */
  25206. export class MultiMaterial extends Material {
  25207. private _subMaterials;
  25208. /**
  25209. * Gets or Sets the list of Materials used within the multi material.
  25210. * They need to be ordered according to the submeshes order in the associated mesh
  25211. */
  25212. get subMaterials(): Nullable<Material>[];
  25213. set subMaterials(value: Nullable<Material>[]);
  25214. /**
  25215. * Function used to align with Node.getChildren()
  25216. * @returns the list of Materials used within the multi material
  25217. */
  25218. getChildren(): Nullable<Material>[];
  25219. /**
  25220. * Instantiates a new Multi Material
  25221. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25222. * separate meshes. This can be use to improve performances.
  25223. * @see https://doc.babylonjs.com/how_to/multi_materials
  25224. * @param name Define the name in the scene
  25225. * @param scene Define the scene the material belongs to
  25226. */
  25227. constructor(name: string, scene: Scene);
  25228. private _hookArray;
  25229. /**
  25230. * Get one of the submaterial by its index in the submaterials array
  25231. * @param index The index to look the sub material at
  25232. * @returns The Material if the index has been defined
  25233. */
  25234. getSubMaterial(index: number): Nullable<Material>;
  25235. /**
  25236. * Get the list of active textures for the whole sub materials list.
  25237. * @returns All the textures that will be used during the rendering
  25238. */
  25239. getActiveTextures(): BaseTexture[];
  25240. /**
  25241. * Gets the current class name of the material e.g. "MultiMaterial"
  25242. * Mainly use in serialization.
  25243. * @returns the class name
  25244. */
  25245. getClassName(): string;
  25246. /**
  25247. * Checks if the material is ready to render the requested sub mesh
  25248. * @param mesh Define the mesh the submesh belongs to
  25249. * @param subMesh Define the sub mesh to look readyness for
  25250. * @param useInstances Define whether or not the material is used with instances
  25251. * @returns true if ready, otherwise false
  25252. */
  25253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25254. /**
  25255. * Clones the current material and its related sub materials
  25256. * @param name Define the name of the newly cloned material
  25257. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25258. * @returns the cloned material
  25259. */
  25260. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25261. /**
  25262. * Serializes the materials into a JSON representation.
  25263. * @returns the JSON representation
  25264. */
  25265. serialize(): any;
  25266. /**
  25267. * Dispose the material and release its associated resources
  25268. * @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)
  25269. * @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)
  25270. * @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)
  25271. */
  25272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25273. /**
  25274. * Creates a MultiMaterial from parsed MultiMaterial data.
  25275. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25276. * @param scene defines the hosting scene
  25277. * @returns a new MultiMaterial
  25278. */
  25279. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25280. }
  25281. }
  25282. declare module BABYLON {
  25283. /**
  25284. * Defines a subdivision inside a mesh
  25285. */
  25286. export class SubMesh implements ICullable {
  25287. /** the material index to use */
  25288. materialIndex: number;
  25289. /** vertex index start */
  25290. verticesStart: number;
  25291. /** vertices count */
  25292. verticesCount: number;
  25293. /** index start */
  25294. indexStart: number;
  25295. /** indices count */
  25296. indexCount: number;
  25297. /** @hidden */
  25298. _materialDefines: Nullable<MaterialDefines>;
  25299. /** @hidden */
  25300. _materialEffect: Nullable<Effect>;
  25301. /** @hidden */
  25302. _effectOverride: Nullable<Effect>;
  25303. /**
  25304. * Gets material defines used by the effect associated to the sub mesh
  25305. */
  25306. get materialDefines(): Nullable<MaterialDefines>;
  25307. /**
  25308. * Sets material defines used by the effect associated to the sub mesh
  25309. */
  25310. set materialDefines(defines: Nullable<MaterialDefines>);
  25311. /**
  25312. * Gets associated effect
  25313. */
  25314. get effect(): Nullable<Effect>;
  25315. /**
  25316. * Sets associated effect (effect used to render this submesh)
  25317. * @param effect defines the effect to associate with
  25318. * @param defines defines the set of defines used to compile this effect
  25319. */
  25320. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25321. /** @hidden */
  25322. _linesIndexCount: number;
  25323. private _mesh;
  25324. private _renderingMesh;
  25325. private _boundingInfo;
  25326. private _linesIndexBuffer;
  25327. /** @hidden */
  25328. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25329. /** @hidden */
  25330. _trianglePlanes: Plane[];
  25331. /** @hidden */
  25332. _lastColliderTransformMatrix: Nullable<Matrix>;
  25333. /** @hidden */
  25334. _renderId: number;
  25335. /** @hidden */
  25336. _alphaIndex: number;
  25337. /** @hidden */
  25338. _distanceToCamera: number;
  25339. /** @hidden */
  25340. _id: number;
  25341. private _currentMaterial;
  25342. /**
  25343. * Add a new submesh to a mesh
  25344. * @param materialIndex defines the material index to use
  25345. * @param verticesStart defines vertex index start
  25346. * @param verticesCount defines vertices count
  25347. * @param indexStart defines index start
  25348. * @param indexCount defines indices count
  25349. * @param mesh defines the parent mesh
  25350. * @param renderingMesh defines an optional rendering mesh
  25351. * @param createBoundingBox defines if bounding box should be created for this submesh
  25352. * @returns the new submesh
  25353. */
  25354. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25355. /**
  25356. * Creates a new submesh
  25357. * @param materialIndex defines the material index to use
  25358. * @param verticesStart defines vertex index start
  25359. * @param verticesCount defines vertices count
  25360. * @param indexStart defines index start
  25361. * @param indexCount defines indices count
  25362. * @param mesh defines the parent mesh
  25363. * @param renderingMesh defines an optional rendering mesh
  25364. * @param createBoundingBox defines if bounding box should be created for this submesh
  25365. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25366. */
  25367. constructor(
  25368. /** the material index to use */
  25369. materialIndex: number,
  25370. /** vertex index start */
  25371. verticesStart: number,
  25372. /** vertices count */
  25373. verticesCount: number,
  25374. /** index start */
  25375. indexStart: number,
  25376. /** indices count */
  25377. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25378. /**
  25379. * Returns true if this submesh covers the entire parent mesh
  25380. * @ignorenaming
  25381. */
  25382. get IsGlobal(): boolean;
  25383. /**
  25384. * Returns the submesh BoudingInfo object
  25385. * @returns current bounding info (or mesh's one if the submesh is global)
  25386. */
  25387. getBoundingInfo(): BoundingInfo;
  25388. /**
  25389. * Sets the submesh BoundingInfo
  25390. * @param boundingInfo defines the new bounding info to use
  25391. * @returns the SubMesh
  25392. */
  25393. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25394. /**
  25395. * Returns the mesh of the current submesh
  25396. * @return the parent mesh
  25397. */
  25398. getMesh(): AbstractMesh;
  25399. /**
  25400. * Returns the rendering mesh of the submesh
  25401. * @returns the rendering mesh (could be different from parent mesh)
  25402. */
  25403. getRenderingMesh(): Mesh;
  25404. /**
  25405. * Returns the replacement mesh of the submesh
  25406. * @returns the replacement mesh (could be different from parent mesh)
  25407. */
  25408. getReplacementMesh(): Nullable<AbstractMesh>;
  25409. /**
  25410. * Returns the effective mesh of the submesh
  25411. * @returns the effective mesh (could be different from parent mesh)
  25412. */
  25413. getEffectiveMesh(): AbstractMesh;
  25414. /**
  25415. * Returns the submesh material
  25416. * @returns null or the current material
  25417. */
  25418. getMaterial(): Nullable<Material>;
  25419. private _IsMultiMaterial;
  25420. /**
  25421. * Sets a new updated BoundingInfo object to the submesh
  25422. * @param data defines an optional position array to use to determine the bounding info
  25423. * @returns the SubMesh
  25424. */
  25425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25426. /** @hidden */
  25427. _checkCollision(collider: Collider): boolean;
  25428. /**
  25429. * Updates the submesh BoundingInfo
  25430. * @param world defines the world matrix to use to update the bounding info
  25431. * @returns the submesh
  25432. */
  25433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25434. /**
  25435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25436. * @param frustumPlanes defines the frustum planes
  25437. * @returns true if the submesh is intersecting with the frustum
  25438. */
  25439. isInFrustum(frustumPlanes: Plane[]): boolean;
  25440. /**
  25441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25442. * @param frustumPlanes defines the frustum planes
  25443. * @returns true if the submesh is inside the frustum
  25444. */
  25445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25446. /**
  25447. * Renders the submesh
  25448. * @param enableAlphaMode defines if alpha needs to be used
  25449. * @returns the submesh
  25450. */
  25451. render(enableAlphaMode: boolean): SubMesh;
  25452. /**
  25453. * @hidden
  25454. */
  25455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25456. /**
  25457. * Checks if the submesh intersects with a ray
  25458. * @param ray defines the ray to test
  25459. * @returns true is the passed ray intersects the submesh bounding box
  25460. */
  25461. canIntersects(ray: Ray): boolean;
  25462. /**
  25463. * Intersects current submesh with a ray
  25464. * @param ray defines the ray to test
  25465. * @param positions defines mesh's positions array
  25466. * @param indices defines mesh's indices array
  25467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25469. * @returns intersection info or null if no intersection
  25470. */
  25471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25472. /** @hidden */
  25473. private _intersectLines;
  25474. /** @hidden */
  25475. private _intersectUnIndexedLines;
  25476. /** @hidden */
  25477. private _intersectTriangles;
  25478. /** @hidden */
  25479. private _intersectUnIndexedTriangles;
  25480. /** @hidden */
  25481. _rebuild(): void;
  25482. /**
  25483. * Creates a new submesh from the passed mesh
  25484. * @param newMesh defines the new hosting mesh
  25485. * @param newRenderingMesh defines an optional rendering mesh
  25486. * @returns the new submesh
  25487. */
  25488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25489. /**
  25490. * Release associated resources
  25491. */
  25492. dispose(): void;
  25493. /**
  25494. * Gets the class name
  25495. * @returns the string "SubMesh".
  25496. */
  25497. getClassName(): string;
  25498. /**
  25499. * Creates a new submesh from indices data
  25500. * @param materialIndex the index of the main mesh material
  25501. * @param startIndex the index where to start the copy in the mesh indices array
  25502. * @param indexCount the number of indices to copy then from the startIndex
  25503. * @param mesh the main mesh to create the submesh from
  25504. * @param renderingMesh the optional rendering mesh
  25505. * @returns a new submesh
  25506. */
  25507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25508. }
  25509. }
  25510. declare module BABYLON {
  25511. /**
  25512. * Class used to represent data loading progression
  25513. */
  25514. export class SceneLoaderFlags {
  25515. private static _ForceFullSceneLoadingForIncremental;
  25516. private static _ShowLoadingScreen;
  25517. private static _CleanBoneMatrixWeights;
  25518. private static _loggingLevel;
  25519. /**
  25520. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25521. */
  25522. static get ForceFullSceneLoadingForIncremental(): boolean;
  25523. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25524. /**
  25525. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25526. */
  25527. static get ShowLoadingScreen(): boolean;
  25528. static set ShowLoadingScreen(value: boolean);
  25529. /**
  25530. * Defines the current logging level (while loading the scene)
  25531. * @ignorenaming
  25532. */
  25533. static get loggingLevel(): number;
  25534. static set loggingLevel(value: number);
  25535. /**
  25536. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25537. */
  25538. static get CleanBoneMatrixWeights(): boolean;
  25539. static set CleanBoneMatrixWeights(value: boolean);
  25540. }
  25541. }
  25542. declare module BABYLON {
  25543. /**
  25544. * Class used to store geometry data (vertex buffers + index buffer)
  25545. */
  25546. export class Geometry implements IGetSetVerticesData {
  25547. /**
  25548. * Gets or sets the ID of the geometry
  25549. */
  25550. id: string;
  25551. /**
  25552. * Gets or sets the unique ID of the geometry
  25553. */
  25554. uniqueId: number;
  25555. /**
  25556. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25557. */
  25558. delayLoadState: number;
  25559. /**
  25560. * Gets the file containing the data to load when running in delay load state
  25561. */
  25562. delayLoadingFile: Nullable<string>;
  25563. /**
  25564. * Callback called when the geometry is updated
  25565. */
  25566. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25567. private _scene;
  25568. private _engine;
  25569. private _meshes;
  25570. private _totalVertices;
  25571. /** @hidden */
  25572. _indices: IndicesArray;
  25573. /** @hidden */
  25574. _vertexBuffers: {
  25575. [key: string]: VertexBuffer;
  25576. };
  25577. private _isDisposed;
  25578. private _extend;
  25579. private _boundingBias;
  25580. /** @hidden */
  25581. _delayInfo: Array<string>;
  25582. private _indexBuffer;
  25583. private _indexBufferIsUpdatable;
  25584. /** @hidden */
  25585. _boundingInfo: Nullable<BoundingInfo>;
  25586. /** @hidden */
  25587. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25588. /** @hidden */
  25589. _softwareSkinningFrameId: number;
  25590. private _vertexArrayObjects;
  25591. private _updatable;
  25592. /** @hidden */
  25593. _positions: Nullable<Vector3[]>;
  25594. /**
  25595. * 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
  25596. */
  25597. get boundingBias(): Vector2;
  25598. /**
  25599. * 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
  25600. */
  25601. set boundingBias(value: Vector2);
  25602. /**
  25603. * Static function used to attach a new empty geometry to a mesh
  25604. * @param mesh defines the mesh to attach the geometry to
  25605. * @returns the new Geometry
  25606. */
  25607. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25608. /** Get the list of meshes using this geometry */
  25609. get meshes(): Mesh[];
  25610. /**
  25611. * 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
  25612. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25613. */
  25614. useBoundingInfoFromGeometry: boolean;
  25615. /**
  25616. * Creates a new geometry
  25617. * @param id defines the unique ID
  25618. * @param scene defines the hosting scene
  25619. * @param vertexData defines the VertexData used to get geometry data
  25620. * @param updatable defines if geometry must be updatable (false by default)
  25621. * @param mesh defines the mesh that will be associated with the geometry
  25622. */
  25623. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25624. /**
  25625. * Gets the current extend of the geometry
  25626. */
  25627. get extend(): {
  25628. minimum: Vector3;
  25629. maximum: Vector3;
  25630. };
  25631. /**
  25632. * Gets the hosting scene
  25633. * @returns the hosting Scene
  25634. */
  25635. getScene(): Scene;
  25636. /**
  25637. * Gets the hosting engine
  25638. * @returns the hosting Engine
  25639. */
  25640. getEngine(): Engine;
  25641. /**
  25642. * Defines if the geometry is ready to use
  25643. * @returns true if the geometry is ready to be used
  25644. */
  25645. isReady(): boolean;
  25646. /**
  25647. * Gets a value indicating that the geometry should not be serialized
  25648. */
  25649. get doNotSerialize(): boolean;
  25650. /** @hidden */
  25651. _rebuild(): void;
  25652. /**
  25653. * Affects all geometry data in one call
  25654. * @param vertexData defines the geometry data
  25655. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25656. */
  25657. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25658. /**
  25659. * Set specific vertex data
  25660. * @param kind defines the data kind (Position, normal, etc...)
  25661. * @param data defines the vertex data to use
  25662. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25663. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25664. */
  25665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25666. /**
  25667. * Removes a specific vertex data
  25668. * @param kind defines the data kind (Position, normal, etc...)
  25669. */
  25670. removeVerticesData(kind: string): void;
  25671. /**
  25672. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25673. * @param buffer defines the vertex buffer to use
  25674. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25675. */
  25676. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25677. /**
  25678. * Update a specific vertex buffer
  25679. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25680. * It will do nothing if the buffer is not updatable
  25681. * @param kind defines the data kind (Position, normal, etc...)
  25682. * @param data defines the data to use
  25683. * @param offset defines the offset in the target buffer where to store the data
  25684. * @param useBytes set to true if the offset is in bytes
  25685. */
  25686. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25687. /**
  25688. * Update a specific vertex buffer
  25689. * This function will create a new buffer if the current one is not updatable
  25690. * @param kind defines the data kind (Position, normal, etc...)
  25691. * @param data defines the data to use
  25692. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25693. */
  25694. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25695. private _updateBoundingInfo;
  25696. /** @hidden */
  25697. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25698. /**
  25699. * Gets total number of vertices
  25700. * @returns the total number of vertices
  25701. */
  25702. getTotalVertices(): number;
  25703. /**
  25704. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25705. * @param kind defines the data kind (Position, normal, etc...)
  25706. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25707. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25708. * @returns a float array containing vertex data
  25709. */
  25710. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25711. /**
  25712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25713. * @param kind defines the data kind (Position, normal, etc...)
  25714. * @returns true if the vertex buffer with the specified kind is updatable
  25715. */
  25716. isVertexBufferUpdatable(kind: string): boolean;
  25717. /**
  25718. * Gets a specific vertex buffer
  25719. * @param kind defines the data kind (Position, normal, etc...)
  25720. * @returns a VertexBuffer
  25721. */
  25722. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25723. /**
  25724. * Returns all vertex buffers
  25725. * @return an object holding all vertex buffers indexed by kind
  25726. */
  25727. getVertexBuffers(): Nullable<{
  25728. [key: string]: VertexBuffer;
  25729. }>;
  25730. /**
  25731. * Gets a boolean indicating if specific vertex buffer is present
  25732. * @param kind defines the data kind (Position, normal, etc...)
  25733. * @returns true if data is present
  25734. */
  25735. isVerticesDataPresent(kind: string): boolean;
  25736. /**
  25737. * Gets a list of all attached data kinds (Position, normal, etc...)
  25738. * @returns a list of string containing all kinds
  25739. */
  25740. getVerticesDataKinds(): string[];
  25741. /**
  25742. * Update index buffer
  25743. * @param indices defines the indices to store in the index buffer
  25744. * @param offset defines the offset in the target buffer where to store the data
  25745. * @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)
  25746. */
  25747. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25748. /**
  25749. * Creates a new index buffer
  25750. * @param indices defines the indices to store in the index buffer
  25751. * @param totalVertices defines the total number of vertices (could be null)
  25752. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25753. */
  25754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25755. /**
  25756. * Return the total number of indices
  25757. * @returns the total number of indices
  25758. */
  25759. getTotalIndices(): number;
  25760. /**
  25761. * Gets the index buffer array
  25762. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25764. * @returns the index buffer array
  25765. */
  25766. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25767. /**
  25768. * Gets the index buffer
  25769. * @return the index buffer
  25770. */
  25771. getIndexBuffer(): Nullable<DataBuffer>;
  25772. /** @hidden */
  25773. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25774. /**
  25775. * Release the associated resources for a specific mesh
  25776. * @param mesh defines the source mesh
  25777. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25778. */
  25779. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25780. /**
  25781. * Apply current geometry to a given mesh
  25782. * @param mesh defines the mesh to apply geometry to
  25783. */
  25784. applyToMesh(mesh: Mesh): void;
  25785. private _updateExtend;
  25786. private _applyToMesh;
  25787. private notifyUpdate;
  25788. /**
  25789. * Load the geometry if it was flagged as delay loaded
  25790. * @param scene defines the hosting scene
  25791. * @param onLoaded defines a callback called when the geometry is loaded
  25792. */
  25793. load(scene: Scene, onLoaded?: () => void): void;
  25794. private _queueLoad;
  25795. /**
  25796. * Invert the geometry to move from a right handed system to a left handed one.
  25797. */
  25798. toLeftHanded(): void;
  25799. /** @hidden */
  25800. _resetPointsArrayCache(): void;
  25801. /** @hidden */
  25802. _generatePointsArray(): boolean;
  25803. /**
  25804. * Gets a value indicating if the geometry is disposed
  25805. * @returns true if the geometry was disposed
  25806. */
  25807. isDisposed(): boolean;
  25808. private _disposeVertexArrayObjects;
  25809. /**
  25810. * Free all associated resources
  25811. */
  25812. dispose(): void;
  25813. /**
  25814. * Clone the current geometry into a new geometry
  25815. * @param id defines the unique ID of the new geometry
  25816. * @returns a new geometry object
  25817. */
  25818. copy(id: string): Geometry;
  25819. /**
  25820. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25821. * @return a JSON representation of the current geometry data (without the vertices data)
  25822. */
  25823. serialize(): any;
  25824. private toNumberArray;
  25825. /**
  25826. * Serialize all vertices data into a JSON oject
  25827. * @returns a JSON representation of the current geometry data
  25828. */
  25829. serializeVerticeData(): any;
  25830. /**
  25831. * Extracts a clone of a mesh geometry
  25832. * @param mesh defines the source mesh
  25833. * @param id defines the unique ID of the new geometry object
  25834. * @returns the new geometry object
  25835. */
  25836. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25837. /**
  25838. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25839. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25840. * Be aware Math.random() could cause collisions, but:
  25841. * "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"
  25842. * @returns a string containing a new GUID
  25843. */
  25844. static RandomId(): string;
  25845. /** @hidden */
  25846. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25847. private static _CleanMatricesWeights;
  25848. /**
  25849. * Create a new geometry from persisted data (Using .babylon file format)
  25850. * @param parsedVertexData defines the persisted data
  25851. * @param scene defines the hosting scene
  25852. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25853. * @returns the new geometry object
  25854. */
  25855. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * Define an interface for all classes that will get and set the data on vertices
  25861. */
  25862. export interface IGetSetVerticesData {
  25863. /**
  25864. * Gets a boolean indicating if specific vertex data is present
  25865. * @param kind defines the vertex data kind to use
  25866. * @returns true is data kind is present
  25867. */
  25868. isVerticesDataPresent(kind: string): boolean;
  25869. /**
  25870. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25871. * @param kind defines the data kind (Position, normal, etc...)
  25872. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25873. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25874. * @returns a float array containing vertex data
  25875. */
  25876. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25877. /**
  25878. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25879. * @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.
  25880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25881. * @returns the indices array or an empty array if the mesh has no geometry
  25882. */
  25883. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25884. /**
  25885. * Set specific vertex data
  25886. * @param kind defines the data kind (Position, normal, etc...)
  25887. * @param data defines the vertex data to use
  25888. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25889. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25890. */
  25891. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25892. /**
  25893. * Update a specific associated vertex buffer
  25894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25895. * - VertexBuffer.PositionKind
  25896. * - VertexBuffer.UVKind
  25897. * - VertexBuffer.UV2Kind
  25898. * - VertexBuffer.UV3Kind
  25899. * - VertexBuffer.UV4Kind
  25900. * - VertexBuffer.UV5Kind
  25901. * - VertexBuffer.UV6Kind
  25902. * - VertexBuffer.ColorKind
  25903. * - VertexBuffer.MatricesIndicesKind
  25904. * - VertexBuffer.MatricesIndicesExtraKind
  25905. * - VertexBuffer.MatricesWeightsKind
  25906. * - VertexBuffer.MatricesWeightsExtraKind
  25907. * @param data defines the data source
  25908. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25909. * @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)
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25912. /**
  25913. * Creates a new index buffer
  25914. * @param indices defines the indices to store in the index buffer
  25915. * @param totalVertices defines the total number of vertices (could be null)
  25916. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25917. */
  25918. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25919. }
  25920. /**
  25921. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25922. */
  25923. export class VertexData {
  25924. /**
  25925. * Mesh side orientation : usually the external or front surface
  25926. */
  25927. static readonly FRONTSIDE: number;
  25928. /**
  25929. * Mesh side orientation : usually the internal or back surface
  25930. */
  25931. static readonly BACKSIDE: number;
  25932. /**
  25933. * Mesh side orientation : both internal and external or front and back surfaces
  25934. */
  25935. static readonly DOUBLESIDE: number;
  25936. /**
  25937. * Mesh side orientation : by default, `FRONTSIDE`
  25938. */
  25939. static readonly DEFAULTSIDE: number;
  25940. /**
  25941. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25942. */
  25943. positions: Nullable<FloatArray>;
  25944. /**
  25945. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25946. */
  25947. normals: Nullable<FloatArray>;
  25948. /**
  25949. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25950. */
  25951. tangents: Nullable<FloatArray>;
  25952. /**
  25953. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25954. */
  25955. uvs: Nullable<FloatArray>;
  25956. /**
  25957. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25958. */
  25959. uvs2: Nullable<FloatArray>;
  25960. /**
  25961. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25962. */
  25963. uvs3: Nullable<FloatArray>;
  25964. /**
  25965. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25966. */
  25967. uvs4: Nullable<FloatArray>;
  25968. /**
  25969. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25970. */
  25971. uvs5: Nullable<FloatArray>;
  25972. /**
  25973. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25974. */
  25975. uvs6: Nullable<FloatArray>;
  25976. /**
  25977. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25978. */
  25979. colors: Nullable<FloatArray>;
  25980. /**
  25981. * 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).
  25982. */
  25983. matricesIndices: Nullable<FloatArray>;
  25984. /**
  25985. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25986. */
  25987. matricesWeights: Nullable<FloatArray>;
  25988. /**
  25989. * An array extending the number of possible indices
  25990. */
  25991. matricesIndicesExtra: Nullable<FloatArray>;
  25992. /**
  25993. * An array extending the number of possible weights when the number of indices is extended
  25994. */
  25995. matricesWeightsExtra: Nullable<FloatArray>;
  25996. /**
  25997. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25998. */
  25999. indices: Nullable<IndicesArray>;
  26000. /**
  26001. * Uses the passed data array to set the set the values for the specified kind of data
  26002. * @param data a linear array of floating numbers
  26003. * @param kind the type of data that is being set, eg positions, colors etc
  26004. */
  26005. set(data: FloatArray, kind: string): void;
  26006. /**
  26007. * Associates the vertexData to the passed Mesh.
  26008. * Sets it as updatable or not (default `false`)
  26009. * @param mesh the mesh the vertexData is applied to
  26010. * @param updatable when used and having the value true allows new data to update the vertexData
  26011. * @returns the VertexData
  26012. */
  26013. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26014. /**
  26015. * Associates the vertexData to the passed Geometry.
  26016. * Sets it as updatable or not (default `false`)
  26017. * @param geometry the geometry the vertexData is applied to
  26018. * @param updatable when used and having the value true allows new data to update the vertexData
  26019. * @returns VertexData
  26020. */
  26021. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26022. /**
  26023. * Updates the associated mesh
  26024. * @param mesh the mesh to be updated
  26025. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26026. * @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
  26027. * @returns VertexData
  26028. */
  26029. updateMesh(mesh: Mesh): VertexData;
  26030. /**
  26031. * Updates the associated geometry
  26032. * @param geometry the geometry to be updated
  26033. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26034. * @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
  26035. * @returns VertexData.
  26036. */
  26037. updateGeometry(geometry: Geometry): VertexData;
  26038. private _applyTo;
  26039. private _update;
  26040. /**
  26041. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26042. * @param matrix the transforming matrix
  26043. * @returns the VertexData
  26044. */
  26045. transform(matrix: Matrix): VertexData;
  26046. /**
  26047. * Merges the passed VertexData into the current one
  26048. * @param other the VertexData to be merged into the current one
  26049. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26050. * @returns the modified VertexData
  26051. */
  26052. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26053. private _mergeElement;
  26054. private _validate;
  26055. /**
  26056. * Serializes the VertexData
  26057. * @returns a serialized object
  26058. */
  26059. serialize(): any;
  26060. /**
  26061. * Extracts the vertexData from a mesh
  26062. * @param mesh the mesh from which to extract the VertexData
  26063. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26064. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26065. * @returns the object VertexData associated to the passed mesh
  26066. */
  26067. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26068. /**
  26069. * Extracts the vertexData from the geometry
  26070. * @param geometry the geometry from which to extract the VertexData
  26071. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26072. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26073. * @returns the object VertexData associated to the passed mesh
  26074. */
  26075. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26076. private static _ExtractFrom;
  26077. /**
  26078. * Creates the VertexData for a Ribbon
  26079. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26080. * * pathArray array of paths, each of which an array of successive Vector3
  26081. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26082. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26083. * * 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
  26084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26085. * * 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)
  26086. * * 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)
  26087. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26088. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26089. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26090. * @returns the VertexData of the ribbon
  26091. */
  26092. static CreateRibbon(options: {
  26093. pathArray: Vector3[][];
  26094. closeArray?: boolean;
  26095. closePath?: boolean;
  26096. offset?: number;
  26097. sideOrientation?: number;
  26098. frontUVs?: Vector4;
  26099. backUVs?: Vector4;
  26100. invertUV?: boolean;
  26101. uvs?: Vector2[];
  26102. colors?: Color4[];
  26103. }): VertexData;
  26104. /**
  26105. * Creates the VertexData for a box
  26106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26107. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26108. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26109. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26110. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26111. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26112. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26114. * * 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)
  26115. * * 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)
  26116. * @returns the VertexData of the box
  26117. */
  26118. static CreateBox(options: {
  26119. size?: number;
  26120. width?: number;
  26121. height?: number;
  26122. depth?: number;
  26123. faceUV?: Vector4[];
  26124. faceColors?: Color4[];
  26125. sideOrientation?: number;
  26126. frontUVs?: Vector4;
  26127. backUVs?: Vector4;
  26128. }): VertexData;
  26129. /**
  26130. * Creates the VertexData for a tiled box
  26131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26132. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26133. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26134. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26136. * @returns the VertexData of the box
  26137. */
  26138. static CreateTiledBox(options: {
  26139. pattern?: number;
  26140. width?: number;
  26141. height?: number;
  26142. depth?: number;
  26143. tileSize?: number;
  26144. tileWidth?: number;
  26145. tileHeight?: number;
  26146. alignHorizontal?: number;
  26147. alignVertical?: number;
  26148. faceUV?: Vector4[];
  26149. faceColors?: Color4[];
  26150. sideOrientation?: number;
  26151. }): VertexData;
  26152. /**
  26153. * Creates the VertexData for a tiled plane
  26154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26155. * * pattern a limited pattern arrangement depending on the number
  26156. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26157. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26158. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26160. * * 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)
  26161. * * 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)
  26162. * @returns the VertexData of the tiled plane
  26163. */
  26164. static CreateTiledPlane(options: {
  26165. pattern?: number;
  26166. tileSize?: number;
  26167. tileWidth?: number;
  26168. tileHeight?: number;
  26169. size?: number;
  26170. width?: number;
  26171. height?: number;
  26172. alignHorizontal?: number;
  26173. alignVertical?: number;
  26174. sideOrientation?: number;
  26175. frontUVs?: Vector4;
  26176. backUVs?: Vector4;
  26177. }): VertexData;
  26178. /**
  26179. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26181. * * segments sets the number of horizontal strips optional, default 32
  26182. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26183. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26184. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26185. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26186. * * 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
  26187. * * 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
  26188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26189. * * 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)
  26190. * * 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)
  26191. * @returns the VertexData of the ellipsoid
  26192. */
  26193. static CreateSphere(options: {
  26194. segments?: number;
  26195. diameter?: number;
  26196. diameterX?: number;
  26197. diameterY?: number;
  26198. diameterZ?: number;
  26199. arc?: number;
  26200. slice?: number;
  26201. sideOrientation?: number;
  26202. frontUVs?: Vector4;
  26203. backUVs?: Vector4;
  26204. }): VertexData;
  26205. /**
  26206. * Creates the VertexData for a cylinder, cone or prism
  26207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26208. * * height sets the height (y direction) of the cylinder, optional, default 2
  26209. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26210. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26211. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26212. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26213. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26214. * * 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
  26215. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26216. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26217. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26218. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26220. * * 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)
  26221. * * 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)
  26222. * @returns the VertexData of the cylinder, cone or prism
  26223. */
  26224. static CreateCylinder(options: {
  26225. height?: number;
  26226. diameterTop?: number;
  26227. diameterBottom?: number;
  26228. diameter?: number;
  26229. tessellation?: number;
  26230. subdivisions?: number;
  26231. arc?: number;
  26232. faceColors?: Color4[];
  26233. faceUV?: Vector4[];
  26234. hasRings?: boolean;
  26235. enclose?: boolean;
  26236. sideOrientation?: number;
  26237. frontUVs?: Vector4;
  26238. backUVs?: Vector4;
  26239. }): VertexData;
  26240. /**
  26241. * Creates the VertexData for a torus
  26242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26243. * * diameter the diameter of the torus, optional default 1
  26244. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26245. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26247. * * 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)
  26248. * * 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)
  26249. * @returns the VertexData of the torus
  26250. */
  26251. static CreateTorus(options: {
  26252. diameter?: number;
  26253. thickness?: number;
  26254. tessellation?: number;
  26255. sideOrientation?: number;
  26256. frontUVs?: Vector4;
  26257. backUVs?: Vector4;
  26258. }): VertexData;
  26259. /**
  26260. * Creates the VertexData of the LineSystem
  26261. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26262. * - lines an array of lines, each line being an array of successive Vector3
  26263. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26264. * @returns the VertexData of the LineSystem
  26265. */
  26266. static CreateLineSystem(options: {
  26267. lines: Vector3[][];
  26268. colors?: Nullable<Color4[][]>;
  26269. }): VertexData;
  26270. /**
  26271. * Create the VertexData for a DashedLines
  26272. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26273. * - points an array successive Vector3
  26274. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26275. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26276. * - dashNb the intended total number of dashes, optional, default 200
  26277. * @returns the VertexData for the DashedLines
  26278. */
  26279. static CreateDashedLines(options: {
  26280. points: Vector3[];
  26281. dashSize?: number;
  26282. gapSize?: number;
  26283. dashNb?: number;
  26284. }): VertexData;
  26285. /**
  26286. * Creates the VertexData for a Ground
  26287. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26288. * - width the width (x direction) of the ground, optional, default 1
  26289. * - height the height (z direction) of the ground, optional, default 1
  26290. * - subdivisions the number of subdivisions per side, optional, default 1
  26291. * @returns the VertexData of the Ground
  26292. */
  26293. static CreateGround(options: {
  26294. width?: number;
  26295. height?: number;
  26296. subdivisions?: number;
  26297. subdivisionsX?: number;
  26298. subdivisionsY?: number;
  26299. }): VertexData;
  26300. /**
  26301. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26303. * * xmin the ground minimum X coordinate, optional, default -1
  26304. * * zmin the ground minimum Z coordinate, optional, default -1
  26305. * * xmax the ground maximum X coordinate, optional, default 1
  26306. * * zmax the ground maximum Z coordinate, optional, default 1
  26307. * * 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}
  26308. * * 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}
  26309. * @returns the VertexData of the TiledGround
  26310. */
  26311. static CreateTiledGround(options: {
  26312. xmin: number;
  26313. zmin: number;
  26314. xmax: number;
  26315. zmax: number;
  26316. subdivisions?: {
  26317. w: number;
  26318. h: number;
  26319. };
  26320. precision?: {
  26321. w: number;
  26322. h: number;
  26323. };
  26324. }): VertexData;
  26325. /**
  26326. * Creates the VertexData of the Ground designed from a heightmap
  26327. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26328. * * width the width (x direction) of the ground
  26329. * * height the height (z direction) of the ground
  26330. * * subdivisions the number of subdivisions per side
  26331. * * minHeight the minimum altitude on the ground, optional, default 0
  26332. * * maxHeight the maximum altitude on the ground, optional default 1
  26333. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26334. * * buffer the array holding the image color data
  26335. * * bufferWidth the width of image
  26336. * * bufferHeight the height of image
  26337. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26338. * @returns the VertexData of the Ground designed from a heightmap
  26339. */
  26340. static CreateGroundFromHeightMap(options: {
  26341. width: number;
  26342. height: number;
  26343. subdivisions: number;
  26344. minHeight: number;
  26345. maxHeight: number;
  26346. colorFilter: Color3;
  26347. buffer: Uint8Array;
  26348. bufferWidth: number;
  26349. bufferHeight: number;
  26350. alphaFilter: number;
  26351. }): VertexData;
  26352. /**
  26353. * Creates the VertexData for a Plane
  26354. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26355. * * size sets the width and height of the plane to the value of size, optional default 1
  26356. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26357. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26359. * * 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)
  26360. * * 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)
  26361. * @returns the VertexData of the box
  26362. */
  26363. static CreatePlane(options: {
  26364. size?: number;
  26365. width?: number;
  26366. height?: number;
  26367. sideOrientation?: number;
  26368. frontUVs?: Vector4;
  26369. backUVs?: Vector4;
  26370. }): VertexData;
  26371. /**
  26372. * Creates the VertexData of the Disc or regular Polygon
  26373. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26374. * * radius the radius of the disc, optional default 0.5
  26375. * * tessellation the number of polygon sides, optional, default 64
  26376. * * 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
  26377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26378. * * 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)
  26379. * * 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)
  26380. * @returns the VertexData of the box
  26381. */
  26382. static CreateDisc(options: {
  26383. radius?: number;
  26384. tessellation?: number;
  26385. arc?: number;
  26386. sideOrientation?: number;
  26387. frontUVs?: Vector4;
  26388. backUVs?: Vector4;
  26389. }): VertexData;
  26390. /**
  26391. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26392. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26393. * @param polygon a mesh built from polygonTriangulation.build()
  26394. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26395. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26396. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26397. * @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)
  26398. * @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)
  26399. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26400. * @returns the VertexData of the Polygon
  26401. */
  26402. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26403. /**
  26404. * Creates the VertexData of the IcoSphere
  26405. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26406. * * radius the radius of the IcoSphere, optional default 1
  26407. * * radiusX allows stretching in the x direction, optional, default radius
  26408. * * radiusY allows stretching in the y direction, optional, default radius
  26409. * * radiusZ allows stretching in the z direction, optional, default radius
  26410. * * flat when true creates a flat shaded mesh, optional, default true
  26411. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26413. * * 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)
  26414. * * 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)
  26415. * @returns the VertexData of the IcoSphere
  26416. */
  26417. static CreateIcoSphere(options: {
  26418. radius?: number;
  26419. radiusX?: number;
  26420. radiusY?: number;
  26421. radiusZ?: number;
  26422. flat?: boolean;
  26423. subdivisions?: number;
  26424. sideOrientation?: number;
  26425. frontUVs?: Vector4;
  26426. backUVs?: Vector4;
  26427. }): VertexData;
  26428. /**
  26429. * Creates the VertexData for a Polyhedron
  26430. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26431. * * type provided types are:
  26432. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26433. * * 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)
  26434. * * size the size of the IcoSphere, optional default 1
  26435. * * sizeX allows stretching in the x direction, optional, default size
  26436. * * sizeY allows stretching in the y direction, optional, default size
  26437. * * sizeZ allows stretching in the z direction, optional, default size
  26438. * * 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
  26439. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26440. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26441. * * flat when true creates a flat shaded mesh, optional, default true
  26442. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26444. * * 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)
  26445. * * 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)
  26446. * @returns the VertexData of the Polyhedron
  26447. */
  26448. static CreatePolyhedron(options: {
  26449. type?: number;
  26450. size?: number;
  26451. sizeX?: number;
  26452. sizeY?: number;
  26453. sizeZ?: number;
  26454. custom?: any;
  26455. faceUV?: Vector4[];
  26456. faceColors?: Color4[];
  26457. flat?: boolean;
  26458. sideOrientation?: number;
  26459. frontUVs?: Vector4;
  26460. backUVs?: Vector4;
  26461. }): VertexData;
  26462. /**
  26463. * Creates the VertexData for a TorusKnot
  26464. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26465. * * radius the radius of the torus knot, optional, default 2
  26466. * * tube the thickness of the tube, optional, default 0.5
  26467. * * radialSegments the number of sides on each tube segments, optional, default 32
  26468. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26469. * * p the number of windings around the z axis, optional, default 2
  26470. * * q the number of windings around the x axis, optional, default 3
  26471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26472. * * 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)
  26473. * * 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)
  26474. * @returns the VertexData of the Torus Knot
  26475. */
  26476. static CreateTorusKnot(options: {
  26477. radius?: number;
  26478. tube?: number;
  26479. radialSegments?: number;
  26480. tubularSegments?: number;
  26481. p?: number;
  26482. q?: number;
  26483. sideOrientation?: number;
  26484. frontUVs?: Vector4;
  26485. backUVs?: Vector4;
  26486. }): VertexData;
  26487. /**
  26488. * Compute normals for given positions and indices
  26489. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26490. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26491. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26492. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26493. * * facetNormals : optional array of facet normals (vector3)
  26494. * * facetPositions : optional array of facet positions (vector3)
  26495. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26496. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26497. * * bInfo : optional bounding info, required for facetPartitioning computation
  26498. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26499. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26500. * * useRightHandedSystem: optional boolean to for right handed system computation
  26501. * * depthSort : optional boolean to enable the facet depth sort computation
  26502. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26503. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26504. */
  26505. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26506. facetNormals?: any;
  26507. facetPositions?: any;
  26508. facetPartitioning?: any;
  26509. ratio?: number;
  26510. bInfo?: any;
  26511. bbSize?: Vector3;
  26512. subDiv?: any;
  26513. useRightHandedSystem?: boolean;
  26514. depthSort?: boolean;
  26515. distanceTo?: Vector3;
  26516. depthSortedFacets?: any;
  26517. }): void;
  26518. /** @hidden */
  26519. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26520. /**
  26521. * Applies VertexData created from the imported parameters to the geometry
  26522. * @param parsedVertexData the parsed data from an imported file
  26523. * @param geometry the geometry to apply the VertexData to
  26524. */
  26525. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26526. }
  26527. }
  26528. declare module BABYLON {
  26529. /**
  26530. * Defines a target to use with MorphTargetManager
  26531. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26532. */
  26533. export class MorphTarget implements IAnimatable {
  26534. /** defines the name of the target */
  26535. name: string;
  26536. /**
  26537. * Gets or sets the list of animations
  26538. */
  26539. animations: Animation[];
  26540. private _scene;
  26541. private _positions;
  26542. private _normals;
  26543. private _tangents;
  26544. private _uvs;
  26545. private _influence;
  26546. private _uniqueId;
  26547. /**
  26548. * Observable raised when the influence changes
  26549. */
  26550. onInfluenceChanged: Observable<boolean>;
  26551. /** @hidden */
  26552. _onDataLayoutChanged: Observable<void>;
  26553. /**
  26554. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26555. */
  26556. get influence(): number;
  26557. set influence(influence: number);
  26558. /**
  26559. * Gets or sets the id of the morph Target
  26560. */
  26561. id: string;
  26562. private _animationPropertiesOverride;
  26563. /**
  26564. * Gets or sets the animation properties override
  26565. */
  26566. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26567. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26568. /**
  26569. * Creates a new MorphTarget
  26570. * @param name defines the name of the target
  26571. * @param influence defines the influence to use
  26572. * @param scene defines the scene the morphtarget belongs to
  26573. */
  26574. constructor(
  26575. /** defines the name of the target */
  26576. name: string, influence?: number, scene?: Nullable<Scene>);
  26577. /**
  26578. * Gets the unique ID of this manager
  26579. */
  26580. get uniqueId(): number;
  26581. /**
  26582. * Gets a boolean defining if the target contains position data
  26583. */
  26584. get hasPositions(): boolean;
  26585. /**
  26586. * Gets a boolean defining if the target contains normal data
  26587. */
  26588. get hasNormals(): boolean;
  26589. /**
  26590. * Gets a boolean defining if the target contains tangent data
  26591. */
  26592. get hasTangents(): boolean;
  26593. /**
  26594. * Gets a boolean defining if the target contains texture coordinates data
  26595. */
  26596. get hasUVs(): boolean;
  26597. /**
  26598. * Affects position data to this target
  26599. * @param data defines the position data to use
  26600. */
  26601. setPositions(data: Nullable<FloatArray>): void;
  26602. /**
  26603. * Gets the position data stored in this target
  26604. * @returns a FloatArray containing the position data (or null if not present)
  26605. */
  26606. getPositions(): Nullable<FloatArray>;
  26607. /**
  26608. * Affects normal data to this target
  26609. * @param data defines the normal data to use
  26610. */
  26611. setNormals(data: Nullable<FloatArray>): void;
  26612. /**
  26613. * Gets the normal data stored in this target
  26614. * @returns a FloatArray containing the normal data (or null if not present)
  26615. */
  26616. getNormals(): Nullable<FloatArray>;
  26617. /**
  26618. * Affects tangent data to this target
  26619. * @param data defines the tangent data to use
  26620. */
  26621. setTangents(data: Nullable<FloatArray>): void;
  26622. /**
  26623. * Gets the tangent data stored in this target
  26624. * @returns a FloatArray containing the tangent data (or null if not present)
  26625. */
  26626. getTangents(): Nullable<FloatArray>;
  26627. /**
  26628. * Affects texture coordinates data to this target
  26629. * @param data defines the texture coordinates data to use
  26630. */
  26631. setUVs(data: Nullable<FloatArray>): void;
  26632. /**
  26633. * Gets the texture coordinates data stored in this target
  26634. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26635. */
  26636. getUVs(): Nullable<FloatArray>;
  26637. /**
  26638. * Clone the current target
  26639. * @returns a new MorphTarget
  26640. */
  26641. clone(): MorphTarget;
  26642. /**
  26643. * Serializes the current target into a Serialization object
  26644. * @returns the serialized object
  26645. */
  26646. serialize(): any;
  26647. /**
  26648. * Returns the string "MorphTarget"
  26649. * @returns "MorphTarget"
  26650. */
  26651. getClassName(): string;
  26652. /**
  26653. * Creates a new target from serialized data
  26654. * @param serializationObject defines the serialized data to use
  26655. * @returns a new MorphTarget
  26656. */
  26657. static Parse(serializationObject: any): MorphTarget;
  26658. /**
  26659. * Creates a MorphTarget from mesh data
  26660. * @param mesh defines the source mesh
  26661. * @param name defines the name to use for the new target
  26662. * @param influence defines the influence to attach to the target
  26663. * @returns a new MorphTarget
  26664. */
  26665. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26666. }
  26667. }
  26668. declare module BABYLON {
  26669. /**
  26670. * This class is used to deform meshes using morphing between different targets
  26671. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26672. */
  26673. export class MorphTargetManager {
  26674. private _targets;
  26675. private _targetInfluenceChangedObservers;
  26676. private _targetDataLayoutChangedObservers;
  26677. private _activeTargets;
  26678. private _scene;
  26679. private _influences;
  26680. private _supportsNormals;
  26681. private _supportsTangents;
  26682. private _supportsUVs;
  26683. private _vertexCount;
  26684. private _uniqueId;
  26685. private _tempInfluences;
  26686. /**
  26687. * Gets or sets a boolean indicating if normals must be morphed
  26688. */
  26689. enableNormalMorphing: boolean;
  26690. /**
  26691. * Gets or sets a boolean indicating if tangents must be morphed
  26692. */
  26693. enableTangentMorphing: boolean;
  26694. /**
  26695. * Gets or sets a boolean indicating if UV must be morphed
  26696. */
  26697. enableUVMorphing: boolean;
  26698. /**
  26699. * Creates a new MorphTargetManager
  26700. * @param scene defines the current scene
  26701. */
  26702. constructor(scene?: Nullable<Scene>);
  26703. /**
  26704. * Gets the unique ID of this manager
  26705. */
  26706. get uniqueId(): number;
  26707. /**
  26708. * Gets the number of vertices handled by this manager
  26709. */
  26710. get vertexCount(): number;
  26711. /**
  26712. * Gets a boolean indicating if this manager supports morphing of normals
  26713. */
  26714. get supportsNormals(): boolean;
  26715. /**
  26716. * Gets a boolean indicating if this manager supports morphing of tangents
  26717. */
  26718. get supportsTangents(): boolean;
  26719. /**
  26720. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26721. */
  26722. get supportsUVs(): boolean;
  26723. /**
  26724. * Gets the number of targets stored in this manager
  26725. */
  26726. get numTargets(): number;
  26727. /**
  26728. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26729. */
  26730. get numInfluencers(): number;
  26731. /**
  26732. * Gets the list of influences (one per target)
  26733. */
  26734. get influences(): Float32Array;
  26735. /**
  26736. * Gets the active target at specified index. An active target is a target with an influence > 0
  26737. * @param index defines the index to check
  26738. * @returns the requested target
  26739. */
  26740. getActiveTarget(index: number): MorphTarget;
  26741. /**
  26742. * Gets the target at specified index
  26743. * @param index defines the index to check
  26744. * @returns the requested target
  26745. */
  26746. getTarget(index: number): MorphTarget;
  26747. /**
  26748. * Add a new target to this manager
  26749. * @param target defines the target to add
  26750. */
  26751. addTarget(target: MorphTarget): void;
  26752. /**
  26753. * Removes a target from the manager
  26754. * @param target defines the target to remove
  26755. */
  26756. removeTarget(target: MorphTarget): void;
  26757. /**
  26758. * Clone the current manager
  26759. * @returns a new MorphTargetManager
  26760. */
  26761. clone(): MorphTargetManager;
  26762. /**
  26763. * Serializes the current manager into a Serialization object
  26764. * @returns the serialized object
  26765. */
  26766. serialize(): any;
  26767. private _syncActiveTargets;
  26768. /**
  26769. * Syncrhonize the targets with all the meshes using this morph target manager
  26770. */
  26771. synchronize(): void;
  26772. /**
  26773. * Creates a new MorphTargetManager from serialized data
  26774. * @param serializationObject defines the serialized data
  26775. * @param scene defines the hosting scene
  26776. * @returns the new MorphTargetManager
  26777. */
  26778. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26779. }
  26780. }
  26781. declare module BABYLON {
  26782. /**
  26783. * Class used to represent a specific level of detail of a mesh
  26784. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26785. */
  26786. export class MeshLODLevel {
  26787. /** Defines the distance where this level should start being displayed */
  26788. distance: number;
  26789. /** Defines the mesh to use to render this level */
  26790. mesh: Nullable<Mesh>;
  26791. /**
  26792. * Creates a new LOD level
  26793. * @param distance defines the distance where this level should star being displayed
  26794. * @param mesh defines the mesh to use to render this level
  26795. */
  26796. constructor(
  26797. /** Defines the distance where this level should start being displayed */
  26798. distance: number,
  26799. /** Defines the mesh to use to render this level */
  26800. mesh: Nullable<Mesh>);
  26801. }
  26802. }
  26803. declare module BABYLON {
  26804. /**
  26805. * Helper class used to generate a canvas to manipulate images
  26806. */
  26807. export class CanvasGenerator {
  26808. /**
  26809. * Create a new canvas (or offscreen canvas depending on the context)
  26810. * @param width defines the expected width
  26811. * @param height defines the expected height
  26812. * @return a new canvas or offscreen canvas
  26813. */
  26814. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26815. }
  26816. }
  26817. declare module BABYLON {
  26818. /**
  26819. * Mesh representing the gorund
  26820. */
  26821. export class GroundMesh extends Mesh {
  26822. /** If octree should be generated */
  26823. generateOctree: boolean;
  26824. private _heightQuads;
  26825. /** @hidden */
  26826. _subdivisionsX: number;
  26827. /** @hidden */
  26828. _subdivisionsY: number;
  26829. /** @hidden */
  26830. _width: number;
  26831. /** @hidden */
  26832. _height: number;
  26833. /** @hidden */
  26834. _minX: number;
  26835. /** @hidden */
  26836. _maxX: number;
  26837. /** @hidden */
  26838. _minZ: number;
  26839. /** @hidden */
  26840. _maxZ: number;
  26841. constructor(name: string, scene: Scene);
  26842. /**
  26843. * "GroundMesh"
  26844. * @returns "GroundMesh"
  26845. */
  26846. getClassName(): string;
  26847. /**
  26848. * The minimum of x and y subdivisions
  26849. */
  26850. get subdivisions(): number;
  26851. /**
  26852. * X subdivisions
  26853. */
  26854. get subdivisionsX(): number;
  26855. /**
  26856. * Y subdivisions
  26857. */
  26858. get subdivisionsY(): number;
  26859. /**
  26860. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26861. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26862. * @param chunksCount the number of subdivisions for x and y
  26863. * @param octreeBlocksSize (Default: 32)
  26864. */
  26865. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26866. /**
  26867. * Returns a height (y) value in the Worl system :
  26868. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26869. * @param x x coordinate
  26870. * @param z z coordinate
  26871. * @returns the ground y position if (x, z) are outside the ground surface.
  26872. */
  26873. getHeightAtCoordinates(x: number, z: number): number;
  26874. /**
  26875. * Returns a normalized vector (Vector3) orthogonal to the ground
  26876. * at the ground coordinates (x, z) expressed in the World system.
  26877. * @param x x coordinate
  26878. * @param z z coordinate
  26879. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26880. */
  26881. getNormalAtCoordinates(x: number, z: number): Vector3;
  26882. /**
  26883. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26884. * at the ground coordinates (x, z) expressed in the World system.
  26885. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26886. * @param x x coordinate
  26887. * @param z z coordinate
  26888. * @param ref vector to store the result
  26889. * @returns the GroundMesh.
  26890. */
  26891. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26892. /**
  26893. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26894. * if the ground has been updated.
  26895. * This can be used in the render loop.
  26896. * @returns the GroundMesh.
  26897. */
  26898. updateCoordinateHeights(): GroundMesh;
  26899. private _getFacetAt;
  26900. private _initHeightQuads;
  26901. private _computeHeightQuads;
  26902. /**
  26903. * Serializes this ground mesh
  26904. * @param serializationObject object to write serialization to
  26905. */
  26906. serialize(serializationObject: any): void;
  26907. /**
  26908. * Parses a serialized ground mesh
  26909. * @param parsedMesh the serialized mesh
  26910. * @param scene the scene to create the ground mesh in
  26911. * @returns the created ground mesh
  26912. */
  26913. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26914. }
  26915. }
  26916. declare module BABYLON {
  26917. /**
  26918. * Interface for Physics-Joint data
  26919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26920. */
  26921. export interface PhysicsJointData {
  26922. /**
  26923. * The main pivot of the joint
  26924. */
  26925. mainPivot?: Vector3;
  26926. /**
  26927. * The connected pivot of the joint
  26928. */
  26929. connectedPivot?: Vector3;
  26930. /**
  26931. * The main axis of the joint
  26932. */
  26933. mainAxis?: Vector3;
  26934. /**
  26935. * The connected axis of the joint
  26936. */
  26937. connectedAxis?: Vector3;
  26938. /**
  26939. * The collision of the joint
  26940. */
  26941. collision?: boolean;
  26942. /**
  26943. * Native Oimo/Cannon/Energy data
  26944. */
  26945. nativeParams?: any;
  26946. }
  26947. /**
  26948. * This is a holder class for the physics joint created by the physics plugin
  26949. * It holds a set of functions to control the underlying joint
  26950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26951. */
  26952. export class PhysicsJoint {
  26953. /**
  26954. * The type of the physics joint
  26955. */
  26956. type: number;
  26957. /**
  26958. * The data for the physics joint
  26959. */
  26960. jointData: PhysicsJointData;
  26961. private _physicsJoint;
  26962. protected _physicsPlugin: IPhysicsEnginePlugin;
  26963. /**
  26964. * Initializes the physics joint
  26965. * @param type The type of the physics joint
  26966. * @param jointData The data for the physics joint
  26967. */
  26968. constructor(
  26969. /**
  26970. * The type of the physics joint
  26971. */
  26972. type: number,
  26973. /**
  26974. * The data for the physics joint
  26975. */
  26976. jointData: PhysicsJointData);
  26977. /**
  26978. * Gets the physics joint
  26979. */
  26980. get physicsJoint(): any;
  26981. /**
  26982. * Sets the physics joint
  26983. */
  26984. set physicsJoint(newJoint: any);
  26985. /**
  26986. * Sets the physics plugin
  26987. */
  26988. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26989. /**
  26990. * Execute a function that is physics-plugin specific.
  26991. * @param {Function} func the function that will be executed.
  26992. * It accepts two parameters: the physics world and the physics joint
  26993. */
  26994. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26995. /**
  26996. * Distance-Joint type
  26997. */
  26998. static DistanceJoint: number;
  26999. /**
  27000. * Hinge-Joint type
  27001. */
  27002. static HingeJoint: number;
  27003. /**
  27004. * Ball-and-Socket joint type
  27005. */
  27006. static BallAndSocketJoint: number;
  27007. /**
  27008. * Wheel-Joint type
  27009. */
  27010. static WheelJoint: number;
  27011. /**
  27012. * Slider-Joint type
  27013. */
  27014. static SliderJoint: number;
  27015. /**
  27016. * Prismatic-Joint type
  27017. */
  27018. static PrismaticJoint: number;
  27019. /**
  27020. * Universal-Joint type
  27021. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27022. */
  27023. static UniversalJoint: number;
  27024. /**
  27025. * Hinge-Joint 2 type
  27026. */
  27027. static Hinge2Joint: number;
  27028. /**
  27029. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27030. */
  27031. static PointToPointJoint: number;
  27032. /**
  27033. * Spring-Joint type
  27034. */
  27035. static SpringJoint: number;
  27036. /**
  27037. * Lock-Joint type
  27038. */
  27039. static LockJoint: number;
  27040. }
  27041. /**
  27042. * A class representing a physics distance joint
  27043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27044. */
  27045. export class DistanceJoint extends PhysicsJoint {
  27046. /**
  27047. *
  27048. * @param jointData The data for the Distance-Joint
  27049. */
  27050. constructor(jointData: DistanceJointData);
  27051. /**
  27052. * Update the predefined distance.
  27053. * @param maxDistance The maximum preferred distance
  27054. * @param minDistance The minimum preferred distance
  27055. */
  27056. updateDistance(maxDistance: number, minDistance?: number): void;
  27057. }
  27058. /**
  27059. * Represents a Motor-Enabled Joint
  27060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27061. */
  27062. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27063. /**
  27064. * Initializes the Motor-Enabled Joint
  27065. * @param type The type of the joint
  27066. * @param jointData The physica joint data for the joint
  27067. */
  27068. constructor(type: number, jointData: PhysicsJointData);
  27069. /**
  27070. * Set the motor values.
  27071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27072. * @param force the force to apply
  27073. * @param maxForce max force for this motor.
  27074. */
  27075. setMotor(force?: number, maxForce?: number): void;
  27076. /**
  27077. * Set the motor's limits.
  27078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27079. * @param upperLimit The upper limit of the motor
  27080. * @param lowerLimit The lower limit of the motor
  27081. */
  27082. setLimit(upperLimit: number, lowerLimit?: number): void;
  27083. }
  27084. /**
  27085. * This class represents a single physics Hinge-Joint
  27086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27087. */
  27088. export class HingeJoint extends MotorEnabledJoint {
  27089. /**
  27090. * Initializes the Hinge-Joint
  27091. * @param jointData The joint data for the Hinge-Joint
  27092. */
  27093. constructor(jointData: PhysicsJointData);
  27094. /**
  27095. * Set the motor values.
  27096. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27097. * @param {number} force the force to apply
  27098. * @param {number} maxForce max force for this motor.
  27099. */
  27100. setMotor(force?: number, maxForce?: number): void;
  27101. /**
  27102. * Set the motor's limits.
  27103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27104. * @param upperLimit The upper limit of the motor
  27105. * @param lowerLimit The lower limit of the motor
  27106. */
  27107. setLimit(upperLimit: number, lowerLimit?: number): void;
  27108. }
  27109. /**
  27110. * This class represents a dual hinge physics joint (same as wheel joint)
  27111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27112. */
  27113. export class Hinge2Joint extends MotorEnabledJoint {
  27114. /**
  27115. * Initializes the Hinge2-Joint
  27116. * @param jointData The joint data for the Hinge2-Joint
  27117. */
  27118. constructor(jointData: PhysicsJointData);
  27119. /**
  27120. * Set the motor values.
  27121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27122. * @param {number} targetSpeed the speed the motor is to reach
  27123. * @param {number} maxForce max force for this motor.
  27124. * @param {motorIndex} the motor's index, 0 or 1.
  27125. */
  27126. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27127. /**
  27128. * Set the motor limits.
  27129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27130. * @param {number} upperLimit the upper limit
  27131. * @param {number} lowerLimit lower limit
  27132. * @param {motorIndex} the motor's index, 0 or 1.
  27133. */
  27134. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27135. }
  27136. /**
  27137. * Interface for a motor enabled joint
  27138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27139. */
  27140. export interface IMotorEnabledJoint {
  27141. /**
  27142. * Physics joint
  27143. */
  27144. physicsJoint: any;
  27145. /**
  27146. * Sets the motor of the motor-enabled joint
  27147. * @param force The force of the motor
  27148. * @param maxForce The maximum force of the motor
  27149. * @param motorIndex The index of the motor
  27150. */
  27151. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27152. /**
  27153. * Sets the limit of the motor
  27154. * @param upperLimit The upper limit of the motor
  27155. * @param lowerLimit The lower limit of the motor
  27156. * @param motorIndex The index of the motor
  27157. */
  27158. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27159. }
  27160. /**
  27161. * Joint data for a Distance-Joint
  27162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27163. */
  27164. export interface DistanceJointData extends PhysicsJointData {
  27165. /**
  27166. * Max distance the 2 joint objects can be apart
  27167. */
  27168. maxDistance: number;
  27169. }
  27170. /**
  27171. * Joint data from a spring joint
  27172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27173. */
  27174. export interface SpringJointData extends PhysicsJointData {
  27175. /**
  27176. * Length of the spring
  27177. */
  27178. length: number;
  27179. /**
  27180. * Stiffness of the spring
  27181. */
  27182. stiffness: number;
  27183. /**
  27184. * Damping of the spring
  27185. */
  27186. damping: number;
  27187. /** this callback will be called when applying the force to the impostors. */
  27188. forceApplicationCallback: () => void;
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /**
  27193. * Holds the data for the raycast result
  27194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27195. */
  27196. export class PhysicsRaycastResult {
  27197. private _hasHit;
  27198. private _hitDistance;
  27199. private _hitNormalWorld;
  27200. private _hitPointWorld;
  27201. private _rayFromWorld;
  27202. private _rayToWorld;
  27203. /**
  27204. * Gets if there was a hit
  27205. */
  27206. get hasHit(): boolean;
  27207. /**
  27208. * Gets the distance from the hit
  27209. */
  27210. get hitDistance(): number;
  27211. /**
  27212. * Gets the hit normal/direction in the world
  27213. */
  27214. get hitNormalWorld(): Vector3;
  27215. /**
  27216. * Gets the hit point in the world
  27217. */
  27218. get hitPointWorld(): Vector3;
  27219. /**
  27220. * Gets the ray "start point" of the ray in the world
  27221. */
  27222. get rayFromWorld(): Vector3;
  27223. /**
  27224. * Gets the ray "end point" of the ray in the world
  27225. */
  27226. get rayToWorld(): Vector3;
  27227. /**
  27228. * Sets the hit data (normal & point in world space)
  27229. * @param hitNormalWorld defines the normal in world space
  27230. * @param hitPointWorld defines the point in world space
  27231. */
  27232. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27233. /**
  27234. * Sets the distance from the start point to the hit point
  27235. * @param distance
  27236. */
  27237. setHitDistance(distance: number): void;
  27238. /**
  27239. * Calculates the distance manually
  27240. */
  27241. calculateHitDistance(): void;
  27242. /**
  27243. * Resets all the values to default
  27244. * @param from The from point on world space
  27245. * @param to The to point on world space
  27246. */
  27247. reset(from?: Vector3, to?: Vector3): void;
  27248. }
  27249. /**
  27250. * Interface for the size containing width and height
  27251. */
  27252. interface IXYZ {
  27253. /**
  27254. * X
  27255. */
  27256. x: number;
  27257. /**
  27258. * Y
  27259. */
  27260. y: number;
  27261. /**
  27262. * Z
  27263. */
  27264. z: number;
  27265. }
  27266. }
  27267. declare module BABYLON {
  27268. /**
  27269. * Interface used to describe a physics joint
  27270. */
  27271. export interface PhysicsImpostorJoint {
  27272. /** Defines the main impostor to which the joint is linked */
  27273. mainImpostor: PhysicsImpostor;
  27274. /** Defines the impostor that is connected to the main impostor using this joint */
  27275. connectedImpostor: PhysicsImpostor;
  27276. /** Defines the joint itself */
  27277. joint: PhysicsJoint;
  27278. }
  27279. /** @hidden */
  27280. export interface IPhysicsEnginePlugin {
  27281. world: any;
  27282. name: string;
  27283. setGravity(gravity: Vector3): void;
  27284. setTimeStep(timeStep: number): void;
  27285. getTimeStep(): number;
  27286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27290. removePhysicsBody(impostor: PhysicsImpostor): void;
  27291. generateJoint(joint: PhysicsImpostorJoint): void;
  27292. removeJoint(joint: PhysicsImpostorJoint): void;
  27293. isSupported(): boolean;
  27294. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27296. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27299. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27301. getBodyMass(impostor: PhysicsImpostor): number;
  27302. getBodyFriction(impostor: PhysicsImpostor): number;
  27303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27304. getBodyRestitution(impostor: PhysicsImpostor): number;
  27305. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27306. getBodyPressure?(impostor: PhysicsImpostor): number;
  27307. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27308. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27309. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27310. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27311. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27312. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27313. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27314. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27315. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27316. sleepBody(impostor: PhysicsImpostor): void;
  27317. wakeUpBody(impostor: PhysicsImpostor): void;
  27318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27319. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27320. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27321. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27322. getRadius(impostor: PhysicsImpostor): number;
  27323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27324. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27325. dispose(): void;
  27326. }
  27327. /**
  27328. * Interface used to define a physics engine
  27329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27330. */
  27331. export interface IPhysicsEngine {
  27332. /**
  27333. * Gets the gravity vector used by the simulation
  27334. */
  27335. gravity: Vector3;
  27336. /**
  27337. * Sets the gravity vector used by the simulation
  27338. * @param gravity defines the gravity vector to use
  27339. */
  27340. setGravity(gravity: Vector3): void;
  27341. /**
  27342. * Set the time step of the physics engine.
  27343. * Default is 1/60.
  27344. * To slow it down, enter 1/600 for example.
  27345. * To speed it up, 1/30
  27346. * @param newTimeStep the new timestep to apply to this world.
  27347. */
  27348. setTimeStep(newTimeStep: number): void;
  27349. /**
  27350. * Get the time step of the physics engine.
  27351. * @returns the current time step
  27352. */
  27353. getTimeStep(): number;
  27354. /**
  27355. * Set the sub time step of the physics engine.
  27356. * Default is 0 meaning there is no sub steps
  27357. * To increase physics resolution precision, set a small value (like 1 ms)
  27358. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27359. */
  27360. setSubTimeStep(subTimeStep: number): void;
  27361. /**
  27362. * Get the sub time step of the physics engine.
  27363. * @returns the current sub time step
  27364. */
  27365. getSubTimeStep(): number;
  27366. /**
  27367. * Release all resources
  27368. */
  27369. dispose(): void;
  27370. /**
  27371. * Gets the name of the current physics plugin
  27372. * @returns the name of the plugin
  27373. */
  27374. getPhysicsPluginName(): string;
  27375. /**
  27376. * Adding a new impostor for the impostor tracking.
  27377. * This will be done by the impostor itself.
  27378. * @param impostor the impostor to add
  27379. */
  27380. addImpostor(impostor: PhysicsImpostor): void;
  27381. /**
  27382. * Remove an impostor from the engine.
  27383. * This impostor and its mesh will not longer be updated by the physics engine.
  27384. * @param impostor the impostor to remove
  27385. */
  27386. removeImpostor(impostor: PhysicsImpostor): void;
  27387. /**
  27388. * Add a joint to the physics engine
  27389. * @param mainImpostor defines the main impostor to which the joint is added.
  27390. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27391. * @param joint defines the joint that will connect both impostors.
  27392. */
  27393. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27394. /**
  27395. * Removes a joint from the simulation
  27396. * @param mainImpostor defines the impostor used with the joint
  27397. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27398. * @param joint defines the joint to remove
  27399. */
  27400. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27401. /**
  27402. * Gets the current plugin used to run the simulation
  27403. * @returns current plugin
  27404. */
  27405. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27406. /**
  27407. * Gets the list of physic impostors
  27408. * @returns an array of PhysicsImpostor
  27409. */
  27410. getImpostors(): Array<PhysicsImpostor>;
  27411. /**
  27412. * Gets the impostor for a physics enabled object
  27413. * @param object defines the object impersonated by the impostor
  27414. * @returns the PhysicsImpostor or null if not found
  27415. */
  27416. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27417. /**
  27418. * Gets the impostor for a physics body object
  27419. * @param body defines physics body used by the impostor
  27420. * @returns the PhysicsImpostor or null if not found
  27421. */
  27422. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27423. /**
  27424. * Does a raycast in the physics world
  27425. * @param from when should the ray start?
  27426. * @param to when should the ray end?
  27427. * @returns PhysicsRaycastResult
  27428. */
  27429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27430. /**
  27431. * Called by the scene. No need to call it.
  27432. * @param delta defines the timespam between frames
  27433. */
  27434. _step(delta: number): void;
  27435. }
  27436. }
  27437. declare module BABYLON {
  27438. /**
  27439. * The interface for the physics imposter parameters
  27440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27441. */
  27442. export interface PhysicsImpostorParameters {
  27443. /**
  27444. * The mass of the physics imposter
  27445. */
  27446. mass: number;
  27447. /**
  27448. * The friction of the physics imposter
  27449. */
  27450. friction?: number;
  27451. /**
  27452. * The coefficient of restitution of the physics imposter
  27453. */
  27454. restitution?: number;
  27455. /**
  27456. * The native options of the physics imposter
  27457. */
  27458. nativeOptions?: any;
  27459. /**
  27460. * Specifies if the parent should be ignored
  27461. */
  27462. ignoreParent?: boolean;
  27463. /**
  27464. * Specifies if bi-directional transformations should be disabled
  27465. */
  27466. disableBidirectionalTransformation?: boolean;
  27467. /**
  27468. * The pressure inside the physics imposter, soft object only
  27469. */
  27470. pressure?: number;
  27471. /**
  27472. * The stiffness the physics imposter, soft object only
  27473. */
  27474. stiffness?: number;
  27475. /**
  27476. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27477. */
  27478. velocityIterations?: number;
  27479. /**
  27480. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27481. */
  27482. positionIterations?: number;
  27483. /**
  27484. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27485. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27486. * Add to fix multiple points
  27487. */
  27488. fixedPoints?: number;
  27489. /**
  27490. * The collision margin around a soft object
  27491. */
  27492. margin?: number;
  27493. /**
  27494. * The collision margin around a soft object
  27495. */
  27496. damping?: number;
  27497. /**
  27498. * The path for a rope based on an extrusion
  27499. */
  27500. path?: any;
  27501. /**
  27502. * The shape of an extrusion used for a rope based on an extrusion
  27503. */
  27504. shape?: any;
  27505. }
  27506. /**
  27507. * Interface for a physics-enabled object
  27508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27509. */
  27510. export interface IPhysicsEnabledObject {
  27511. /**
  27512. * The position of the physics-enabled object
  27513. */
  27514. position: Vector3;
  27515. /**
  27516. * The rotation of the physics-enabled object
  27517. */
  27518. rotationQuaternion: Nullable<Quaternion>;
  27519. /**
  27520. * The scale of the physics-enabled object
  27521. */
  27522. scaling: Vector3;
  27523. /**
  27524. * The rotation of the physics-enabled object
  27525. */
  27526. rotation?: Vector3;
  27527. /**
  27528. * The parent of the physics-enabled object
  27529. */
  27530. parent?: any;
  27531. /**
  27532. * The bounding info of the physics-enabled object
  27533. * @returns The bounding info of the physics-enabled object
  27534. */
  27535. getBoundingInfo(): BoundingInfo;
  27536. /**
  27537. * Computes the world matrix
  27538. * @param force Specifies if the world matrix should be computed by force
  27539. * @returns A world matrix
  27540. */
  27541. computeWorldMatrix(force: boolean): Matrix;
  27542. /**
  27543. * Gets the world matrix
  27544. * @returns A world matrix
  27545. */
  27546. getWorldMatrix?(): Matrix;
  27547. /**
  27548. * Gets the child meshes
  27549. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27550. * @returns An array of abstract meshes
  27551. */
  27552. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27553. /**
  27554. * Gets the vertex data
  27555. * @param kind The type of vertex data
  27556. * @returns A nullable array of numbers, or a float32 array
  27557. */
  27558. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27559. /**
  27560. * Gets the indices from the mesh
  27561. * @returns A nullable array of index arrays
  27562. */
  27563. getIndices?(): Nullable<IndicesArray>;
  27564. /**
  27565. * Gets the scene from the mesh
  27566. * @returns the indices array or null
  27567. */
  27568. getScene?(): Scene;
  27569. /**
  27570. * Gets the absolute position from the mesh
  27571. * @returns the absolute position
  27572. */
  27573. getAbsolutePosition(): Vector3;
  27574. /**
  27575. * Gets the absolute pivot point from the mesh
  27576. * @returns the absolute pivot point
  27577. */
  27578. getAbsolutePivotPoint(): Vector3;
  27579. /**
  27580. * Rotates the mesh
  27581. * @param axis The axis of rotation
  27582. * @param amount The amount of rotation
  27583. * @param space The space of the rotation
  27584. * @returns The rotation transform node
  27585. */
  27586. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27587. /**
  27588. * Translates the mesh
  27589. * @param axis The axis of translation
  27590. * @param distance The distance of translation
  27591. * @param space The space of the translation
  27592. * @returns The transform node
  27593. */
  27594. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27595. /**
  27596. * Sets the absolute position of the mesh
  27597. * @param absolutePosition The absolute position of the mesh
  27598. * @returns The transform node
  27599. */
  27600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27601. /**
  27602. * Gets the class name of the mesh
  27603. * @returns The class name
  27604. */
  27605. getClassName(): string;
  27606. }
  27607. /**
  27608. * Represents a physics imposter
  27609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27610. */
  27611. export class PhysicsImpostor {
  27612. /**
  27613. * The physics-enabled object used as the physics imposter
  27614. */
  27615. object: IPhysicsEnabledObject;
  27616. /**
  27617. * The type of the physics imposter
  27618. */
  27619. type: number;
  27620. private _options;
  27621. private _scene?;
  27622. /**
  27623. * The default object size of the imposter
  27624. */
  27625. static DEFAULT_OBJECT_SIZE: Vector3;
  27626. /**
  27627. * The identity quaternion of the imposter
  27628. */
  27629. static IDENTITY_QUATERNION: Quaternion;
  27630. /** @hidden */
  27631. _pluginData: any;
  27632. private _physicsEngine;
  27633. private _physicsBody;
  27634. private _bodyUpdateRequired;
  27635. private _onBeforePhysicsStepCallbacks;
  27636. private _onAfterPhysicsStepCallbacks;
  27637. /** @hidden */
  27638. _onPhysicsCollideCallbacks: Array<{
  27639. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27640. otherImpostors: Array<PhysicsImpostor>;
  27641. }>;
  27642. private _deltaPosition;
  27643. private _deltaRotation;
  27644. private _deltaRotationConjugated;
  27645. /** @hidden */
  27646. _isFromLine: boolean;
  27647. private _parent;
  27648. private _isDisposed;
  27649. private static _tmpVecs;
  27650. private static _tmpQuat;
  27651. /**
  27652. * Specifies if the physics imposter is disposed
  27653. */
  27654. get isDisposed(): boolean;
  27655. /**
  27656. * Gets the mass of the physics imposter
  27657. */
  27658. get mass(): number;
  27659. set mass(value: number);
  27660. /**
  27661. * Gets the coefficient of friction
  27662. */
  27663. get friction(): number;
  27664. /**
  27665. * Sets the coefficient of friction
  27666. */
  27667. set friction(value: number);
  27668. /**
  27669. * Gets the coefficient of restitution
  27670. */
  27671. get restitution(): number;
  27672. /**
  27673. * Sets the coefficient of restitution
  27674. */
  27675. set restitution(value: number);
  27676. /**
  27677. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27678. */
  27679. get pressure(): number;
  27680. /**
  27681. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27682. */
  27683. set pressure(value: number);
  27684. /**
  27685. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27686. */
  27687. get stiffness(): number;
  27688. /**
  27689. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27690. */
  27691. set stiffness(value: number);
  27692. /**
  27693. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27694. */
  27695. get velocityIterations(): number;
  27696. /**
  27697. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27698. */
  27699. set velocityIterations(value: number);
  27700. /**
  27701. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27702. */
  27703. get positionIterations(): number;
  27704. /**
  27705. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27706. */
  27707. set positionIterations(value: number);
  27708. /**
  27709. * The unique id of the physics imposter
  27710. * set by the physics engine when adding this impostor to the array
  27711. */
  27712. uniqueId: number;
  27713. /**
  27714. * @hidden
  27715. */
  27716. soft: boolean;
  27717. /**
  27718. * @hidden
  27719. */
  27720. segments: number;
  27721. private _joints;
  27722. /**
  27723. * Initializes the physics imposter
  27724. * @param object The physics-enabled object used as the physics imposter
  27725. * @param type The type of the physics imposter
  27726. * @param _options The options for the physics imposter
  27727. * @param _scene The Babylon scene
  27728. */
  27729. constructor(
  27730. /**
  27731. * The physics-enabled object used as the physics imposter
  27732. */
  27733. object: IPhysicsEnabledObject,
  27734. /**
  27735. * The type of the physics imposter
  27736. */
  27737. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27738. /**
  27739. * This function will completly initialize this impostor.
  27740. * It will create a new body - but only if this mesh has no parent.
  27741. * If it has, this impostor will not be used other than to define the impostor
  27742. * of the child mesh.
  27743. * @hidden
  27744. */
  27745. _init(): void;
  27746. private _getPhysicsParent;
  27747. /**
  27748. * Should a new body be generated.
  27749. * @returns boolean specifying if body initialization is required
  27750. */
  27751. isBodyInitRequired(): boolean;
  27752. /**
  27753. * Sets the updated scaling
  27754. * @param updated Specifies if the scaling is updated
  27755. */
  27756. setScalingUpdated(): void;
  27757. /**
  27758. * Force a regeneration of this or the parent's impostor's body.
  27759. * Use under cautious - This will remove all joints already implemented.
  27760. */
  27761. forceUpdate(): void;
  27762. /**
  27763. * Gets the body that holds this impostor. Either its own, or its parent.
  27764. */
  27765. get physicsBody(): any;
  27766. /**
  27767. * Get the parent of the physics imposter
  27768. * @returns Physics imposter or null
  27769. */
  27770. get parent(): Nullable<PhysicsImpostor>;
  27771. /**
  27772. * Sets the parent of the physics imposter
  27773. */
  27774. set parent(value: Nullable<PhysicsImpostor>);
  27775. /**
  27776. * Set the physics body. Used mainly by the physics engine/plugin
  27777. */
  27778. set physicsBody(physicsBody: any);
  27779. /**
  27780. * Resets the update flags
  27781. */
  27782. resetUpdateFlags(): void;
  27783. /**
  27784. * Gets the object extend size
  27785. * @returns the object extend size
  27786. */
  27787. getObjectExtendSize(): Vector3;
  27788. /**
  27789. * Gets the object center
  27790. * @returns The object center
  27791. */
  27792. getObjectCenter(): Vector3;
  27793. /**
  27794. * Get a specific parameter from the options parameters
  27795. * @param paramName The object parameter name
  27796. * @returns The object parameter
  27797. */
  27798. getParam(paramName: string): any;
  27799. /**
  27800. * Sets a specific parameter in the options given to the physics plugin
  27801. * @param paramName The parameter name
  27802. * @param value The value of the parameter
  27803. */
  27804. setParam(paramName: string, value: number): void;
  27805. /**
  27806. * Specifically change the body's mass option. Won't recreate the physics body object
  27807. * @param mass The mass of the physics imposter
  27808. */
  27809. setMass(mass: number): void;
  27810. /**
  27811. * Gets the linear velocity
  27812. * @returns linear velocity or null
  27813. */
  27814. getLinearVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the linear velocity
  27817. * @param velocity linear velocity or null
  27818. */
  27819. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Gets the angular velocity
  27822. * @returns angular velocity or null
  27823. */
  27824. getAngularVelocity(): Nullable<Vector3>;
  27825. /**
  27826. * Sets the angular velocity
  27827. * @param velocity The velocity or null
  27828. */
  27829. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27830. /**
  27831. * Execute a function with the physics plugin native code
  27832. * Provide a function the will have two variables - the world object and the physics body object
  27833. * @param func The function to execute with the physics plugin native code
  27834. */
  27835. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27836. /**
  27837. * Register a function that will be executed before the physics world is stepping forward
  27838. * @param func The function to execute before the physics world is stepped forward
  27839. */
  27840. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregister a function that will be executed before the physics world is stepping forward
  27843. * @param func The function to execute before the physics world is stepped forward
  27844. */
  27845. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * Register a function that will be executed after the physics step
  27848. * @param func The function to execute after physics step
  27849. */
  27850. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27851. /**
  27852. * Unregisters a function that will be executed after the physics step
  27853. * @param func The function to execute after physics step
  27854. */
  27855. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27856. /**
  27857. * register a function that will be executed when this impostor collides against a different body
  27858. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27859. * @param func Callback that is executed on collision
  27860. */
  27861. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27862. /**
  27863. * Unregisters the physics imposter on contact
  27864. * @param collideAgainst The physics object to collide against
  27865. * @param func Callback to execute on collision
  27866. */
  27867. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27868. private _tmpQuat;
  27869. private _tmpQuat2;
  27870. /**
  27871. * Get the parent rotation
  27872. * @returns The parent rotation
  27873. */
  27874. getParentsRotation(): Quaternion;
  27875. /**
  27876. * this function is executed by the physics engine.
  27877. */
  27878. beforeStep: () => void;
  27879. /**
  27880. * this function is executed by the physics engine
  27881. */
  27882. afterStep: () => void;
  27883. /**
  27884. * Legacy collision detection event support
  27885. */
  27886. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27887. /**
  27888. * event and body object due to cannon's event-based architecture.
  27889. */
  27890. onCollide: (e: {
  27891. body: any;
  27892. }) => void;
  27893. /**
  27894. * Apply a force
  27895. * @param force The force to apply
  27896. * @param contactPoint The contact point for the force
  27897. * @returns The physics imposter
  27898. */
  27899. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27900. /**
  27901. * Apply an impulse
  27902. * @param force The impulse force
  27903. * @param contactPoint The contact point for the impulse force
  27904. * @returns The physics imposter
  27905. */
  27906. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27907. /**
  27908. * A help function to create a joint
  27909. * @param otherImpostor A physics imposter used to create a joint
  27910. * @param jointType The type of joint
  27911. * @param jointData The data for the joint
  27912. * @returns The physics imposter
  27913. */
  27914. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27915. /**
  27916. * Add a joint to this impostor with a different impostor
  27917. * @param otherImpostor A physics imposter used to add a joint
  27918. * @param joint The joint to add
  27919. * @returns The physics imposter
  27920. */
  27921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27922. /**
  27923. * Add an anchor to a cloth impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param width ratio across width from 0 to 1
  27926. * @param height ratio up height from 0 to 1
  27927. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27928. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27929. * @returns impostor the soft imposter
  27930. */
  27931. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27932. /**
  27933. * Add a hook to a rope impostor
  27934. * @param otherImpostor rigid impostor to anchor to
  27935. * @param length ratio across rope from 0 to 1
  27936. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27937. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27938. * @returns impostor the rope imposter
  27939. */
  27940. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27941. /**
  27942. * Will keep this body still, in a sleep mode.
  27943. * @returns the physics imposter
  27944. */
  27945. sleep(): PhysicsImpostor;
  27946. /**
  27947. * Wake the body up.
  27948. * @returns The physics imposter
  27949. */
  27950. wakeUp(): PhysicsImpostor;
  27951. /**
  27952. * Clones the physics imposter
  27953. * @param newObject The physics imposter clones to this physics-enabled object
  27954. * @returns A nullable physics imposter
  27955. */
  27956. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27957. /**
  27958. * Disposes the physics imposter
  27959. */
  27960. dispose(): void;
  27961. /**
  27962. * Sets the delta position
  27963. * @param position The delta position amount
  27964. */
  27965. setDeltaPosition(position: Vector3): void;
  27966. /**
  27967. * Sets the delta rotation
  27968. * @param rotation The delta rotation amount
  27969. */
  27970. setDeltaRotation(rotation: Quaternion): void;
  27971. /**
  27972. * Gets the box size of the physics imposter and stores the result in the input parameter
  27973. * @param result Stores the box size
  27974. * @returns The physics imposter
  27975. */
  27976. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27977. /**
  27978. * Gets the radius of the physics imposter
  27979. * @returns Radius of the physics imposter
  27980. */
  27981. getRadius(): number;
  27982. /**
  27983. * Sync a bone with this impostor
  27984. * @param bone The bone to sync to the impostor.
  27985. * @param boneMesh The mesh that the bone is influencing.
  27986. * @param jointPivot The pivot of the joint / bone in local space.
  27987. * @param distToJoint Optional distance from the impostor to the joint.
  27988. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27989. */
  27990. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27991. /**
  27992. * Sync impostor to a bone
  27993. * @param bone The bone that the impostor will be synced to.
  27994. * @param boneMesh The mesh that the bone is influencing.
  27995. * @param jointPivot The pivot of the joint / bone in local space.
  27996. * @param distToJoint Optional distance from the impostor to the joint.
  27997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27998. * @param boneAxis Optional vector3 axis the bone is aligned with
  27999. */
  28000. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28001. /**
  28002. * No-Imposter type
  28003. */
  28004. static NoImpostor: number;
  28005. /**
  28006. * Sphere-Imposter type
  28007. */
  28008. static SphereImpostor: number;
  28009. /**
  28010. * Box-Imposter type
  28011. */
  28012. static BoxImpostor: number;
  28013. /**
  28014. * Plane-Imposter type
  28015. */
  28016. static PlaneImpostor: number;
  28017. /**
  28018. * Mesh-imposter type
  28019. */
  28020. static MeshImpostor: number;
  28021. /**
  28022. * Capsule-Impostor type (Ammo.js plugin only)
  28023. */
  28024. static CapsuleImpostor: number;
  28025. /**
  28026. * Cylinder-Imposter type
  28027. */
  28028. static CylinderImpostor: number;
  28029. /**
  28030. * Particle-Imposter type
  28031. */
  28032. static ParticleImpostor: number;
  28033. /**
  28034. * Heightmap-Imposter type
  28035. */
  28036. static HeightmapImpostor: number;
  28037. /**
  28038. * ConvexHull-Impostor type (Ammo.js plugin only)
  28039. */
  28040. static ConvexHullImpostor: number;
  28041. /**
  28042. * Custom-Imposter type (Ammo.js plugin only)
  28043. */
  28044. static CustomImpostor: number;
  28045. /**
  28046. * Rope-Imposter type
  28047. */
  28048. static RopeImpostor: number;
  28049. /**
  28050. * Cloth-Imposter type
  28051. */
  28052. static ClothImpostor: number;
  28053. /**
  28054. * Softbody-Imposter type
  28055. */
  28056. static SoftbodyImpostor: number;
  28057. }
  28058. }
  28059. declare module BABYLON {
  28060. /**
  28061. * @hidden
  28062. **/
  28063. export class _CreationDataStorage {
  28064. closePath?: boolean;
  28065. closeArray?: boolean;
  28066. idx: number[];
  28067. dashSize: number;
  28068. gapSize: number;
  28069. path3D: Path3D;
  28070. pathArray: Vector3[][];
  28071. arc: number;
  28072. radius: number;
  28073. cap: number;
  28074. tessellation: number;
  28075. }
  28076. /**
  28077. * @hidden
  28078. **/
  28079. class _InstanceDataStorage {
  28080. visibleInstances: any;
  28081. batchCache: _InstancesBatch;
  28082. instancesBufferSize: number;
  28083. instancesBuffer: Nullable<Buffer>;
  28084. instancesData: Float32Array;
  28085. overridenInstanceCount: number;
  28086. isFrozen: boolean;
  28087. previousBatch: Nullable<_InstancesBatch>;
  28088. hardwareInstancedRendering: boolean;
  28089. sideOrientation: number;
  28090. manualUpdate: boolean;
  28091. }
  28092. /**
  28093. * @hidden
  28094. **/
  28095. export class _InstancesBatch {
  28096. mustReturn: boolean;
  28097. visibleInstances: Nullable<InstancedMesh[]>[];
  28098. renderSelf: boolean[];
  28099. hardwareInstancedRendering: boolean[];
  28100. }
  28101. /**
  28102. * @hidden
  28103. **/
  28104. class _ThinInstanceDataStorage {
  28105. instancesCount: number;
  28106. matrixBuffer: Nullable<Buffer>;
  28107. matrixBufferSize: number;
  28108. matrixData: Nullable<Float32Array>;
  28109. boundingVectors: Array<Vector3>;
  28110. worldMatrices: Nullable<Matrix[]>;
  28111. }
  28112. /**
  28113. * Class used to represent renderable models
  28114. */
  28115. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28116. /**
  28117. * Mesh side orientation : usually the external or front surface
  28118. */
  28119. static readonly FRONTSIDE: number;
  28120. /**
  28121. * Mesh side orientation : usually the internal or back surface
  28122. */
  28123. static readonly BACKSIDE: number;
  28124. /**
  28125. * Mesh side orientation : both internal and external or front and back surfaces
  28126. */
  28127. static readonly DOUBLESIDE: number;
  28128. /**
  28129. * Mesh side orientation : by default, `FRONTSIDE`
  28130. */
  28131. static readonly DEFAULTSIDE: number;
  28132. /**
  28133. * Mesh cap setting : no cap
  28134. */
  28135. static readonly NO_CAP: number;
  28136. /**
  28137. * Mesh cap setting : one cap at the beginning of the mesh
  28138. */
  28139. static readonly CAP_START: number;
  28140. /**
  28141. * Mesh cap setting : one cap at the end of the mesh
  28142. */
  28143. static readonly CAP_END: number;
  28144. /**
  28145. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28146. */
  28147. static readonly CAP_ALL: number;
  28148. /**
  28149. * Mesh pattern setting : no flip or rotate
  28150. */
  28151. static readonly NO_FLIP: number;
  28152. /**
  28153. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28154. */
  28155. static readonly FLIP_TILE: number;
  28156. /**
  28157. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28158. */
  28159. static readonly ROTATE_TILE: number;
  28160. /**
  28161. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28162. */
  28163. static readonly FLIP_ROW: number;
  28164. /**
  28165. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28166. */
  28167. static readonly ROTATE_ROW: number;
  28168. /**
  28169. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28170. */
  28171. static readonly FLIP_N_ROTATE_TILE: number;
  28172. /**
  28173. * Mesh pattern setting : rotate pattern and rotate
  28174. */
  28175. static readonly FLIP_N_ROTATE_ROW: number;
  28176. /**
  28177. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28178. */
  28179. static readonly CENTER: number;
  28180. /**
  28181. * Mesh tile positioning : part tiles on left
  28182. */
  28183. static readonly LEFT: number;
  28184. /**
  28185. * Mesh tile positioning : part tiles on right
  28186. */
  28187. static readonly RIGHT: number;
  28188. /**
  28189. * Mesh tile positioning : part tiles on top
  28190. */
  28191. static readonly TOP: number;
  28192. /**
  28193. * Mesh tile positioning : part tiles on bottom
  28194. */
  28195. static readonly BOTTOM: number;
  28196. /**
  28197. * Gets the default side orientation.
  28198. * @param orientation the orientation to value to attempt to get
  28199. * @returns the default orientation
  28200. * @hidden
  28201. */
  28202. static _GetDefaultSideOrientation(orientation?: number): number;
  28203. private _internalMeshDataInfo;
  28204. get computeBonesUsingShaders(): boolean;
  28205. set computeBonesUsingShaders(value: boolean);
  28206. /**
  28207. * An event triggered before rendering the mesh
  28208. */
  28209. get onBeforeRenderObservable(): Observable<Mesh>;
  28210. /**
  28211. * An event triggered before binding the mesh
  28212. */
  28213. get onBeforeBindObservable(): Observable<Mesh>;
  28214. /**
  28215. * An event triggered after rendering the mesh
  28216. */
  28217. get onAfterRenderObservable(): Observable<Mesh>;
  28218. /**
  28219. * An event triggered before drawing the mesh
  28220. */
  28221. get onBeforeDrawObservable(): Observable<Mesh>;
  28222. private _onBeforeDrawObserver;
  28223. /**
  28224. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28225. */
  28226. set onBeforeDraw(callback: () => void);
  28227. get hasInstances(): boolean;
  28228. get hasThinInstances(): boolean;
  28229. /**
  28230. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28231. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28232. */
  28233. delayLoadState: number;
  28234. /**
  28235. * Gets the list of instances created from this mesh
  28236. * it is not supposed to be modified manually.
  28237. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28238. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28239. */
  28240. instances: InstancedMesh[];
  28241. /**
  28242. * Gets the file containing delay loading data for this mesh
  28243. */
  28244. delayLoadingFile: string;
  28245. /** @hidden */
  28246. _binaryInfo: any;
  28247. /**
  28248. * User defined function used to change how LOD level selection is done
  28249. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28250. */
  28251. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28252. /**
  28253. * Gets or sets the morph target manager
  28254. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28255. */
  28256. get morphTargetManager(): Nullable<MorphTargetManager>;
  28257. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28258. /** @hidden */
  28259. _creationDataStorage: Nullable<_CreationDataStorage>;
  28260. /** @hidden */
  28261. _geometry: Nullable<Geometry>;
  28262. /** @hidden */
  28263. _delayInfo: Array<string>;
  28264. /** @hidden */
  28265. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28266. /** @hidden */
  28267. _instanceDataStorage: _InstanceDataStorage;
  28268. /** @hidden */
  28269. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28270. private _effectiveMaterial;
  28271. /** @hidden */
  28272. _shouldGenerateFlatShading: boolean;
  28273. /** @hidden */
  28274. _originalBuilderSideOrientation: number;
  28275. /**
  28276. * Use this property to change the original side orientation defined at construction time
  28277. */
  28278. overrideMaterialSideOrientation: Nullable<number>;
  28279. /**
  28280. * Gets the source mesh (the one used to clone this one from)
  28281. */
  28282. get source(): Nullable<Mesh>;
  28283. /**
  28284. * Gets the list of clones of this mesh
  28285. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28286. * Note that useClonedMeshMap=true is the default setting
  28287. */
  28288. get cloneMeshMap(): Nullable<{
  28289. [id: string]: Mesh | undefined;
  28290. }>;
  28291. /**
  28292. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28293. */
  28294. get isUnIndexed(): boolean;
  28295. set isUnIndexed(value: boolean);
  28296. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28297. get worldMatrixInstancedBuffer(): Float32Array;
  28298. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28299. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28300. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28301. /**
  28302. * @constructor
  28303. * @param name The value used by scene.getMeshByName() to do a lookup.
  28304. * @param scene The scene to add this mesh to.
  28305. * @param parent The parent of this mesh, if it has one
  28306. * @param source An optional Mesh from which geometry is shared, cloned.
  28307. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28308. * When false, achieved by calling a clone(), also passing False.
  28309. * This will make creation of children, recursive.
  28310. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28311. */
  28312. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28313. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28314. doNotInstantiate: boolean;
  28315. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28316. /**
  28317. * Gets the class name
  28318. * @returns the string "Mesh".
  28319. */
  28320. getClassName(): string;
  28321. /** @hidden */
  28322. get _isMesh(): boolean;
  28323. /**
  28324. * Returns a description of this mesh
  28325. * @param fullDetails define if full details about this mesh must be used
  28326. * @returns a descriptive string representing this mesh
  28327. */
  28328. toString(fullDetails?: boolean): string;
  28329. /** @hidden */
  28330. _unBindEffect(): void;
  28331. /**
  28332. * Gets a boolean indicating if this mesh has LOD
  28333. */
  28334. get hasLODLevels(): boolean;
  28335. /**
  28336. * Gets the list of MeshLODLevel associated with the current mesh
  28337. * @returns an array of MeshLODLevel
  28338. */
  28339. getLODLevels(): MeshLODLevel[];
  28340. private _sortLODLevels;
  28341. /**
  28342. * Add a mesh as LOD level triggered at the given distance.
  28343. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28344. * @param distance The distance from the center of the object to show this level
  28345. * @param mesh The mesh to be added as LOD level (can be null)
  28346. * @return This mesh (for chaining)
  28347. */
  28348. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28349. /**
  28350. * Returns the LOD level mesh at the passed distance or null if not found.
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param distance The distance from the center of the object to show this level
  28353. * @returns a Mesh or `null`
  28354. */
  28355. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28356. /**
  28357. * Remove a mesh from the LOD array
  28358. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28359. * @param mesh defines the mesh to be removed
  28360. * @return This mesh (for chaining)
  28361. */
  28362. removeLODLevel(mesh: Mesh): Mesh;
  28363. /**
  28364. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28366. * @param camera defines the camera to use to compute distance
  28367. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28368. * @return This mesh (for chaining)
  28369. */
  28370. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28371. /**
  28372. * Gets the mesh internal Geometry object
  28373. */
  28374. get geometry(): Nullable<Geometry>;
  28375. /**
  28376. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28377. * @returns the total number of vertices
  28378. */
  28379. getTotalVertices(): number;
  28380. /**
  28381. * Returns the content of an associated vertex buffer
  28382. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28383. * - VertexBuffer.PositionKind
  28384. * - VertexBuffer.UVKind
  28385. * - VertexBuffer.UV2Kind
  28386. * - VertexBuffer.UV3Kind
  28387. * - VertexBuffer.UV4Kind
  28388. * - VertexBuffer.UV5Kind
  28389. * - VertexBuffer.UV6Kind
  28390. * - VertexBuffer.ColorKind
  28391. * - VertexBuffer.MatricesIndicesKind
  28392. * - VertexBuffer.MatricesIndicesExtraKind
  28393. * - VertexBuffer.MatricesWeightsKind
  28394. * - VertexBuffer.MatricesWeightsExtraKind
  28395. * @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
  28396. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28397. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28398. */
  28399. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28400. /**
  28401. * Returns the mesh VertexBuffer object from the requested `kind`
  28402. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28403. * - VertexBuffer.PositionKind
  28404. * - VertexBuffer.NormalKind
  28405. * - VertexBuffer.UVKind
  28406. * - VertexBuffer.UV2Kind
  28407. * - VertexBuffer.UV3Kind
  28408. * - VertexBuffer.UV4Kind
  28409. * - VertexBuffer.UV5Kind
  28410. * - VertexBuffer.UV6Kind
  28411. * - VertexBuffer.ColorKind
  28412. * - VertexBuffer.MatricesIndicesKind
  28413. * - VertexBuffer.MatricesIndicesExtraKind
  28414. * - VertexBuffer.MatricesWeightsKind
  28415. * - VertexBuffer.MatricesWeightsExtraKind
  28416. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28417. */
  28418. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28419. /**
  28420. * Tests if a specific vertex buffer is associated with this mesh
  28421. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28422. * - VertexBuffer.PositionKind
  28423. * - VertexBuffer.NormalKind
  28424. * - VertexBuffer.UVKind
  28425. * - VertexBuffer.UV2Kind
  28426. * - VertexBuffer.UV3Kind
  28427. * - VertexBuffer.UV4Kind
  28428. * - VertexBuffer.UV5Kind
  28429. * - VertexBuffer.UV6Kind
  28430. * - VertexBuffer.ColorKind
  28431. * - VertexBuffer.MatricesIndicesKind
  28432. * - VertexBuffer.MatricesIndicesExtraKind
  28433. * - VertexBuffer.MatricesWeightsKind
  28434. * - VertexBuffer.MatricesWeightsExtraKind
  28435. * @returns a boolean
  28436. */
  28437. isVerticesDataPresent(kind: string): boolean;
  28438. /**
  28439. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28440. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28441. * - VertexBuffer.PositionKind
  28442. * - VertexBuffer.UVKind
  28443. * - VertexBuffer.UV2Kind
  28444. * - VertexBuffer.UV3Kind
  28445. * - VertexBuffer.UV4Kind
  28446. * - VertexBuffer.UV5Kind
  28447. * - VertexBuffer.UV6Kind
  28448. * - VertexBuffer.ColorKind
  28449. * - VertexBuffer.MatricesIndicesKind
  28450. * - VertexBuffer.MatricesIndicesExtraKind
  28451. * - VertexBuffer.MatricesWeightsKind
  28452. * - VertexBuffer.MatricesWeightsExtraKind
  28453. * @returns a boolean
  28454. */
  28455. isVertexBufferUpdatable(kind: string): boolean;
  28456. /**
  28457. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28459. * - VertexBuffer.PositionKind
  28460. * - VertexBuffer.NormalKind
  28461. * - VertexBuffer.UVKind
  28462. * - VertexBuffer.UV2Kind
  28463. * - VertexBuffer.UV3Kind
  28464. * - VertexBuffer.UV4Kind
  28465. * - VertexBuffer.UV5Kind
  28466. * - VertexBuffer.UV6Kind
  28467. * - VertexBuffer.ColorKind
  28468. * - VertexBuffer.MatricesIndicesKind
  28469. * - VertexBuffer.MatricesIndicesExtraKind
  28470. * - VertexBuffer.MatricesWeightsKind
  28471. * - VertexBuffer.MatricesWeightsExtraKind
  28472. * @returns an array of strings
  28473. */
  28474. getVerticesDataKinds(): string[];
  28475. /**
  28476. * Returns a positive integer : the total number of indices in this mesh geometry.
  28477. * @returns the numner of indices or zero if the mesh has no geometry.
  28478. */
  28479. getTotalIndices(): number;
  28480. /**
  28481. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28482. * @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.
  28483. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28484. * @returns the indices array or an empty array if the mesh has no geometry
  28485. */
  28486. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28487. get isBlocked(): boolean;
  28488. /**
  28489. * Determine if the current mesh is ready to be rendered
  28490. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28491. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28492. * @returns true if all associated assets are ready (material, textures, shaders)
  28493. */
  28494. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28495. /**
  28496. * 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.
  28497. */
  28498. get areNormalsFrozen(): boolean;
  28499. /**
  28500. * 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.
  28501. * @returns the current mesh
  28502. */
  28503. freezeNormals(): Mesh;
  28504. /**
  28505. * 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
  28506. * @returns the current mesh
  28507. */
  28508. unfreezeNormals(): Mesh;
  28509. /**
  28510. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28511. */
  28512. set overridenInstanceCount(count: number);
  28513. /** @hidden */
  28514. _preActivate(): Mesh;
  28515. /** @hidden */
  28516. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28517. /** @hidden */
  28518. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28519. protected _afterComputeWorldMatrix(): void;
  28520. /** @hidden */
  28521. _postActivate(): void;
  28522. /**
  28523. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28524. * This means the mesh underlying bounding box and sphere are recomputed.
  28525. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28526. * @returns the current mesh
  28527. */
  28528. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28529. /** @hidden */
  28530. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28531. /**
  28532. * This function will subdivide the mesh into multiple submeshes
  28533. * @param count defines the expected number of submeshes
  28534. */
  28535. subdivide(count: number): void;
  28536. /**
  28537. * Copy a FloatArray into a specific associated vertex buffer
  28538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28539. * - VertexBuffer.PositionKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. * @param data defines the data source
  28552. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28553. * @param stride defines the data stride size (can be null)
  28554. * @returns the current mesh
  28555. */
  28556. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28557. /**
  28558. * Delete a vertex buffer associated with this mesh
  28559. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28560. * - VertexBuffer.PositionKind
  28561. * - VertexBuffer.UVKind
  28562. * - VertexBuffer.UV2Kind
  28563. * - VertexBuffer.UV3Kind
  28564. * - VertexBuffer.UV4Kind
  28565. * - VertexBuffer.UV5Kind
  28566. * - VertexBuffer.UV6Kind
  28567. * - VertexBuffer.ColorKind
  28568. * - VertexBuffer.MatricesIndicesKind
  28569. * - VertexBuffer.MatricesIndicesExtraKind
  28570. * - VertexBuffer.MatricesWeightsKind
  28571. * - VertexBuffer.MatricesWeightsExtraKind
  28572. */
  28573. removeVerticesData(kind: string): void;
  28574. /**
  28575. * Flags an associated vertex buffer as updatable
  28576. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28577. * - VertexBuffer.PositionKind
  28578. * - VertexBuffer.UVKind
  28579. * - VertexBuffer.UV2Kind
  28580. * - VertexBuffer.UV3Kind
  28581. * - VertexBuffer.UV4Kind
  28582. * - VertexBuffer.UV5Kind
  28583. * - VertexBuffer.UV6Kind
  28584. * - VertexBuffer.ColorKind
  28585. * - VertexBuffer.MatricesIndicesKind
  28586. * - VertexBuffer.MatricesIndicesExtraKind
  28587. * - VertexBuffer.MatricesWeightsKind
  28588. * - VertexBuffer.MatricesWeightsExtraKind
  28589. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28590. */
  28591. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28592. /**
  28593. * Sets the mesh global Vertex Buffer
  28594. * @param buffer defines the buffer to use
  28595. * @returns the current mesh
  28596. */
  28597. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28598. /**
  28599. * Update a specific associated vertex buffer
  28600. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28601. * - VertexBuffer.PositionKind
  28602. * - VertexBuffer.UVKind
  28603. * - VertexBuffer.UV2Kind
  28604. * - VertexBuffer.UV3Kind
  28605. * - VertexBuffer.UV4Kind
  28606. * - VertexBuffer.UV5Kind
  28607. * - VertexBuffer.UV6Kind
  28608. * - VertexBuffer.ColorKind
  28609. * - VertexBuffer.MatricesIndicesKind
  28610. * - VertexBuffer.MatricesIndicesExtraKind
  28611. * - VertexBuffer.MatricesWeightsKind
  28612. * - VertexBuffer.MatricesWeightsExtraKind
  28613. * @param data defines the data source
  28614. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28615. * @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)
  28616. * @returns the current mesh
  28617. */
  28618. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28619. /**
  28620. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28621. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28622. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28623. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28624. * @returns the current mesh
  28625. */
  28626. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28627. /**
  28628. * Creates a un-shared specific occurence of the geometry for the mesh.
  28629. * @returns the current mesh
  28630. */
  28631. makeGeometryUnique(): Mesh;
  28632. /**
  28633. * Set the index buffer of this mesh
  28634. * @param indices defines the source data
  28635. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28636. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28637. * @returns the current mesh
  28638. */
  28639. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28640. /**
  28641. * Update the current index buffer
  28642. * @param indices defines the source data
  28643. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28644. * @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)
  28645. * @returns the current mesh
  28646. */
  28647. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28648. /**
  28649. * Invert the geometry to move from a right handed system to a left handed one.
  28650. * @returns the current mesh
  28651. */
  28652. toLeftHanded(): Mesh;
  28653. /** @hidden */
  28654. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28655. /** @hidden */
  28656. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28657. /**
  28658. * Registers for this mesh a javascript function called just before the rendering process
  28659. * @param func defines the function to call before rendering this mesh
  28660. * @returns the current mesh
  28661. */
  28662. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28663. /**
  28664. * Disposes a previously registered javascript function called before the rendering
  28665. * @param func defines the function to remove
  28666. * @returns the current mesh
  28667. */
  28668. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28669. /**
  28670. * Registers for this mesh a javascript function called just after the rendering is complete
  28671. * @param func defines the function to call after rendering this mesh
  28672. * @returns the current mesh
  28673. */
  28674. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28675. /**
  28676. * Disposes a previously registered javascript function called after the rendering.
  28677. * @param func defines the function to remove
  28678. * @returns the current mesh
  28679. */
  28680. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28681. /** @hidden */
  28682. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28683. /** @hidden */
  28684. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28685. /** @hidden */
  28686. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28687. /** @hidden */
  28688. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28689. /** @hidden */
  28690. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28691. /** @hidden */
  28692. _rebuild(): void;
  28693. /** @hidden */
  28694. _freeze(): void;
  28695. /** @hidden */
  28696. _unFreeze(): void;
  28697. /**
  28698. * 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
  28699. * @param subMesh defines the subMesh to render
  28700. * @param enableAlphaMode defines if alpha mode can be changed
  28701. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28702. * @returns the current mesh
  28703. */
  28704. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28705. private _onBeforeDraw;
  28706. /**
  28707. * Renormalize the mesh and patch it up if there are no weights
  28708. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28709. * However in the case of zero weights then we set just a single influence to 1.
  28710. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28711. */
  28712. cleanMatrixWeights(): void;
  28713. private normalizeSkinFourWeights;
  28714. private normalizeSkinWeightsAndExtra;
  28715. /**
  28716. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28717. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28718. * the user know there was an issue with importing the mesh
  28719. * @returns a validation object with skinned, valid and report string
  28720. */
  28721. validateSkinning(): {
  28722. skinned: boolean;
  28723. valid: boolean;
  28724. report: string;
  28725. };
  28726. /** @hidden */
  28727. _checkDelayState(): Mesh;
  28728. private _queueLoad;
  28729. /**
  28730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28731. * A mesh is in the frustum if its bounding box intersects the frustum
  28732. * @param frustumPlanes defines the frustum to test
  28733. * @returns true if the mesh is in the frustum planes
  28734. */
  28735. isInFrustum(frustumPlanes: Plane[]): boolean;
  28736. /**
  28737. * Sets the mesh material by the material or multiMaterial `id` property
  28738. * @param id is a string identifying the material or the multiMaterial
  28739. * @returns the current mesh
  28740. */
  28741. setMaterialByID(id: string): Mesh;
  28742. /**
  28743. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28744. * @returns an array of IAnimatable
  28745. */
  28746. getAnimatables(): IAnimatable[];
  28747. /**
  28748. * Modifies the mesh geometry according to the passed transformation matrix.
  28749. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28750. * The mesh normals are modified using the same transformation.
  28751. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28752. * @param transform defines the transform matrix to use
  28753. * @see https://doc.babylonjs.com/resources/baking_transformations
  28754. * @returns the current mesh
  28755. */
  28756. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28757. /**
  28758. * Modifies the mesh geometry according to its own current World Matrix.
  28759. * The mesh World Matrix is then reset.
  28760. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28761. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28762. * @see https://doc.babylonjs.com/resources/baking_transformations
  28763. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28764. * @returns the current mesh
  28765. */
  28766. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28767. /** @hidden */
  28768. get _positions(): Nullable<Vector3[]>;
  28769. /** @hidden */
  28770. _resetPointsArrayCache(): Mesh;
  28771. /** @hidden */
  28772. _generatePointsArray(): boolean;
  28773. /**
  28774. * Returns a new Mesh object generated from the current mesh properties.
  28775. * This method must not get confused with createInstance()
  28776. * @param name is a string, the name given to the new mesh
  28777. * @param newParent can be any Node object (default `null`)
  28778. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28779. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28780. * @returns a new mesh
  28781. */
  28782. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28783. /**
  28784. * Releases resources associated with this mesh.
  28785. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28786. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28787. */
  28788. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28789. /** @hidden */
  28790. _disposeInstanceSpecificData(): void;
  28791. /** @hidden */
  28792. _disposeThinInstanceSpecificData(): void;
  28793. /**
  28794. * Modifies the mesh geometry according to a displacement map.
  28795. * 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.
  28796. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28797. * @param url is a string, the URL from the image file is to be downloaded.
  28798. * @param minHeight is the lower limit of the displacement.
  28799. * @param maxHeight is the upper limit of the displacement.
  28800. * @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.
  28801. * @param uvOffset is an optional vector2 used to offset UV.
  28802. * @param uvScale is an optional vector2 used to scale UV.
  28803. * @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.
  28804. * @returns the Mesh.
  28805. */
  28806. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28807. /**
  28808. * Modifies the mesh geometry according to a displacementMap buffer.
  28809. * 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.
  28810. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28811. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28812. * @param heightMapWidth is the width of the buffer image.
  28813. * @param heightMapHeight is the height of the buffer image.
  28814. * @param minHeight is the lower limit of the displacement.
  28815. * @param maxHeight is the upper limit of the displacement.
  28816. * @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.
  28817. * @param uvOffset is an optional vector2 used to offset UV.
  28818. * @param uvScale is an optional vector2 used to scale UV.
  28819. * @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.
  28820. * @returns the Mesh.
  28821. */
  28822. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28823. /**
  28824. * Modify the mesh to get a flat shading rendering.
  28825. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28826. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28827. * @returns current mesh
  28828. */
  28829. convertToFlatShadedMesh(): Mesh;
  28830. /**
  28831. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28832. * In other words, more vertices, no more indices and a single bigger VBO.
  28833. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28834. * @returns current mesh
  28835. */
  28836. convertToUnIndexedMesh(): Mesh;
  28837. /**
  28838. * Inverses facet orientations.
  28839. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28840. * @param flipNormals will also inverts the normals
  28841. * @returns current mesh
  28842. */
  28843. flipFaces(flipNormals?: boolean): Mesh;
  28844. /**
  28845. * Increase the number of facets and hence vertices in a mesh
  28846. * Vertex normals are interpolated from existing vertex normals
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28849. */
  28850. increaseVertices(numberPerEdge: number): void;
  28851. /**
  28852. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28853. * This will undo any application of covertToFlatShadedMesh
  28854. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28855. */
  28856. forceSharedVertices(): void;
  28857. /** @hidden */
  28858. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28859. /** @hidden */
  28860. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28861. /**
  28862. * Creates a new InstancedMesh object from the mesh model.
  28863. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28864. * @param name defines the name of the new instance
  28865. * @returns a new InstancedMesh
  28866. */
  28867. createInstance(name: string): InstancedMesh;
  28868. /**
  28869. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28870. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28871. * @returns the current mesh
  28872. */
  28873. synchronizeInstances(): Mesh;
  28874. /**
  28875. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28876. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28877. * This should be used together with the simplification to avoid disappearing triangles.
  28878. * @param successCallback an optional success callback to be called after the optimization finished.
  28879. * @returns the current mesh
  28880. */
  28881. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28882. /**
  28883. * Serialize current mesh
  28884. * @param serializationObject defines the object which will receive the serialization data
  28885. */
  28886. serialize(serializationObject: any): void;
  28887. /** @hidden */
  28888. _syncGeometryWithMorphTargetManager(): void;
  28889. /** @hidden */
  28890. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28891. /**
  28892. * Returns a new Mesh object parsed from the source provided.
  28893. * @param parsedMesh is the source
  28894. * @param scene defines the hosting scene
  28895. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28896. * @returns a new Mesh
  28897. */
  28898. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28899. /**
  28900. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28902. * @param name defines the name of the mesh to create
  28903. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28904. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28905. * @param closePath creates a seam between the first and the last points of each path of the path array
  28906. * @param offset is taken in account only if the `pathArray` is containing a single path
  28907. * @param scene defines the hosting scene
  28908. * @param updatable defines if the mesh must be flagged as updatable
  28909. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28910. * @param instance 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)
  28911. * @returns a new Mesh
  28912. */
  28913. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28914. /**
  28915. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28916. * @param name defines the name of the mesh to create
  28917. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28918. * @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
  28919. * @param scene defines the hosting scene
  28920. * @param updatable defines if the mesh must be flagged as updatable
  28921. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28922. * @returns a new Mesh
  28923. */
  28924. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28925. /**
  28926. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28927. * @param name defines the name of the mesh to create
  28928. * @param size sets the size (float) of each box side (default 1)
  28929. * @param scene defines the hosting scene
  28930. * @param updatable defines if the mesh must be flagged as updatable
  28931. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28932. * @returns a new Mesh
  28933. */
  28934. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28935. /**
  28936. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28937. * @param name defines the name of the mesh to create
  28938. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28939. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28940. * @param scene defines the hosting scene
  28941. * @param updatable defines if the mesh must be flagged as updatable
  28942. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28943. * @returns a new Mesh
  28944. */
  28945. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28946. /**
  28947. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28948. * @param name defines the name of the mesh to create
  28949. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28950. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28951. * @param scene defines the hosting scene
  28952. * @returns a new Mesh
  28953. */
  28954. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28955. /**
  28956. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28957. * @param name defines the name of the mesh to create
  28958. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28959. * @param diameterTop set the top cap diameter (floats, default 1)
  28960. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28961. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28962. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28963. * @param scene defines the hosting scene
  28964. * @param updatable defines if the mesh must be flagged as updatable
  28965. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28966. * @returns a new Mesh
  28967. */
  28968. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28969. /**
  28970. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28971. * @param name defines the name of the mesh to create
  28972. * @param diameter sets the diameter size (float) of the torus (default 1)
  28973. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28974. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28975. * @param scene defines the hosting scene
  28976. * @param updatable defines if the mesh must be flagged as updatable
  28977. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28978. * @returns a new Mesh
  28979. */
  28980. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28981. /**
  28982. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28983. * @param name defines the name of the mesh to create
  28984. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28985. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28986. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28987. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28988. * @param p the number of windings on X axis (positive integers, default 2)
  28989. * @param q the number of windings on Y axis (positive integers, default 3)
  28990. * @param scene defines the hosting scene
  28991. * @param updatable defines if the mesh must be flagged as updatable
  28992. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28996. /**
  28997. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28998. * @param name defines the name of the mesh to create
  28999. * @param points is an array successive Vector3
  29000. * @param scene defines the hosting scene
  29001. * @param updatable defines if the mesh must be flagged as updatable
  29002. * @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).
  29003. * @returns a new Mesh
  29004. */
  29005. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29006. /**
  29007. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29008. * @param name defines the name of the mesh to create
  29009. * @param points is an array successive Vector3
  29010. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29011. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29012. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29013. * @param scene defines the hosting scene
  29014. * @param updatable defines if the mesh must be flagged as updatable
  29015. * @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)
  29016. * @returns a new Mesh
  29017. */
  29018. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29019. /**
  29020. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29021. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29022. * 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.
  29023. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29024. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29025. * Remember you can only change the shape positions, not their number when updating a polygon.
  29026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29027. * @param name defines the name of the mesh to create
  29028. * @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
  29029. * @param scene defines the hosting scene
  29030. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29031. * @param updatable defines if the mesh must be flagged as updatable
  29032. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29033. * @param earcutInjection can be used to inject your own earcut reference
  29034. * @returns a new Mesh
  29035. */
  29036. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29037. /**
  29038. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29040. * @param name defines the name of the mesh to create
  29041. * @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
  29042. * @param depth defines the height of extrusion
  29043. * @param scene defines the hosting scene
  29044. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29045. * @param updatable defines if the mesh must be flagged as updatable
  29046. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29047. * @param earcutInjection can be used to inject your own earcut reference
  29048. * @returns a new Mesh
  29049. */
  29050. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29051. /**
  29052. * Creates an extruded shape mesh.
  29053. * 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
  29054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29056. * @param name defines the name of the mesh to create
  29057. * @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
  29058. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29059. * @param scale is the value to scale the shape
  29060. * @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
  29061. * @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
  29062. * @param scene defines the hosting scene
  29063. * @param updatable defines if the mesh must be flagged as updatable
  29064. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29065. * @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)
  29066. * @returns a new Mesh
  29067. */
  29068. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29069. /**
  29070. * Creates an custom extruded shape mesh.
  29071. * The custom extrusion is a parametric shape.
  29072. * It has no predefined shape. Its final shape will depend on the input parameters.
  29073. * Please consider using the same method from the MeshBuilder class instead
  29074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29075. * @param name defines the name of the mesh to create
  29076. * @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
  29077. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29078. * @param scaleFunction is a custom Javascript function called on each path point
  29079. * @param rotationFunction is a custom Javascript function called on each path point
  29080. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29081. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29082. * @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
  29083. * @param scene defines the hosting scene
  29084. * @param updatable defines if the mesh must be flagged as updatable
  29085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29086. * @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)
  29087. * @returns a new Mesh
  29088. */
  29089. 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;
  29090. /**
  29091. * Creates lathe mesh.
  29092. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29093. * Please consider using the same method from the MeshBuilder class instead
  29094. * @param name defines the name of the mesh to create
  29095. * @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
  29096. * @param radius is the radius value of the lathe
  29097. * @param tessellation is the side number of the lathe.
  29098. * @param scene defines the hosting scene
  29099. * @param updatable defines if the mesh must be flagged as updatable
  29100. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29101. * @returns a new Mesh
  29102. */
  29103. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29104. /**
  29105. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29106. * @param name defines the name of the mesh to create
  29107. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29108. * @param scene defines the hosting scene
  29109. * @param updatable defines if the mesh must be flagged as updatable
  29110. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29111. * @returns a new Mesh
  29112. */
  29113. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29114. /**
  29115. * Creates a ground mesh.
  29116. * Please consider using the same method from the MeshBuilder class instead
  29117. * @param name defines the name of the mesh to create
  29118. * @param width set the width of the ground
  29119. * @param height set the height of the ground
  29120. * @param subdivisions sets the number of subdivisions per side
  29121. * @param scene defines the hosting scene
  29122. * @param updatable defines if the mesh must be flagged as updatable
  29123. * @returns a new Mesh
  29124. */
  29125. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29126. /**
  29127. * Creates a tiled ground mesh.
  29128. * Please consider using the same method from the MeshBuilder class instead
  29129. * @param name defines the name of the mesh to create
  29130. * @param xmin set the ground minimum X coordinate
  29131. * @param zmin set the ground minimum Y coordinate
  29132. * @param xmax set the ground maximum X coordinate
  29133. * @param zmax set the ground maximum Z coordinate
  29134. * @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
  29135. * @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
  29136. * @param scene defines the hosting scene
  29137. * @param updatable defines if the mesh must be flagged as updatable
  29138. * @returns a new Mesh
  29139. */
  29140. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29141. w: number;
  29142. h: number;
  29143. }, precision: {
  29144. w: number;
  29145. h: number;
  29146. }, scene: Scene, updatable?: boolean): Mesh;
  29147. /**
  29148. * Creates a ground mesh from a height map.
  29149. * Please consider using the same method from the MeshBuilder class instead
  29150. * @see https://doc.babylonjs.com/babylon101/height_map
  29151. * @param name defines the name of the mesh to create
  29152. * @param url sets the URL of the height map image resource
  29153. * @param width set the ground width size
  29154. * @param height set the ground height size
  29155. * @param subdivisions sets the number of subdivision per side
  29156. * @param minHeight is the minimum altitude on the ground
  29157. * @param maxHeight is the maximum altitude on the ground
  29158. * @param scene defines the hosting scene
  29159. * @param updatable defines if the mesh must be flagged as updatable
  29160. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29161. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29162. * @returns a new Mesh
  29163. */
  29164. 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;
  29165. /**
  29166. * Creates a tube mesh.
  29167. * The tube is a parametric shape.
  29168. * It has no predefined shape. Its final shape will depend on the input parameters.
  29169. * Please consider using the same method from the MeshBuilder class instead
  29170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29171. * @param name defines the name of the mesh to create
  29172. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29173. * @param radius sets the tube radius size
  29174. * @param tessellation is the number of sides on the tubular surface
  29175. * @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
  29176. * @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
  29177. * @param scene defines the hosting scene
  29178. * @param updatable defines if the mesh must be flagged as updatable
  29179. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29180. * @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)
  29181. * @returns a new Mesh
  29182. */
  29183. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29184. (i: number, distance: number): number;
  29185. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29186. /**
  29187. * Creates a polyhedron mesh.
  29188. * Please consider using the same method from the MeshBuilder class instead.
  29189. * * 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
  29190. * * The parameter `size` (positive float, default 1) sets the polygon size
  29191. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29192. * * 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`
  29193. * * 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
  29194. * * 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)`)
  29195. * * 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
  29196. * * 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
  29197. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29198. * * 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
  29199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29200. * @param name defines the name of the mesh to create
  29201. * @param options defines the options used to create the mesh
  29202. * @param scene defines the hosting scene
  29203. * @returns a new Mesh
  29204. */
  29205. static CreatePolyhedron(name: string, options: {
  29206. type?: number;
  29207. size?: number;
  29208. sizeX?: number;
  29209. sizeY?: number;
  29210. sizeZ?: number;
  29211. custom?: any;
  29212. faceUV?: Vector4[];
  29213. faceColors?: Color4[];
  29214. updatable?: boolean;
  29215. sideOrientation?: number;
  29216. }, scene: Scene): Mesh;
  29217. /**
  29218. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29219. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29220. * * 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`)
  29221. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29222. * * 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
  29223. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29224. * * 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
  29225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29226. * @param name defines the name of the mesh
  29227. * @param options defines the options used to create the mesh
  29228. * @param scene defines the hosting scene
  29229. * @returns a new Mesh
  29230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29231. */
  29232. static CreateIcoSphere(name: string, options: {
  29233. radius?: number;
  29234. flat?: boolean;
  29235. subdivisions?: number;
  29236. sideOrientation?: number;
  29237. updatable?: boolean;
  29238. }, scene: Scene): Mesh;
  29239. /**
  29240. * Creates a decal mesh.
  29241. * Please consider using the same method from the MeshBuilder class instead.
  29242. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29243. * @param name defines the name of the mesh
  29244. * @param sourceMesh defines the mesh receiving the decal
  29245. * @param position sets the position of the decal in world coordinates
  29246. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29247. * @param size sets the decal scaling
  29248. * @param angle sets the angle to rotate the decal
  29249. * @returns a new Mesh
  29250. */
  29251. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29252. /**
  29253. * Prepare internal position array for software CPU skinning
  29254. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29255. */
  29256. setPositionsForCPUSkinning(): Float32Array;
  29257. /**
  29258. * Prepare internal normal array for software CPU skinning
  29259. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29260. */
  29261. setNormalsForCPUSkinning(): Float32Array;
  29262. /**
  29263. * Updates the vertex buffer by applying transformation from the bones
  29264. * @param skeleton defines the skeleton to apply to current mesh
  29265. * @returns the current mesh
  29266. */
  29267. applySkeleton(skeleton: Skeleton): Mesh;
  29268. /**
  29269. * 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
  29270. * @param meshes defines the list of meshes to scan
  29271. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29272. */
  29273. static MinMax(meshes: AbstractMesh[]): {
  29274. min: Vector3;
  29275. max: Vector3;
  29276. };
  29277. /**
  29278. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29279. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29280. * @returns a vector3
  29281. */
  29282. static Center(meshesOrMinMaxVector: {
  29283. min: Vector3;
  29284. max: Vector3;
  29285. } | AbstractMesh[]): Vector3;
  29286. /**
  29287. * Merge the array of meshes into a single mesh for performance reasons.
  29288. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29289. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29290. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29291. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29292. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29293. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29294. * @returns a new mesh
  29295. */
  29296. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29297. /** @hidden */
  29298. addInstance(instance: InstancedMesh): void;
  29299. /** @hidden */
  29300. removeInstance(instance: InstancedMesh): void;
  29301. }
  29302. }
  29303. declare module BABYLON {
  29304. /**
  29305. * This is the base class of all the camera used in the application.
  29306. * @see https://doc.babylonjs.com/features/cameras
  29307. */
  29308. export class Camera extends Node {
  29309. /** @hidden */
  29310. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29311. /**
  29312. * This is the default projection mode used by the cameras.
  29313. * It helps recreating a feeling of perspective and better appreciate depth.
  29314. * This is the best way to simulate real life cameras.
  29315. */
  29316. static readonly PERSPECTIVE_CAMERA: number;
  29317. /**
  29318. * This helps creating camera with an orthographic mode.
  29319. * 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.
  29320. */
  29321. static readonly ORTHOGRAPHIC_CAMERA: number;
  29322. /**
  29323. * This is the default FOV mode for perspective cameras.
  29324. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29325. */
  29326. static readonly FOVMODE_VERTICAL_FIXED: number;
  29327. /**
  29328. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29329. */
  29330. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29331. /**
  29332. * This specifies ther is no need for a camera rig.
  29333. * Basically only one eye is rendered corresponding to the camera.
  29334. */
  29335. static readonly RIG_MODE_NONE: number;
  29336. /**
  29337. * Simulates a camera Rig with one blue eye and one red eye.
  29338. * This can be use with 3d blue and red glasses.
  29339. */
  29340. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29341. /**
  29342. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29343. */
  29344. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29345. /**
  29346. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29347. */
  29348. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29349. /**
  29350. * Defines that both eyes of the camera will be rendered over under each other.
  29351. */
  29352. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29353. /**
  29354. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29355. */
  29356. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29357. /**
  29358. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29359. */
  29360. static readonly RIG_MODE_VR: number;
  29361. /**
  29362. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29363. */
  29364. static readonly RIG_MODE_WEBVR: number;
  29365. /**
  29366. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29367. */
  29368. static readonly RIG_MODE_CUSTOM: number;
  29369. /**
  29370. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29371. */
  29372. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29373. /**
  29374. * Define the input manager associated with the camera.
  29375. */
  29376. inputs: CameraInputsManager<Camera>;
  29377. /** @hidden */
  29378. _position: Vector3;
  29379. /**
  29380. * Define the current local position of the camera in the scene
  29381. */
  29382. get position(): Vector3;
  29383. set position(newPosition: Vector3);
  29384. protected _upVector: Vector3;
  29385. /**
  29386. * The vector the camera should consider as up.
  29387. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29388. */
  29389. set upVector(vec: Vector3);
  29390. get upVector(): Vector3;
  29391. /**
  29392. * Define the current limit on the left side for an orthographic camera
  29393. * In scene unit
  29394. */
  29395. orthoLeft: Nullable<number>;
  29396. /**
  29397. * Define the current limit on the right side for an orthographic camera
  29398. * In scene unit
  29399. */
  29400. orthoRight: Nullable<number>;
  29401. /**
  29402. * Define the current limit on the bottom side for an orthographic camera
  29403. * In scene unit
  29404. */
  29405. orthoBottom: Nullable<number>;
  29406. /**
  29407. * Define the current limit on the top side for an orthographic camera
  29408. * In scene unit
  29409. */
  29410. orthoTop: Nullable<number>;
  29411. /**
  29412. * Field Of View is set in Radians. (default is 0.8)
  29413. */
  29414. fov: number;
  29415. /**
  29416. * Define the minimum distance the camera can see from.
  29417. * This is important to note that the depth buffer are not infinite and the closer it starts
  29418. * the more your scene might encounter depth fighting issue.
  29419. */
  29420. minZ: number;
  29421. /**
  29422. * Define the maximum distance the camera can see to.
  29423. * This is important to note that the depth buffer are not infinite and the further it end
  29424. * the more your scene might encounter depth fighting issue.
  29425. */
  29426. maxZ: number;
  29427. /**
  29428. * Define the default inertia of the camera.
  29429. * This helps giving a smooth feeling to the camera movement.
  29430. */
  29431. inertia: number;
  29432. /**
  29433. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29434. */
  29435. mode: number;
  29436. /**
  29437. * Define whether the camera is intermediate.
  29438. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29439. */
  29440. isIntermediate: boolean;
  29441. /**
  29442. * Define the viewport of the camera.
  29443. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29444. */
  29445. viewport: Viewport;
  29446. /**
  29447. * Restricts the camera to viewing objects with the same layerMask.
  29448. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29449. */
  29450. layerMask: number;
  29451. /**
  29452. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29453. */
  29454. fovMode: number;
  29455. /**
  29456. * Rig mode of the camera.
  29457. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29458. * This is normally controlled byt the camera themselves as internal use.
  29459. */
  29460. cameraRigMode: number;
  29461. /**
  29462. * Defines the distance between both "eyes" in case of a RIG
  29463. */
  29464. interaxialDistance: number;
  29465. /**
  29466. * Defines if stereoscopic rendering is done side by side or over under.
  29467. */
  29468. isStereoscopicSideBySide: boolean;
  29469. /**
  29470. * 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
  29471. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29472. * else in the scene. (Eg. security camera)
  29473. *
  29474. * 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)
  29475. */
  29476. customRenderTargets: RenderTargetTexture[];
  29477. /**
  29478. * When set, the camera will render to this render target instead of the default canvas
  29479. *
  29480. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29481. */
  29482. outputRenderTarget: Nullable<RenderTargetTexture>;
  29483. /**
  29484. * Observable triggered when the camera view matrix has changed.
  29485. */
  29486. onViewMatrixChangedObservable: Observable<Camera>;
  29487. /**
  29488. * Observable triggered when the camera Projection matrix has changed.
  29489. */
  29490. onProjectionMatrixChangedObservable: Observable<Camera>;
  29491. /**
  29492. * Observable triggered when the inputs have been processed.
  29493. */
  29494. onAfterCheckInputsObservable: Observable<Camera>;
  29495. /**
  29496. * Observable triggered when reset has been called and applied to the camera.
  29497. */
  29498. onRestoreStateObservable: Observable<Camera>;
  29499. /**
  29500. * Is this camera a part of a rig system?
  29501. */
  29502. isRigCamera: boolean;
  29503. /**
  29504. * If isRigCamera set to true this will be set with the parent camera.
  29505. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29506. */
  29507. rigParent?: Camera;
  29508. /** @hidden */
  29509. _cameraRigParams: any;
  29510. /** @hidden */
  29511. _rigCameras: Camera[];
  29512. /** @hidden */
  29513. _rigPostProcess: Nullable<PostProcess>;
  29514. protected _webvrViewMatrix: Matrix;
  29515. /** @hidden */
  29516. _skipRendering: boolean;
  29517. /** @hidden */
  29518. _projectionMatrix: Matrix;
  29519. /** @hidden */
  29520. _postProcesses: Nullable<PostProcess>[];
  29521. /** @hidden */
  29522. _activeMeshes: SmartArray<AbstractMesh>;
  29523. protected _globalPosition: Vector3;
  29524. /** @hidden */
  29525. _computedViewMatrix: Matrix;
  29526. private _doNotComputeProjectionMatrix;
  29527. private _transformMatrix;
  29528. private _frustumPlanes;
  29529. private _refreshFrustumPlanes;
  29530. private _storedFov;
  29531. private _stateStored;
  29532. /**
  29533. * Instantiates a new camera object.
  29534. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29535. * @see https://doc.babylonjs.com/features/cameras
  29536. * @param name Defines the name of the camera in the scene
  29537. * @param position Defines the position of the camera
  29538. * @param scene Defines the scene the camera belongs too
  29539. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29540. */
  29541. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29542. /**
  29543. * Store current camera state (fov, position, etc..)
  29544. * @returns the camera
  29545. */
  29546. storeState(): Camera;
  29547. /**
  29548. * Restores the camera state values if it has been stored. You must call storeState() first
  29549. */
  29550. protected _restoreStateValues(): boolean;
  29551. /**
  29552. * Restored camera state. You must call storeState() first.
  29553. * @returns true if restored and false otherwise
  29554. */
  29555. restoreState(): boolean;
  29556. /**
  29557. * Gets the class name of the camera.
  29558. * @returns the class name
  29559. */
  29560. getClassName(): string;
  29561. /** @hidden */
  29562. readonly _isCamera: boolean;
  29563. /**
  29564. * Gets a string representation of the camera useful for debug purpose.
  29565. * @param fullDetails Defines that a more verboe level of logging is required
  29566. * @returns the string representation
  29567. */
  29568. toString(fullDetails?: boolean): string;
  29569. /**
  29570. * Gets the current world space position of the camera.
  29571. */
  29572. get globalPosition(): Vector3;
  29573. /**
  29574. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29575. * @returns the active meshe list
  29576. */
  29577. getActiveMeshes(): SmartArray<AbstractMesh>;
  29578. /**
  29579. * Check whether a mesh is part of the current active mesh list of the camera
  29580. * @param mesh Defines the mesh to check
  29581. * @returns true if active, false otherwise
  29582. */
  29583. isActiveMesh(mesh: Mesh): boolean;
  29584. /**
  29585. * Is this camera ready to be used/rendered
  29586. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29587. * @return true if the camera is ready
  29588. */
  29589. isReady(completeCheck?: boolean): boolean;
  29590. /** @hidden */
  29591. _initCache(): void;
  29592. /** @hidden */
  29593. _updateCache(ignoreParentClass?: boolean): void;
  29594. /** @hidden */
  29595. _isSynchronized(): boolean;
  29596. /** @hidden */
  29597. _isSynchronizedViewMatrix(): boolean;
  29598. /** @hidden */
  29599. _isSynchronizedProjectionMatrix(): boolean;
  29600. /**
  29601. * Attach the input controls to a specific dom element to get the input from.
  29602. * @param element Defines the element the controls should be listened from
  29603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29604. */
  29605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29606. /**
  29607. * Detach the current controls from the specified dom element.
  29608. * @param element Defines the element to stop listening the inputs from
  29609. */
  29610. detachControl(element: HTMLElement): void;
  29611. /**
  29612. * Update the camera state according to the different inputs gathered during the frame.
  29613. */
  29614. update(): void;
  29615. /** @hidden */
  29616. _checkInputs(): void;
  29617. /** @hidden */
  29618. get rigCameras(): Camera[];
  29619. /**
  29620. * Gets the post process used by the rig cameras
  29621. */
  29622. get rigPostProcess(): Nullable<PostProcess>;
  29623. /**
  29624. * Internal, gets the first post proces.
  29625. * @returns the first post process to be run on this camera.
  29626. */
  29627. _getFirstPostProcess(): Nullable<PostProcess>;
  29628. private _cascadePostProcessesToRigCams;
  29629. /**
  29630. * Attach a post process to the camera.
  29631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29632. * @param postProcess The post process to attach to the camera
  29633. * @param insertAt The position of the post process in case several of them are in use in the scene
  29634. * @returns the position the post process has been inserted at
  29635. */
  29636. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29637. /**
  29638. * Detach a post process to the camera.
  29639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29640. * @param postProcess The post process to detach from the camera
  29641. */
  29642. detachPostProcess(postProcess: PostProcess): void;
  29643. /**
  29644. * Gets the current world matrix of the camera
  29645. */
  29646. getWorldMatrix(): Matrix;
  29647. /** @hidden */
  29648. _getViewMatrix(): Matrix;
  29649. /**
  29650. * Gets the current view matrix of the camera.
  29651. * @param force forces the camera to recompute the matrix without looking at the cached state
  29652. * @returns the view matrix
  29653. */
  29654. getViewMatrix(force?: boolean): Matrix;
  29655. /**
  29656. * Freeze the projection matrix.
  29657. * It will prevent the cache check of the camera projection compute and can speed up perf
  29658. * if no parameter of the camera are meant to change
  29659. * @param projection Defines manually a projection if necessary
  29660. */
  29661. freezeProjectionMatrix(projection?: Matrix): void;
  29662. /**
  29663. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29664. */
  29665. unfreezeProjectionMatrix(): void;
  29666. /**
  29667. * Gets the current projection matrix of the camera.
  29668. * @param force forces the camera to recompute the matrix without looking at the cached state
  29669. * @returns the projection matrix
  29670. */
  29671. getProjectionMatrix(force?: boolean): Matrix;
  29672. /**
  29673. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29674. * @returns a Matrix
  29675. */
  29676. getTransformationMatrix(): Matrix;
  29677. private _updateFrustumPlanes;
  29678. /**
  29679. * Checks if a cullable object (mesh...) is in the camera frustum
  29680. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29681. * @param target The object to check
  29682. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29683. * @returns true if the object is in frustum otherwise false
  29684. */
  29685. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29686. /**
  29687. * Checks if a cullable object (mesh...) is in the camera frustum
  29688. * Unlike isInFrustum this cheks the full bounding box
  29689. * @param target The object to check
  29690. * @returns true if the object is in frustum otherwise false
  29691. */
  29692. isCompletelyInFrustum(target: ICullable): boolean;
  29693. /**
  29694. * Gets a ray in the forward direction from the camera.
  29695. * @param length Defines the length of the ray to create
  29696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29697. * @param origin Defines the start point of the ray which defaults to the camera position
  29698. * @returns the forward ray
  29699. */
  29700. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29701. /**
  29702. * Gets a ray in the forward direction from the camera.
  29703. * @param refRay the ray to (re)use when setting the values
  29704. * @param length Defines the length of the ray to create
  29705. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29706. * @param origin Defines the start point of the ray which defaults to the camera position
  29707. * @returns the forward ray
  29708. */
  29709. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29710. /**
  29711. * Releases resources associated with this node.
  29712. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29713. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29714. */
  29715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29716. /** @hidden */
  29717. _isLeftCamera: boolean;
  29718. /**
  29719. * Gets the left camera of a rig setup in case of Rigged Camera
  29720. */
  29721. get isLeftCamera(): boolean;
  29722. /** @hidden */
  29723. _isRightCamera: boolean;
  29724. /**
  29725. * Gets the right camera of a rig setup in case of Rigged Camera
  29726. */
  29727. get isRightCamera(): boolean;
  29728. /**
  29729. * Gets the left camera of a rig setup in case of Rigged Camera
  29730. */
  29731. get leftCamera(): Nullable<FreeCamera>;
  29732. /**
  29733. * Gets the right camera of a rig setup in case of Rigged Camera
  29734. */
  29735. get rightCamera(): Nullable<FreeCamera>;
  29736. /**
  29737. * Gets the left camera target of a rig setup in case of Rigged Camera
  29738. * @returns the target position
  29739. */
  29740. getLeftTarget(): Nullable<Vector3>;
  29741. /**
  29742. * Gets the right camera target of a rig setup in case of Rigged Camera
  29743. * @returns the target position
  29744. */
  29745. getRightTarget(): Nullable<Vector3>;
  29746. /**
  29747. * @hidden
  29748. */
  29749. setCameraRigMode(mode: number, rigParams: any): void;
  29750. /** @hidden */
  29751. static _setStereoscopicRigMode(camera: Camera): void;
  29752. /** @hidden */
  29753. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29754. /** @hidden */
  29755. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29756. /** @hidden */
  29757. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29758. /** @hidden */
  29759. _getVRProjectionMatrix(): Matrix;
  29760. protected _updateCameraRotationMatrix(): void;
  29761. protected _updateWebVRCameraRotationMatrix(): void;
  29762. /**
  29763. * This function MUST be overwritten by the different WebVR cameras available.
  29764. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29765. * @hidden
  29766. */
  29767. _getWebVRProjectionMatrix(): Matrix;
  29768. /**
  29769. * This function MUST be overwritten by the different WebVR cameras available.
  29770. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29771. * @hidden
  29772. */
  29773. _getWebVRViewMatrix(): Matrix;
  29774. /** @hidden */
  29775. setCameraRigParameter(name: string, value: any): void;
  29776. /**
  29777. * needs to be overridden by children so sub has required properties to be copied
  29778. * @hidden
  29779. */
  29780. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29781. /**
  29782. * May need to be overridden by children
  29783. * @hidden
  29784. */
  29785. _updateRigCameras(): void;
  29786. /** @hidden */
  29787. _setupInputs(): void;
  29788. /**
  29789. * Serialiaze the camera setup to a json represention
  29790. * @returns the JSON representation
  29791. */
  29792. serialize(): any;
  29793. /**
  29794. * Clones the current camera.
  29795. * @param name The cloned camera name
  29796. * @returns the cloned camera
  29797. */
  29798. clone(name: string): Camera;
  29799. /**
  29800. * Gets the direction of the camera relative to a given local axis.
  29801. * @param localAxis Defines the reference axis to provide a relative direction.
  29802. * @return the direction
  29803. */
  29804. getDirection(localAxis: Vector3): Vector3;
  29805. /**
  29806. * Returns the current camera absolute rotation
  29807. */
  29808. get absoluteRotation(): Quaternion;
  29809. /**
  29810. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29811. * @param localAxis Defines the reference axis to provide a relative direction.
  29812. * @param result Defines the vector to store the result in
  29813. */
  29814. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29815. /**
  29816. * Gets a camera constructor for a given camera type
  29817. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29818. * @param name The name of the camera the result will be able to instantiate
  29819. * @param scene The scene the result will construct the camera in
  29820. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29821. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29822. * @returns a factory method to construc the camera
  29823. */
  29824. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29825. /**
  29826. * Compute the world matrix of the camera.
  29827. * @returns the camera world matrix
  29828. */
  29829. computeWorldMatrix(): Matrix;
  29830. /**
  29831. * Parse a JSON and creates the camera from the parsed information
  29832. * @param parsedCamera The JSON to parse
  29833. * @param scene The scene to instantiate the camera in
  29834. * @returns the newly constructed camera
  29835. */
  29836. static Parse(parsedCamera: any, scene: Scene): Camera;
  29837. }
  29838. }
  29839. declare module BABYLON {
  29840. /**
  29841. * Class containing static functions to help procedurally build meshes
  29842. */
  29843. export class DiscBuilder {
  29844. /**
  29845. * Creates a plane polygonal mesh. By default, this is a disc
  29846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29847. * * 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
  29848. * * 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
  29849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29850. * * 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
  29851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29852. * @param name defines the name of the mesh
  29853. * @param options defines the options used to create the mesh
  29854. * @param scene defines the hosting scene
  29855. * @returns the plane polygonal mesh
  29856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29857. */
  29858. static CreateDisc(name: string, options: {
  29859. radius?: number;
  29860. tessellation?: number;
  29861. arc?: number;
  29862. updatable?: boolean;
  29863. sideOrientation?: number;
  29864. frontUVs?: Vector4;
  29865. backUVs?: Vector4;
  29866. }, scene?: Nullable<Scene>): Mesh;
  29867. }
  29868. }
  29869. declare module BABYLON {
  29870. /**
  29871. * Options to be used when creating a FresnelParameters.
  29872. */
  29873. export type IFresnelParametersCreationOptions = {
  29874. /**
  29875. * Define the color used on edges (grazing angle)
  29876. */
  29877. leftColor?: Color3;
  29878. /**
  29879. * Define the color used on center
  29880. */
  29881. rightColor?: Color3;
  29882. /**
  29883. * Define bias applied to computed fresnel term
  29884. */
  29885. bias?: number;
  29886. /**
  29887. * Defined the power exponent applied to fresnel term
  29888. */
  29889. power?: number;
  29890. /**
  29891. * Define if the fresnel effect is enable or not.
  29892. */
  29893. isEnabled?: boolean;
  29894. };
  29895. /**
  29896. * Serialized format for FresnelParameters.
  29897. */
  29898. export type IFresnelParametersSerialized = {
  29899. /**
  29900. * Define the color used on edges (grazing angle) [as an array]
  29901. */
  29902. leftColor: number[];
  29903. /**
  29904. * Define the color used on center [as an array]
  29905. */
  29906. rightColor: number[];
  29907. /**
  29908. * Define bias applied to computed fresnel term
  29909. */
  29910. bias: number;
  29911. /**
  29912. * Defined the power exponent applied to fresnel term
  29913. */
  29914. power?: number;
  29915. /**
  29916. * Define if the fresnel effect is enable or not.
  29917. */
  29918. isEnabled: boolean;
  29919. };
  29920. /**
  29921. * This represents all the required information to add a fresnel effect on a material:
  29922. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29923. */
  29924. export class FresnelParameters {
  29925. private _isEnabled;
  29926. /**
  29927. * Define if the fresnel effect is enable or not.
  29928. */
  29929. get isEnabled(): boolean;
  29930. set isEnabled(value: boolean);
  29931. /**
  29932. * Define the color used on edges (grazing angle)
  29933. */
  29934. leftColor: Color3;
  29935. /**
  29936. * Define the color used on center
  29937. */
  29938. rightColor: Color3;
  29939. /**
  29940. * Define bias applied to computed fresnel term
  29941. */
  29942. bias: number;
  29943. /**
  29944. * Defined the power exponent applied to fresnel term
  29945. */
  29946. power: number;
  29947. /**
  29948. * Creates a new FresnelParameters object.
  29949. *
  29950. * @param options provide your own settings to optionally to override defaults
  29951. */
  29952. constructor(options?: IFresnelParametersCreationOptions);
  29953. /**
  29954. * Clones the current fresnel and its valuues
  29955. * @returns a clone fresnel configuration
  29956. */
  29957. clone(): FresnelParameters;
  29958. /**
  29959. * Determines equality between FresnelParameters objects
  29960. * @param otherFresnelParameters defines the second operand
  29961. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29962. */
  29963. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29964. /**
  29965. * Serializes the current fresnel parameters to a JSON representation.
  29966. * @return the JSON serialization
  29967. */
  29968. serialize(): IFresnelParametersSerialized;
  29969. /**
  29970. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29971. * @param parsedFresnelParameters Define the JSON representation
  29972. * @returns the parsed parameters
  29973. */
  29974. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29975. }
  29976. }
  29977. declare module BABYLON {
  29978. /**
  29979. * This groups all the flags used to control the materials channel.
  29980. */
  29981. export class MaterialFlags {
  29982. private static _DiffuseTextureEnabled;
  29983. /**
  29984. * Are diffuse textures enabled in the application.
  29985. */
  29986. static get DiffuseTextureEnabled(): boolean;
  29987. static set DiffuseTextureEnabled(value: boolean);
  29988. private static _DetailTextureEnabled;
  29989. /**
  29990. * Are detail textures enabled in the application.
  29991. */
  29992. static get DetailTextureEnabled(): boolean;
  29993. static set DetailTextureEnabled(value: boolean);
  29994. private static _AmbientTextureEnabled;
  29995. /**
  29996. * Are ambient textures enabled in the application.
  29997. */
  29998. static get AmbientTextureEnabled(): boolean;
  29999. static set AmbientTextureEnabled(value: boolean);
  30000. private static _OpacityTextureEnabled;
  30001. /**
  30002. * Are opacity textures enabled in the application.
  30003. */
  30004. static get OpacityTextureEnabled(): boolean;
  30005. static set OpacityTextureEnabled(value: boolean);
  30006. private static _ReflectionTextureEnabled;
  30007. /**
  30008. * Are reflection textures enabled in the application.
  30009. */
  30010. static get ReflectionTextureEnabled(): boolean;
  30011. static set ReflectionTextureEnabled(value: boolean);
  30012. private static _EmissiveTextureEnabled;
  30013. /**
  30014. * Are emissive textures enabled in the application.
  30015. */
  30016. static get EmissiveTextureEnabled(): boolean;
  30017. static set EmissiveTextureEnabled(value: boolean);
  30018. private static _SpecularTextureEnabled;
  30019. /**
  30020. * Are specular textures enabled in the application.
  30021. */
  30022. static get SpecularTextureEnabled(): boolean;
  30023. static set SpecularTextureEnabled(value: boolean);
  30024. private static _BumpTextureEnabled;
  30025. /**
  30026. * Are bump textures enabled in the application.
  30027. */
  30028. static get BumpTextureEnabled(): boolean;
  30029. static set BumpTextureEnabled(value: boolean);
  30030. private static _LightmapTextureEnabled;
  30031. /**
  30032. * Are lightmap textures enabled in the application.
  30033. */
  30034. static get LightmapTextureEnabled(): boolean;
  30035. static set LightmapTextureEnabled(value: boolean);
  30036. private static _RefractionTextureEnabled;
  30037. /**
  30038. * Are refraction textures enabled in the application.
  30039. */
  30040. static get RefractionTextureEnabled(): boolean;
  30041. static set RefractionTextureEnabled(value: boolean);
  30042. private static _ColorGradingTextureEnabled;
  30043. /**
  30044. * Are color grading textures enabled in the application.
  30045. */
  30046. static get ColorGradingTextureEnabled(): boolean;
  30047. static set ColorGradingTextureEnabled(value: boolean);
  30048. private static _FresnelEnabled;
  30049. /**
  30050. * Are fresnels enabled in the application.
  30051. */
  30052. static get FresnelEnabled(): boolean;
  30053. static set FresnelEnabled(value: boolean);
  30054. private static _ClearCoatTextureEnabled;
  30055. /**
  30056. * Are clear coat textures enabled in the application.
  30057. */
  30058. static get ClearCoatTextureEnabled(): boolean;
  30059. static set ClearCoatTextureEnabled(value: boolean);
  30060. private static _ClearCoatBumpTextureEnabled;
  30061. /**
  30062. * Are clear coat bump textures enabled in the application.
  30063. */
  30064. static get ClearCoatBumpTextureEnabled(): boolean;
  30065. static set ClearCoatBumpTextureEnabled(value: boolean);
  30066. private static _ClearCoatTintTextureEnabled;
  30067. /**
  30068. * Are clear coat tint textures enabled in the application.
  30069. */
  30070. static get ClearCoatTintTextureEnabled(): boolean;
  30071. static set ClearCoatTintTextureEnabled(value: boolean);
  30072. private static _SheenTextureEnabled;
  30073. /**
  30074. * Are sheen textures enabled in the application.
  30075. */
  30076. static get SheenTextureEnabled(): boolean;
  30077. static set SheenTextureEnabled(value: boolean);
  30078. private static _AnisotropicTextureEnabled;
  30079. /**
  30080. * Are anisotropic textures enabled in the application.
  30081. */
  30082. static get AnisotropicTextureEnabled(): boolean;
  30083. static set AnisotropicTextureEnabled(value: boolean);
  30084. private static _ThicknessTextureEnabled;
  30085. /**
  30086. * Are thickness textures enabled in the application.
  30087. */
  30088. static get ThicknessTextureEnabled(): boolean;
  30089. static set ThicknessTextureEnabled(value: boolean);
  30090. }
  30091. }
  30092. declare module BABYLON {
  30093. /** @hidden */
  30094. export var defaultFragmentDeclaration: {
  30095. name: string;
  30096. shader: string;
  30097. };
  30098. }
  30099. declare module BABYLON {
  30100. /** @hidden */
  30101. export var defaultUboDeclaration: {
  30102. name: string;
  30103. shader: string;
  30104. };
  30105. }
  30106. declare module BABYLON {
  30107. /** @hidden */
  30108. export var prePassDeclaration: {
  30109. name: string;
  30110. shader: string;
  30111. };
  30112. }
  30113. declare module BABYLON {
  30114. /** @hidden */
  30115. export var lightFragmentDeclaration: {
  30116. name: string;
  30117. shader: string;
  30118. };
  30119. }
  30120. declare module BABYLON {
  30121. /** @hidden */
  30122. export var lightUboDeclaration: {
  30123. name: string;
  30124. shader: string;
  30125. };
  30126. }
  30127. declare module BABYLON {
  30128. /** @hidden */
  30129. export var lightsFragmentFunctions: {
  30130. name: string;
  30131. shader: string;
  30132. };
  30133. }
  30134. declare module BABYLON {
  30135. /** @hidden */
  30136. export var shadowsFragmentFunctions: {
  30137. name: string;
  30138. shader: string;
  30139. };
  30140. }
  30141. declare module BABYLON {
  30142. /** @hidden */
  30143. export var fresnelFunction: {
  30144. name: string;
  30145. shader: string;
  30146. };
  30147. }
  30148. declare module BABYLON {
  30149. /** @hidden */
  30150. export var bumpFragmentMainFunctions: {
  30151. name: string;
  30152. shader: string;
  30153. };
  30154. }
  30155. declare module BABYLON {
  30156. /** @hidden */
  30157. export var bumpFragmentFunctions: {
  30158. name: string;
  30159. shader: string;
  30160. };
  30161. }
  30162. declare module BABYLON {
  30163. /** @hidden */
  30164. export var logDepthDeclaration: {
  30165. name: string;
  30166. shader: string;
  30167. };
  30168. }
  30169. declare module BABYLON {
  30170. /** @hidden */
  30171. export var bumpFragment: {
  30172. name: string;
  30173. shader: string;
  30174. };
  30175. }
  30176. declare module BABYLON {
  30177. /** @hidden */
  30178. export var depthPrePass: {
  30179. name: string;
  30180. shader: string;
  30181. };
  30182. }
  30183. declare module BABYLON {
  30184. /** @hidden */
  30185. export var lightFragment: {
  30186. name: string;
  30187. shader: string;
  30188. };
  30189. }
  30190. declare module BABYLON {
  30191. /** @hidden */
  30192. export var logDepthFragment: {
  30193. name: string;
  30194. shader: string;
  30195. };
  30196. }
  30197. declare module BABYLON {
  30198. /** @hidden */
  30199. export var defaultPixelShader: {
  30200. name: string;
  30201. shader: string;
  30202. };
  30203. }
  30204. declare module BABYLON {
  30205. /** @hidden */
  30206. export var defaultVertexDeclaration: {
  30207. name: string;
  30208. shader: string;
  30209. };
  30210. }
  30211. declare module BABYLON {
  30212. /** @hidden */
  30213. export var bumpVertexDeclaration: {
  30214. name: string;
  30215. shader: string;
  30216. };
  30217. }
  30218. declare module BABYLON {
  30219. /** @hidden */
  30220. export var bumpVertex: {
  30221. name: string;
  30222. shader: string;
  30223. };
  30224. }
  30225. declare module BABYLON {
  30226. /** @hidden */
  30227. export var fogVertex: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module BABYLON {
  30233. /** @hidden */
  30234. export var shadowsVertex: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module BABYLON {
  30240. /** @hidden */
  30241. export var pointCloudVertex: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module BABYLON {
  30247. /** @hidden */
  30248. export var logDepthVertex: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module BABYLON {
  30254. /** @hidden */
  30255. export var defaultVertexShader: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module BABYLON {
  30261. /**
  30262. * @hidden
  30263. */
  30264. export interface IMaterialDetailMapDefines {
  30265. DETAIL: boolean;
  30266. DETAILDIRECTUV: number;
  30267. DETAIL_NORMALBLENDMETHOD: number;
  30268. /** @hidden */
  30269. _areTexturesDirty: boolean;
  30270. }
  30271. /**
  30272. * Define the code related to the detail map parameters of a material
  30273. *
  30274. * Inspired from:
  30275. * 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
  30276. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30277. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30278. */
  30279. export class DetailMapConfiguration {
  30280. private _texture;
  30281. /**
  30282. * The detail texture of the material.
  30283. */
  30284. texture: Nullable<BaseTexture>;
  30285. /**
  30286. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30287. * Bigger values mean stronger blending
  30288. */
  30289. diffuseBlendLevel: number;
  30290. /**
  30291. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30292. * Bigger values mean stronger blending. Only used with PBR materials
  30293. */
  30294. roughnessBlendLevel: number;
  30295. /**
  30296. * Defines how strong the bump effect from the detail map is
  30297. * Bigger values mean stronger effect
  30298. */
  30299. bumpLevel: number;
  30300. private _normalBlendMethod;
  30301. /**
  30302. * The method used to blend the bump and detail normals together
  30303. */
  30304. normalBlendMethod: number;
  30305. private _isEnabled;
  30306. /**
  30307. * Enable or disable the detail map on this material
  30308. */
  30309. isEnabled: boolean;
  30310. /** @hidden */
  30311. private _internalMarkAllSubMeshesAsTexturesDirty;
  30312. /** @hidden */
  30313. _markAllSubMeshesAsTexturesDirty(): void;
  30314. /**
  30315. * Instantiate a new detail map
  30316. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30317. */
  30318. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30319. /**
  30320. * Gets whether the submesh is ready to be used or not.
  30321. * @param defines the list of "defines" to update.
  30322. * @param scene defines the scene the material belongs to.
  30323. * @returns - boolean indicating that the submesh is ready or not.
  30324. */
  30325. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30326. /**
  30327. * Update the defines for detail map usage
  30328. * @param defines the list of "defines" to update.
  30329. * @param scene defines the scene the material belongs to.
  30330. */
  30331. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30332. /**
  30333. * Binds the material data.
  30334. * @param uniformBuffer defines the Uniform buffer to fill in.
  30335. * @param scene defines the scene the material belongs to.
  30336. * @param isFrozen defines whether the material is frozen or not.
  30337. */
  30338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30339. /**
  30340. * Checks to see if a texture is used in the material.
  30341. * @param texture - Base texture to use.
  30342. * @returns - Boolean specifying if a texture is used in the material.
  30343. */
  30344. hasTexture(texture: BaseTexture): boolean;
  30345. /**
  30346. * Returns an array of the actively used textures.
  30347. * @param activeTextures Array of BaseTextures
  30348. */
  30349. getActiveTextures(activeTextures: BaseTexture[]): void;
  30350. /**
  30351. * Returns the animatable textures.
  30352. * @param animatables Array of animatable textures.
  30353. */
  30354. getAnimatables(animatables: IAnimatable[]): void;
  30355. /**
  30356. * Disposes the resources of the material.
  30357. * @param forceDisposeTextures - Forces the disposal of all textures.
  30358. */
  30359. dispose(forceDisposeTextures?: boolean): void;
  30360. /**
  30361. * Get the current class name useful for serialization or dynamic coding.
  30362. * @returns "DetailMap"
  30363. */
  30364. getClassName(): string;
  30365. /**
  30366. * Add the required uniforms to the current list.
  30367. * @param uniforms defines the current uniform list.
  30368. */
  30369. static AddUniforms(uniforms: string[]): void;
  30370. /**
  30371. * Add the required samplers to the current list.
  30372. * @param samplers defines the current sampler list.
  30373. */
  30374. static AddSamplers(samplers: string[]): void;
  30375. /**
  30376. * Add the required uniforms to the current buffer.
  30377. * @param uniformBuffer defines the current uniform buffer.
  30378. */
  30379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30380. /**
  30381. * Makes a duplicate of the current instance into another one.
  30382. * @param detailMap define the instance where to copy the info
  30383. */
  30384. copyTo(detailMap: DetailMapConfiguration): void;
  30385. /**
  30386. * Serializes this detail map instance
  30387. * @returns - An object with the serialized instance.
  30388. */
  30389. serialize(): any;
  30390. /**
  30391. * Parses a detail map setting from a serialized object.
  30392. * @param source - Serialized object.
  30393. * @param scene Defines the scene we are parsing for
  30394. * @param rootUrl Defines the rootUrl to load from
  30395. */
  30396. parse(source: any, scene: Scene, rootUrl: string): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /** @hidden */
  30401. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30402. MAINUV1: boolean;
  30403. MAINUV2: boolean;
  30404. DIFFUSE: boolean;
  30405. DIFFUSEDIRECTUV: number;
  30406. DETAIL: boolean;
  30407. DETAILDIRECTUV: number;
  30408. DETAIL_NORMALBLENDMETHOD: number;
  30409. AMBIENT: boolean;
  30410. AMBIENTDIRECTUV: number;
  30411. OPACITY: boolean;
  30412. OPACITYDIRECTUV: number;
  30413. OPACITYRGB: boolean;
  30414. REFLECTION: boolean;
  30415. EMISSIVE: boolean;
  30416. EMISSIVEDIRECTUV: number;
  30417. SPECULAR: boolean;
  30418. SPECULARDIRECTUV: number;
  30419. BUMP: boolean;
  30420. BUMPDIRECTUV: number;
  30421. PARALLAX: boolean;
  30422. PARALLAXOCCLUSION: boolean;
  30423. SPECULAROVERALPHA: boolean;
  30424. CLIPPLANE: boolean;
  30425. CLIPPLANE2: boolean;
  30426. CLIPPLANE3: boolean;
  30427. CLIPPLANE4: boolean;
  30428. CLIPPLANE5: boolean;
  30429. CLIPPLANE6: boolean;
  30430. ALPHATEST: boolean;
  30431. DEPTHPREPASS: boolean;
  30432. ALPHAFROMDIFFUSE: boolean;
  30433. POINTSIZE: boolean;
  30434. FOG: boolean;
  30435. SPECULARTERM: boolean;
  30436. DIFFUSEFRESNEL: boolean;
  30437. OPACITYFRESNEL: boolean;
  30438. REFLECTIONFRESNEL: boolean;
  30439. REFRACTIONFRESNEL: boolean;
  30440. EMISSIVEFRESNEL: boolean;
  30441. FRESNEL: boolean;
  30442. NORMAL: boolean;
  30443. UV1: boolean;
  30444. UV2: boolean;
  30445. VERTEXCOLOR: boolean;
  30446. VERTEXALPHA: boolean;
  30447. NUM_BONE_INFLUENCERS: number;
  30448. BonesPerMesh: number;
  30449. BONETEXTURE: boolean;
  30450. INSTANCES: boolean;
  30451. THIN_INSTANCES: boolean;
  30452. GLOSSINESS: boolean;
  30453. ROUGHNESS: boolean;
  30454. EMISSIVEASILLUMINATION: boolean;
  30455. LINKEMISSIVEWITHDIFFUSE: boolean;
  30456. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30457. LIGHTMAP: boolean;
  30458. LIGHTMAPDIRECTUV: number;
  30459. OBJECTSPACE_NORMALMAP: boolean;
  30460. USELIGHTMAPASSHADOWMAP: boolean;
  30461. REFLECTIONMAP_3D: boolean;
  30462. REFLECTIONMAP_SPHERICAL: boolean;
  30463. REFLECTIONMAP_PLANAR: boolean;
  30464. REFLECTIONMAP_CUBIC: boolean;
  30465. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30466. REFLECTIONMAP_PROJECTION: boolean;
  30467. REFLECTIONMAP_SKYBOX: boolean;
  30468. REFLECTIONMAP_EXPLICIT: boolean;
  30469. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30470. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30471. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30472. INVERTCUBICMAP: boolean;
  30473. LOGARITHMICDEPTH: boolean;
  30474. REFRACTION: boolean;
  30475. REFRACTIONMAP_3D: boolean;
  30476. REFLECTIONOVERALPHA: boolean;
  30477. TWOSIDEDLIGHTING: boolean;
  30478. SHADOWFLOAT: boolean;
  30479. MORPHTARGETS: boolean;
  30480. MORPHTARGETS_NORMAL: boolean;
  30481. MORPHTARGETS_TANGENT: boolean;
  30482. MORPHTARGETS_UV: boolean;
  30483. NUM_MORPH_INFLUENCERS: number;
  30484. NONUNIFORMSCALING: boolean;
  30485. PREMULTIPLYALPHA: boolean;
  30486. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30487. ALPHABLEND: boolean;
  30488. PREPASS: boolean;
  30489. SCENE_MRT_COUNT: number;
  30490. RGBDLIGHTMAP: boolean;
  30491. RGBDREFLECTION: boolean;
  30492. RGBDREFRACTION: boolean;
  30493. IMAGEPROCESSING: boolean;
  30494. VIGNETTE: boolean;
  30495. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30496. VIGNETTEBLENDMODEOPAQUE: boolean;
  30497. TONEMAPPING: boolean;
  30498. TONEMAPPING_ACES: boolean;
  30499. CONTRAST: boolean;
  30500. COLORCURVES: boolean;
  30501. COLORGRADING: boolean;
  30502. COLORGRADING3D: boolean;
  30503. SAMPLER3DGREENDEPTH: boolean;
  30504. SAMPLER3DBGRMAP: boolean;
  30505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30506. MULTIVIEW: boolean;
  30507. /**
  30508. * If the reflection texture on this material is in linear color space
  30509. * @hidden
  30510. */
  30511. IS_REFLECTION_LINEAR: boolean;
  30512. /**
  30513. * If the refraction texture on this material is in linear color space
  30514. * @hidden
  30515. */
  30516. IS_REFRACTION_LINEAR: boolean;
  30517. EXPOSURE: boolean;
  30518. constructor();
  30519. setReflectionMode(modeToEnable: string): void;
  30520. }
  30521. /**
  30522. * This is the default material used in Babylon. It is the best trade off between quality
  30523. * and performances.
  30524. * @see https://doc.babylonjs.com/babylon101/materials
  30525. */
  30526. export class StandardMaterial extends PushMaterial {
  30527. private _diffuseTexture;
  30528. /**
  30529. * The basic texture of the material as viewed under a light.
  30530. */
  30531. diffuseTexture: Nullable<BaseTexture>;
  30532. private _ambientTexture;
  30533. /**
  30534. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30535. */
  30536. ambientTexture: Nullable<BaseTexture>;
  30537. private _opacityTexture;
  30538. /**
  30539. * Define the transparency of the material from a texture.
  30540. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30541. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30542. */
  30543. opacityTexture: Nullable<BaseTexture>;
  30544. private _reflectionTexture;
  30545. /**
  30546. * Define the texture used to display the reflection.
  30547. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30548. */
  30549. reflectionTexture: Nullable<BaseTexture>;
  30550. private _emissiveTexture;
  30551. /**
  30552. * Define texture of the material as if self lit.
  30553. * This will be mixed in the final result even in the absence of light.
  30554. */
  30555. emissiveTexture: Nullable<BaseTexture>;
  30556. private _specularTexture;
  30557. /**
  30558. * Define how the color and intensity of the highlight given by the light in the material.
  30559. */
  30560. specularTexture: Nullable<BaseTexture>;
  30561. private _bumpTexture;
  30562. /**
  30563. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30564. * 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.
  30565. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30566. */
  30567. bumpTexture: Nullable<BaseTexture>;
  30568. private _lightmapTexture;
  30569. /**
  30570. * Complex lighting can be computationally expensive to compute at runtime.
  30571. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30572. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30573. */
  30574. lightmapTexture: Nullable<BaseTexture>;
  30575. private _refractionTexture;
  30576. /**
  30577. * Define the texture used to display the refraction.
  30578. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30579. */
  30580. refractionTexture: Nullable<BaseTexture>;
  30581. /**
  30582. * The color of the material lit by the environmental background lighting.
  30583. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30584. */
  30585. ambientColor: Color3;
  30586. /**
  30587. * The basic color of the material as viewed under a light.
  30588. */
  30589. diffuseColor: Color3;
  30590. /**
  30591. * Define how the color and intensity of the highlight given by the light in the material.
  30592. */
  30593. specularColor: Color3;
  30594. /**
  30595. * Define the color of the material as if self lit.
  30596. * This will be mixed in the final result even in the absence of light.
  30597. */
  30598. emissiveColor: Color3;
  30599. /**
  30600. * Defines how sharp are the highlights in the material.
  30601. * The bigger the value the sharper giving a more glossy feeling to the result.
  30602. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30603. */
  30604. specularPower: number;
  30605. private _useAlphaFromDiffuseTexture;
  30606. /**
  30607. * Does the transparency come from the diffuse texture alpha channel.
  30608. */
  30609. useAlphaFromDiffuseTexture: boolean;
  30610. private _useEmissiveAsIllumination;
  30611. /**
  30612. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30613. */
  30614. useEmissiveAsIllumination: boolean;
  30615. private _linkEmissiveWithDiffuse;
  30616. /**
  30617. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30618. * the emissive level when the final color is close to one.
  30619. */
  30620. linkEmissiveWithDiffuse: boolean;
  30621. private _useSpecularOverAlpha;
  30622. /**
  30623. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30624. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30625. */
  30626. useSpecularOverAlpha: boolean;
  30627. private _useReflectionOverAlpha;
  30628. /**
  30629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30631. */
  30632. useReflectionOverAlpha: boolean;
  30633. private _disableLighting;
  30634. /**
  30635. * Does lights from the scene impacts this material.
  30636. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30637. */
  30638. disableLighting: boolean;
  30639. private _useObjectSpaceNormalMap;
  30640. /**
  30641. * Allows using an object space normal map (instead of tangent space).
  30642. */
  30643. useObjectSpaceNormalMap: boolean;
  30644. private _useParallax;
  30645. /**
  30646. * Is parallax enabled or not.
  30647. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30648. */
  30649. useParallax: boolean;
  30650. private _useParallaxOcclusion;
  30651. /**
  30652. * Is parallax occlusion enabled or not.
  30653. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30654. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30655. */
  30656. useParallaxOcclusion: boolean;
  30657. /**
  30658. * 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.
  30659. */
  30660. parallaxScaleBias: number;
  30661. private _roughness;
  30662. /**
  30663. * Helps to define how blurry the reflections should appears in the material.
  30664. */
  30665. roughness: number;
  30666. /**
  30667. * In case of refraction, define the value of the index of refraction.
  30668. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30669. */
  30670. indexOfRefraction: number;
  30671. /**
  30672. * Invert the refraction texture alongside the y axis.
  30673. * It can be useful with procedural textures or probe for instance.
  30674. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30675. */
  30676. invertRefractionY: boolean;
  30677. /**
  30678. * Defines the alpha limits in alpha test mode.
  30679. */
  30680. alphaCutOff: number;
  30681. private _useLightmapAsShadowmap;
  30682. /**
  30683. * In case of light mapping, define whether the map contains light or shadow informations.
  30684. */
  30685. useLightmapAsShadowmap: boolean;
  30686. private _diffuseFresnelParameters;
  30687. /**
  30688. * Define the diffuse fresnel parameters of the material.
  30689. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30690. */
  30691. diffuseFresnelParameters: FresnelParameters;
  30692. private _opacityFresnelParameters;
  30693. /**
  30694. * Define the opacity fresnel parameters of the material.
  30695. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30696. */
  30697. opacityFresnelParameters: FresnelParameters;
  30698. private _reflectionFresnelParameters;
  30699. /**
  30700. * Define the reflection fresnel parameters of the material.
  30701. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30702. */
  30703. reflectionFresnelParameters: FresnelParameters;
  30704. private _refractionFresnelParameters;
  30705. /**
  30706. * Define the refraction fresnel parameters of the material.
  30707. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30708. */
  30709. refractionFresnelParameters: FresnelParameters;
  30710. private _emissiveFresnelParameters;
  30711. /**
  30712. * Define the emissive fresnel parameters of the material.
  30713. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30714. */
  30715. emissiveFresnelParameters: FresnelParameters;
  30716. private _useReflectionFresnelFromSpecular;
  30717. /**
  30718. * If true automatically deducts the fresnels values from the material specularity.
  30719. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30720. */
  30721. useReflectionFresnelFromSpecular: boolean;
  30722. private _useGlossinessFromSpecularMapAlpha;
  30723. /**
  30724. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30725. */
  30726. useGlossinessFromSpecularMapAlpha: boolean;
  30727. private _maxSimultaneousLights;
  30728. /**
  30729. * Defines the maximum number of lights that can be used in the material
  30730. */
  30731. maxSimultaneousLights: number;
  30732. private _invertNormalMapX;
  30733. /**
  30734. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30735. */
  30736. invertNormalMapX: boolean;
  30737. private _invertNormalMapY;
  30738. /**
  30739. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30740. */
  30741. invertNormalMapY: boolean;
  30742. private _twoSidedLighting;
  30743. /**
  30744. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30745. */
  30746. twoSidedLighting: boolean;
  30747. /**
  30748. * Default configuration related to image processing available in the standard Material.
  30749. */
  30750. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30751. /**
  30752. * Gets the image processing configuration used either in this material.
  30753. */
  30754. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30755. /**
  30756. * Sets the Default image processing configuration used either in the this material.
  30757. *
  30758. * If sets to null, the scene one is in use.
  30759. */
  30760. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30761. /**
  30762. * Keep track of the image processing observer to allow dispose and replace.
  30763. */
  30764. private _imageProcessingObserver;
  30765. /**
  30766. * Attaches a new image processing configuration to the Standard Material.
  30767. * @param configuration
  30768. */
  30769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30770. /**
  30771. * Gets wether the color curves effect is enabled.
  30772. */
  30773. get cameraColorCurvesEnabled(): boolean;
  30774. /**
  30775. * Sets wether the color curves effect is enabled.
  30776. */
  30777. set cameraColorCurvesEnabled(value: boolean);
  30778. /**
  30779. * Gets wether the color grading effect is enabled.
  30780. */
  30781. get cameraColorGradingEnabled(): boolean;
  30782. /**
  30783. * Gets wether the color grading effect is enabled.
  30784. */
  30785. set cameraColorGradingEnabled(value: boolean);
  30786. /**
  30787. * Gets wether tonemapping is enabled or not.
  30788. */
  30789. get cameraToneMappingEnabled(): boolean;
  30790. /**
  30791. * Sets wether tonemapping is enabled or not
  30792. */
  30793. set cameraToneMappingEnabled(value: boolean);
  30794. /**
  30795. * The camera exposure used on this material.
  30796. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30797. * This corresponds to a photographic exposure.
  30798. */
  30799. get cameraExposure(): number;
  30800. /**
  30801. * The camera exposure used on this material.
  30802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30803. * This corresponds to a photographic exposure.
  30804. */
  30805. set cameraExposure(value: number);
  30806. /**
  30807. * Gets The camera contrast used on this material.
  30808. */
  30809. get cameraContrast(): number;
  30810. /**
  30811. * Sets The camera contrast used on this material.
  30812. */
  30813. set cameraContrast(value: number);
  30814. /**
  30815. * Gets the Color Grading 2D Lookup Texture.
  30816. */
  30817. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30818. /**
  30819. * Sets the Color Grading 2D Lookup Texture.
  30820. */
  30821. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30822. /**
  30823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30825. * 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;
  30826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30827. */
  30828. get cameraColorCurves(): Nullable<ColorCurves>;
  30829. /**
  30830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30832. * 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;
  30833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30834. */
  30835. set cameraColorCurves(value: Nullable<ColorCurves>);
  30836. /**
  30837. * Can this material render to several textures at once
  30838. */
  30839. get canRenderToMRT(): boolean;
  30840. /**
  30841. * Defines the detail map parameters for the material.
  30842. */
  30843. readonly detailMap: DetailMapConfiguration;
  30844. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30845. protected _worldViewProjectionMatrix: Matrix;
  30846. protected _globalAmbientColor: Color3;
  30847. protected _useLogarithmicDepth: boolean;
  30848. protected _rebuildInParallel: boolean;
  30849. /**
  30850. * Instantiates a new standard material.
  30851. * This is the default material used in Babylon. It is the best trade off between quality
  30852. * and performances.
  30853. * @see https://doc.babylonjs.com/babylon101/materials
  30854. * @param name Define the name of the material in the scene
  30855. * @param scene Define the scene the material belong to
  30856. */
  30857. constructor(name: string, scene: Scene);
  30858. /**
  30859. * Gets a boolean indicating that current material needs to register RTT
  30860. */
  30861. get hasRenderTargetTextures(): boolean;
  30862. /**
  30863. * Gets the current class name of the material e.g. "StandardMaterial"
  30864. * Mainly use in serialization.
  30865. * @returns the class name
  30866. */
  30867. getClassName(): string;
  30868. /**
  30869. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30870. * You can try switching to logarithmic depth.
  30871. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30872. */
  30873. get useLogarithmicDepth(): boolean;
  30874. set useLogarithmicDepth(value: boolean);
  30875. /**
  30876. * Specifies if the material will require alpha blending
  30877. * @returns a boolean specifying if alpha blending is needed
  30878. */
  30879. needAlphaBlending(): boolean;
  30880. /**
  30881. * Specifies if this material should be rendered in alpha test mode
  30882. * @returns a boolean specifying if an alpha test is needed.
  30883. */
  30884. needAlphaTesting(): boolean;
  30885. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30886. /**
  30887. * Get the texture used for alpha test purpose.
  30888. * @returns the diffuse texture in case of the standard material.
  30889. */
  30890. getAlphaTestTexture(): Nullable<BaseTexture>;
  30891. /**
  30892. * Get if the submesh is ready to be used and all its information available.
  30893. * Child classes can use it to update shaders
  30894. * @param mesh defines the mesh to check
  30895. * @param subMesh defines which submesh to check
  30896. * @param useInstances specifies that instances should be used
  30897. * @returns a boolean indicating that the submesh is ready or not
  30898. */
  30899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30900. /**
  30901. * Builds the material UBO layouts.
  30902. * Used internally during the effect preparation.
  30903. */
  30904. buildUniformLayout(): void;
  30905. /**
  30906. * Unbinds the material from the mesh
  30907. */
  30908. unbind(): void;
  30909. /**
  30910. * Binds the submesh to this material by preparing the effect and shader to draw
  30911. * @param world defines the world transformation matrix
  30912. * @param mesh defines the mesh containing the submesh
  30913. * @param subMesh defines the submesh to bind the material to
  30914. */
  30915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30916. /**
  30917. * Get the list of animatables in the material.
  30918. * @returns the list of animatables object used in the material
  30919. */
  30920. getAnimatables(): IAnimatable[];
  30921. /**
  30922. * Gets the active textures from the material
  30923. * @returns an array of textures
  30924. */
  30925. getActiveTextures(): BaseTexture[];
  30926. /**
  30927. * Specifies if the material uses a texture
  30928. * @param texture defines the texture to check against the material
  30929. * @returns a boolean specifying if the material uses the texture
  30930. */
  30931. hasTexture(texture: BaseTexture): boolean;
  30932. /**
  30933. * Disposes the material
  30934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30936. */
  30937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30938. /**
  30939. * Makes a duplicate of the material, and gives it a new name
  30940. * @param name defines the new name for the duplicated material
  30941. * @returns the cloned material
  30942. */
  30943. clone(name: string): StandardMaterial;
  30944. /**
  30945. * Serializes this material in a JSON representation
  30946. * @returns the serialized material object
  30947. */
  30948. serialize(): any;
  30949. /**
  30950. * Creates a standard material from parsed material data
  30951. * @param source defines the JSON representation of the material
  30952. * @param scene defines the hosting scene
  30953. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30954. * @returns a new standard material
  30955. */
  30956. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30957. /**
  30958. * Are diffuse textures enabled in the application.
  30959. */
  30960. static get DiffuseTextureEnabled(): boolean;
  30961. static set DiffuseTextureEnabled(value: boolean);
  30962. /**
  30963. * Are detail textures enabled in the application.
  30964. */
  30965. static get DetailTextureEnabled(): boolean;
  30966. static set DetailTextureEnabled(value: boolean);
  30967. /**
  30968. * Are ambient textures enabled in the application.
  30969. */
  30970. static get AmbientTextureEnabled(): boolean;
  30971. static set AmbientTextureEnabled(value: boolean);
  30972. /**
  30973. * Are opacity textures enabled in the application.
  30974. */
  30975. static get OpacityTextureEnabled(): boolean;
  30976. static set OpacityTextureEnabled(value: boolean);
  30977. /**
  30978. * Are reflection textures enabled in the application.
  30979. */
  30980. static get ReflectionTextureEnabled(): boolean;
  30981. static set ReflectionTextureEnabled(value: boolean);
  30982. /**
  30983. * Are emissive textures enabled in the application.
  30984. */
  30985. static get EmissiveTextureEnabled(): boolean;
  30986. static set EmissiveTextureEnabled(value: boolean);
  30987. /**
  30988. * Are specular textures enabled in the application.
  30989. */
  30990. static get SpecularTextureEnabled(): boolean;
  30991. static set SpecularTextureEnabled(value: boolean);
  30992. /**
  30993. * Are bump textures enabled in the application.
  30994. */
  30995. static get BumpTextureEnabled(): boolean;
  30996. static set BumpTextureEnabled(value: boolean);
  30997. /**
  30998. * Are lightmap textures enabled in the application.
  30999. */
  31000. static get LightmapTextureEnabled(): boolean;
  31001. static set LightmapTextureEnabled(value: boolean);
  31002. /**
  31003. * Are refraction textures enabled in the application.
  31004. */
  31005. static get RefractionTextureEnabled(): boolean;
  31006. static set RefractionTextureEnabled(value: boolean);
  31007. /**
  31008. * Are color grading textures enabled in the application.
  31009. */
  31010. static get ColorGradingTextureEnabled(): boolean;
  31011. static set ColorGradingTextureEnabled(value: boolean);
  31012. /**
  31013. * Are fresnels enabled in the application.
  31014. */
  31015. static get FresnelEnabled(): boolean;
  31016. static set FresnelEnabled(value: boolean);
  31017. }
  31018. }
  31019. declare module BABYLON {
  31020. /**
  31021. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31022. *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.
  31023. * The SPS is also a particle system. It provides some methods to manage the particles.
  31024. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31025. *
  31026. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31027. */
  31028. export class SolidParticleSystem implements IDisposable {
  31029. /**
  31030. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31031. * Example : var p = SPS.particles[i];
  31032. */
  31033. particles: SolidParticle[];
  31034. /**
  31035. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31036. */
  31037. nbParticles: number;
  31038. /**
  31039. * If the particles must ever face the camera (default false). Useful for planar particles.
  31040. */
  31041. billboard: boolean;
  31042. /**
  31043. * Recompute normals when adding a shape
  31044. */
  31045. recomputeNormals: boolean;
  31046. /**
  31047. * This a counter ofr your own usage. It's not set by any SPS functions.
  31048. */
  31049. counter: number;
  31050. /**
  31051. * The SPS name. This name is also given to the underlying mesh.
  31052. */
  31053. name: string;
  31054. /**
  31055. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31056. */
  31057. mesh: Mesh;
  31058. /**
  31059. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31060. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31061. */
  31062. vars: any;
  31063. /**
  31064. * This array is populated when the SPS is set as 'pickable'.
  31065. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31066. * Each element of this array is an object `{idx: int, faceId: int}`.
  31067. * `idx` is the picked particle index in the `SPS.particles` array
  31068. * `faceId` is the picked face index counted within this particle.
  31069. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31070. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31071. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31072. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31073. */
  31074. pickedParticles: {
  31075. idx: number;
  31076. faceId: number;
  31077. }[];
  31078. /**
  31079. * This array is populated when the SPS is set as 'pickable'
  31080. * Each key of this array is a submesh index.
  31081. * Each element of this array is a second array defined like this :
  31082. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31083. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31084. * `idx` is the picked particle index in the `SPS.particles` array
  31085. * `faceId` is the picked face index counted within this particle.
  31086. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31087. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31088. */
  31089. pickedBySubMesh: {
  31090. idx: number;
  31091. faceId: number;
  31092. }[][];
  31093. /**
  31094. * This array is populated when `enableDepthSort` is set to true.
  31095. * Each element of this array is an instance of the class DepthSortedParticle.
  31096. */
  31097. depthSortedParticles: DepthSortedParticle[];
  31098. /**
  31099. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31100. * @hidden
  31101. */
  31102. _bSphereOnly: boolean;
  31103. /**
  31104. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31105. * @hidden
  31106. */
  31107. _bSphereRadiusFactor: number;
  31108. private _scene;
  31109. private _positions;
  31110. private _indices;
  31111. private _normals;
  31112. private _colors;
  31113. private _uvs;
  31114. private _indices32;
  31115. private _positions32;
  31116. private _normals32;
  31117. private _fixedNormal32;
  31118. private _colors32;
  31119. private _uvs32;
  31120. private _index;
  31121. private _updatable;
  31122. private _pickable;
  31123. private _isVisibilityBoxLocked;
  31124. private _alwaysVisible;
  31125. private _depthSort;
  31126. private _expandable;
  31127. private _shapeCounter;
  31128. private _copy;
  31129. private _color;
  31130. private _computeParticleColor;
  31131. private _computeParticleTexture;
  31132. private _computeParticleRotation;
  31133. private _computeParticleVertex;
  31134. private _computeBoundingBox;
  31135. private _depthSortParticles;
  31136. private _camera;
  31137. private _mustUnrotateFixedNormals;
  31138. private _particlesIntersect;
  31139. private _needs32Bits;
  31140. private _isNotBuilt;
  31141. private _lastParticleId;
  31142. private _idxOfId;
  31143. private _multimaterialEnabled;
  31144. private _useModelMaterial;
  31145. private _indicesByMaterial;
  31146. private _materialIndexes;
  31147. private _depthSortFunction;
  31148. private _materialSortFunction;
  31149. private _materials;
  31150. private _multimaterial;
  31151. private _materialIndexesById;
  31152. private _defaultMaterial;
  31153. private _autoUpdateSubMeshes;
  31154. private _tmpVertex;
  31155. /**
  31156. * Creates a SPS (Solid Particle System) object.
  31157. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31158. * @param scene (Scene) is the scene in which the SPS is added.
  31159. * @param options defines the options of the sps e.g.
  31160. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31161. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31162. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31163. * * 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.
  31164. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31165. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31166. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31167. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31168. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31169. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31170. */
  31171. constructor(name: string, scene: Scene, options?: {
  31172. updatable?: boolean;
  31173. isPickable?: boolean;
  31174. enableDepthSort?: boolean;
  31175. particleIntersection?: boolean;
  31176. boundingSphereOnly?: boolean;
  31177. bSphereRadiusFactor?: number;
  31178. expandable?: boolean;
  31179. useModelMaterial?: boolean;
  31180. enableMultiMaterial?: boolean;
  31181. });
  31182. /**
  31183. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31184. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31185. * @returns the created mesh
  31186. */
  31187. buildMesh(): Mesh;
  31188. /**
  31189. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31190. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31191. * Thus the particles generated from `digest()` have their property `position` set yet.
  31192. * @param mesh ( Mesh ) is the mesh to be digested
  31193. * @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
  31194. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31195. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31197. * @returns the current SPS
  31198. */
  31199. digest(mesh: Mesh, options?: {
  31200. facetNb?: number;
  31201. number?: number;
  31202. delta?: number;
  31203. storage?: [];
  31204. }): SolidParticleSystem;
  31205. /**
  31206. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31207. * @hidden
  31208. */
  31209. private _unrotateFixedNormals;
  31210. /**
  31211. * Resets the temporary working copy particle
  31212. * @hidden
  31213. */
  31214. private _resetCopy;
  31215. /**
  31216. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31217. * @param p the current index in the positions array to be updated
  31218. * @param ind the current index in the indices array
  31219. * @param shape a Vector3 array, the shape geometry
  31220. * @param positions the positions array to be updated
  31221. * @param meshInd the shape indices array
  31222. * @param indices the indices array to be updated
  31223. * @param meshUV the shape uv array
  31224. * @param uvs the uv array to be updated
  31225. * @param meshCol the shape color array
  31226. * @param colors the color array to be updated
  31227. * @param meshNor the shape normals array
  31228. * @param normals the normals array to be updated
  31229. * @param idx the particle index
  31230. * @param idxInShape the particle index in its shape
  31231. * @param options the addShape() method passed options
  31232. * @model the particle model
  31233. * @hidden
  31234. */
  31235. private _meshBuilder;
  31236. /**
  31237. * Returns a shape Vector3 array from positions float array
  31238. * @param positions float array
  31239. * @returns a vector3 array
  31240. * @hidden
  31241. */
  31242. private _posToShape;
  31243. /**
  31244. * Returns a shapeUV array from a float uvs (array deep copy)
  31245. * @param uvs as a float array
  31246. * @returns a shapeUV array
  31247. * @hidden
  31248. */
  31249. private _uvsToShapeUV;
  31250. /**
  31251. * Adds a new particle object in the particles array
  31252. * @param idx particle index in particles array
  31253. * @param id particle id
  31254. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31255. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31256. * @param model particle ModelShape object
  31257. * @param shapeId model shape identifier
  31258. * @param idxInShape index of the particle in the current model
  31259. * @param bInfo model bounding info object
  31260. * @param storage target storage array, if any
  31261. * @hidden
  31262. */
  31263. private _addParticle;
  31264. /**
  31265. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31266. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31267. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31268. * @param nb (positive integer) the number of particles to be created from this model
  31269. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31270. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31271. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31272. * @returns the number of shapes in the system
  31273. */
  31274. addShape(mesh: Mesh, nb: number, options?: {
  31275. positionFunction?: any;
  31276. vertexFunction?: any;
  31277. storage?: [];
  31278. }): number;
  31279. /**
  31280. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31281. * @hidden
  31282. */
  31283. private _rebuildParticle;
  31284. /**
  31285. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31286. * @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.
  31287. * @returns the SPS.
  31288. */
  31289. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31290. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31291. * Returns an array with the removed particles.
  31292. * 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.
  31293. * The SPS can't be empty so at least one particle needs to remain in place.
  31294. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31295. * @param start index of the first particle to remove
  31296. * @param end index of the last particle to remove (included)
  31297. * @returns an array populated with the removed particles
  31298. */
  31299. removeParticles(start: number, end: number): SolidParticle[];
  31300. /**
  31301. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31302. * @param solidParticleArray an array populated with Solid Particles objects
  31303. * @returns the SPS
  31304. */
  31305. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31306. /**
  31307. * Creates a new particle and modifies the SPS mesh geometry :
  31308. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31309. * - calls _addParticle() to populate the particle array
  31310. * factorized code from addShape() and insertParticlesFromArray()
  31311. * @param idx particle index in the particles array
  31312. * @param i particle index in its shape
  31313. * @param modelShape particle ModelShape object
  31314. * @param shape shape vertex array
  31315. * @param meshInd shape indices array
  31316. * @param meshUV shape uv array
  31317. * @param meshCol shape color array
  31318. * @param meshNor shape normals array
  31319. * @param bbInfo shape bounding info
  31320. * @param storage target particle storage
  31321. * @options addShape() passed options
  31322. * @hidden
  31323. */
  31324. private _insertNewParticle;
  31325. /**
  31326. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31327. * This method calls `updateParticle()` for each particle of the SPS.
  31328. * For an animated SPS, it is usually called within the render loop.
  31329. * 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.
  31330. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31331. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31332. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31333. * @returns the SPS.
  31334. */
  31335. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31336. /**
  31337. * Disposes the SPS.
  31338. */
  31339. dispose(): void;
  31340. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31341. * idx is the particle index in the SPS
  31342. * faceId is the picked face index counted within this particle.
  31343. * Returns null if the pickInfo can't identify a picked particle.
  31344. * @param pickingInfo (PickingInfo object)
  31345. * @returns {idx: number, faceId: number} or null
  31346. */
  31347. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31348. idx: number;
  31349. faceId: number;
  31350. }>;
  31351. /**
  31352. * Returns a SolidParticle object from its identifier : particle.id
  31353. * @param id (integer) the particle Id
  31354. * @returns the searched particle or null if not found in the SPS.
  31355. */
  31356. getParticleById(id: number): Nullable<SolidParticle>;
  31357. /**
  31358. * Returns a new array populated with the particles having the passed shapeId.
  31359. * @param shapeId (integer) the shape identifier
  31360. * @returns a new solid particle array
  31361. */
  31362. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31363. /**
  31364. * Populates the passed array "ref" with the particles having the passed shapeId.
  31365. * @param shapeId the shape identifier
  31366. * @returns the SPS
  31367. * @param ref
  31368. */
  31369. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31370. /**
  31371. * Computes the required SubMeshes according the materials assigned to the particles.
  31372. * @returns the solid particle system.
  31373. * Does nothing if called before the SPS mesh is built.
  31374. */
  31375. computeSubMeshes(): SolidParticleSystem;
  31376. /**
  31377. * Sorts the solid particles by material when MultiMaterial is enabled.
  31378. * Updates the indices32 array.
  31379. * Updates the indicesByMaterial array.
  31380. * Updates the mesh indices array.
  31381. * @returns the SPS
  31382. * @hidden
  31383. */
  31384. private _sortParticlesByMaterial;
  31385. /**
  31386. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31387. * @hidden
  31388. */
  31389. private _setMaterialIndexesById;
  31390. /**
  31391. * Returns an array with unique values of Materials from the passed array
  31392. * @param array the material array to be checked and filtered
  31393. * @hidden
  31394. */
  31395. private _filterUniqueMaterialId;
  31396. /**
  31397. * Sets a new Standard Material as _defaultMaterial if not already set.
  31398. * @hidden
  31399. */
  31400. private _setDefaultMaterial;
  31401. /**
  31402. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31403. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31404. * @returns the SPS.
  31405. */
  31406. refreshVisibleSize(): SolidParticleSystem;
  31407. /**
  31408. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31409. * @param size the size (float) of the visibility box
  31410. * note : this doesn't lock the SPS mesh bounding box.
  31411. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31412. */
  31413. setVisibilityBox(size: number): void;
  31414. /**
  31415. * Gets whether the SPS as always visible or not
  31416. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31417. */
  31418. get isAlwaysVisible(): boolean;
  31419. /**
  31420. * Sets the SPS as always visible or not
  31421. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31422. */
  31423. set isAlwaysVisible(val: boolean);
  31424. /**
  31425. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31426. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31427. */
  31428. set isVisibilityBoxLocked(val: boolean);
  31429. /**
  31430. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31431. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31432. */
  31433. get isVisibilityBoxLocked(): boolean;
  31434. /**
  31435. * Tells to `setParticles()` to compute the particle rotations or not.
  31436. * Default value : true. The SPS is faster when it's set to false.
  31437. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31438. */
  31439. set computeParticleRotation(val: boolean);
  31440. /**
  31441. * Tells to `setParticles()` to compute the particle colors or not.
  31442. * Default value : true. The SPS is faster when it's set to false.
  31443. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31444. */
  31445. set computeParticleColor(val: boolean);
  31446. set computeParticleTexture(val: boolean);
  31447. /**
  31448. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31449. * Default value : false. The SPS is faster when it's set to false.
  31450. * Note : the particle custom vertex positions aren't stored values.
  31451. */
  31452. set computeParticleVertex(val: boolean);
  31453. /**
  31454. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31455. */
  31456. set computeBoundingBox(val: boolean);
  31457. /**
  31458. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31459. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31460. * Default : `true`
  31461. */
  31462. set depthSortParticles(val: boolean);
  31463. /**
  31464. * Gets if `setParticles()` computes the particle rotations or not.
  31465. * Default value : true. The SPS is faster when it's set to false.
  31466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31467. */
  31468. get computeParticleRotation(): boolean;
  31469. /**
  31470. * Gets if `setParticles()` computes the particle colors or not.
  31471. * Default value : true. The SPS is faster when it's set to false.
  31472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31473. */
  31474. get computeParticleColor(): boolean;
  31475. /**
  31476. * Gets if `setParticles()` computes the particle textures or not.
  31477. * Default value : true. The SPS is faster when it's set to false.
  31478. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31479. */
  31480. get computeParticleTexture(): boolean;
  31481. /**
  31482. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31483. * Default value : false. The SPS is faster when it's set to false.
  31484. * Note : the particle custom vertex positions aren't stored values.
  31485. */
  31486. get computeParticleVertex(): boolean;
  31487. /**
  31488. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31489. */
  31490. get computeBoundingBox(): boolean;
  31491. /**
  31492. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31493. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31494. * Default : `true`
  31495. */
  31496. get depthSortParticles(): boolean;
  31497. /**
  31498. * Gets if the SPS is created as expandable at construction time.
  31499. * Default : `false`
  31500. */
  31501. get expandable(): boolean;
  31502. /**
  31503. * Gets if the SPS supports the Multi Materials
  31504. */
  31505. get multimaterialEnabled(): boolean;
  31506. /**
  31507. * Gets if the SPS uses the model materials for its own multimaterial.
  31508. */
  31509. get useModelMaterial(): boolean;
  31510. /**
  31511. * The SPS used material array.
  31512. */
  31513. get materials(): Material[];
  31514. /**
  31515. * Sets the SPS MultiMaterial from the passed materials.
  31516. * Note : the passed array is internally copied and not used then by reference.
  31517. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31518. */
  31519. setMultiMaterial(materials: Material[]): void;
  31520. /**
  31521. * The SPS computed multimaterial object
  31522. */
  31523. get multimaterial(): MultiMaterial;
  31524. set multimaterial(mm: MultiMaterial);
  31525. /**
  31526. * If the subMeshes must be updated on the next call to setParticles()
  31527. */
  31528. get autoUpdateSubMeshes(): boolean;
  31529. set autoUpdateSubMeshes(val: boolean);
  31530. /**
  31531. * This function does nothing. It may be overwritten to set all the particle first values.
  31532. * The SPS doesn't call this function, you may have to call it by your own.
  31533. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31534. */
  31535. initParticles(): void;
  31536. /**
  31537. * This function does nothing. It may be overwritten to recycle a particle.
  31538. * The SPS doesn't call this function, you may have to call it by your own.
  31539. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31540. * @param particle The particle to recycle
  31541. * @returns the recycled particle
  31542. */
  31543. recycleParticle(particle: SolidParticle): SolidParticle;
  31544. /**
  31545. * Updates a particle : this function should be overwritten by the user.
  31546. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31547. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31548. * @example : just set a particle position or velocity and recycle conditions
  31549. * @param particle The particle to update
  31550. * @returns the updated particle
  31551. */
  31552. updateParticle(particle: SolidParticle): SolidParticle;
  31553. /**
  31554. * Updates a vertex of a particle : it can be overwritten by the user.
  31555. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31556. * @param particle the current particle
  31557. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31558. * @param pt the index of the current vertex in the particle shape
  31559. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31560. * @example : just set a vertex particle position or color
  31561. * @returns the sps
  31562. */
  31563. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31564. /**
  31565. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31566. * This does nothing and may be overwritten by the user.
  31567. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31569. * @param update the boolean update value actually passed to setParticles()
  31570. */
  31571. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31572. /**
  31573. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31574. * This will be passed three parameters.
  31575. * This does nothing and may be overwritten by the user.
  31576. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31577. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31578. * @param update the boolean update value actually passed to setParticles()
  31579. */
  31580. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31581. }
  31582. }
  31583. declare module BABYLON {
  31584. /**
  31585. * Represents one particle of a solid particle system.
  31586. */
  31587. export class SolidParticle {
  31588. /**
  31589. * particle global index
  31590. */
  31591. idx: number;
  31592. /**
  31593. * particle identifier
  31594. */
  31595. id: number;
  31596. /**
  31597. * The color of the particle
  31598. */
  31599. color: Nullable<Color4>;
  31600. /**
  31601. * The world space position of the particle.
  31602. */
  31603. position: Vector3;
  31604. /**
  31605. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31606. */
  31607. rotation: Vector3;
  31608. /**
  31609. * The world space rotation quaternion of the particle.
  31610. */
  31611. rotationQuaternion: Nullable<Quaternion>;
  31612. /**
  31613. * The scaling of the particle.
  31614. */
  31615. scaling: Vector3;
  31616. /**
  31617. * The uvs of the particle.
  31618. */
  31619. uvs: Vector4;
  31620. /**
  31621. * The current speed of the particle.
  31622. */
  31623. velocity: Vector3;
  31624. /**
  31625. * The pivot point in the particle local space.
  31626. */
  31627. pivot: Vector3;
  31628. /**
  31629. * Must the particle be translated from its pivot point in its local space ?
  31630. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31631. * Default : false
  31632. */
  31633. translateFromPivot: boolean;
  31634. /**
  31635. * Is the particle active or not ?
  31636. */
  31637. alive: boolean;
  31638. /**
  31639. * Is the particle visible or not ?
  31640. */
  31641. isVisible: boolean;
  31642. /**
  31643. * Index of this particle in the global "positions" array (Internal use)
  31644. * @hidden
  31645. */
  31646. _pos: number;
  31647. /**
  31648. * @hidden Index of this particle in the global "indices" array (Internal use)
  31649. */
  31650. _ind: number;
  31651. /**
  31652. * @hidden ModelShape of this particle (Internal use)
  31653. */
  31654. _model: ModelShape;
  31655. /**
  31656. * ModelShape id of this particle
  31657. */
  31658. shapeId: number;
  31659. /**
  31660. * Index of the particle in its shape id
  31661. */
  31662. idxInShape: number;
  31663. /**
  31664. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31665. */
  31666. _modelBoundingInfo: BoundingInfo;
  31667. /**
  31668. * @hidden Particle BoundingInfo object (Internal use)
  31669. */
  31670. _boundingInfo: BoundingInfo;
  31671. /**
  31672. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31673. */
  31674. _sps: SolidParticleSystem;
  31675. /**
  31676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31677. */
  31678. _stillInvisible: boolean;
  31679. /**
  31680. * @hidden Last computed particle rotation matrix
  31681. */
  31682. _rotationMatrix: number[];
  31683. /**
  31684. * Parent particle Id, if any.
  31685. * Default null.
  31686. */
  31687. parentId: Nullable<number>;
  31688. /**
  31689. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31690. */
  31691. materialIndex: Nullable<number>;
  31692. /**
  31693. * Custom object or properties.
  31694. */
  31695. props: Nullable<any>;
  31696. /**
  31697. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31698. * The possible values are :
  31699. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31700. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31701. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31702. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31703. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31704. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31705. * */
  31706. cullingStrategy: number;
  31707. /**
  31708. * @hidden Internal global position in the SPS.
  31709. */
  31710. _globalPosition: Vector3;
  31711. /**
  31712. * Creates a Solid Particle object.
  31713. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31714. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31715. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31716. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31717. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31718. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31719. * @param shapeId (integer) is the model shape identifier in the SPS.
  31720. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31721. * @param sps defines the sps it is associated to
  31722. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31723. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31724. */
  31725. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31726. /**
  31727. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31728. * @param target the particle target
  31729. * @returns the current particle
  31730. */
  31731. copyToRef(target: SolidParticle): SolidParticle;
  31732. /**
  31733. * Legacy support, changed scale to scaling
  31734. */
  31735. get scale(): Vector3;
  31736. /**
  31737. * Legacy support, changed scale to scaling
  31738. */
  31739. set scale(scale: Vector3);
  31740. /**
  31741. * Legacy support, changed quaternion to rotationQuaternion
  31742. */
  31743. get quaternion(): Nullable<Quaternion>;
  31744. /**
  31745. * Legacy support, changed quaternion to rotationQuaternion
  31746. */
  31747. set quaternion(q: Nullable<Quaternion>);
  31748. /**
  31749. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31750. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31751. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31752. * @returns true if it intersects
  31753. */
  31754. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31755. /**
  31756. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31757. * A particle is in the frustum if its bounding box intersects the frustum
  31758. * @param frustumPlanes defines the frustum to test
  31759. * @returns true if the particle is in the frustum planes
  31760. */
  31761. isInFrustum(frustumPlanes: Plane[]): boolean;
  31762. /**
  31763. * get the rotation matrix of the particle
  31764. * @hidden
  31765. */
  31766. getRotationMatrix(m: Matrix): void;
  31767. }
  31768. /**
  31769. * Represents the shape of the model used by one particle of a solid particle system.
  31770. * SPS internal tool, don't use it manually.
  31771. */
  31772. export class ModelShape {
  31773. /**
  31774. * The shape id
  31775. * @hidden
  31776. */
  31777. shapeID: number;
  31778. /**
  31779. * flat array of model positions (internal use)
  31780. * @hidden
  31781. */
  31782. _shape: Vector3[];
  31783. /**
  31784. * flat array of model UVs (internal use)
  31785. * @hidden
  31786. */
  31787. _shapeUV: number[];
  31788. /**
  31789. * color array of the model
  31790. * @hidden
  31791. */
  31792. _shapeColors: number[];
  31793. /**
  31794. * indices array of the model
  31795. * @hidden
  31796. */
  31797. _indices: number[];
  31798. /**
  31799. * normals array of the model
  31800. * @hidden
  31801. */
  31802. _normals: number[];
  31803. /**
  31804. * length of the shape in the model indices array (internal use)
  31805. * @hidden
  31806. */
  31807. _indicesLength: number;
  31808. /**
  31809. * Custom position function (internal use)
  31810. * @hidden
  31811. */
  31812. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31813. /**
  31814. * Custom vertex function (internal use)
  31815. * @hidden
  31816. */
  31817. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31818. /**
  31819. * Model material (internal use)
  31820. * @hidden
  31821. */
  31822. _material: Nullable<Material>;
  31823. /**
  31824. * 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.
  31825. * SPS internal tool, don't use it manually.
  31826. * @hidden
  31827. */
  31828. 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>);
  31829. }
  31830. /**
  31831. * Represents a Depth Sorted Particle in the solid particle system.
  31832. * @hidden
  31833. */
  31834. export class DepthSortedParticle {
  31835. /**
  31836. * Particle index
  31837. */
  31838. idx: number;
  31839. /**
  31840. * Index of the particle in the "indices" array
  31841. */
  31842. ind: number;
  31843. /**
  31844. * Length of the particle shape in the "indices" array
  31845. */
  31846. indicesLength: number;
  31847. /**
  31848. * Squared distance from the particle to the camera
  31849. */
  31850. sqDistance: number;
  31851. /**
  31852. * Material index when used with MultiMaterials
  31853. */
  31854. materialIndex: number;
  31855. /**
  31856. * Creates a new sorted particle
  31857. * @param materialIndex
  31858. */
  31859. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31860. }
  31861. /**
  31862. * Represents a solid particle vertex
  31863. */
  31864. export class SolidParticleVertex {
  31865. /**
  31866. * Vertex position
  31867. */
  31868. position: Vector3;
  31869. /**
  31870. * Vertex color
  31871. */
  31872. color: Color4;
  31873. /**
  31874. * Vertex UV
  31875. */
  31876. uv: Vector2;
  31877. /**
  31878. * Creates a new solid particle vertex
  31879. */
  31880. constructor();
  31881. /** Vertex x coordinate */
  31882. get x(): number;
  31883. set x(val: number);
  31884. /** Vertex y coordinate */
  31885. get y(): number;
  31886. set y(val: number);
  31887. /** Vertex z coordinate */
  31888. get z(): number;
  31889. set z(val: number);
  31890. }
  31891. }
  31892. declare module BABYLON {
  31893. /**
  31894. * @hidden
  31895. */
  31896. export class _MeshCollisionData {
  31897. _checkCollisions: boolean;
  31898. _collisionMask: number;
  31899. _collisionGroup: number;
  31900. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31901. _collider: Nullable<Collider>;
  31902. _oldPositionForCollisions: Vector3;
  31903. _diffPositionForCollisions: Vector3;
  31904. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31905. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31906. }
  31907. }
  31908. declare module BABYLON {
  31909. /** @hidden */
  31910. class _FacetDataStorage {
  31911. facetPositions: Vector3[];
  31912. facetNormals: Vector3[];
  31913. facetPartitioning: number[][];
  31914. facetNb: number;
  31915. partitioningSubdivisions: number;
  31916. partitioningBBoxRatio: number;
  31917. facetDataEnabled: boolean;
  31918. facetParameters: any;
  31919. bbSize: Vector3;
  31920. subDiv: {
  31921. max: number;
  31922. X: number;
  31923. Y: number;
  31924. Z: number;
  31925. };
  31926. facetDepthSort: boolean;
  31927. facetDepthSortEnabled: boolean;
  31928. depthSortedIndices: IndicesArray;
  31929. depthSortedFacets: {
  31930. ind: number;
  31931. sqDistance: number;
  31932. }[];
  31933. facetDepthSortFunction: (f1: {
  31934. ind: number;
  31935. sqDistance: number;
  31936. }, f2: {
  31937. ind: number;
  31938. sqDistance: number;
  31939. }) => number;
  31940. facetDepthSortFrom: Vector3;
  31941. facetDepthSortOrigin: Vector3;
  31942. invertedMatrix: Matrix;
  31943. }
  31944. /**
  31945. * @hidden
  31946. **/
  31947. class _InternalAbstractMeshDataInfo {
  31948. _hasVertexAlpha: boolean;
  31949. _useVertexColors: boolean;
  31950. _numBoneInfluencers: number;
  31951. _applyFog: boolean;
  31952. _receiveShadows: boolean;
  31953. _facetData: _FacetDataStorage;
  31954. _visibility: number;
  31955. _skeleton: Nullable<Skeleton>;
  31956. _layerMask: number;
  31957. _computeBonesUsingShaders: boolean;
  31958. _isActive: boolean;
  31959. _onlyForInstances: boolean;
  31960. _isActiveIntermediate: boolean;
  31961. _onlyForInstancesIntermediate: boolean;
  31962. _actAsRegularMesh: boolean;
  31963. }
  31964. /**
  31965. * Class used to store all common mesh properties
  31966. */
  31967. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31968. /** No occlusion */
  31969. static OCCLUSION_TYPE_NONE: number;
  31970. /** Occlusion set to optimisitic */
  31971. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31972. /** Occlusion set to strict */
  31973. static OCCLUSION_TYPE_STRICT: number;
  31974. /** Use an accurante occlusion algorithm */
  31975. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31976. /** Use a conservative occlusion algorithm */
  31977. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31978. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31979. * Test order :
  31980. * Is the bounding sphere outside the frustum ?
  31981. * If not, are the bounding box vertices outside the frustum ?
  31982. * It not, then the cullable object is in the frustum.
  31983. */
  31984. static readonly CULLINGSTRATEGY_STANDARD: number;
  31985. /** Culling strategy : Bounding Sphere Only.
  31986. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31987. * It's also less accurate than the standard because some not visible objects can still be selected.
  31988. * Test : is the bounding sphere outside the frustum ?
  31989. * If not, then the cullable object is in the frustum.
  31990. */
  31991. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31992. /** Culling strategy : Optimistic Inclusion.
  31993. * This in an inclusion test first, then the standard exclusion test.
  31994. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31995. * 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.
  31996. * Anyway, it's as accurate as the standard strategy.
  31997. * Test :
  31998. * Is the cullable object bounding sphere center in the frustum ?
  31999. * If not, apply the default culling strategy.
  32000. */
  32001. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32002. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32003. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32004. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32005. * 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.
  32006. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32007. * Test :
  32008. * Is the cullable object bounding sphere center in the frustum ?
  32009. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32010. */
  32011. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32012. /**
  32013. * No billboard
  32014. */
  32015. static get BILLBOARDMODE_NONE(): number;
  32016. /** Billboard on X axis */
  32017. static get BILLBOARDMODE_X(): number;
  32018. /** Billboard on Y axis */
  32019. static get BILLBOARDMODE_Y(): number;
  32020. /** Billboard on Z axis */
  32021. static get BILLBOARDMODE_Z(): number;
  32022. /** Billboard on all axes */
  32023. static get BILLBOARDMODE_ALL(): number;
  32024. /** Billboard on using position instead of orientation */
  32025. static get BILLBOARDMODE_USE_POSITION(): number;
  32026. /** @hidden */
  32027. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32028. /**
  32029. * The culling strategy to use to check whether the mesh must be rendered or not.
  32030. * This value can be changed at any time and will be used on the next render mesh selection.
  32031. * The possible values are :
  32032. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32033. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32034. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32035. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32036. * Please read each static variable documentation to get details about the culling process.
  32037. * */
  32038. cullingStrategy: number;
  32039. /**
  32040. * Gets the number of facets in the mesh
  32041. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32042. */
  32043. get facetNb(): number;
  32044. /**
  32045. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32047. */
  32048. get partitioningSubdivisions(): number;
  32049. set partitioningSubdivisions(nb: number);
  32050. /**
  32051. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32052. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32053. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32054. */
  32055. get partitioningBBoxRatio(): number;
  32056. set partitioningBBoxRatio(ratio: number);
  32057. /**
  32058. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32059. * Works only for updatable meshes.
  32060. * Doesn't work with multi-materials
  32061. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32062. */
  32063. get mustDepthSortFacets(): boolean;
  32064. set mustDepthSortFacets(sort: boolean);
  32065. /**
  32066. * The location (Vector3) where the facet depth sort must be computed from.
  32067. * By default, the active camera position.
  32068. * Used only when facet depth sort is enabled
  32069. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32070. */
  32071. get facetDepthSortFrom(): Vector3;
  32072. set facetDepthSortFrom(location: Vector3);
  32073. /**
  32074. * gets a boolean indicating if facetData is enabled
  32075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32076. */
  32077. get isFacetDataEnabled(): boolean;
  32078. /** @hidden */
  32079. _updateNonUniformScalingState(value: boolean): boolean;
  32080. /**
  32081. * An event triggered when this mesh collides with another one
  32082. */
  32083. onCollideObservable: Observable<AbstractMesh>;
  32084. /** Set a function to call when this mesh collides with another one */
  32085. set onCollide(callback: () => void);
  32086. /**
  32087. * An event triggered when the collision's position changes
  32088. */
  32089. onCollisionPositionChangeObservable: Observable<Vector3>;
  32090. /** Set a function to call when the collision's position changes */
  32091. set onCollisionPositionChange(callback: () => void);
  32092. /**
  32093. * An event triggered when material is changed
  32094. */
  32095. onMaterialChangedObservable: Observable<AbstractMesh>;
  32096. /**
  32097. * Gets or sets the orientation for POV movement & rotation
  32098. */
  32099. definedFacingForward: boolean;
  32100. /** @hidden */
  32101. _occlusionQuery: Nullable<WebGLQuery>;
  32102. /** @hidden */
  32103. _renderingGroup: Nullable<RenderingGroup>;
  32104. /**
  32105. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32106. */
  32107. get visibility(): number;
  32108. /**
  32109. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32110. */
  32111. set visibility(value: number);
  32112. /** Gets or sets the alpha index used to sort transparent meshes
  32113. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32114. */
  32115. alphaIndex: number;
  32116. /**
  32117. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32118. */
  32119. isVisible: boolean;
  32120. /**
  32121. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32122. */
  32123. isPickable: boolean;
  32124. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32125. showSubMeshesBoundingBox: boolean;
  32126. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32127. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32128. */
  32129. isBlocker: boolean;
  32130. /**
  32131. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32132. */
  32133. enablePointerMoveEvents: boolean;
  32134. private _renderingGroupId;
  32135. /**
  32136. * Specifies the rendering group id for this mesh (0 by default)
  32137. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32138. */
  32139. get renderingGroupId(): number;
  32140. set renderingGroupId(value: number);
  32141. private _material;
  32142. /** Gets or sets current material */
  32143. get material(): Nullable<Material>;
  32144. set material(value: Nullable<Material>);
  32145. /**
  32146. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32147. * @see https://doc.babylonjs.com/babylon101/shadows
  32148. */
  32149. get receiveShadows(): boolean;
  32150. set receiveShadows(value: boolean);
  32151. /** Defines color to use when rendering outline */
  32152. outlineColor: Color3;
  32153. /** Define width to use when rendering outline */
  32154. outlineWidth: number;
  32155. /** Defines color to use when rendering overlay */
  32156. overlayColor: Color3;
  32157. /** Defines alpha to use when rendering overlay */
  32158. overlayAlpha: number;
  32159. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32160. get hasVertexAlpha(): boolean;
  32161. set hasVertexAlpha(value: boolean);
  32162. /** 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) */
  32163. get useVertexColors(): boolean;
  32164. set useVertexColors(value: boolean);
  32165. /**
  32166. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32167. */
  32168. get computeBonesUsingShaders(): boolean;
  32169. set computeBonesUsingShaders(value: boolean);
  32170. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32171. get numBoneInfluencers(): number;
  32172. set numBoneInfluencers(value: number);
  32173. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32174. get applyFog(): boolean;
  32175. set applyFog(value: boolean);
  32176. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32177. useOctreeForRenderingSelection: boolean;
  32178. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32179. useOctreeForPicking: boolean;
  32180. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32181. useOctreeForCollisions: boolean;
  32182. /**
  32183. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32184. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32185. */
  32186. get layerMask(): number;
  32187. set layerMask(value: number);
  32188. /**
  32189. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32190. */
  32191. alwaysSelectAsActiveMesh: boolean;
  32192. /**
  32193. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32194. */
  32195. doNotSyncBoundingInfo: boolean;
  32196. /**
  32197. * Gets or sets the current action manager
  32198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32199. */
  32200. actionManager: Nullable<AbstractActionManager>;
  32201. private _meshCollisionData;
  32202. /**
  32203. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32204. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32205. */
  32206. ellipsoid: Vector3;
  32207. /**
  32208. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32209. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32210. */
  32211. ellipsoidOffset: Vector3;
  32212. /**
  32213. * Gets or sets a collision mask used to mask collisions (default is -1).
  32214. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32215. */
  32216. get collisionMask(): number;
  32217. set collisionMask(mask: number);
  32218. /**
  32219. * Gets or sets the current collision group mask (-1 by default).
  32220. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32221. */
  32222. get collisionGroup(): number;
  32223. set collisionGroup(mask: number);
  32224. /**
  32225. * Gets or sets current surrounding meshes (null by default).
  32226. *
  32227. * By default collision detection is tested against every mesh in the scene.
  32228. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32229. * meshes will be tested for the collision.
  32230. *
  32231. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32232. */
  32233. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32234. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32235. /**
  32236. * Defines edge width used when edgesRenderer is enabled
  32237. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32238. */
  32239. edgesWidth: number;
  32240. /**
  32241. * Defines edge color used when edgesRenderer is enabled
  32242. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32243. */
  32244. edgesColor: Color4;
  32245. /** @hidden */
  32246. _edgesRenderer: Nullable<IEdgesRenderer>;
  32247. /** @hidden */
  32248. _masterMesh: Nullable<AbstractMesh>;
  32249. /** @hidden */
  32250. _boundingInfo: Nullable<BoundingInfo>;
  32251. /** @hidden */
  32252. _renderId: number;
  32253. /**
  32254. * Gets or sets the list of subMeshes
  32255. * @see https://doc.babylonjs.com/how_to/multi_materials
  32256. */
  32257. subMeshes: SubMesh[];
  32258. /** @hidden */
  32259. _intersectionsInProgress: AbstractMesh[];
  32260. /** @hidden */
  32261. _unIndexed: boolean;
  32262. /** @hidden */
  32263. _lightSources: Light[];
  32264. /** Gets the list of lights affecting that mesh */
  32265. get lightSources(): Light[];
  32266. /** @hidden */
  32267. get _positions(): Nullable<Vector3[]>;
  32268. /** @hidden */
  32269. _waitingData: {
  32270. lods: Nullable<any>;
  32271. actions: Nullable<any>;
  32272. freezeWorldMatrix: Nullable<boolean>;
  32273. };
  32274. /** @hidden */
  32275. _bonesTransformMatrices: Nullable<Float32Array>;
  32276. /** @hidden */
  32277. _transformMatrixTexture: Nullable<RawTexture>;
  32278. /**
  32279. * Gets or sets a skeleton to apply skining transformations
  32280. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32281. */
  32282. set skeleton(value: Nullable<Skeleton>);
  32283. get skeleton(): Nullable<Skeleton>;
  32284. /**
  32285. * An event triggered when the mesh is rebuilt.
  32286. */
  32287. onRebuildObservable: Observable<AbstractMesh>;
  32288. /**
  32289. * Creates a new AbstractMesh
  32290. * @param name defines the name of the mesh
  32291. * @param scene defines the hosting scene
  32292. */
  32293. constructor(name: string, scene?: Nullable<Scene>);
  32294. /**
  32295. * Returns the string "AbstractMesh"
  32296. * @returns "AbstractMesh"
  32297. */
  32298. getClassName(): string;
  32299. /**
  32300. * Gets a string representation of the current mesh
  32301. * @param fullDetails defines a boolean indicating if full details must be included
  32302. * @returns a string representation of the current mesh
  32303. */
  32304. toString(fullDetails?: boolean): string;
  32305. /**
  32306. * @hidden
  32307. */
  32308. protected _getEffectiveParent(): Nullable<Node>;
  32309. /** @hidden */
  32310. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32311. /** @hidden */
  32312. _rebuild(): void;
  32313. /** @hidden */
  32314. _resyncLightSources(): void;
  32315. /** @hidden */
  32316. _resyncLightSource(light: Light): void;
  32317. /** @hidden */
  32318. _unBindEffect(): void;
  32319. /** @hidden */
  32320. _removeLightSource(light: Light, dispose: boolean): void;
  32321. private _markSubMeshesAsDirty;
  32322. /** @hidden */
  32323. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32324. /** @hidden */
  32325. _markSubMeshesAsAttributesDirty(): void;
  32326. /** @hidden */
  32327. _markSubMeshesAsMiscDirty(): void;
  32328. /**
  32329. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32330. */
  32331. get scaling(): Vector3;
  32332. set scaling(newScaling: Vector3);
  32333. /**
  32334. * Returns true if the mesh is blocked. Implemented by child classes
  32335. */
  32336. get isBlocked(): boolean;
  32337. /**
  32338. * Returns the mesh itself by default. Implemented by child classes
  32339. * @param camera defines the camera to use to pick the right LOD level
  32340. * @returns the currentAbstractMesh
  32341. */
  32342. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32343. /**
  32344. * Returns 0 by default. Implemented by child classes
  32345. * @returns an integer
  32346. */
  32347. getTotalVertices(): number;
  32348. /**
  32349. * Returns a positive integer : the total number of indices in this mesh geometry.
  32350. * @returns the numner of indices or zero if the mesh has no geometry.
  32351. */
  32352. getTotalIndices(): number;
  32353. /**
  32354. * Returns null by default. Implemented by child classes
  32355. * @returns null
  32356. */
  32357. getIndices(): Nullable<IndicesArray>;
  32358. /**
  32359. * Returns the array of the requested vertex data kind. Implemented by child classes
  32360. * @param kind defines the vertex data kind to use
  32361. * @returns null
  32362. */
  32363. getVerticesData(kind: string): Nullable<FloatArray>;
  32364. /**
  32365. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32366. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32367. * Note that a new underlying VertexBuffer object is created each call.
  32368. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32369. * @param kind defines vertex data kind:
  32370. * * VertexBuffer.PositionKind
  32371. * * VertexBuffer.UVKind
  32372. * * VertexBuffer.UV2Kind
  32373. * * VertexBuffer.UV3Kind
  32374. * * VertexBuffer.UV4Kind
  32375. * * VertexBuffer.UV5Kind
  32376. * * VertexBuffer.UV6Kind
  32377. * * VertexBuffer.ColorKind
  32378. * * VertexBuffer.MatricesIndicesKind
  32379. * * VertexBuffer.MatricesIndicesExtraKind
  32380. * * VertexBuffer.MatricesWeightsKind
  32381. * * VertexBuffer.MatricesWeightsExtraKind
  32382. * @param data defines the data source
  32383. * @param updatable defines if the data must be flagged as updatable (or static)
  32384. * @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
  32385. * @returns the current mesh
  32386. */
  32387. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32388. /**
  32389. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32390. * If the mesh has no geometry, it is simply returned as it is.
  32391. * @param kind defines vertex data kind:
  32392. * * VertexBuffer.PositionKind
  32393. * * VertexBuffer.UVKind
  32394. * * VertexBuffer.UV2Kind
  32395. * * VertexBuffer.UV3Kind
  32396. * * VertexBuffer.UV4Kind
  32397. * * VertexBuffer.UV5Kind
  32398. * * VertexBuffer.UV6Kind
  32399. * * VertexBuffer.ColorKind
  32400. * * VertexBuffer.MatricesIndicesKind
  32401. * * VertexBuffer.MatricesIndicesExtraKind
  32402. * * VertexBuffer.MatricesWeightsKind
  32403. * * VertexBuffer.MatricesWeightsExtraKind
  32404. * @param data defines the data source
  32405. * @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
  32406. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32407. * @returns the current mesh
  32408. */
  32409. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32410. /**
  32411. * Sets the mesh indices,
  32412. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32413. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32414. * @param totalVertices Defines the total number of vertices
  32415. * @returns the current mesh
  32416. */
  32417. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32418. /**
  32419. * Gets a boolean indicating if specific vertex data is present
  32420. * @param kind defines the vertex data kind to use
  32421. * @returns true is data kind is present
  32422. */
  32423. isVerticesDataPresent(kind: string): boolean;
  32424. /**
  32425. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32426. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32427. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32428. * @returns a BoundingInfo
  32429. */
  32430. getBoundingInfo(): BoundingInfo;
  32431. /**
  32432. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32433. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32434. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32435. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32436. * @returns the current mesh
  32437. */
  32438. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32439. /**
  32440. * Overwrite the current bounding info
  32441. * @param boundingInfo defines the new bounding info
  32442. * @returns the current mesh
  32443. */
  32444. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32445. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32446. get useBones(): boolean;
  32447. /** @hidden */
  32448. _preActivate(): void;
  32449. /** @hidden */
  32450. _preActivateForIntermediateRendering(renderId: number): void;
  32451. /** @hidden */
  32452. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32453. /** @hidden */
  32454. _postActivate(): void;
  32455. /** @hidden */
  32456. _freeze(): void;
  32457. /** @hidden */
  32458. _unFreeze(): void;
  32459. /**
  32460. * Gets the current world matrix
  32461. * @returns a Matrix
  32462. */
  32463. getWorldMatrix(): Matrix;
  32464. /** @hidden */
  32465. _getWorldMatrixDeterminant(): number;
  32466. /**
  32467. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32468. */
  32469. get isAnInstance(): boolean;
  32470. /**
  32471. * Gets a boolean indicating if this mesh has instances
  32472. */
  32473. get hasInstances(): boolean;
  32474. /**
  32475. * Gets a boolean indicating if this mesh has thin instances
  32476. */
  32477. get hasThinInstances(): boolean;
  32478. /**
  32479. * Perform relative position change from the point of view of behind the front of the mesh.
  32480. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32481. * Supports definition of mesh facing forward or backward
  32482. * @param amountRight defines the distance on the right axis
  32483. * @param amountUp defines the distance on the up axis
  32484. * @param amountForward defines the distance on the forward axis
  32485. * @returns the current mesh
  32486. */
  32487. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32488. /**
  32489. * Calculate relative position change from the point of view of behind the front of the mesh.
  32490. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32491. * Supports definition of mesh facing forward or backward
  32492. * @param amountRight defines the distance on the right axis
  32493. * @param amountUp defines the distance on the up axis
  32494. * @param amountForward defines the distance on the forward axis
  32495. * @returns the new displacement vector
  32496. */
  32497. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32498. /**
  32499. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32500. * Supports definition of mesh facing forward or backward
  32501. * @param flipBack defines the flip
  32502. * @param twirlClockwise defines the twirl
  32503. * @param tiltRight defines the tilt
  32504. * @returns the current mesh
  32505. */
  32506. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32507. /**
  32508. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32509. * Supports definition of mesh facing forward or backward.
  32510. * @param flipBack defines the flip
  32511. * @param twirlClockwise defines the twirl
  32512. * @param tiltRight defines the tilt
  32513. * @returns the new rotation vector
  32514. */
  32515. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32516. /**
  32517. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32518. * This means the mesh underlying bounding box and sphere are recomputed.
  32519. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32520. * @returns the current mesh
  32521. */
  32522. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32523. /** @hidden */
  32524. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32525. /** @hidden */
  32526. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32527. /** @hidden */
  32528. _updateBoundingInfo(): AbstractMesh;
  32529. /** @hidden */
  32530. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32531. /** @hidden */
  32532. protected _afterComputeWorldMatrix(): void;
  32533. /** @hidden */
  32534. get _effectiveMesh(): AbstractMesh;
  32535. /**
  32536. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32537. * A mesh is in the frustum if its bounding box intersects the frustum
  32538. * @param frustumPlanes defines the frustum to test
  32539. * @returns true if the mesh is in the frustum planes
  32540. */
  32541. isInFrustum(frustumPlanes: Plane[]): boolean;
  32542. /**
  32543. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32544. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32545. * @param frustumPlanes defines the frustum to test
  32546. * @returns true if the mesh is completely in the frustum planes
  32547. */
  32548. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32549. /**
  32550. * True if the mesh intersects another mesh or a SolidParticle object
  32551. * @param mesh defines a target mesh or SolidParticle to test
  32552. * @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)
  32553. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32554. * @returns true if there is an intersection
  32555. */
  32556. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32557. /**
  32558. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32559. * @param point defines the point to test
  32560. * @returns true if there is an intersection
  32561. */
  32562. intersectsPoint(point: Vector3): boolean;
  32563. /**
  32564. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. */
  32567. get checkCollisions(): boolean;
  32568. set checkCollisions(collisionEnabled: boolean);
  32569. /**
  32570. * Gets Collider object used to compute collisions (not physics)
  32571. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32572. */
  32573. get collider(): Nullable<Collider>;
  32574. /**
  32575. * Move the mesh using collision engine
  32576. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32577. * @param displacement defines the requested displacement vector
  32578. * @returns the current mesh
  32579. */
  32580. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32581. private _onCollisionPositionChange;
  32582. /** @hidden */
  32583. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32584. /** @hidden */
  32585. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32586. /** @hidden */
  32587. _checkCollision(collider: Collider): AbstractMesh;
  32588. /** @hidden */
  32589. _generatePointsArray(): boolean;
  32590. /**
  32591. * Checks if the passed Ray intersects with the mesh
  32592. * @param ray defines the ray to use
  32593. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32594. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32595. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32596. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32597. * @returns the picking info
  32598. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32599. */
  32600. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32601. /**
  32602. * Clones the current mesh
  32603. * @param name defines the mesh name
  32604. * @param newParent defines the new mesh parent
  32605. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32606. * @returns the new mesh
  32607. */
  32608. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32609. /**
  32610. * Disposes all the submeshes of the current meshnp
  32611. * @returns the current mesh
  32612. */
  32613. releaseSubMeshes(): AbstractMesh;
  32614. /**
  32615. * Releases resources associated with this abstract mesh.
  32616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32618. */
  32619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32620. /**
  32621. * Adds the passed mesh as a child to the current mesh
  32622. * @param mesh defines the child mesh
  32623. * @returns the current mesh
  32624. */
  32625. addChild(mesh: AbstractMesh): AbstractMesh;
  32626. /**
  32627. * Removes the passed mesh from the current mesh children list
  32628. * @param mesh defines the child mesh
  32629. * @returns the current mesh
  32630. */
  32631. removeChild(mesh: AbstractMesh): AbstractMesh;
  32632. /** @hidden */
  32633. private _initFacetData;
  32634. /**
  32635. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32636. * This method can be called within the render loop.
  32637. * 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
  32638. * @returns the current mesh
  32639. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32640. */
  32641. updateFacetData(): AbstractMesh;
  32642. /**
  32643. * Returns the facetLocalNormals array.
  32644. * The normals are expressed in the mesh local spac
  32645. * @returns an array of Vector3
  32646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32647. */
  32648. getFacetLocalNormals(): Vector3[];
  32649. /**
  32650. * Returns the facetLocalPositions array.
  32651. * The facet positions are expressed in the mesh local space
  32652. * @returns an array of Vector3
  32653. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32654. */
  32655. getFacetLocalPositions(): Vector3[];
  32656. /**
  32657. * Returns the facetLocalPartioning array
  32658. * @returns an array of array of numbers
  32659. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32660. */
  32661. getFacetLocalPartitioning(): number[][];
  32662. /**
  32663. * Returns the i-th facet position in the world system.
  32664. * This method allocates a new Vector3 per call
  32665. * @param i defines the facet index
  32666. * @returns a new Vector3
  32667. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32668. */
  32669. getFacetPosition(i: number): Vector3;
  32670. /**
  32671. * Sets the reference Vector3 with the i-th facet position in the world system
  32672. * @param i defines the facet index
  32673. * @param ref defines the target vector
  32674. * @returns the current mesh
  32675. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32676. */
  32677. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32678. /**
  32679. * Returns the i-th facet normal in the world system.
  32680. * This method allocates a new Vector3 per call
  32681. * @param i defines the facet index
  32682. * @returns a new Vector3
  32683. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32684. */
  32685. getFacetNormal(i: number): Vector3;
  32686. /**
  32687. * Sets the reference Vector3 with the i-th facet normal in the world system
  32688. * @param i defines the facet index
  32689. * @param ref defines the target vector
  32690. * @returns the current mesh
  32691. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32692. */
  32693. getFacetNormalToRef(i: number, ref: Vector3): this;
  32694. /**
  32695. * 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)
  32696. * @param x defines x coordinate
  32697. * @param y defines y coordinate
  32698. * @param z defines z coordinate
  32699. * @returns the array of facet indexes
  32700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32701. */
  32702. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32703. /**
  32704. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32705. * @param projected sets as the (x,y,z) world projection on the facet
  32706. * @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
  32707. * @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
  32708. * @param x defines x coordinate
  32709. * @param y defines y coordinate
  32710. * @param z defines z coordinate
  32711. * @returns the face index if found (or null instead)
  32712. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32713. */
  32714. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32715. /**
  32716. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32717. * @param projected sets as the (x,y,z) local projection on the facet
  32718. * @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
  32719. * @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
  32720. * @param x defines x coordinate
  32721. * @param y defines y coordinate
  32722. * @param z defines z coordinate
  32723. * @returns the face index if found (or null instead)
  32724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32725. */
  32726. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32727. /**
  32728. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32729. * @returns the parameters
  32730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32731. */
  32732. getFacetDataParameters(): any;
  32733. /**
  32734. * Disables the feature FacetData and frees the related memory
  32735. * @returns the current mesh
  32736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32737. */
  32738. disableFacetData(): AbstractMesh;
  32739. /**
  32740. * Updates the AbstractMesh indices array
  32741. * @param indices defines the data source
  32742. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32743. * @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)
  32744. * @returns the current mesh
  32745. */
  32746. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32747. /**
  32748. * Creates new normals data for the mesh
  32749. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32750. * @returns the current mesh
  32751. */
  32752. createNormals(updatable: boolean): AbstractMesh;
  32753. /**
  32754. * Align the mesh with a normal
  32755. * @param normal defines the normal to use
  32756. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32757. * @returns the current mesh
  32758. */
  32759. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32760. /** @hidden */
  32761. _checkOcclusionQuery(): boolean;
  32762. /**
  32763. * Disables the mesh edge rendering mode
  32764. * @returns the currentAbstractMesh
  32765. */
  32766. disableEdgesRendering(): AbstractMesh;
  32767. /**
  32768. * Enables the edge rendering mode on the mesh.
  32769. * This mode makes the mesh edges visible
  32770. * @param epsilon defines the maximal distance between two angles to detect a face
  32771. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32772. * @returns the currentAbstractMesh
  32773. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32774. */
  32775. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32776. /**
  32777. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32778. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32779. */
  32780. getConnectedParticleSystems(): IParticleSystem[];
  32781. }
  32782. }
  32783. declare module BABYLON {
  32784. /**
  32785. * Interface used to define ActionEvent
  32786. */
  32787. export interface IActionEvent {
  32788. /** The mesh or sprite that triggered the action */
  32789. source: any;
  32790. /** The X mouse cursor position at the time of the event */
  32791. pointerX: number;
  32792. /** The Y mouse cursor position at the time of the event */
  32793. pointerY: number;
  32794. /** The mesh that is currently pointed at (can be null) */
  32795. meshUnderPointer: Nullable<AbstractMesh>;
  32796. /** the original (browser) event that triggered the ActionEvent */
  32797. sourceEvent?: any;
  32798. /** additional data for the event */
  32799. additionalData?: any;
  32800. }
  32801. /**
  32802. * ActionEvent is the event being sent when an action is triggered.
  32803. */
  32804. export class ActionEvent implements IActionEvent {
  32805. /** The mesh or sprite that triggered the action */
  32806. source: any;
  32807. /** The X mouse cursor position at the time of the event */
  32808. pointerX: number;
  32809. /** The Y mouse cursor position at the time of the event */
  32810. pointerY: number;
  32811. /** The mesh that is currently pointed at (can be null) */
  32812. meshUnderPointer: Nullable<AbstractMesh>;
  32813. /** the original (browser) event that triggered the ActionEvent */
  32814. sourceEvent?: any;
  32815. /** additional data for the event */
  32816. additionalData?: any;
  32817. /**
  32818. * Creates a new ActionEvent
  32819. * @param source The mesh or sprite that triggered the action
  32820. * @param pointerX The X mouse cursor position at the time of the event
  32821. * @param pointerY The Y mouse cursor position at the time of the event
  32822. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32823. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32824. * @param additionalData additional data for the event
  32825. */
  32826. constructor(
  32827. /** The mesh or sprite that triggered the action */
  32828. source: any,
  32829. /** The X mouse cursor position at the time of the event */
  32830. pointerX: number,
  32831. /** The Y mouse cursor position at the time of the event */
  32832. pointerY: number,
  32833. /** The mesh that is currently pointed at (can be null) */
  32834. meshUnderPointer: Nullable<AbstractMesh>,
  32835. /** the original (browser) event that triggered the ActionEvent */
  32836. sourceEvent?: any,
  32837. /** additional data for the event */
  32838. additionalData?: any);
  32839. /**
  32840. * Helper function to auto-create an ActionEvent from a source mesh.
  32841. * @param source The source mesh that triggered the event
  32842. * @param evt The original (browser) event
  32843. * @param additionalData additional data for the event
  32844. * @returns the new ActionEvent
  32845. */
  32846. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32847. /**
  32848. * Helper function to auto-create an ActionEvent from a source sprite
  32849. * @param source The source sprite that triggered the event
  32850. * @param scene Scene associated with the sprite
  32851. * @param evt The original (browser) event
  32852. * @param additionalData additional data for the event
  32853. * @returns the new ActionEvent
  32854. */
  32855. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32856. /**
  32857. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32858. * @param scene the scene where the event occurred
  32859. * @param evt The original (browser) event
  32860. * @returns the new ActionEvent
  32861. */
  32862. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32863. /**
  32864. * Helper function to auto-create an ActionEvent from a primitive
  32865. * @param prim defines the target primitive
  32866. * @param pointerPos defines the pointer position
  32867. * @param evt The original (browser) event
  32868. * @param additionalData additional data for the event
  32869. * @returns the new ActionEvent
  32870. */
  32871. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32872. }
  32873. }
  32874. declare module BABYLON {
  32875. /**
  32876. * Abstract class used to decouple action Manager from scene and meshes.
  32877. * Do not instantiate.
  32878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32879. */
  32880. export abstract class AbstractActionManager implements IDisposable {
  32881. /** Gets the list of active triggers */
  32882. static Triggers: {
  32883. [key: string]: number;
  32884. };
  32885. /** Gets the cursor to use when hovering items */
  32886. hoverCursor: string;
  32887. /** Gets the list of actions */
  32888. actions: IAction[];
  32889. /**
  32890. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32891. */
  32892. isRecursive: boolean;
  32893. /**
  32894. * Releases all associated resources
  32895. */
  32896. abstract dispose(): void;
  32897. /**
  32898. * Does this action manager has pointer triggers
  32899. */
  32900. abstract get hasPointerTriggers(): boolean;
  32901. /**
  32902. * Does this action manager has pick triggers
  32903. */
  32904. abstract get hasPickTriggers(): boolean;
  32905. /**
  32906. * Process a specific trigger
  32907. * @param trigger defines the trigger to process
  32908. * @param evt defines the event details to be processed
  32909. */
  32910. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32911. /**
  32912. * Does this action manager handles actions of any of the given triggers
  32913. * @param triggers defines the triggers to be tested
  32914. * @return a boolean indicating whether one (or more) of the triggers is handled
  32915. */
  32916. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32917. /**
  32918. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32919. * speed.
  32920. * @param triggerA defines the trigger to be tested
  32921. * @param triggerB defines the trigger to be tested
  32922. * @return a boolean indicating whether one (or more) of the triggers is handled
  32923. */
  32924. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32925. /**
  32926. * Does this action manager handles actions of a given trigger
  32927. * @param trigger defines the trigger to be tested
  32928. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32929. * @return whether the trigger is handled
  32930. */
  32931. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32932. /**
  32933. * Serialize this manager to a JSON object
  32934. * @param name defines the property name to store this manager
  32935. * @returns a JSON representation of this manager
  32936. */
  32937. abstract serialize(name: string): any;
  32938. /**
  32939. * Registers an action to this action manager
  32940. * @param action defines the action to be registered
  32941. * @return the action amended (prepared) after registration
  32942. */
  32943. abstract registerAction(action: IAction): Nullable<IAction>;
  32944. /**
  32945. * Unregisters an action to this action manager
  32946. * @param action defines the action to be unregistered
  32947. * @return a boolean indicating whether the action has been unregistered
  32948. */
  32949. abstract unregisterAction(action: IAction): Boolean;
  32950. /**
  32951. * Does exist one action manager with at least one trigger
  32952. **/
  32953. static get HasTriggers(): boolean;
  32954. /**
  32955. * Does exist one action manager with at least one pick trigger
  32956. **/
  32957. static get HasPickTriggers(): boolean;
  32958. /**
  32959. * Does exist one action manager that handles actions of a given trigger
  32960. * @param trigger defines the trigger to be tested
  32961. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32962. **/
  32963. static HasSpecificTrigger(trigger: number): boolean;
  32964. }
  32965. }
  32966. declare module BABYLON {
  32967. /**
  32968. * Defines how a node can be built from a string name.
  32969. */
  32970. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32971. /**
  32972. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32973. */
  32974. export class Node implements IBehaviorAware<Node> {
  32975. /** @hidden */
  32976. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32977. private static _NodeConstructors;
  32978. /**
  32979. * Add a new node constructor
  32980. * @param type defines the type name of the node to construct
  32981. * @param constructorFunc defines the constructor function
  32982. */
  32983. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32984. /**
  32985. * Returns a node constructor based on type name
  32986. * @param type defines the type name
  32987. * @param name defines the new node name
  32988. * @param scene defines the hosting scene
  32989. * @param options defines optional options to transmit to constructors
  32990. * @returns the new constructor or null
  32991. */
  32992. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32993. /**
  32994. * Gets or sets the name of the node
  32995. */
  32996. name: string;
  32997. /**
  32998. * Gets or sets the id of the node
  32999. */
  33000. id: string;
  33001. /**
  33002. * Gets or sets the unique id of the node
  33003. */
  33004. uniqueId: number;
  33005. /**
  33006. * Gets or sets a string used to store user defined state for the node
  33007. */
  33008. state: string;
  33009. /**
  33010. * Gets or sets an object used to store user defined information for the node
  33011. */
  33012. metadata: any;
  33013. /**
  33014. * For internal use only. Please do not use.
  33015. */
  33016. reservedDataStore: any;
  33017. /**
  33018. * List of inspectable custom properties (used by the Inspector)
  33019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33020. */
  33021. inspectableCustomProperties: IInspectable[];
  33022. private _doNotSerialize;
  33023. /**
  33024. * Gets or sets a boolean used to define if the node must be serialized
  33025. */
  33026. get doNotSerialize(): boolean;
  33027. set doNotSerialize(value: boolean);
  33028. /** @hidden */
  33029. _isDisposed: boolean;
  33030. /**
  33031. * Gets a list of Animations associated with the node
  33032. */
  33033. animations: Animation[];
  33034. protected _ranges: {
  33035. [name: string]: Nullable<AnimationRange>;
  33036. };
  33037. /**
  33038. * Callback raised when the node is ready to be used
  33039. */
  33040. onReady: Nullable<(node: Node) => void>;
  33041. private _isEnabled;
  33042. private _isParentEnabled;
  33043. private _isReady;
  33044. /** @hidden */
  33045. _currentRenderId: number;
  33046. private _parentUpdateId;
  33047. /** @hidden */
  33048. _childUpdateId: number;
  33049. /** @hidden */
  33050. _waitingParentId: Nullable<string>;
  33051. /** @hidden */
  33052. _scene: Scene;
  33053. /** @hidden */
  33054. _cache: any;
  33055. private _parentNode;
  33056. private _children;
  33057. /** @hidden */
  33058. _worldMatrix: Matrix;
  33059. /** @hidden */
  33060. _worldMatrixDeterminant: number;
  33061. /** @hidden */
  33062. _worldMatrixDeterminantIsDirty: boolean;
  33063. /** @hidden */
  33064. private _sceneRootNodesIndex;
  33065. /**
  33066. * Gets a boolean indicating if the node has been disposed
  33067. * @returns true if the node was disposed
  33068. */
  33069. isDisposed(): boolean;
  33070. /**
  33071. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33072. * @see https://doc.babylonjs.com/how_to/parenting
  33073. */
  33074. set parent(parent: Nullable<Node>);
  33075. get parent(): Nullable<Node>;
  33076. /** @hidden */
  33077. _addToSceneRootNodes(): void;
  33078. /** @hidden */
  33079. _removeFromSceneRootNodes(): void;
  33080. private _animationPropertiesOverride;
  33081. /**
  33082. * Gets or sets the animation properties override
  33083. */
  33084. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33085. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33086. /**
  33087. * Gets a string identifying the name of the class
  33088. * @returns "Node" string
  33089. */
  33090. getClassName(): string;
  33091. /** @hidden */
  33092. readonly _isNode: boolean;
  33093. /**
  33094. * An event triggered when the mesh is disposed
  33095. */
  33096. onDisposeObservable: Observable<Node>;
  33097. private _onDisposeObserver;
  33098. /**
  33099. * Sets a callback that will be raised when the node will be disposed
  33100. */
  33101. set onDispose(callback: () => void);
  33102. /**
  33103. * Creates a new Node
  33104. * @param name the name and id to be given to this node
  33105. * @param scene the scene this node will be added to
  33106. */
  33107. constructor(name: string, scene?: Nullable<Scene>);
  33108. /**
  33109. * Gets the scene of the node
  33110. * @returns a scene
  33111. */
  33112. getScene(): Scene;
  33113. /**
  33114. * Gets the engine of the node
  33115. * @returns a Engine
  33116. */
  33117. getEngine(): Engine;
  33118. private _behaviors;
  33119. /**
  33120. * Attach a behavior to the node
  33121. * @see https://doc.babylonjs.com/features/behaviour
  33122. * @param behavior defines the behavior to attach
  33123. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33124. * @returns the current Node
  33125. */
  33126. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33127. /**
  33128. * Remove an attached behavior
  33129. * @see https://doc.babylonjs.com/features/behaviour
  33130. * @param behavior defines the behavior to attach
  33131. * @returns the current Node
  33132. */
  33133. removeBehavior(behavior: Behavior<Node>): Node;
  33134. /**
  33135. * Gets the list of attached behaviors
  33136. * @see https://doc.babylonjs.com/features/behaviour
  33137. */
  33138. get behaviors(): Behavior<Node>[];
  33139. /**
  33140. * Gets an attached behavior by name
  33141. * @param name defines the name of the behavior to look for
  33142. * @see https://doc.babylonjs.com/features/behaviour
  33143. * @returns null if behavior was not found else the requested behavior
  33144. */
  33145. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33146. /**
  33147. * Returns the latest update of the World matrix
  33148. * @returns a Matrix
  33149. */
  33150. getWorldMatrix(): Matrix;
  33151. /** @hidden */
  33152. _getWorldMatrixDeterminant(): number;
  33153. /**
  33154. * Returns directly the latest state of the mesh World matrix.
  33155. * A Matrix is returned.
  33156. */
  33157. get worldMatrixFromCache(): Matrix;
  33158. /** @hidden */
  33159. _initCache(): void;
  33160. /** @hidden */
  33161. updateCache(force?: boolean): void;
  33162. /** @hidden */
  33163. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33164. /** @hidden */
  33165. _updateCache(ignoreParentClass?: boolean): void;
  33166. /** @hidden */
  33167. _isSynchronized(): boolean;
  33168. /** @hidden */
  33169. _markSyncedWithParent(): void;
  33170. /** @hidden */
  33171. isSynchronizedWithParent(): boolean;
  33172. /** @hidden */
  33173. isSynchronized(): boolean;
  33174. /**
  33175. * Is this node ready to be used/rendered
  33176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33177. * @return true if the node is ready
  33178. */
  33179. isReady(completeCheck?: boolean): boolean;
  33180. /**
  33181. * Is this node enabled?
  33182. * 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
  33183. * @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
  33184. * @return whether this node (and its parent) is enabled
  33185. */
  33186. isEnabled(checkAncestors?: boolean): boolean;
  33187. /** @hidden */
  33188. protected _syncParentEnabledState(): void;
  33189. /**
  33190. * Set the enabled state of this node
  33191. * @param value defines the new enabled state
  33192. */
  33193. setEnabled(value: boolean): void;
  33194. /**
  33195. * Is this node a descendant of the given node?
  33196. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33197. * @param ancestor defines the parent node to inspect
  33198. * @returns a boolean indicating if this node is a descendant of the given node
  33199. */
  33200. isDescendantOf(ancestor: Node): boolean;
  33201. /** @hidden */
  33202. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33203. /**
  33204. * Will return all nodes that have this node as ascendant
  33205. * @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
  33206. * @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
  33207. * @return all children nodes of all types
  33208. */
  33209. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33210. /**
  33211. * Get all child-meshes of this node
  33212. * @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)
  33213. * @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
  33214. * @returns an array of AbstractMesh
  33215. */
  33216. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33217. /**
  33218. * Get all direct children of this node
  33219. * @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
  33220. * @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)
  33221. * @returns an array of Node
  33222. */
  33223. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33224. /** @hidden */
  33225. _setReady(state: boolean): void;
  33226. /**
  33227. * Get an animation by name
  33228. * @param name defines the name of the animation to look for
  33229. * @returns null if not found else the requested animation
  33230. */
  33231. getAnimationByName(name: string): Nullable<Animation>;
  33232. /**
  33233. * Creates an animation range for this node
  33234. * @param name defines the name of the range
  33235. * @param from defines the starting key
  33236. * @param to defines the end key
  33237. */
  33238. createAnimationRange(name: string, from: number, to: number): void;
  33239. /**
  33240. * Delete a specific animation range
  33241. * @param name defines the name of the range to delete
  33242. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33243. */
  33244. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33245. /**
  33246. * Get an animation range by name
  33247. * @param name defines the name of the animation range to look for
  33248. * @returns null if not found else the requested animation range
  33249. */
  33250. getAnimationRange(name: string): Nullable<AnimationRange>;
  33251. /**
  33252. * Gets the list of all animation ranges defined on this node
  33253. * @returns an array
  33254. */
  33255. getAnimationRanges(): Nullable<AnimationRange>[];
  33256. /**
  33257. * Will start the animation sequence
  33258. * @param name defines the range frames for animation sequence
  33259. * @param loop defines if the animation should loop (false by default)
  33260. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33261. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33262. * @returns the object created for this animation. If range does not exist, it will return null
  33263. */
  33264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33265. /**
  33266. * Serialize animation ranges into a JSON compatible object
  33267. * @returns serialization object
  33268. */
  33269. serializeAnimationRanges(): any;
  33270. /**
  33271. * Computes the world matrix of the node
  33272. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33273. * @returns the world matrix
  33274. */
  33275. computeWorldMatrix(force?: boolean): Matrix;
  33276. /**
  33277. * Releases resources associated with this node.
  33278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33280. */
  33281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33282. /**
  33283. * Parse animation range data from a serialization object and store them into a given node
  33284. * @param node defines where to store the animation ranges
  33285. * @param parsedNode defines the serialization object to read data from
  33286. * @param scene defines the hosting scene
  33287. */
  33288. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33289. /**
  33290. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33291. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33292. * @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
  33293. * @returns the new bounding vectors
  33294. */
  33295. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33296. min: Vector3;
  33297. max: Vector3;
  33298. };
  33299. }
  33300. }
  33301. declare module BABYLON {
  33302. /**
  33303. * @hidden
  33304. */
  33305. export class _IAnimationState {
  33306. key: number;
  33307. repeatCount: number;
  33308. workValue?: any;
  33309. loopMode?: number;
  33310. offsetValue?: any;
  33311. highLimitValue?: any;
  33312. }
  33313. /**
  33314. * Class used to store any kind of animation
  33315. */
  33316. export class Animation {
  33317. /**Name of the animation */
  33318. name: string;
  33319. /**Property to animate */
  33320. targetProperty: string;
  33321. /**The frames per second of the animation */
  33322. framePerSecond: number;
  33323. /**The data type of the animation */
  33324. dataType: number;
  33325. /**The loop mode of the animation */
  33326. loopMode?: number | undefined;
  33327. /**Specifies if blending should be enabled */
  33328. enableBlending?: boolean | undefined;
  33329. /**
  33330. * Use matrix interpolation instead of using direct key value when animating matrices
  33331. */
  33332. static AllowMatricesInterpolation: boolean;
  33333. /**
  33334. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33335. */
  33336. static AllowMatrixDecomposeForInterpolation: boolean;
  33337. /** Define the Url to load snippets */
  33338. static SnippetUrl: string;
  33339. /** Snippet ID if the animation was created from the snippet server */
  33340. snippetId: string;
  33341. /**
  33342. * Stores the key frames of the animation
  33343. */
  33344. private _keys;
  33345. /**
  33346. * Stores the easing function of the animation
  33347. */
  33348. private _easingFunction;
  33349. /**
  33350. * @hidden Internal use only
  33351. */
  33352. _runtimeAnimations: RuntimeAnimation[];
  33353. /**
  33354. * The set of event that will be linked to this animation
  33355. */
  33356. private _events;
  33357. /**
  33358. * Stores an array of target property paths
  33359. */
  33360. targetPropertyPath: string[];
  33361. /**
  33362. * Stores the blending speed of the animation
  33363. */
  33364. blendingSpeed: number;
  33365. /**
  33366. * Stores the animation ranges for the animation
  33367. */
  33368. private _ranges;
  33369. /**
  33370. * @hidden Internal use
  33371. */
  33372. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33373. /**
  33374. * Sets up an animation
  33375. * @param property The property to animate
  33376. * @param animationType The animation type to apply
  33377. * @param framePerSecond The frames per second of the animation
  33378. * @param easingFunction The easing function used in the animation
  33379. * @returns The created animation
  33380. */
  33381. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33382. /**
  33383. * Create and start an animation on a node
  33384. * @param name defines the name of the global animation that will be run on all nodes
  33385. * @param node defines the root node where the animation will take place
  33386. * @param targetProperty defines property to animate
  33387. * @param framePerSecond defines the number of frame per second yo use
  33388. * @param totalFrame defines the number of frames in total
  33389. * @param from defines the initial value
  33390. * @param to defines the final value
  33391. * @param loopMode defines which loop mode you want to use (off by default)
  33392. * @param easingFunction defines the easing function to use (linear by default)
  33393. * @param onAnimationEnd defines the callback to call when animation end
  33394. * @returns the animatable created for this animation
  33395. */
  33396. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33397. /**
  33398. * Create and start an animation on a node and its descendants
  33399. * @param name defines the name of the global animation that will be run on all nodes
  33400. * @param node defines the root node where the animation will take place
  33401. * @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
  33402. * @param targetProperty defines property to animate
  33403. * @param framePerSecond defines the number of frame per second to use
  33404. * @param totalFrame defines the number of frames in total
  33405. * @param from defines the initial value
  33406. * @param to defines the final value
  33407. * @param loopMode defines which loop mode you want to use (off by default)
  33408. * @param easingFunction defines the easing function to use (linear by default)
  33409. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33410. * @returns the list of animatables created for all nodes
  33411. * @example https://www.babylonjs-playground.com/#MH0VLI
  33412. */
  33413. 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[]>;
  33414. /**
  33415. * Creates a new animation, merges it with the existing animations and starts it
  33416. * @param name Name of the animation
  33417. * @param node Node which contains the scene that begins the animations
  33418. * @param targetProperty Specifies which property to animate
  33419. * @param framePerSecond The frames per second of the animation
  33420. * @param totalFrame The total number of frames
  33421. * @param from The frame at the beginning of the animation
  33422. * @param to The frame at the end of the animation
  33423. * @param loopMode Specifies the loop mode of the animation
  33424. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33425. * @param onAnimationEnd Callback to run once the animation is complete
  33426. * @returns Nullable animation
  33427. */
  33428. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33429. /**
  33430. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33431. * @param sourceAnimation defines the Animation containing keyframes to convert
  33432. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33433. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33434. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33435. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33436. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33437. */
  33438. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33439. /**
  33440. * Transition property of an host to the target Value
  33441. * @param property The property to transition
  33442. * @param targetValue The target Value of the property
  33443. * @param host The object where the property to animate belongs
  33444. * @param scene Scene used to run the animation
  33445. * @param frameRate Framerate (in frame/s) to use
  33446. * @param transition The transition type we want to use
  33447. * @param duration The duration of the animation, in milliseconds
  33448. * @param onAnimationEnd Callback trigger at the end of the animation
  33449. * @returns Nullable animation
  33450. */
  33451. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33452. /**
  33453. * Return the array of runtime animations currently using this animation
  33454. */
  33455. get runtimeAnimations(): RuntimeAnimation[];
  33456. /**
  33457. * Specifies if any of the runtime animations are currently running
  33458. */
  33459. get hasRunningRuntimeAnimations(): boolean;
  33460. /**
  33461. * Initializes the animation
  33462. * @param name Name of the animation
  33463. * @param targetProperty Property to animate
  33464. * @param framePerSecond The frames per second of the animation
  33465. * @param dataType The data type of the animation
  33466. * @param loopMode The loop mode of the animation
  33467. * @param enableBlending Specifies if blending should be enabled
  33468. */
  33469. constructor(
  33470. /**Name of the animation */
  33471. name: string,
  33472. /**Property to animate */
  33473. targetProperty: string,
  33474. /**The frames per second of the animation */
  33475. framePerSecond: number,
  33476. /**The data type of the animation */
  33477. dataType: number,
  33478. /**The loop mode of the animation */
  33479. loopMode?: number | undefined,
  33480. /**Specifies if blending should be enabled */
  33481. enableBlending?: boolean | undefined);
  33482. /**
  33483. * Converts the animation to a string
  33484. * @param fullDetails support for multiple levels of logging within scene loading
  33485. * @returns String form of the animation
  33486. */
  33487. toString(fullDetails?: boolean): string;
  33488. /**
  33489. * Add an event to this animation
  33490. * @param event Event to add
  33491. */
  33492. addEvent(event: AnimationEvent): void;
  33493. /**
  33494. * Remove all events found at the given frame
  33495. * @param frame The frame to remove events from
  33496. */
  33497. removeEvents(frame: number): void;
  33498. /**
  33499. * Retrieves all the events from the animation
  33500. * @returns Events from the animation
  33501. */
  33502. getEvents(): AnimationEvent[];
  33503. /**
  33504. * Creates an animation range
  33505. * @param name Name of the animation range
  33506. * @param from Starting frame of the animation range
  33507. * @param to Ending frame of the animation
  33508. */
  33509. createRange(name: string, from: number, to: number): void;
  33510. /**
  33511. * Deletes an animation range by name
  33512. * @param name Name of the animation range to delete
  33513. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33514. */
  33515. deleteRange(name: string, deleteFrames?: boolean): void;
  33516. /**
  33517. * Gets the animation range by name, or null if not defined
  33518. * @param name Name of the animation range
  33519. * @returns Nullable animation range
  33520. */
  33521. getRange(name: string): Nullable<AnimationRange>;
  33522. /**
  33523. * Gets the key frames from the animation
  33524. * @returns The key frames of the animation
  33525. */
  33526. getKeys(): Array<IAnimationKey>;
  33527. /**
  33528. * Gets the highest frame rate of the animation
  33529. * @returns Highest frame rate of the animation
  33530. */
  33531. getHighestFrame(): number;
  33532. /**
  33533. * Gets the easing function of the animation
  33534. * @returns Easing function of the animation
  33535. */
  33536. getEasingFunction(): IEasingFunction;
  33537. /**
  33538. * Sets the easing function of the animation
  33539. * @param easingFunction A custom mathematical formula for animation
  33540. */
  33541. setEasingFunction(easingFunction: EasingFunction): void;
  33542. /**
  33543. * Interpolates a scalar linearly
  33544. * @param startValue Start value of the animation curve
  33545. * @param endValue End value of the animation curve
  33546. * @param gradient Scalar amount to interpolate
  33547. * @returns Interpolated scalar value
  33548. */
  33549. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33550. /**
  33551. * Interpolates a scalar cubically
  33552. * @param startValue Start value of the animation curve
  33553. * @param outTangent End tangent of the animation
  33554. * @param endValue End value of the animation curve
  33555. * @param inTangent Start tangent of the animation curve
  33556. * @param gradient Scalar amount to interpolate
  33557. * @returns Interpolated scalar value
  33558. */
  33559. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33560. /**
  33561. * Interpolates a quaternion using a spherical linear interpolation
  33562. * @param startValue Start value of the animation curve
  33563. * @param endValue End value of the animation curve
  33564. * @param gradient Scalar amount to interpolate
  33565. * @returns Interpolated quaternion value
  33566. */
  33567. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33568. /**
  33569. * Interpolates a quaternion cubically
  33570. * @param startValue Start value of the animation curve
  33571. * @param outTangent End tangent of the animation curve
  33572. * @param endValue End value of the animation curve
  33573. * @param inTangent Start tangent of the animation curve
  33574. * @param gradient Scalar amount to interpolate
  33575. * @returns Interpolated quaternion value
  33576. */
  33577. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33578. /**
  33579. * Interpolates a Vector3 linearl
  33580. * @param startValue Start value of the animation curve
  33581. * @param endValue End value of the animation curve
  33582. * @param gradient Scalar amount to interpolate
  33583. * @returns Interpolated scalar value
  33584. */
  33585. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33586. /**
  33587. * Interpolates a Vector3 cubically
  33588. * @param startValue Start value of the animation curve
  33589. * @param outTangent End tangent of the animation
  33590. * @param endValue End value of the animation curve
  33591. * @param inTangent Start tangent of the animation curve
  33592. * @param gradient Scalar amount to interpolate
  33593. * @returns InterpolatedVector3 value
  33594. */
  33595. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33596. /**
  33597. * Interpolates a Vector2 linearly
  33598. * @param startValue Start value of the animation curve
  33599. * @param endValue End value of the animation curve
  33600. * @param gradient Scalar amount to interpolate
  33601. * @returns Interpolated Vector2 value
  33602. */
  33603. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33604. /**
  33605. * Interpolates a Vector2 cubically
  33606. * @param startValue Start value of the animation curve
  33607. * @param outTangent End tangent of the animation
  33608. * @param endValue End value of the animation curve
  33609. * @param inTangent Start tangent of the animation curve
  33610. * @param gradient Scalar amount to interpolate
  33611. * @returns Interpolated Vector2 value
  33612. */
  33613. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33614. /**
  33615. * Interpolates a size linearly
  33616. * @param startValue Start value of the animation curve
  33617. * @param endValue End value of the animation curve
  33618. * @param gradient Scalar amount to interpolate
  33619. * @returns Interpolated Size value
  33620. */
  33621. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33622. /**
  33623. * Interpolates a Color3 linearly
  33624. * @param startValue Start value of the animation curve
  33625. * @param endValue End value of the animation curve
  33626. * @param gradient Scalar amount to interpolate
  33627. * @returns Interpolated Color3 value
  33628. */
  33629. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33630. /**
  33631. * Interpolates a Color4 linearly
  33632. * @param startValue Start value of the animation curve
  33633. * @param endValue End value of the animation curve
  33634. * @param gradient Scalar amount to interpolate
  33635. * @returns Interpolated Color3 value
  33636. */
  33637. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33638. /**
  33639. * @hidden Internal use only
  33640. */
  33641. _getKeyValue(value: any): any;
  33642. /**
  33643. * @hidden Internal use only
  33644. */
  33645. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33646. /**
  33647. * Defines the function to use to interpolate matrices
  33648. * @param startValue defines the start matrix
  33649. * @param endValue defines the end matrix
  33650. * @param gradient defines the gradient between both matrices
  33651. * @param result defines an optional target matrix where to store the interpolation
  33652. * @returns the interpolated matrix
  33653. */
  33654. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33655. /**
  33656. * Makes a copy of the animation
  33657. * @returns Cloned animation
  33658. */
  33659. clone(): Animation;
  33660. /**
  33661. * Sets the key frames of the animation
  33662. * @param values The animation key frames to set
  33663. */
  33664. setKeys(values: Array<IAnimationKey>): void;
  33665. /**
  33666. * Serializes the animation to an object
  33667. * @returns Serialized object
  33668. */
  33669. serialize(): any;
  33670. /**
  33671. * Float animation type
  33672. */
  33673. static readonly ANIMATIONTYPE_FLOAT: number;
  33674. /**
  33675. * Vector3 animation type
  33676. */
  33677. static readonly ANIMATIONTYPE_VECTOR3: number;
  33678. /**
  33679. * Quaternion animation type
  33680. */
  33681. static readonly ANIMATIONTYPE_QUATERNION: number;
  33682. /**
  33683. * Matrix animation type
  33684. */
  33685. static readonly ANIMATIONTYPE_MATRIX: number;
  33686. /**
  33687. * Color3 animation type
  33688. */
  33689. static readonly ANIMATIONTYPE_COLOR3: number;
  33690. /**
  33691. * Color3 animation type
  33692. */
  33693. static readonly ANIMATIONTYPE_COLOR4: number;
  33694. /**
  33695. * Vector2 animation type
  33696. */
  33697. static readonly ANIMATIONTYPE_VECTOR2: number;
  33698. /**
  33699. * Size animation type
  33700. */
  33701. static readonly ANIMATIONTYPE_SIZE: number;
  33702. /**
  33703. * Relative Loop Mode
  33704. */
  33705. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33706. /**
  33707. * Cycle Loop Mode
  33708. */
  33709. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33710. /**
  33711. * Constant Loop Mode
  33712. */
  33713. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33714. /** @hidden */
  33715. static _UniversalLerp(left: any, right: any, amount: number): any;
  33716. /**
  33717. * Parses an animation object and creates an animation
  33718. * @param parsedAnimation Parsed animation object
  33719. * @returns Animation object
  33720. */
  33721. static Parse(parsedAnimation: any): Animation;
  33722. /**
  33723. * Appends the serialized animations from the source animations
  33724. * @param source Source containing the animations
  33725. * @param destination Target to store the animations
  33726. */
  33727. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33728. /**
  33729. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33730. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33731. * @param url defines the url to load from
  33732. * @returns a promise that will resolve to the new animation or an array of animations
  33733. */
  33734. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33735. /**
  33736. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33737. * @param snippetId defines the snippet to load
  33738. * @returns a promise that will resolve to the new animation or a new array of animations
  33739. */
  33740. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33741. }
  33742. }
  33743. declare module BABYLON {
  33744. /**
  33745. * Interface containing an array of animations
  33746. */
  33747. export interface IAnimatable {
  33748. /**
  33749. * Array of animations
  33750. */
  33751. animations: Nullable<Array<Animation>>;
  33752. }
  33753. }
  33754. declare module BABYLON {
  33755. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33756. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33758. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33759. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33760. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33761. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33762. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33763. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33764. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33765. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33766. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33767. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33768. /**
  33769. * Decorator used to define property that can be serialized as reference to a camera
  33770. * @param sourceName defines the name of the property to decorate
  33771. */
  33772. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33773. /**
  33774. * Class used to help serialization objects
  33775. */
  33776. export class SerializationHelper {
  33777. /** @hidden */
  33778. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33779. /** @hidden */
  33780. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33781. /** @hidden */
  33782. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33783. /** @hidden */
  33784. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33785. /**
  33786. * Appends the serialized animations from the source animations
  33787. * @param source Source containing the animations
  33788. * @param destination Target to store the animations
  33789. */
  33790. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33791. /**
  33792. * Static function used to serialized a specific entity
  33793. * @param entity defines the entity to serialize
  33794. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33795. * @returns a JSON compatible object representing the serialization of the entity
  33796. */
  33797. static Serialize<T>(entity: T, serializationObject?: any): any;
  33798. /**
  33799. * Creates a new entity from a serialization data object
  33800. * @param creationFunction defines a function used to instanciated the new entity
  33801. * @param source defines the source serialization data
  33802. * @param scene defines the hosting scene
  33803. * @param rootUrl defines the root url for resources
  33804. * @returns a new entity
  33805. */
  33806. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33807. /**
  33808. * Clones an object
  33809. * @param creationFunction defines the function used to instanciate the new object
  33810. * @param source defines the source object
  33811. * @returns the cloned object
  33812. */
  33813. static Clone<T>(creationFunction: () => T, source: T): T;
  33814. /**
  33815. * Instanciates a new object based on a source one (some data will be shared between both object)
  33816. * @param creationFunction defines the function used to instanciate the new object
  33817. * @param source defines the source object
  33818. * @returns the new object
  33819. */
  33820. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33821. }
  33822. }
  33823. declare module BABYLON {
  33824. /**
  33825. * Base class of all the textures in babylon.
  33826. * It groups all the common properties the materials, post process, lights... might need
  33827. * in order to make a correct use of the texture.
  33828. */
  33829. export class BaseTexture implements IAnimatable {
  33830. /**
  33831. * Default anisotropic filtering level for the application.
  33832. * It is set to 4 as a good tradeoff between perf and quality.
  33833. */
  33834. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33835. /**
  33836. * Gets or sets the unique id of the texture
  33837. */
  33838. uniqueId: number;
  33839. /**
  33840. * Define the name of the texture.
  33841. */
  33842. name: string;
  33843. /**
  33844. * Gets or sets an object used to store user defined information.
  33845. */
  33846. metadata: any;
  33847. /**
  33848. * For internal use only. Please do not use.
  33849. */
  33850. reservedDataStore: any;
  33851. private _hasAlpha;
  33852. /**
  33853. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33854. */
  33855. set hasAlpha(value: boolean);
  33856. get hasAlpha(): boolean;
  33857. /**
  33858. * Defines if the alpha value should be determined via the rgb values.
  33859. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33860. */
  33861. getAlphaFromRGB: boolean;
  33862. /**
  33863. * Intensity or strength of the texture.
  33864. * It is commonly used by materials to fine tune the intensity of the texture
  33865. */
  33866. level: number;
  33867. /**
  33868. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33869. * This is part of the texture as textures usually maps to one uv set.
  33870. */
  33871. coordinatesIndex: number;
  33872. protected _coordinatesMode: number;
  33873. /**
  33874. * How a texture is mapped.
  33875. *
  33876. * | Value | Type | Description |
  33877. * | ----- | ----------------------------------- | ----------- |
  33878. * | 0 | EXPLICIT_MODE | |
  33879. * | 1 | SPHERICAL_MODE | |
  33880. * | 2 | PLANAR_MODE | |
  33881. * | 3 | CUBIC_MODE | |
  33882. * | 4 | PROJECTION_MODE | |
  33883. * | 5 | SKYBOX_MODE | |
  33884. * | 6 | INVCUBIC_MODE | |
  33885. * | 7 | EQUIRECTANGULAR_MODE | |
  33886. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33887. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33888. */
  33889. set coordinatesMode(value: number);
  33890. get coordinatesMode(): number;
  33891. private _wrapU;
  33892. /**
  33893. * | Value | Type | Description |
  33894. * | ----- | ------------------ | ----------- |
  33895. * | 0 | CLAMP_ADDRESSMODE | |
  33896. * | 1 | WRAP_ADDRESSMODE | |
  33897. * | 2 | MIRROR_ADDRESSMODE | |
  33898. */
  33899. get wrapU(): number;
  33900. set wrapU(value: number);
  33901. private _wrapV;
  33902. /**
  33903. * | Value | Type | Description |
  33904. * | ----- | ------------------ | ----------- |
  33905. * | 0 | CLAMP_ADDRESSMODE | |
  33906. * | 1 | WRAP_ADDRESSMODE | |
  33907. * | 2 | MIRROR_ADDRESSMODE | |
  33908. */
  33909. get wrapV(): number;
  33910. set wrapV(value: number);
  33911. /**
  33912. * | Value | Type | Description |
  33913. * | ----- | ------------------ | ----------- |
  33914. * | 0 | CLAMP_ADDRESSMODE | |
  33915. * | 1 | WRAP_ADDRESSMODE | |
  33916. * | 2 | MIRROR_ADDRESSMODE | |
  33917. */
  33918. wrapR: number;
  33919. /**
  33920. * With compliant hardware and browser (supporting anisotropic filtering)
  33921. * this defines the level of anisotropic filtering in the texture.
  33922. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33923. */
  33924. anisotropicFilteringLevel: number;
  33925. /**
  33926. * Define if the texture is a cube texture or if false a 2d texture.
  33927. */
  33928. get isCube(): boolean;
  33929. set isCube(value: boolean);
  33930. /**
  33931. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33932. */
  33933. get is3D(): boolean;
  33934. set is3D(value: boolean);
  33935. /**
  33936. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33937. */
  33938. get is2DArray(): boolean;
  33939. set is2DArray(value: boolean);
  33940. private _gammaSpace;
  33941. /**
  33942. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33943. * HDR texture are usually stored in linear space.
  33944. * This only impacts the PBR and Background materials
  33945. */
  33946. get gammaSpace(): boolean;
  33947. set gammaSpace(gamma: boolean);
  33948. /**
  33949. * Gets or sets whether or not the texture contains RGBD data.
  33950. */
  33951. get isRGBD(): boolean;
  33952. set isRGBD(value: boolean);
  33953. /**
  33954. * Is Z inverted in the texture (useful in a cube texture).
  33955. */
  33956. invertZ: boolean;
  33957. /**
  33958. * Are mip maps generated for this texture or not.
  33959. */
  33960. get noMipmap(): boolean;
  33961. /**
  33962. * @hidden
  33963. */
  33964. lodLevelInAlpha: boolean;
  33965. /**
  33966. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33967. */
  33968. get lodGenerationOffset(): number;
  33969. set lodGenerationOffset(value: number);
  33970. /**
  33971. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33972. */
  33973. get lodGenerationScale(): number;
  33974. set lodGenerationScale(value: number);
  33975. /**
  33976. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33977. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33978. * average roughness values.
  33979. */
  33980. get linearSpecularLOD(): boolean;
  33981. set linearSpecularLOD(value: boolean);
  33982. /**
  33983. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33984. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33985. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33986. */
  33987. get irradianceTexture(): Nullable<BaseTexture>;
  33988. set irradianceTexture(value: Nullable<BaseTexture>);
  33989. /**
  33990. * Define if the texture is a render target.
  33991. */
  33992. isRenderTarget: boolean;
  33993. /**
  33994. * Define the unique id of the texture in the scene.
  33995. */
  33996. get uid(): string;
  33997. /** @hidden */
  33998. _prefiltered: boolean;
  33999. /**
  34000. * Return a string representation of the texture.
  34001. * @returns the texture as a string
  34002. */
  34003. toString(): string;
  34004. /**
  34005. * Get the class name of the texture.
  34006. * @returns "BaseTexture"
  34007. */
  34008. getClassName(): string;
  34009. /**
  34010. * Define the list of animation attached to the texture.
  34011. */
  34012. animations: Animation[];
  34013. /**
  34014. * An event triggered when the texture is disposed.
  34015. */
  34016. onDisposeObservable: Observable<BaseTexture>;
  34017. private _onDisposeObserver;
  34018. /**
  34019. * Callback triggered when the texture has been disposed.
  34020. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34021. */
  34022. set onDispose(callback: () => void);
  34023. /**
  34024. * Define the current state of the loading sequence when in delayed load mode.
  34025. */
  34026. delayLoadState: number;
  34027. protected _scene: Nullable<Scene>;
  34028. protected _engine: Nullable<ThinEngine>;
  34029. /** @hidden */
  34030. _texture: Nullable<InternalTexture>;
  34031. private _uid;
  34032. /**
  34033. * Define if the texture is preventinga material to render or not.
  34034. * If not and the texture is not ready, the engine will use a default black texture instead.
  34035. */
  34036. get isBlocking(): boolean;
  34037. /**
  34038. * Instantiates a new BaseTexture.
  34039. * Base class of all the textures in babylon.
  34040. * It groups all the common properties the materials, post process, lights... might need
  34041. * in order to make a correct use of the texture.
  34042. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34043. */
  34044. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34045. /**
  34046. * Get the scene the texture belongs to.
  34047. * @returns the scene or null if undefined
  34048. */
  34049. getScene(): Nullable<Scene>;
  34050. /** @hidden */
  34051. protected _getEngine(): Nullable<ThinEngine>;
  34052. /**
  34053. * Get the texture transform matrix used to offset tile the texture for istance.
  34054. * @returns the transformation matrix
  34055. */
  34056. getTextureMatrix(): Matrix;
  34057. /**
  34058. * Get the texture reflection matrix used to rotate/transform the reflection.
  34059. * @returns the reflection matrix
  34060. */
  34061. getReflectionTextureMatrix(): Matrix;
  34062. /**
  34063. * Get the underlying lower level texture from Babylon.
  34064. * @returns the insternal texture
  34065. */
  34066. getInternalTexture(): Nullable<InternalTexture>;
  34067. /**
  34068. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34069. * @returns true if ready or not blocking
  34070. */
  34071. isReadyOrNotBlocking(): boolean;
  34072. /**
  34073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34074. * @returns true if fully ready
  34075. */
  34076. isReady(): boolean;
  34077. private _cachedSize;
  34078. /**
  34079. * Get the size of the texture.
  34080. * @returns the texture size.
  34081. */
  34082. getSize(): ISize;
  34083. /**
  34084. * Get the base size of the texture.
  34085. * It can be different from the size if the texture has been resized for POT for instance
  34086. * @returns the base size
  34087. */
  34088. getBaseSize(): ISize;
  34089. /**
  34090. * Update the sampling mode of the texture.
  34091. * Default is Trilinear mode.
  34092. *
  34093. * | Value | Type | Description |
  34094. * | ----- | ------------------ | ----------- |
  34095. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34096. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34097. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34098. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34099. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34100. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34101. * | 7 | NEAREST_LINEAR | |
  34102. * | 8 | NEAREST_NEAREST | |
  34103. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34104. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34105. * | 11 | LINEAR_LINEAR | |
  34106. * | 12 | LINEAR_NEAREST | |
  34107. *
  34108. * > _mag_: magnification filter (close to the viewer)
  34109. * > _min_: minification filter (far from the viewer)
  34110. * > _mip_: filter used between mip map levels
  34111. *@param samplingMode Define the new sampling mode of the texture
  34112. */
  34113. updateSamplingMode(samplingMode: number): void;
  34114. /**
  34115. * Scales the texture if is `canRescale()`
  34116. * @param ratio the resize factor we want to use to rescale
  34117. */
  34118. scale(ratio: number): void;
  34119. /**
  34120. * Get if the texture can rescale.
  34121. */
  34122. get canRescale(): boolean;
  34123. /** @hidden */
  34124. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34125. /** @hidden */
  34126. _rebuild(): void;
  34127. /**
  34128. * Triggers the load sequence in delayed load mode.
  34129. */
  34130. delayLoad(): void;
  34131. /**
  34132. * Clones the texture.
  34133. * @returns the cloned texture
  34134. */
  34135. clone(): Nullable<BaseTexture>;
  34136. /**
  34137. * Get the texture underlying type (INT, FLOAT...)
  34138. */
  34139. get textureType(): number;
  34140. /**
  34141. * Get the texture underlying format (RGB, RGBA...)
  34142. */
  34143. get textureFormat(): number;
  34144. /**
  34145. * Indicates that textures need to be re-calculated for all materials
  34146. */
  34147. protected _markAllSubMeshesAsTexturesDirty(): void;
  34148. /**
  34149. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34150. * This will returns an RGBA array buffer containing either in values (0-255) or
  34151. * float values (0-1) depending of the underlying buffer type.
  34152. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34153. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34154. * @param buffer defines a user defined buffer to fill with data (can be null)
  34155. * @returns The Array buffer containing the pixels data.
  34156. */
  34157. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34158. /**
  34159. * Release and destroy the underlying lower level texture aka internalTexture.
  34160. */
  34161. releaseInternalTexture(): void;
  34162. /** @hidden */
  34163. get _lodTextureHigh(): Nullable<BaseTexture>;
  34164. /** @hidden */
  34165. get _lodTextureMid(): Nullable<BaseTexture>;
  34166. /** @hidden */
  34167. get _lodTextureLow(): Nullable<BaseTexture>;
  34168. /**
  34169. * Dispose the texture and release its associated resources.
  34170. */
  34171. dispose(): void;
  34172. /**
  34173. * Serialize the texture into a JSON representation that can be parsed later on.
  34174. * @returns the JSON representation of the texture
  34175. */
  34176. serialize(): any;
  34177. /**
  34178. * Helper function to be called back once a list of texture contains only ready textures.
  34179. * @param textures Define the list of textures to wait for
  34180. * @param callback Define the callback triggered once the entire list will be ready
  34181. */
  34182. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34183. private static _isScene;
  34184. }
  34185. }
  34186. declare module BABYLON {
  34187. /**
  34188. * Options to be used when creating an effect.
  34189. */
  34190. export interface IEffectCreationOptions {
  34191. /**
  34192. * Atrributes that will be used in the shader.
  34193. */
  34194. attributes: string[];
  34195. /**
  34196. * Uniform varible names that will be set in the shader.
  34197. */
  34198. uniformsNames: string[];
  34199. /**
  34200. * Uniform buffer variable names that will be set in the shader.
  34201. */
  34202. uniformBuffersNames: string[];
  34203. /**
  34204. * Sampler texture variable names that will be set in the shader.
  34205. */
  34206. samplers: string[];
  34207. /**
  34208. * Define statements that will be set in the shader.
  34209. */
  34210. defines: any;
  34211. /**
  34212. * Possible fallbacks for this effect to improve performance when needed.
  34213. */
  34214. fallbacks: Nullable<IEffectFallbacks>;
  34215. /**
  34216. * Callback that will be called when the shader is compiled.
  34217. */
  34218. onCompiled: Nullable<(effect: Effect) => void>;
  34219. /**
  34220. * Callback that will be called if an error occurs during shader compilation.
  34221. */
  34222. onError: Nullable<(effect: Effect, errors: string) => void>;
  34223. /**
  34224. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34225. */
  34226. indexParameters?: any;
  34227. /**
  34228. * Max number of lights that can be used in the shader.
  34229. */
  34230. maxSimultaneousLights?: number;
  34231. /**
  34232. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34233. */
  34234. transformFeedbackVaryings?: Nullable<string[]>;
  34235. /**
  34236. * 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
  34237. */
  34238. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34239. /**
  34240. * Is this effect rendering to several color attachments ?
  34241. */
  34242. multiTarget?: boolean;
  34243. }
  34244. /**
  34245. * Effect containing vertex and fragment shader that can be executed on an object.
  34246. */
  34247. export class Effect implements IDisposable {
  34248. /**
  34249. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34250. */
  34251. static ShadersRepository: string;
  34252. /**
  34253. * Enable logging of the shader code when a compilation error occurs
  34254. */
  34255. static LogShaderCodeOnCompilationError: boolean;
  34256. /**
  34257. * Name of the effect.
  34258. */
  34259. name: any;
  34260. /**
  34261. * String container all the define statements that should be set on the shader.
  34262. */
  34263. defines: string;
  34264. /**
  34265. * Callback that will be called when the shader is compiled.
  34266. */
  34267. onCompiled: Nullable<(effect: Effect) => void>;
  34268. /**
  34269. * Callback that will be called if an error occurs during shader compilation.
  34270. */
  34271. onError: Nullable<(effect: Effect, errors: string) => void>;
  34272. /**
  34273. * Callback that will be called when effect is bound.
  34274. */
  34275. onBind: Nullable<(effect: Effect) => void>;
  34276. /**
  34277. * Unique ID of the effect.
  34278. */
  34279. uniqueId: number;
  34280. /**
  34281. * Observable that will be called when the shader is compiled.
  34282. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34283. */
  34284. onCompileObservable: Observable<Effect>;
  34285. /**
  34286. * Observable that will be called if an error occurs during shader compilation.
  34287. */
  34288. onErrorObservable: Observable<Effect>;
  34289. /** @hidden */
  34290. _onBindObservable: Nullable<Observable<Effect>>;
  34291. /**
  34292. * @hidden
  34293. * Specifies if the effect was previously ready
  34294. */
  34295. _wasPreviouslyReady: boolean;
  34296. /**
  34297. * Observable that will be called when effect is bound.
  34298. */
  34299. get onBindObservable(): Observable<Effect>;
  34300. /** @hidden */
  34301. _bonesComputationForcedToCPU: boolean;
  34302. /** @hidden */
  34303. _multiTarget: boolean;
  34304. private static _uniqueIdSeed;
  34305. private _engine;
  34306. private _uniformBuffersNames;
  34307. private _uniformBuffersNamesList;
  34308. private _uniformsNames;
  34309. private _samplerList;
  34310. private _samplers;
  34311. private _isReady;
  34312. private _compilationError;
  34313. private _allFallbacksProcessed;
  34314. private _attributesNames;
  34315. private _attributes;
  34316. private _attributeLocationByName;
  34317. private _uniforms;
  34318. /**
  34319. * Key for the effect.
  34320. * @hidden
  34321. */
  34322. _key: string;
  34323. private _indexParameters;
  34324. private _fallbacks;
  34325. private _vertexSourceCode;
  34326. private _fragmentSourceCode;
  34327. private _vertexSourceCodeOverride;
  34328. private _fragmentSourceCodeOverride;
  34329. private _transformFeedbackVaryings;
  34330. /**
  34331. * Compiled shader to webGL program.
  34332. * @hidden
  34333. */
  34334. _pipelineContext: Nullable<IPipelineContext>;
  34335. private _valueCache;
  34336. private static _baseCache;
  34337. /**
  34338. * Instantiates an effect.
  34339. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34340. * @param baseName Name of the effect.
  34341. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34342. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34343. * @param samplers List of sampler variables that will be passed to the shader.
  34344. * @param engine Engine to be used to render the effect
  34345. * @param defines Define statements to be added to the shader.
  34346. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34347. * @param onCompiled Callback that will be called when the shader is compiled.
  34348. * @param onError Callback that will be called if an error occurs during shader compilation.
  34349. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34350. */
  34351. 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);
  34352. private _useFinalCode;
  34353. /**
  34354. * Unique key for this effect
  34355. */
  34356. get key(): string;
  34357. /**
  34358. * If the effect has been compiled and prepared.
  34359. * @returns if the effect is compiled and prepared.
  34360. */
  34361. isReady(): boolean;
  34362. private _isReadyInternal;
  34363. /**
  34364. * The engine the effect was initialized with.
  34365. * @returns the engine.
  34366. */
  34367. getEngine(): Engine;
  34368. /**
  34369. * The pipeline context for this effect
  34370. * @returns the associated pipeline context
  34371. */
  34372. getPipelineContext(): Nullable<IPipelineContext>;
  34373. /**
  34374. * The set of names of attribute variables for the shader.
  34375. * @returns An array of attribute names.
  34376. */
  34377. getAttributesNames(): string[];
  34378. /**
  34379. * Returns the attribute at the given index.
  34380. * @param index The index of the attribute.
  34381. * @returns The location of the attribute.
  34382. */
  34383. getAttributeLocation(index: number): number;
  34384. /**
  34385. * Returns the attribute based on the name of the variable.
  34386. * @param name of the attribute to look up.
  34387. * @returns the attribute location.
  34388. */
  34389. getAttributeLocationByName(name: string): number;
  34390. /**
  34391. * The number of attributes.
  34392. * @returns the numnber of attributes.
  34393. */
  34394. getAttributesCount(): number;
  34395. /**
  34396. * Gets the index of a uniform variable.
  34397. * @param uniformName of the uniform to look up.
  34398. * @returns the index.
  34399. */
  34400. getUniformIndex(uniformName: string): number;
  34401. /**
  34402. * Returns the attribute based on the name of the variable.
  34403. * @param uniformName of the uniform to look up.
  34404. * @returns the location of the uniform.
  34405. */
  34406. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34407. /**
  34408. * Returns an array of sampler variable names
  34409. * @returns The array of sampler variable names.
  34410. */
  34411. getSamplers(): string[];
  34412. /**
  34413. * Returns an array of uniform variable names
  34414. * @returns The array of uniform variable names.
  34415. */
  34416. getUniformNames(): string[];
  34417. /**
  34418. * Returns an array of uniform buffer variable names
  34419. * @returns The array of uniform buffer variable names.
  34420. */
  34421. getUniformBuffersNames(): string[];
  34422. /**
  34423. * Returns the index parameters used to create the effect
  34424. * @returns The index parameters object
  34425. */
  34426. getIndexParameters(): any;
  34427. /**
  34428. * The error from the last compilation.
  34429. * @returns the error string.
  34430. */
  34431. getCompilationError(): string;
  34432. /**
  34433. * Gets a boolean indicating that all fallbacks were used during compilation
  34434. * @returns true if all fallbacks were used
  34435. */
  34436. allFallbacksProcessed(): boolean;
  34437. /**
  34438. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34439. * @param func The callback to be used.
  34440. */
  34441. executeWhenCompiled(func: (effect: Effect) => void): void;
  34442. private _checkIsReady;
  34443. private _loadShader;
  34444. /**
  34445. * Gets the vertex shader source code of this effect
  34446. */
  34447. get vertexSourceCode(): string;
  34448. /**
  34449. * Gets the fragment shader source code of this effect
  34450. */
  34451. get fragmentSourceCode(): string;
  34452. /**
  34453. * Recompiles the webGL program
  34454. * @param vertexSourceCode The source code for the vertex shader.
  34455. * @param fragmentSourceCode The source code for the fragment shader.
  34456. * @param onCompiled Callback called when completed.
  34457. * @param onError Callback called on error.
  34458. * @hidden
  34459. */
  34460. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34461. /**
  34462. * Prepares the effect
  34463. * @hidden
  34464. */
  34465. _prepareEffect(): void;
  34466. private _getShaderCodeAndErrorLine;
  34467. private _processCompilationErrors;
  34468. /**
  34469. * Checks if the effect is supported. (Must be called after compilation)
  34470. */
  34471. get isSupported(): boolean;
  34472. /**
  34473. * Binds a texture to the engine to be used as output of the shader.
  34474. * @param channel Name of the output variable.
  34475. * @param texture Texture to bind.
  34476. * @hidden
  34477. */
  34478. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34479. /**
  34480. * Sets a texture on the engine to be used in the shader.
  34481. * @param channel Name of the sampler variable.
  34482. * @param texture Texture to set.
  34483. */
  34484. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34485. /**
  34486. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34487. * @param channel Name of the sampler variable.
  34488. * @param texture Texture to set.
  34489. */
  34490. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34491. /**
  34492. * Sets an array of textures on the engine to be used in the shader.
  34493. * @param channel Name of the variable.
  34494. * @param textures Textures to set.
  34495. */
  34496. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34497. /**
  34498. * 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)
  34499. * @param channel Name of the sampler variable.
  34500. * @param postProcess Post process to get the input texture from.
  34501. */
  34502. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34503. /**
  34504. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34505. * 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)
  34506. * @param channel Name of the sampler variable.
  34507. * @param postProcess Post process to get the output texture from.
  34508. */
  34509. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34510. /** @hidden */
  34511. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34512. /** @hidden */
  34513. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34514. /** @hidden */
  34515. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34516. /** @hidden */
  34517. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34518. /**
  34519. * Binds a buffer to a uniform.
  34520. * @param buffer Buffer to bind.
  34521. * @param name Name of the uniform variable to bind to.
  34522. */
  34523. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34524. /**
  34525. * Binds block to a uniform.
  34526. * @param blockName Name of the block to bind.
  34527. * @param index Index to bind.
  34528. */
  34529. bindUniformBlock(blockName: string, index: number): void;
  34530. /**
  34531. * Sets an interger value on a uniform variable.
  34532. * @param uniformName Name of the variable.
  34533. * @param value Value to be set.
  34534. * @returns this effect.
  34535. */
  34536. setInt(uniformName: string, value: number): Effect;
  34537. /**
  34538. * Sets an int array on a uniform variable.
  34539. * @param uniformName Name of the variable.
  34540. * @param array array to be set.
  34541. * @returns this effect.
  34542. */
  34543. setIntArray(uniformName: string, array: Int32Array): Effect;
  34544. /**
  34545. * 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)
  34546. * @param uniformName Name of the variable.
  34547. * @param array array to be set.
  34548. * @returns this effect.
  34549. */
  34550. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34551. /**
  34552. * 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)
  34553. * @param uniformName Name of the variable.
  34554. * @param array array to be set.
  34555. * @returns this effect.
  34556. */
  34557. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34558. /**
  34559. * 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)
  34560. * @param uniformName Name of the variable.
  34561. * @param array array to be set.
  34562. * @returns this effect.
  34563. */
  34564. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34565. /**
  34566. * Sets an float array on a uniform variable.
  34567. * @param uniformName Name of the variable.
  34568. * @param array array to be set.
  34569. * @returns this effect.
  34570. */
  34571. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34572. /**
  34573. * 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)
  34574. * @param uniformName Name of the variable.
  34575. * @param array array to be set.
  34576. * @returns this effect.
  34577. */
  34578. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34579. /**
  34580. * 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)
  34581. * @param uniformName Name of the variable.
  34582. * @param array array to be set.
  34583. * @returns this effect.
  34584. */
  34585. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34586. /**
  34587. * 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)
  34588. * @param uniformName Name of the variable.
  34589. * @param array array to be set.
  34590. * @returns this effect.
  34591. */
  34592. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34593. /**
  34594. * Sets an array on a uniform variable.
  34595. * @param uniformName Name of the variable.
  34596. * @param array array to be set.
  34597. * @returns this effect.
  34598. */
  34599. setArray(uniformName: string, array: number[]): Effect;
  34600. /**
  34601. * 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)
  34602. * @param uniformName Name of the variable.
  34603. * @param array array to be set.
  34604. * @returns this effect.
  34605. */
  34606. setArray2(uniformName: string, array: number[]): Effect;
  34607. /**
  34608. * 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)
  34609. * @param uniformName Name of the variable.
  34610. * @param array array to be set.
  34611. * @returns this effect.
  34612. */
  34613. setArray3(uniformName: string, array: number[]): Effect;
  34614. /**
  34615. * 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)
  34616. * @param uniformName Name of the variable.
  34617. * @param array array to be set.
  34618. * @returns this effect.
  34619. */
  34620. setArray4(uniformName: string, array: number[]): Effect;
  34621. /**
  34622. * Sets matrices on a uniform variable.
  34623. * @param uniformName Name of the variable.
  34624. * @param matrices matrices to be set.
  34625. * @returns this effect.
  34626. */
  34627. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34628. /**
  34629. * Sets matrix on a uniform variable.
  34630. * @param uniformName Name of the variable.
  34631. * @param matrix matrix to be set.
  34632. * @returns this effect.
  34633. */
  34634. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34635. /**
  34636. * 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)
  34637. * @param uniformName Name of the variable.
  34638. * @param matrix matrix to be set.
  34639. * @returns this effect.
  34640. */
  34641. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34642. /**
  34643. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34644. * @param uniformName Name of the variable.
  34645. * @param matrix matrix to be set.
  34646. * @returns this effect.
  34647. */
  34648. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34649. /**
  34650. * Sets a float on a uniform variable.
  34651. * @param uniformName Name of the variable.
  34652. * @param value value to be set.
  34653. * @returns this effect.
  34654. */
  34655. setFloat(uniformName: string, value: number): Effect;
  34656. /**
  34657. * Sets a boolean on a uniform variable.
  34658. * @param uniformName Name of the variable.
  34659. * @param bool value to be set.
  34660. * @returns this effect.
  34661. */
  34662. setBool(uniformName: string, bool: boolean): Effect;
  34663. /**
  34664. * Sets a Vector2 on a uniform variable.
  34665. * @param uniformName Name of the variable.
  34666. * @param vector2 vector2 to be set.
  34667. * @returns this effect.
  34668. */
  34669. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34670. /**
  34671. * Sets a float2 on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param x First float in float2.
  34674. * @param y Second float in float2.
  34675. * @returns this effect.
  34676. */
  34677. setFloat2(uniformName: string, x: number, y: number): Effect;
  34678. /**
  34679. * Sets a Vector3 on a uniform variable.
  34680. * @param uniformName Name of the variable.
  34681. * @param vector3 Value to be set.
  34682. * @returns this effect.
  34683. */
  34684. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34685. /**
  34686. * Sets a float3 on a uniform variable.
  34687. * @param uniformName Name of the variable.
  34688. * @param x First float in float3.
  34689. * @param y Second float in float3.
  34690. * @param z Third float in float3.
  34691. * @returns this effect.
  34692. */
  34693. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34694. /**
  34695. * Sets a Vector4 on a uniform variable.
  34696. * @param uniformName Name of the variable.
  34697. * @param vector4 Value to be set.
  34698. * @returns this effect.
  34699. */
  34700. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34701. /**
  34702. * Sets a float4 on a uniform variable.
  34703. * @param uniformName Name of the variable.
  34704. * @param x First float in float4.
  34705. * @param y Second float in float4.
  34706. * @param z Third float in float4.
  34707. * @param w Fourth float in float4.
  34708. * @returns this effect.
  34709. */
  34710. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34711. /**
  34712. * Sets a Color3 on a uniform variable.
  34713. * @param uniformName Name of the variable.
  34714. * @param color3 Value to be set.
  34715. * @returns this effect.
  34716. */
  34717. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34718. /**
  34719. * Sets a Color4 on a uniform variable.
  34720. * @param uniformName Name of the variable.
  34721. * @param color3 Value to be set.
  34722. * @param alpha Alpha value to be set.
  34723. * @returns this effect.
  34724. */
  34725. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34726. /**
  34727. * Sets a Color4 on a uniform variable
  34728. * @param uniformName defines the name of the variable
  34729. * @param color4 defines the value to be set
  34730. * @returns this effect.
  34731. */
  34732. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34733. /** Release all associated resources */
  34734. dispose(): void;
  34735. /**
  34736. * This function will add a new shader to the shader store
  34737. * @param name the name of the shader
  34738. * @param pixelShader optional pixel shader content
  34739. * @param vertexShader optional vertex shader content
  34740. */
  34741. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34742. /**
  34743. * Store of each shader (The can be looked up using effect.key)
  34744. */
  34745. static ShadersStore: {
  34746. [key: string]: string;
  34747. };
  34748. /**
  34749. * Store of each included file for a shader (The can be looked up using effect.key)
  34750. */
  34751. static IncludesShadersStore: {
  34752. [key: string]: string;
  34753. };
  34754. /**
  34755. * Resets the cache of effects.
  34756. */
  34757. static ResetCache(): void;
  34758. }
  34759. }
  34760. declare module BABYLON {
  34761. /**
  34762. * Interface used to describe the capabilities of the engine relatively to the current browser
  34763. */
  34764. export interface EngineCapabilities {
  34765. /** Maximum textures units per fragment shader */
  34766. maxTexturesImageUnits: number;
  34767. /** Maximum texture units per vertex shader */
  34768. maxVertexTextureImageUnits: number;
  34769. /** Maximum textures units in the entire pipeline */
  34770. maxCombinedTexturesImageUnits: number;
  34771. /** Maximum texture size */
  34772. maxTextureSize: number;
  34773. /** Maximum texture samples */
  34774. maxSamples?: number;
  34775. /** Maximum cube texture size */
  34776. maxCubemapTextureSize: number;
  34777. /** Maximum render texture size */
  34778. maxRenderTextureSize: number;
  34779. /** Maximum number of vertex attributes */
  34780. maxVertexAttribs: number;
  34781. /** Maximum number of varyings */
  34782. maxVaryingVectors: number;
  34783. /** Maximum number of uniforms per vertex shader */
  34784. maxVertexUniformVectors: number;
  34785. /** Maximum number of uniforms per fragment shader */
  34786. maxFragmentUniformVectors: number;
  34787. /** Defines if standard derivates (dx/dy) are supported */
  34788. standardDerivatives: boolean;
  34789. /** Defines if s3tc texture compression is supported */
  34790. s3tc?: WEBGL_compressed_texture_s3tc;
  34791. /** Defines if pvrtc texture compression is supported */
  34792. pvrtc: any;
  34793. /** Defines if etc1 texture compression is supported */
  34794. etc1: any;
  34795. /** Defines if etc2 texture compression is supported */
  34796. etc2: any;
  34797. /** Defines if astc texture compression is supported */
  34798. astc: any;
  34799. /** Defines if bptc texture compression is supported */
  34800. bptc: any;
  34801. /** Defines if float textures are supported */
  34802. textureFloat: boolean;
  34803. /** Defines if vertex array objects are supported */
  34804. vertexArrayObject: boolean;
  34805. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34806. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34807. /** Gets the maximum level of anisotropy supported */
  34808. maxAnisotropy: number;
  34809. /** Defines if instancing is supported */
  34810. instancedArrays: boolean;
  34811. /** Defines if 32 bits indices are supported */
  34812. uintIndices: boolean;
  34813. /** Defines if high precision shaders are supported */
  34814. highPrecisionShaderSupported: boolean;
  34815. /** Defines if depth reading in the fragment shader is supported */
  34816. fragmentDepthSupported: boolean;
  34817. /** Defines if float texture linear filtering is supported*/
  34818. textureFloatLinearFiltering: boolean;
  34819. /** Defines if rendering to float textures is supported */
  34820. textureFloatRender: boolean;
  34821. /** Defines if half float textures are supported*/
  34822. textureHalfFloat: boolean;
  34823. /** Defines if half float texture linear filtering is supported*/
  34824. textureHalfFloatLinearFiltering: boolean;
  34825. /** Defines if rendering to half float textures is supported */
  34826. textureHalfFloatRender: boolean;
  34827. /** Defines if textureLOD shader command is supported */
  34828. textureLOD: boolean;
  34829. /** Defines if draw buffers extension is supported */
  34830. drawBuffersExtension: boolean;
  34831. /** Defines if depth textures are supported */
  34832. depthTextureExtension: boolean;
  34833. /** Defines if float color buffer are supported */
  34834. colorBufferFloat: boolean;
  34835. /** Gets disjoint timer query extension (null if not supported) */
  34836. timerQuery?: EXT_disjoint_timer_query;
  34837. /** Defines if timestamp can be used with timer query */
  34838. canUseTimestampForTimerQuery: boolean;
  34839. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34840. multiview?: any;
  34841. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34842. oculusMultiview?: any;
  34843. /** Function used to let the system compiles shaders in background */
  34844. parallelShaderCompile?: {
  34845. COMPLETION_STATUS_KHR: number;
  34846. };
  34847. /** Max number of texture samples for MSAA */
  34848. maxMSAASamples: number;
  34849. /** Defines if the blend min max extension is supported */
  34850. blendMinMax: boolean;
  34851. }
  34852. }
  34853. declare module BABYLON {
  34854. /**
  34855. * @hidden
  34856. **/
  34857. export class DepthCullingState {
  34858. private _isDepthTestDirty;
  34859. private _isDepthMaskDirty;
  34860. private _isDepthFuncDirty;
  34861. private _isCullFaceDirty;
  34862. private _isCullDirty;
  34863. private _isZOffsetDirty;
  34864. private _isFrontFaceDirty;
  34865. private _depthTest;
  34866. private _depthMask;
  34867. private _depthFunc;
  34868. private _cull;
  34869. private _cullFace;
  34870. private _zOffset;
  34871. private _frontFace;
  34872. /**
  34873. * Initializes the state.
  34874. */
  34875. constructor();
  34876. get isDirty(): boolean;
  34877. get zOffset(): number;
  34878. set zOffset(value: number);
  34879. get cullFace(): Nullable<number>;
  34880. set cullFace(value: Nullable<number>);
  34881. get cull(): Nullable<boolean>;
  34882. set cull(value: Nullable<boolean>);
  34883. get depthFunc(): Nullable<number>;
  34884. set depthFunc(value: Nullable<number>);
  34885. get depthMask(): boolean;
  34886. set depthMask(value: boolean);
  34887. get depthTest(): boolean;
  34888. set depthTest(value: boolean);
  34889. get frontFace(): Nullable<number>;
  34890. set frontFace(value: Nullable<number>);
  34891. reset(): void;
  34892. apply(gl: WebGLRenderingContext): void;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. /**
  34897. * @hidden
  34898. **/
  34899. export class StencilState {
  34900. /** 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 */
  34901. static readonly ALWAYS: number;
  34902. /** Passed to stencilOperation to specify that stencil value must be kept */
  34903. static readonly KEEP: number;
  34904. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34905. static readonly REPLACE: number;
  34906. private _isStencilTestDirty;
  34907. private _isStencilMaskDirty;
  34908. private _isStencilFuncDirty;
  34909. private _isStencilOpDirty;
  34910. private _stencilTest;
  34911. private _stencilMask;
  34912. private _stencilFunc;
  34913. private _stencilFuncRef;
  34914. private _stencilFuncMask;
  34915. private _stencilOpStencilFail;
  34916. private _stencilOpDepthFail;
  34917. private _stencilOpStencilDepthPass;
  34918. get isDirty(): boolean;
  34919. get stencilFunc(): number;
  34920. set stencilFunc(value: number);
  34921. get stencilFuncRef(): number;
  34922. set stencilFuncRef(value: number);
  34923. get stencilFuncMask(): number;
  34924. set stencilFuncMask(value: number);
  34925. get stencilOpStencilFail(): number;
  34926. set stencilOpStencilFail(value: number);
  34927. get stencilOpDepthFail(): number;
  34928. set stencilOpDepthFail(value: number);
  34929. get stencilOpStencilDepthPass(): number;
  34930. set stencilOpStencilDepthPass(value: number);
  34931. get stencilMask(): number;
  34932. set stencilMask(value: number);
  34933. get stencilTest(): boolean;
  34934. set stencilTest(value: boolean);
  34935. constructor();
  34936. reset(): void;
  34937. apply(gl: WebGLRenderingContext): void;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * @hidden
  34943. **/
  34944. export class AlphaState {
  34945. private _isAlphaBlendDirty;
  34946. private _isBlendFunctionParametersDirty;
  34947. private _isBlendEquationParametersDirty;
  34948. private _isBlendConstantsDirty;
  34949. private _alphaBlend;
  34950. private _blendFunctionParameters;
  34951. private _blendEquationParameters;
  34952. private _blendConstants;
  34953. /**
  34954. * Initializes the state.
  34955. */
  34956. constructor();
  34957. get isDirty(): boolean;
  34958. get alphaBlend(): boolean;
  34959. set alphaBlend(value: boolean);
  34960. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34961. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34962. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34963. reset(): void;
  34964. apply(gl: WebGLRenderingContext): void;
  34965. }
  34966. }
  34967. declare module BABYLON {
  34968. /** @hidden */
  34969. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34970. attributeProcessor(attribute: string): string;
  34971. varyingProcessor(varying: string, isFragment: boolean): string;
  34972. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34973. }
  34974. }
  34975. declare module BABYLON {
  34976. /**
  34977. * Interface for attribute information associated with buffer instanciation
  34978. */
  34979. export interface InstancingAttributeInfo {
  34980. /**
  34981. * Name of the GLSL attribute
  34982. * if attribute index is not specified, this is used to retrieve the index from the effect
  34983. */
  34984. attributeName: string;
  34985. /**
  34986. * Index/offset of the attribute in the vertex shader
  34987. * if not specified, this will be computes from the name.
  34988. */
  34989. index?: number;
  34990. /**
  34991. * size of the attribute, 1, 2, 3 or 4
  34992. */
  34993. attributeSize: number;
  34994. /**
  34995. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34996. */
  34997. offset: number;
  34998. /**
  34999. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35000. * default to 1
  35001. */
  35002. divisor?: number;
  35003. /**
  35004. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35005. * default is FLOAT
  35006. */
  35007. attributeType?: number;
  35008. /**
  35009. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35010. */
  35011. normalized?: boolean;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. interface ThinEngine {
  35016. /**
  35017. * Update a video texture
  35018. * @param texture defines the texture to update
  35019. * @param video defines the video element to use
  35020. * @param invertY defines if data must be stored with Y axis inverted
  35021. */
  35022. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. interface ThinEngine {
  35027. /**
  35028. * Creates a dynamic texture
  35029. * @param width defines the width of the texture
  35030. * @param height defines the height of the texture
  35031. * @param generateMipMaps defines if the engine should generate the mip levels
  35032. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35033. * @returns the dynamic texture inside an InternalTexture
  35034. */
  35035. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35036. /**
  35037. * Update the content of a dynamic texture
  35038. * @param texture defines the texture to update
  35039. * @param canvas defines the canvas containing the source
  35040. * @param invertY defines if data must be stored with Y axis inverted
  35041. * @param premulAlpha defines if alpha is stored as premultiplied
  35042. * @param format defines the format of the data
  35043. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35044. */
  35045. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Settings for finer control over video usage
  35051. */
  35052. export interface VideoTextureSettings {
  35053. /**
  35054. * Applies `autoplay` to video, if specified
  35055. */
  35056. autoPlay?: boolean;
  35057. /**
  35058. * Applies `loop` to video, if specified
  35059. */
  35060. loop?: boolean;
  35061. /**
  35062. * Automatically updates internal texture from video at every frame in the render loop
  35063. */
  35064. autoUpdateTexture: boolean;
  35065. /**
  35066. * Image src displayed during the video loading or until the user interacts with the video.
  35067. */
  35068. poster?: string;
  35069. }
  35070. /**
  35071. * If you want to display a video in your scene, this is the special texture for that.
  35072. * This special texture works similar to other textures, with the exception of a few parameters.
  35073. * @see https://doc.babylonjs.com/how_to/video_texture
  35074. */
  35075. export class VideoTexture extends Texture {
  35076. /**
  35077. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35078. */
  35079. readonly autoUpdateTexture: boolean;
  35080. /**
  35081. * The video instance used by the texture internally
  35082. */
  35083. readonly video: HTMLVideoElement;
  35084. private _onUserActionRequestedObservable;
  35085. /**
  35086. * Event triggerd when a dom action is required by the user to play the video.
  35087. * This happens due to recent changes in browser policies preventing video to auto start.
  35088. */
  35089. get onUserActionRequestedObservable(): Observable<Texture>;
  35090. private _generateMipMaps;
  35091. private _stillImageCaptured;
  35092. private _displayingPosterTexture;
  35093. private _settings;
  35094. private _createInternalTextureOnEvent;
  35095. private _frameId;
  35096. private _currentSrc;
  35097. /**
  35098. * Creates a video texture.
  35099. * If you want to display a video in your scene, this is the special texture for that.
  35100. * This special texture works similar to other textures, with the exception of a few parameters.
  35101. * @see https://doc.babylonjs.com/how_to/video_texture
  35102. * @param name optional name, will detect from video source, if not defined
  35103. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35104. * @param scene is obviously the current scene.
  35105. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35106. * @param invertY is false by default but can be used to invert video on Y axis
  35107. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35108. * @param settings allows finer control over video usage
  35109. */
  35110. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35111. private _getName;
  35112. private _getVideo;
  35113. private _createInternalTexture;
  35114. private reset;
  35115. /**
  35116. * @hidden Internal method to initiate `update`.
  35117. */
  35118. _rebuild(): void;
  35119. /**
  35120. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35121. */
  35122. update(): void;
  35123. /**
  35124. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35125. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35126. */
  35127. updateTexture(isVisible: boolean): void;
  35128. protected _updateInternalTexture: () => void;
  35129. /**
  35130. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35131. * @param url New url.
  35132. */
  35133. updateURL(url: string): void;
  35134. /**
  35135. * Clones the texture.
  35136. * @returns the cloned texture
  35137. */
  35138. clone(): VideoTexture;
  35139. /**
  35140. * Dispose the texture and release its associated resources.
  35141. */
  35142. dispose(): void;
  35143. /**
  35144. * Creates a video texture straight from a stream.
  35145. * @param scene Define the scene the texture should be created in
  35146. * @param stream Define the stream the texture should be created from
  35147. * @returns The created video texture as a promise
  35148. */
  35149. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35150. /**
  35151. * Creates a video texture straight from your WebCam video feed.
  35152. * @param scene Define the scene the texture should be created in
  35153. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35154. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35155. * @returns The created video texture as a promise
  35156. */
  35157. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35158. minWidth: number;
  35159. maxWidth: number;
  35160. minHeight: number;
  35161. maxHeight: number;
  35162. deviceId: string;
  35163. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35164. /**
  35165. * Creates a video texture straight from your WebCam video feed.
  35166. * @param scene Define the scene the texture should be created in
  35167. * @param onReady Define a callback to triggered once the texture will be ready
  35168. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35169. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35170. */
  35171. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35172. minWidth: number;
  35173. maxWidth: number;
  35174. minHeight: number;
  35175. maxHeight: number;
  35176. deviceId: string;
  35177. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35178. }
  35179. }
  35180. declare module BABYLON {
  35181. /**
  35182. * Defines the interface used by objects working like Scene
  35183. * @hidden
  35184. */
  35185. export interface ISceneLike {
  35186. _addPendingData(data: any): void;
  35187. _removePendingData(data: any): void;
  35188. offlineProvider: IOfflineProvider;
  35189. }
  35190. /**
  35191. * Information about the current host
  35192. */
  35193. export interface HostInformation {
  35194. /**
  35195. * Defines if the current host is a mobile
  35196. */
  35197. isMobile: boolean;
  35198. }
  35199. /** Interface defining initialization parameters for Engine class */
  35200. export interface EngineOptions extends WebGLContextAttributes {
  35201. /**
  35202. * Defines if the engine should no exceed a specified device ratio
  35203. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35204. */
  35205. limitDeviceRatio?: number;
  35206. /**
  35207. * Defines if webvr should be enabled automatically
  35208. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35209. */
  35210. autoEnableWebVR?: boolean;
  35211. /**
  35212. * Defines if webgl2 should be turned off even if supported
  35213. * @see https://doc.babylonjs.com/features/webgl2
  35214. */
  35215. disableWebGL2Support?: boolean;
  35216. /**
  35217. * Defines if webaudio should be initialized as well
  35218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35219. */
  35220. audioEngine?: boolean;
  35221. /**
  35222. * Defines if animations should run using a deterministic lock step
  35223. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35224. */
  35225. deterministicLockstep?: boolean;
  35226. /** Defines the maximum steps to use with deterministic lock step mode */
  35227. lockstepMaxSteps?: number;
  35228. /** Defines the seconds between each deterministic lock step */
  35229. timeStep?: number;
  35230. /**
  35231. * Defines that engine should ignore context lost events
  35232. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35233. */
  35234. doNotHandleContextLost?: boolean;
  35235. /**
  35236. * Defines that engine should ignore modifying touch action attribute and style
  35237. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35238. */
  35239. doNotHandleTouchAction?: boolean;
  35240. /**
  35241. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35242. */
  35243. useHighPrecisionFloats?: boolean;
  35244. /**
  35245. * Make the canvas XR Compatible for XR sessions
  35246. */
  35247. xrCompatible?: boolean;
  35248. /**
  35249. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35250. */
  35251. useHighPrecisionMatrix?: boolean;
  35252. }
  35253. /**
  35254. * The base engine class (root of all engines)
  35255. */
  35256. export class ThinEngine {
  35257. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35258. static ExceptionList: ({
  35259. key: string;
  35260. capture: string;
  35261. captureConstraint: number;
  35262. targets: string[];
  35263. } | {
  35264. key: string;
  35265. capture: null;
  35266. captureConstraint: null;
  35267. targets: string[];
  35268. })[];
  35269. /** @hidden */
  35270. static _TextureLoaders: IInternalTextureLoader[];
  35271. /**
  35272. * Returns the current npm package of the sdk
  35273. */
  35274. static get NpmPackage(): string;
  35275. /**
  35276. * Returns the current version of the framework
  35277. */
  35278. static get Version(): string;
  35279. /**
  35280. * Returns a string describing the current engine
  35281. */
  35282. get description(): string;
  35283. /**
  35284. * Gets or sets the epsilon value used by collision engine
  35285. */
  35286. static CollisionsEpsilon: number;
  35287. /**
  35288. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35289. */
  35290. static get ShadersRepository(): string;
  35291. static set ShadersRepository(value: string);
  35292. /** @hidden */
  35293. _shaderProcessor: IShaderProcessor;
  35294. /**
  35295. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35296. */
  35297. forcePOTTextures: boolean;
  35298. /**
  35299. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35300. */
  35301. isFullscreen: boolean;
  35302. /**
  35303. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35304. */
  35305. cullBackFaces: boolean;
  35306. /**
  35307. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35308. */
  35309. renderEvenInBackground: boolean;
  35310. /**
  35311. * Gets or sets a boolean indicating that cache can be kept between frames
  35312. */
  35313. preventCacheWipeBetweenFrames: boolean;
  35314. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35315. validateShaderPrograms: boolean;
  35316. /**
  35317. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35318. * This can provide greater z depth for distant objects.
  35319. */
  35320. useReverseDepthBuffer: boolean;
  35321. /**
  35322. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35323. */
  35324. disableUniformBuffers: boolean;
  35325. /** @hidden */
  35326. _uniformBuffers: UniformBuffer[];
  35327. /**
  35328. * Gets a boolean indicating that the engine supports uniform buffers
  35329. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35330. */
  35331. get supportsUniformBuffers(): boolean;
  35332. /** @hidden */
  35333. _gl: WebGLRenderingContext;
  35334. /** @hidden */
  35335. _webGLVersion: number;
  35336. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35337. protected _windowIsBackground: boolean;
  35338. protected _creationOptions: EngineOptions;
  35339. protected _highPrecisionShadersAllowed: boolean;
  35340. /** @hidden */
  35341. get _shouldUseHighPrecisionShader(): boolean;
  35342. /**
  35343. * Gets a boolean indicating that only power of 2 textures are supported
  35344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35345. */
  35346. get needPOTTextures(): boolean;
  35347. /** @hidden */
  35348. _badOS: boolean;
  35349. /** @hidden */
  35350. _badDesktopOS: boolean;
  35351. private _hardwareScalingLevel;
  35352. /** @hidden */
  35353. _caps: EngineCapabilities;
  35354. private _isStencilEnable;
  35355. private _glVersion;
  35356. private _glRenderer;
  35357. private _glVendor;
  35358. /** @hidden */
  35359. _videoTextureSupported: boolean;
  35360. protected _renderingQueueLaunched: boolean;
  35361. protected _activeRenderLoops: (() => void)[];
  35362. /**
  35363. * Observable signaled when a context lost event is raised
  35364. */
  35365. onContextLostObservable: Observable<ThinEngine>;
  35366. /**
  35367. * Observable signaled when a context restored event is raised
  35368. */
  35369. onContextRestoredObservable: Observable<ThinEngine>;
  35370. private _onContextLost;
  35371. private _onContextRestored;
  35372. protected _contextWasLost: boolean;
  35373. /** @hidden */
  35374. _doNotHandleContextLost: boolean;
  35375. /**
  35376. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35378. */
  35379. get doNotHandleContextLost(): boolean;
  35380. set doNotHandleContextLost(value: boolean);
  35381. /**
  35382. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35383. */
  35384. disableVertexArrayObjects: boolean;
  35385. /** @hidden */
  35386. protected _colorWrite: boolean;
  35387. /** @hidden */
  35388. protected _colorWriteChanged: boolean;
  35389. /** @hidden */
  35390. protected _depthCullingState: DepthCullingState;
  35391. /** @hidden */
  35392. protected _stencilState: StencilState;
  35393. /** @hidden */
  35394. _alphaState: AlphaState;
  35395. /** @hidden */
  35396. _alphaMode: number;
  35397. /** @hidden */
  35398. _alphaEquation: number;
  35399. /** @hidden */
  35400. _internalTexturesCache: InternalTexture[];
  35401. /** @hidden */
  35402. protected _activeChannel: number;
  35403. private _currentTextureChannel;
  35404. /** @hidden */
  35405. protected _boundTexturesCache: {
  35406. [key: string]: Nullable<InternalTexture>;
  35407. };
  35408. /** @hidden */
  35409. protected _currentEffect: Nullable<Effect>;
  35410. /** @hidden */
  35411. protected _currentProgram: Nullable<WebGLProgram>;
  35412. private _compiledEffects;
  35413. private _vertexAttribArraysEnabled;
  35414. /** @hidden */
  35415. protected _cachedViewport: Nullable<IViewportLike>;
  35416. private _cachedVertexArrayObject;
  35417. /** @hidden */
  35418. protected _cachedVertexBuffers: any;
  35419. /** @hidden */
  35420. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35421. /** @hidden */
  35422. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35423. /** @hidden */
  35424. _currentRenderTarget: Nullable<InternalTexture>;
  35425. private _uintIndicesCurrentlySet;
  35426. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35427. /** @hidden */
  35428. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35429. /** @hidden */
  35430. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35431. private _currentBufferPointers;
  35432. private _currentInstanceLocations;
  35433. private _currentInstanceBuffers;
  35434. private _textureUnits;
  35435. /** @hidden */
  35436. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35437. /** @hidden */
  35438. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35439. /** @hidden */
  35440. _boundRenderFunction: any;
  35441. private _vaoRecordInProgress;
  35442. private _mustWipeVertexAttributes;
  35443. private _emptyTexture;
  35444. private _emptyCubeTexture;
  35445. private _emptyTexture3D;
  35446. private _emptyTexture2DArray;
  35447. /** @hidden */
  35448. _frameHandler: number;
  35449. private _nextFreeTextureSlots;
  35450. private _maxSimultaneousTextures;
  35451. private _activeRequests;
  35452. /** @hidden */
  35453. _transformTextureUrl: Nullable<(url: string) => string>;
  35454. /**
  35455. * Gets information about the current host
  35456. */
  35457. hostInformation: HostInformation;
  35458. protected get _supportsHardwareTextureRescaling(): boolean;
  35459. private _framebufferDimensionsObject;
  35460. /**
  35461. * sets the object from which width and height will be taken from when getting render width and height
  35462. * Will fallback to the gl object
  35463. * @param dimensions the framebuffer width and height that will be used.
  35464. */
  35465. set framebufferDimensionsObject(dimensions: Nullable<{
  35466. framebufferWidth: number;
  35467. framebufferHeight: number;
  35468. }>);
  35469. /**
  35470. * Gets the current viewport
  35471. */
  35472. get currentViewport(): Nullable<IViewportLike>;
  35473. /**
  35474. * Gets the default empty texture
  35475. */
  35476. get emptyTexture(): InternalTexture;
  35477. /**
  35478. * Gets the default empty 3D texture
  35479. */
  35480. get emptyTexture3D(): InternalTexture;
  35481. /**
  35482. * Gets the default empty 2D array texture
  35483. */
  35484. get emptyTexture2DArray(): InternalTexture;
  35485. /**
  35486. * Gets the default empty cube texture
  35487. */
  35488. get emptyCubeTexture(): InternalTexture;
  35489. /**
  35490. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35491. */
  35492. readonly premultipliedAlpha: boolean;
  35493. /**
  35494. * Observable event triggered before each texture is initialized
  35495. */
  35496. onBeforeTextureInitObservable: Observable<Texture>;
  35497. /**
  35498. * Creates a new engine
  35499. * @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
  35500. * @param antialias defines enable antialiasing (default: false)
  35501. * @param options defines further options to be sent to the getContext() function
  35502. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35503. */
  35504. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35505. private _rebuildInternalTextures;
  35506. private _rebuildEffects;
  35507. /**
  35508. * Gets a boolean indicating if all created effects are ready
  35509. * @returns true if all effects are ready
  35510. */
  35511. areAllEffectsReady(): boolean;
  35512. protected _rebuildBuffers(): void;
  35513. protected _initGLContext(): void;
  35514. /**
  35515. * Gets version of the current webGL context
  35516. */
  35517. get webGLVersion(): number;
  35518. /**
  35519. * Gets a string identifying the name of the class
  35520. * @returns "Engine" string
  35521. */
  35522. getClassName(): string;
  35523. /**
  35524. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35525. */
  35526. get isStencilEnable(): boolean;
  35527. /** @hidden */
  35528. _prepareWorkingCanvas(): void;
  35529. /**
  35530. * Reset the texture cache to empty state
  35531. */
  35532. resetTextureCache(): void;
  35533. /**
  35534. * Gets an object containing information about the current webGL context
  35535. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35536. */
  35537. getGlInfo(): {
  35538. vendor: string;
  35539. renderer: string;
  35540. version: string;
  35541. };
  35542. /**
  35543. * Defines the hardware scaling level.
  35544. * By default the hardware scaling level is computed from the window device ratio.
  35545. * 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.
  35546. * @param level defines the level to use
  35547. */
  35548. setHardwareScalingLevel(level: number): void;
  35549. /**
  35550. * Gets the current hardware scaling level.
  35551. * By default the hardware scaling level is computed from the window device ratio.
  35552. * 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.
  35553. * @returns a number indicating the current hardware scaling level
  35554. */
  35555. getHardwareScalingLevel(): number;
  35556. /**
  35557. * Gets the list of loaded textures
  35558. * @returns an array containing all loaded textures
  35559. */
  35560. getLoadedTexturesCache(): InternalTexture[];
  35561. /**
  35562. * Gets the object containing all engine capabilities
  35563. * @returns the EngineCapabilities object
  35564. */
  35565. getCaps(): EngineCapabilities;
  35566. /**
  35567. * stop executing a render loop function and remove it from the execution array
  35568. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35569. */
  35570. stopRenderLoop(renderFunction?: () => void): void;
  35571. /** @hidden */
  35572. _renderLoop(): void;
  35573. /**
  35574. * Gets the HTML canvas attached with the current webGL context
  35575. * @returns a HTML canvas
  35576. */
  35577. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35578. /**
  35579. * Gets host window
  35580. * @returns the host window object
  35581. */
  35582. getHostWindow(): Nullable<Window>;
  35583. /**
  35584. * Gets the current render width
  35585. * @param useScreen defines if screen size must be used (or the current render target if any)
  35586. * @returns a number defining the current render width
  35587. */
  35588. getRenderWidth(useScreen?: boolean): number;
  35589. /**
  35590. * Gets the current render height
  35591. * @param useScreen defines if screen size must be used (or the current render target if any)
  35592. * @returns a number defining the current render height
  35593. */
  35594. getRenderHeight(useScreen?: boolean): number;
  35595. /**
  35596. * Can be used to override the current requestAnimationFrame requester.
  35597. * @hidden
  35598. */
  35599. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35600. /**
  35601. * Register and execute a render loop. The engine can have more than one render function
  35602. * @param renderFunction defines the function to continuously execute
  35603. */
  35604. runRenderLoop(renderFunction: () => void): void;
  35605. /**
  35606. * Clear the current render buffer or the current render target (if any is set up)
  35607. * @param color defines the color to use
  35608. * @param backBuffer defines if the back buffer must be cleared
  35609. * @param depth defines if the depth buffer must be cleared
  35610. * @param stencil defines if the stencil buffer must be cleared
  35611. */
  35612. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35613. private _viewportCached;
  35614. /** @hidden */
  35615. _viewport(x: number, y: number, width: number, height: number): void;
  35616. /**
  35617. * Set the WebGL's viewport
  35618. * @param viewport defines the viewport element to be used
  35619. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35620. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35621. */
  35622. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35623. /**
  35624. * Begin a new frame
  35625. */
  35626. beginFrame(): void;
  35627. /**
  35628. * Enf the current frame
  35629. */
  35630. endFrame(): void;
  35631. /**
  35632. * Resize the view according to the canvas' size
  35633. */
  35634. resize(): void;
  35635. /**
  35636. * Force a specific size of the canvas
  35637. * @param width defines the new canvas' width
  35638. * @param height defines the new canvas' height
  35639. * @returns true if the size was changed
  35640. */
  35641. setSize(width: number, height: number): boolean;
  35642. /**
  35643. * Binds the frame buffer to the specified texture.
  35644. * @param texture The texture to render to or null for the default canvas
  35645. * @param faceIndex The face of the texture to render to in case of cube texture
  35646. * @param requiredWidth The width of the target to render to
  35647. * @param requiredHeight The height of the target to render to
  35648. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35649. * @param lodLevel defines the lod level to bind to the frame buffer
  35650. * @param layer defines the 2d array index to bind to frame buffer to
  35651. */
  35652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35653. /** @hidden */
  35654. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35655. /**
  35656. * Unbind the current render target texture from the webGL context
  35657. * @param texture defines the render target texture to unbind
  35658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35660. */
  35661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35662. /**
  35663. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35664. */
  35665. flushFramebuffer(): void;
  35666. /**
  35667. * Unbind the current render target and bind the default framebuffer
  35668. */
  35669. restoreDefaultFramebuffer(): void;
  35670. /** @hidden */
  35671. protected _resetVertexBufferBinding(): void;
  35672. /**
  35673. * Creates a vertex buffer
  35674. * @param data the data for the vertex buffer
  35675. * @returns the new WebGL static buffer
  35676. */
  35677. createVertexBuffer(data: DataArray): DataBuffer;
  35678. private _createVertexBuffer;
  35679. /**
  35680. * Creates a dynamic vertex buffer
  35681. * @param data the data for the dynamic vertex buffer
  35682. * @returns the new WebGL dynamic buffer
  35683. */
  35684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35685. protected _resetIndexBufferBinding(): void;
  35686. /**
  35687. * Creates a new index buffer
  35688. * @param indices defines the content of the index buffer
  35689. * @param updatable defines if the index buffer must be updatable
  35690. * @returns a new webGL buffer
  35691. */
  35692. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35693. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35694. /**
  35695. * Bind a webGL buffer to the webGL context
  35696. * @param buffer defines the buffer to bind
  35697. */
  35698. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35699. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35700. private bindBuffer;
  35701. /**
  35702. * update the bound buffer with the given data
  35703. * @param data defines the data to update
  35704. */
  35705. updateArrayBuffer(data: Float32Array): void;
  35706. private _vertexAttribPointer;
  35707. /** @hidden */
  35708. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35709. private _bindVertexBuffersAttributes;
  35710. /**
  35711. * Records a vertex array object
  35712. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35713. * @param vertexBuffers defines the list of vertex buffers to store
  35714. * @param indexBuffer defines the index buffer to store
  35715. * @param effect defines the effect to store
  35716. * @returns the new vertex array object
  35717. */
  35718. recordVertexArrayObject(vertexBuffers: {
  35719. [key: string]: VertexBuffer;
  35720. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35721. /**
  35722. * Bind a specific vertex array object
  35723. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35724. * @param vertexArrayObject defines the vertex array object to bind
  35725. * @param indexBuffer defines the index buffer to bind
  35726. */
  35727. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35728. /**
  35729. * Bind webGl buffers directly to the webGL context
  35730. * @param vertexBuffer defines the vertex buffer to bind
  35731. * @param indexBuffer defines the index buffer to bind
  35732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35734. * @param effect defines the effect associated with the vertex buffer
  35735. */
  35736. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35737. private _unbindVertexArrayObject;
  35738. /**
  35739. * Bind a list of vertex buffers to the webGL context
  35740. * @param vertexBuffers defines the list of vertex buffers to bind
  35741. * @param indexBuffer defines the index buffer to bind
  35742. * @param effect defines the effect associated with the vertex buffers
  35743. */
  35744. bindBuffers(vertexBuffers: {
  35745. [key: string]: Nullable<VertexBuffer>;
  35746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35747. /**
  35748. * Unbind all instance attributes
  35749. */
  35750. unbindInstanceAttributes(): void;
  35751. /**
  35752. * Release and free the memory of a vertex array object
  35753. * @param vao defines the vertex array object to delete
  35754. */
  35755. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35756. /** @hidden */
  35757. _releaseBuffer(buffer: DataBuffer): boolean;
  35758. protected _deleteBuffer(buffer: DataBuffer): void;
  35759. /**
  35760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35761. * @param instancesBuffer defines the webGL buffer to update and bind
  35762. * @param data defines the data to store in the buffer
  35763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35764. */
  35765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35766. /**
  35767. * Bind the content of a webGL buffer used with instantiation
  35768. * @param instancesBuffer defines the webGL buffer to bind
  35769. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35770. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35771. */
  35772. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35773. /**
  35774. * Disable the instance attribute corresponding to the name in parameter
  35775. * @param name defines the name of the attribute to disable
  35776. */
  35777. disableInstanceAttributeByName(name: string): void;
  35778. /**
  35779. * Disable the instance attribute corresponding to the location in parameter
  35780. * @param attributeLocation defines the attribute location of the attribute to disable
  35781. */
  35782. disableInstanceAttribute(attributeLocation: number): void;
  35783. /**
  35784. * Disable the attribute corresponding to the location in parameter
  35785. * @param attributeLocation defines the attribute location of the attribute to disable
  35786. */
  35787. disableAttributeByIndex(attributeLocation: number): void;
  35788. /**
  35789. * Send a draw order
  35790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35791. * @param indexStart defines the starting index
  35792. * @param indexCount defines the number of index to draw
  35793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35794. */
  35795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35796. /**
  35797. * Draw a list of points
  35798. * @param verticesStart defines the index of first vertex to draw
  35799. * @param verticesCount defines the count of vertices to draw
  35800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35801. */
  35802. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35803. /**
  35804. * Draw a list of unindexed primitives
  35805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35806. * @param verticesStart defines the index of first vertex to draw
  35807. * @param verticesCount defines the count of vertices to draw
  35808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35809. */
  35810. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35811. /**
  35812. * Draw a list of indexed primitives
  35813. * @param fillMode defines the primitive to use
  35814. * @param indexStart defines the starting index
  35815. * @param indexCount defines the number of index to draw
  35816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35817. */
  35818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35819. /**
  35820. * Draw a list of unindexed primitives
  35821. * @param fillMode defines the primitive to use
  35822. * @param verticesStart defines the index of first vertex to draw
  35823. * @param verticesCount defines the count of vertices to draw
  35824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35825. */
  35826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35827. private _drawMode;
  35828. /** @hidden */
  35829. protected _reportDrawCall(): void;
  35830. /** @hidden */
  35831. _releaseEffect(effect: Effect): void;
  35832. /** @hidden */
  35833. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35834. /**
  35835. * Create a new effect (used to store vertex/fragment shaders)
  35836. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35837. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35838. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35839. * @param samplers defines an array of string used to represent textures
  35840. * @param defines defines the string containing the defines to use to compile the shaders
  35841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35842. * @param onCompiled defines a function to call when the effect creation is successful
  35843. * @param onError defines a function to call when the effect creation has failed
  35844. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35845. * @returns the new Effect
  35846. */
  35847. 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;
  35848. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35849. private _compileShader;
  35850. private _compileRawShader;
  35851. /** @hidden */
  35852. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35853. /**
  35854. * Directly creates a webGL program
  35855. * @param pipelineContext defines the pipeline context to attach to
  35856. * @param vertexCode defines the vertex shader code to use
  35857. * @param fragmentCode defines the fragment shader code to use
  35858. * @param context defines the webGL context to use (if not set, the current one will be used)
  35859. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35860. * @returns the new webGL program
  35861. */
  35862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35863. /**
  35864. * Creates a webGL program
  35865. * @param pipelineContext defines the pipeline context to attach to
  35866. * @param vertexCode defines the vertex shader code to use
  35867. * @param fragmentCode defines the fragment shader code to use
  35868. * @param defines defines the string containing the defines to use to compile the shaders
  35869. * @param context defines the webGL context to use (if not set, the current one will be used)
  35870. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35871. * @returns the new webGL program
  35872. */
  35873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35874. /**
  35875. * Creates a new pipeline context
  35876. * @returns the new pipeline
  35877. */
  35878. createPipelineContext(): IPipelineContext;
  35879. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35880. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35881. /** @hidden */
  35882. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35883. /** @hidden */
  35884. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35885. /** @hidden */
  35886. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35887. /**
  35888. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35889. * @param pipelineContext defines the pipeline context to use
  35890. * @param uniformsNames defines the list of uniform names
  35891. * @returns an array of webGL uniform locations
  35892. */
  35893. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35894. /**
  35895. * Gets the lsit of active attributes for a given webGL program
  35896. * @param pipelineContext defines the pipeline context to use
  35897. * @param attributesNames defines the list of attribute names to get
  35898. * @returns an array of indices indicating the offset of each attribute
  35899. */
  35900. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35901. /**
  35902. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35903. * @param effect defines the effect to activate
  35904. */
  35905. enableEffect(effect: Nullable<Effect>): void;
  35906. /**
  35907. * Set the value of an uniform to a number (int)
  35908. * @param uniform defines the webGL uniform location where to store the value
  35909. * @param value defines the int number to store
  35910. */
  35911. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35912. /**
  35913. * Set the value of an uniform to an array of int32
  35914. * @param uniform defines the webGL uniform location where to store the value
  35915. * @param array defines the array of int32 to store
  35916. */
  35917. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35918. /**
  35919. * Set the value of an uniform to an array of int32 (stored as vec2)
  35920. * @param uniform defines the webGL uniform location where to store the value
  35921. * @param array defines the array of int32 to store
  35922. */
  35923. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35924. /**
  35925. * Set the value of an uniform to an array of int32 (stored as vec3)
  35926. * @param uniform defines the webGL uniform location where to store the value
  35927. * @param array defines the array of int32 to store
  35928. */
  35929. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35930. /**
  35931. * Set the value of an uniform to an array of int32 (stored as vec4)
  35932. * @param uniform defines the webGL uniform location where to store the value
  35933. * @param array defines the array of int32 to store
  35934. */
  35935. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35936. /**
  35937. * Set the value of an uniform to an array of number
  35938. * @param uniform defines the webGL uniform location where to store the value
  35939. * @param array defines the array of number to store
  35940. */
  35941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35942. /**
  35943. * Set the value of an uniform to an array of number (stored as vec2)
  35944. * @param uniform defines the webGL uniform location where to store the value
  35945. * @param array defines the array of number to store
  35946. */
  35947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35948. /**
  35949. * Set the value of an uniform to an array of number (stored as vec3)
  35950. * @param uniform defines the webGL uniform location where to store the value
  35951. * @param array defines the array of number to store
  35952. */
  35953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35954. /**
  35955. * Set the value of an uniform to an array of number (stored as vec4)
  35956. * @param uniform defines the webGL uniform location where to store the value
  35957. * @param array defines the array of number to store
  35958. */
  35959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35960. /**
  35961. * Set the value of an uniform to an array of float32 (stored as matrices)
  35962. * @param uniform defines the webGL uniform location where to store the value
  35963. * @param matrices defines the array of float32 to store
  35964. */
  35965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35966. /**
  35967. * Set the value of an uniform to a matrix (3x3)
  35968. * @param uniform defines the webGL uniform location where to store the value
  35969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35970. */
  35971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35972. /**
  35973. * Set the value of an uniform to a matrix (2x2)
  35974. * @param uniform defines the webGL uniform location where to store the value
  35975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35976. */
  35977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35978. /**
  35979. * Set the value of an uniform to a number (float)
  35980. * @param uniform defines the webGL uniform location where to store the value
  35981. * @param value defines the float number to store
  35982. */
  35983. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35984. /**
  35985. * Set the value of an uniform to a vec2
  35986. * @param uniform defines the webGL uniform location where to store the value
  35987. * @param x defines the 1st component of the value
  35988. * @param y defines the 2nd component of the value
  35989. */
  35990. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35991. /**
  35992. * Set the value of an uniform to a vec3
  35993. * @param uniform defines the webGL uniform location where to store the value
  35994. * @param x defines the 1st component of the value
  35995. * @param y defines the 2nd component of the value
  35996. * @param z defines the 3rd component of the value
  35997. */
  35998. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35999. /**
  36000. * Set the value of an uniform to a vec4
  36001. * @param uniform defines the webGL uniform location where to store the value
  36002. * @param x defines the 1st component of the value
  36003. * @param y defines the 2nd component of the value
  36004. * @param z defines the 3rd component of the value
  36005. * @param w defines the 4th component of the value
  36006. */
  36007. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36008. /**
  36009. * Apply all cached states (depth, culling, stencil and alpha)
  36010. */
  36011. applyStates(): void;
  36012. /**
  36013. * Enable or disable color writing
  36014. * @param enable defines the state to set
  36015. */
  36016. setColorWrite(enable: boolean): void;
  36017. /**
  36018. * Gets a boolean indicating if color writing is enabled
  36019. * @returns the current color writing state
  36020. */
  36021. getColorWrite(): boolean;
  36022. /**
  36023. * Gets the depth culling state manager
  36024. */
  36025. get depthCullingState(): DepthCullingState;
  36026. /**
  36027. * Gets the alpha state manager
  36028. */
  36029. get alphaState(): AlphaState;
  36030. /**
  36031. * Gets the stencil state manager
  36032. */
  36033. get stencilState(): StencilState;
  36034. /**
  36035. * Clears the list of texture accessible through engine.
  36036. * This can help preventing texture load conflict due to name collision.
  36037. */
  36038. clearInternalTexturesCache(): void;
  36039. /**
  36040. * Force the entire cache to be cleared
  36041. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36042. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36043. */
  36044. wipeCaches(bruteForce?: boolean): void;
  36045. /** @hidden */
  36046. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36047. min: number;
  36048. mag: number;
  36049. };
  36050. /** @hidden */
  36051. _createTexture(): WebGLTexture;
  36052. /**
  36053. * Usually called from Texture.ts.
  36054. * Passed information to create a WebGLTexture
  36055. * @param url defines a value which contains one of the following:
  36056. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36057. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36058. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36059. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36060. * @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)
  36061. * @param scene needed for loading to the correct scene
  36062. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36063. * @param onLoad optional callback to be called upon successful completion
  36064. * @param onError optional callback to be called upon failure
  36065. * @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
  36066. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36067. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36068. * @param forcedExtension defines the extension to use to pick the right loader
  36069. * @param mimeType defines an optional mime type
  36070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36071. */
  36072. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  36073. /**
  36074. * Loads an image as an HTMLImageElement.
  36075. * @param input url string, ArrayBuffer, or Blob to load
  36076. * @param onLoad callback called when the image successfully loads
  36077. * @param onError callback called when the image fails to load
  36078. * @param offlineProvider offline provider for caching
  36079. * @param mimeType optional mime type
  36080. * @returns the HTMLImageElement of the loaded image
  36081. * @hidden
  36082. */
  36083. 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>;
  36084. /**
  36085. * @hidden
  36086. */
  36087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36088. private _unpackFlipYCached;
  36089. /**
  36090. * In case you are sharing the context with other applications, it might
  36091. * be interested to not cache the unpack flip y state to ensure a consistent
  36092. * value would be set.
  36093. */
  36094. enableUnpackFlipYCached: boolean;
  36095. /** @hidden */
  36096. _unpackFlipY(value: boolean): void;
  36097. /** @hidden */
  36098. _getUnpackAlignement(): number;
  36099. private _getTextureTarget;
  36100. /**
  36101. * Update the sampling mode of a given texture
  36102. * @param samplingMode defines the required sampling mode
  36103. * @param texture defines the texture to update
  36104. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36105. */
  36106. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36107. /**
  36108. * Update the sampling mode of a given texture
  36109. * @param texture defines the texture to update
  36110. * @param wrapU defines the texture wrap mode of the u coordinates
  36111. * @param wrapV defines the texture wrap mode of the v coordinates
  36112. * @param wrapR defines the texture wrap mode of the r coordinates
  36113. */
  36114. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36115. /** @hidden */
  36116. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36117. width: number;
  36118. height: number;
  36119. layers?: number;
  36120. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36121. /** @hidden */
  36122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36123. /** @hidden */
  36124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36125. /**
  36126. * Update a portion of an internal texture
  36127. * @param texture defines the texture to update
  36128. * @param imageData defines the data to store into the texture
  36129. * @param xOffset defines the x coordinates of the update rectangle
  36130. * @param yOffset defines the y coordinates of the update rectangle
  36131. * @param width defines the width of the update rectangle
  36132. * @param height defines the height of the update rectangle
  36133. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36134. * @param lod defines the lod level to update (0 by default)
  36135. */
  36136. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36137. /** @hidden */
  36138. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36139. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36140. private _prepareWebGLTexture;
  36141. /** @hidden */
  36142. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36143. private _getDepthStencilBuffer;
  36144. /** @hidden */
  36145. _releaseFramebufferObjects(texture: InternalTexture): void;
  36146. /** @hidden */
  36147. _releaseTexture(texture: InternalTexture): void;
  36148. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36149. protected _setProgram(program: WebGLProgram): void;
  36150. protected _boundUniforms: {
  36151. [key: number]: WebGLUniformLocation;
  36152. };
  36153. /**
  36154. * Binds an effect to the webGL context
  36155. * @param effect defines the effect to bind
  36156. */
  36157. bindSamplers(effect: Effect): void;
  36158. private _activateCurrentTexture;
  36159. /** @hidden */
  36160. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36161. /** @hidden */
  36162. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36163. /**
  36164. * Unbind all textures from the webGL context
  36165. */
  36166. unbindAllTextures(): void;
  36167. /**
  36168. * Sets a texture to the according uniform.
  36169. * @param channel The texture channel
  36170. * @param uniform The uniform to set
  36171. * @param texture The texture to apply
  36172. */
  36173. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36174. private _bindSamplerUniformToChannel;
  36175. private _getTextureWrapMode;
  36176. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36177. /**
  36178. * Sets an array of texture to the webGL context
  36179. * @param channel defines the channel where the texture array must be set
  36180. * @param uniform defines the associated uniform location
  36181. * @param textures defines the array of textures to bind
  36182. */
  36183. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36184. /** @hidden */
  36185. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36186. private _setTextureParameterFloat;
  36187. private _setTextureParameterInteger;
  36188. /**
  36189. * Unbind all vertex attributes from the webGL context
  36190. */
  36191. unbindAllAttributes(): void;
  36192. /**
  36193. * 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
  36194. */
  36195. releaseEffects(): void;
  36196. /**
  36197. * Dispose and release all associated resources
  36198. */
  36199. dispose(): void;
  36200. /**
  36201. * Attach a new callback raised when context lost event is fired
  36202. * @param callback defines the callback to call
  36203. */
  36204. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36205. /**
  36206. * Attach a new callback raised when context restored event is fired
  36207. * @param callback defines the callback to call
  36208. */
  36209. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36210. /**
  36211. * Get the current error code of the webGL context
  36212. * @returns the error code
  36213. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36214. */
  36215. getError(): number;
  36216. private _canRenderToFloatFramebuffer;
  36217. private _canRenderToHalfFloatFramebuffer;
  36218. private _canRenderToFramebuffer;
  36219. /** @hidden */
  36220. _getWebGLTextureType(type: number): number;
  36221. /** @hidden */
  36222. _getInternalFormat(format: number): number;
  36223. /** @hidden */
  36224. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36225. /** @hidden */
  36226. _getRGBAMultiSampleBufferFormat(type: number): number;
  36227. /** @hidden */
  36228. _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;
  36229. /**
  36230. * Loads a file from a url
  36231. * @param url url to load
  36232. * @param onSuccess callback called when the file successfully loads
  36233. * @param onProgress callback called while file is loading (if the server supports this mode)
  36234. * @param offlineProvider defines the offline provider for caching
  36235. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36236. * @param onError callback called when the file fails to load
  36237. * @returns a file request object
  36238. * @hidden
  36239. */
  36240. 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;
  36241. /**
  36242. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36243. * @param x defines the x coordinate of the rectangle where pixels must be read
  36244. * @param y defines the y coordinate of the rectangle where pixels must be read
  36245. * @param width defines the width of the rectangle where pixels must be read
  36246. * @param height defines the height of the rectangle where pixels must be read
  36247. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36248. * @returns a Uint8Array containing RGBA colors
  36249. */
  36250. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36251. private static _isSupported;
  36252. /**
  36253. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36254. * @returns true if the engine can be created
  36255. * @ignorenaming
  36256. */
  36257. static isSupported(): boolean;
  36258. /**
  36259. * Find the next highest power of two.
  36260. * @param x Number to start search from.
  36261. * @return Next highest power of two.
  36262. */
  36263. static CeilingPOT(x: number): number;
  36264. /**
  36265. * Find the next lowest power of two.
  36266. * @param x Number to start search from.
  36267. * @return Next lowest power of two.
  36268. */
  36269. static FloorPOT(x: number): number;
  36270. /**
  36271. * Find the nearest power of two.
  36272. * @param x Number to start search from.
  36273. * @return Next nearest power of two.
  36274. */
  36275. static NearestPOT(x: number): number;
  36276. /**
  36277. * Get the closest exponent of two
  36278. * @param value defines the value to approximate
  36279. * @param max defines the maximum value to return
  36280. * @param mode defines how to define the closest value
  36281. * @returns closest exponent of two of the given value
  36282. */
  36283. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36284. /**
  36285. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36286. * @param func - the function to be called
  36287. * @param requester - the object that will request the next frame. Falls back to window.
  36288. * @returns frame number
  36289. */
  36290. static QueueNewFrame(func: () => void, requester?: any): number;
  36291. /**
  36292. * Gets host document
  36293. * @returns the host document object
  36294. */
  36295. getHostDocument(): Nullable<Document>;
  36296. }
  36297. }
  36298. declare module BABYLON {
  36299. /**
  36300. * Class representing spherical harmonics coefficients to the 3rd degree
  36301. */
  36302. export class SphericalHarmonics {
  36303. /**
  36304. * Defines whether or not the harmonics have been prescaled for rendering.
  36305. */
  36306. preScaled: boolean;
  36307. /**
  36308. * The l0,0 coefficients of the spherical harmonics
  36309. */
  36310. l00: Vector3;
  36311. /**
  36312. * The l1,-1 coefficients of the spherical harmonics
  36313. */
  36314. l1_1: Vector3;
  36315. /**
  36316. * The l1,0 coefficients of the spherical harmonics
  36317. */
  36318. l10: Vector3;
  36319. /**
  36320. * The l1,1 coefficients of the spherical harmonics
  36321. */
  36322. l11: Vector3;
  36323. /**
  36324. * The l2,-2 coefficients of the spherical harmonics
  36325. */
  36326. l2_2: Vector3;
  36327. /**
  36328. * The l2,-1 coefficients of the spherical harmonics
  36329. */
  36330. l2_1: Vector3;
  36331. /**
  36332. * The l2,0 coefficients of the spherical harmonics
  36333. */
  36334. l20: Vector3;
  36335. /**
  36336. * The l2,1 coefficients of the spherical harmonics
  36337. */
  36338. l21: Vector3;
  36339. /**
  36340. * The l2,2 coefficients of the spherical harmonics
  36341. */
  36342. l22: Vector3;
  36343. /**
  36344. * Adds a light to the spherical harmonics
  36345. * @param direction the direction of the light
  36346. * @param color the color of the light
  36347. * @param deltaSolidAngle the delta solid angle of the light
  36348. */
  36349. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36350. /**
  36351. * Scales the spherical harmonics by the given amount
  36352. * @param scale the amount to scale
  36353. */
  36354. scaleInPlace(scale: number): void;
  36355. /**
  36356. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36357. *
  36358. * ```
  36359. * E_lm = A_l * L_lm
  36360. * ```
  36361. *
  36362. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36363. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36364. * the scaling factors are given in equation 9.
  36365. */
  36366. convertIncidentRadianceToIrradiance(): void;
  36367. /**
  36368. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36369. *
  36370. * ```
  36371. * L = (1/pi) * E * rho
  36372. * ```
  36373. *
  36374. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36375. */
  36376. convertIrradianceToLambertianRadiance(): void;
  36377. /**
  36378. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36379. * required operations at run time.
  36380. *
  36381. * This is simply done by scaling back the SH with Ylm constants parameter.
  36382. * The trigonometric part being applied by the shader at run time.
  36383. */
  36384. preScaleForRendering(): void;
  36385. /**
  36386. * Constructs a spherical harmonics from an array.
  36387. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36388. * @returns the spherical harmonics
  36389. */
  36390. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36391. /**
  36392. * Gets the spherical harmonics from polynomial
  36393. * @param polynomial the spherical polynomial
  36394. * @returns the spherical harmonics
  36395. */
  36396. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36397. }
  36398. /**
  36399. * Class representing spherical polynomial coefficients to the 3rd degree
  36400. */
  36401. export class SphericalPolynomial {
  36402. private _harmonics;
  36403. /**
  36404. * The spherical harmonics used to create the polynomials.
  36405. */
  36406. get preScaledHarmonics(): SphericalHarmonics;
  36407. /**
  36408. * The x coefficients of the spherical polynomial
  36409. */
  36410. x: Vector3;
  36411. /**
  36412. * The y coefficients of the spherical polynomial
  36413. */
  36414. y: Vector3;
  36415. /**
  36416. * The z coefficients of the spherical polynomial
  36417. */
  36418. z: Vector3;
  36419. /**
  36420. * The xx coefficients of the spherical polynomial
  36421. */
  36422. xx: Vector3;
  36423. /**
  36424. * The yy coefficients of the spherical polynomial
  36425. */
  36426. yy: Vector3;
  36427. /**
  36428. * The zz coefficients of the spherical polynomial
  36429. */
  36430. zz: Vector3;
  36431. /**
  36432. * The xy coefficients of the spherical polynomial
  36433. */
  36434. xy: Vector3;
  36435. /**
  36436. * The yz coefficients of the spherical polynomial
  36437. */
  36438. yz: Vector3;
  36439. /**
  36440. * The zx coefficients of the spherical polynomial
  36441. */
  36442. zx: Vector3;
  36443. /**
  36444. * Adds an ambient color to the spherical polynomial
  36445. * @param color the color to add
  36446. */
  36447. addAmbient(color: Color3): void;
  36448. /**
  36449. * Scales the spherical polynomial by the given amount
  36450. * @param scale the amount to scale
  36451. */
  36452. scaleInPlace(scale: number): void;
  36453. /**
  36454. * Gets the spherical polynomial from harmonics
  36455. * @param harmonics the spherical harmonics
  36456. * @returns the spherical polynomial
  36457. */
  36458. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36459. /**
  36460. * Constructs a spherical polynomial from an array.
  36461. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36462. * @returns the spherical polynomial
  36463. */
  36464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36465. }
  36466. }
  36467. declare module BABYLON {
  36468. /**
  36469. * Defines the source of the internal texture
  36470. */
  36471. export enum InternalTextureSource {
  36472. /**
  36473. * The source of the texture data is unknown
  36474. */
  36475. Unknown = 0,
  36476. /**
  36477. * Texture data comes from an URL
  36478. */
  36479. Url = 1,
  36480. /**
  36481. * Texture data is only used for temporary storage
  36482. */
  36483. Temp = 2,
  36484. /**
  36485. * Texture data comes from raw data (ArrayBuffer)
  36486. */
  36487. Raw = 3,
  36488. /**
  36489. * Texture content is dynamic (video or dynamic texture)
  36490. */
  36491. Dynamic = 4,
  36492. /**
  36493. * Texture content is generated by rendering to it
  36494. */
  36495. RenderTarget = 5,
  36496. /**
  36497. * Texture content is part of a multi render target process
  36498. */
  36499. MultiRenderTarget = 6,
  36500. /**
  36501. * Texture data comes from a cube data file
  36502. */
  36503. Cube = 7,
  36504. /**
  36505. * Texture data comes from a raw cube data
  36506. */
  36507. CubeRaw = 8,
  36508. /**
  36509. * Texture data come from a prefiltered cube data file
  36510. */
  36511. CubePrefiltered = 9,
  36512. /**
  36513. * Texture content is raw 3D data
  36514. */
  36515. Raw3D = 10,
  36516. /**
  36517. * Texture content is raw 2D array data
  36518. */
  36519. Raw2DArray = 11,
  36520. /**
  36521. * Texture content is a depth texture
  36522. */
  36523. Depth = 12,
  36524. /**
  36525. * Texture data comes from a raw cube data encoded with RGBD
  36526. */
  36527. CubeRawRGBD = 13
  36528. }
  36529. /**
  36530. * Class used to store data associated with WebGL texture data for the engine
  36531. * This class should not be used directly
  36532. */
  36533. export class InternalTexture {
  36534. /** @hidden */
  36535. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36536. /**
  36537. * Defines if the texture is ready
  36538. */
  36539. isReady: boolean;
  36540. /**
  36541. * Defines if the texture is a cube texture
  36542. */
  36543. isCube: boolean;
  36544. /**
  36545. * Defines if the texture contains 3D data
  36546. */
  36547. is3D: boolean;
  36548. /**
  36549. * Defines if the texture contains 2D array data
  36550. */
  36551. is2DArray: boolean;
  36552. /**
  36553. * Defines if the texture contains multiview data
  36554. */
  36555. isMultiview: boolean;
  36556. /**
  36557. * Gets the URL used to load this texture
  36558. */
  36559. url: string;
  36560. /**
  36561. * Gets the sampling mode of the texture
  36562. */
  36563. samplingMode: number;
  36564. /**
  36565. * Gets a boolean indicating if the texture needs mipmaps generation
  36566. */
  36567. generateMipMaps: boolean;
  36568. /**
  36569. * Gets the number of samples used by the texture (WebGL2+ only)
  36570. */
  36571. samples: number;
  36572. /**
  36573. * Gets the type of the texture (int, float...)
  36574. */
  36575. type: number;
  36576. /**
  36577. * Gets the format of the texture (RGB, RGBA...)
  36578. */
  36579. format: number;
  36580. /**
  36581. * Observable called when the texture is loaded
  36582. */
  36583. onLoadedObservable: Observable<InternalTexture>;
  36584. /**
  36585. * Gets the width of the texture
  36586. */
  36587. width: number;
  36588. /**
  36589. * Gets the height of the texture
  36590. */
  36591. height: number;
  36592. /**
  36593. * Gets the depth of the texture
  36594. */
  36595. depth: number;
  36596. /**
  36597. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36598. */
  36599. baseWidth: number;
  36600. /**
  36601. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36602. */
  36603. baseHeight: number;
  36604. /**
  36605. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36606. */
  36607. baseDepth: number;
  36608. /**
  36609. * Gets a boolean indicating if the texture is inverted on Y axis
  36610. */
  36611. invertY: boolean;
  36612. /** @hidden */
  36613. _invertVScale: boolean;
  36614. /** @hidden */
  36615. _associatedChannel: number;
  36616. /** @hidden */
  36617. _source: InternalTextureSource;
  36618. /** @hidden */
  36619. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36620. /** @hidden */
  36621. _bufferView: Nullable<ArrayBufferView>;
  36622. /** @hidden */
  36623. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36624. /** @hidden */
  36625. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36626. /** @hidden */
  36627. _size: number;
  36628. /** @hidden */
  36629. _extension: string;
  36630. /** @hidden */
  36631. _files: Nullable<string[]>;
  36632. /** @hidden */
  36633. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36634. /** @hidden */
  36635. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36636. /** @hidden */
  36637. _framebuffer: Nullable<WebGLFramebuffer>;
  36638. /** @hidden */
  36639. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36640. /** @hidden */
  36641. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36642. /** @hidden */
  36643. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36644. /** @hidden */
  36645. _attachments: Nullable<number[]>;
  36646. /** @hidden */
  36647. _textureArray: Nullable<InternalTexture[]>;
  36648. /** @hidden */
  36649. _cachedCoordinatesMode: Nullable<number>;
  36650. /** @hidden */
  36651. _cachedWrapU: Nullable<number>;
  36652. /** @hidden */
  36653. _cachedWrapV: Nullable<number>;
  36654. /** @hidden */
  36655. _cachedWrapR: Nullable<number>;
  36656. /** @hidden */
  36657. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36658. /** @hidden */
  36659. _isDisabled: boolean;
  36660. /** @hidden */
  36661. _compression: Nullable<string>;
  36662. /** @hidden */
  36663. _generateStencilBuffer: boolean;
  36664. /** @hidden */
  36665. _generateDepthBuffer: boolean;
  36666. /** @hidden */
  36667. _comparisonFunction: number;
  36668. /** @hidden */
  36669. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36670. /** @hidden */
  36671. _lodGenerationScale: number;
  36672. /** @hidden */
  36673. _lodGenerationOffset: number;
  36674. /** @hidden */
  36675. _depthStencilTexture: Nullable<InternalTexture>;
  36676. /** @hidden */
  36677. _colorTextureArray: Nullable<WebGLTexture>;
  36678. /** @hidden */
  36679. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36680. /** @hidden */
  36681. _lodTextureHigh: Nullable<BaseTexture>;
  36682. /** @hidden */
  36683. _lodTextureMid: Nullable<BaseTexture>;
  36684. /** @hidden */
  36685. _lodTextureLow: Nullable<BaseTexture>;
  36686. /** @hidden */
  36687. _isRGBD: boolean;
  36688. /** @hidden */
  36689. _linearSpecularLOD: boolean;
  36690. /** @hidden */
  36691. _irradianceTexture: Nullable<BaseTexture>;
  36692. /** @hidden */
  36693. _webGLTexture: Nullable<WebGLTexture>;
  36694. /** @hidden */
  36695. _references: number;
  36696. /** @hidden */
  36697. _gammaSpace: Nullable<boolean>;
  36698. private _engine;
  36699. /**
  36700. * Gets the Engine the texture belongs to.
  36701. * @returns The babylon engine
  36702. */
  36703. getEngine(): ThinEngine;
  36704. /**
  36705. * Gets the data source type of the texture
  36706. */
  36707. get source(): InternalTextureSource;
  36708. /**
  36709. * Creates a new InternalTexture
  36710. * @param engine defines the engine to use
  36711. * @param source defines the type of data that will be used
  36712. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36713. */
  36714. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36715. /**
  36716. * Increments the number of references (ie. the number of Texture that point to it)
  36717. */
  36718. incrementReferences(): void;
  36719. /**
  36720. * Change the size of the texture (not the size of the content)
  36721. * @param width defines the new width
  36722. * @param height defines the new height
  36723. * @param depth defines the new depth (1 by default)
  36724. */
  36725. updateSize(width: int, height: int, depth?: int): void;
  36726. /** @hidden */
  36727. _rebuild(): void;
  36728. /** @hidden */
  36729. _swapAndDie(target: InternalTexture): void;
  36730. /**
  36731. * Dispose the current allocated resources
  36732. */
  36733. dispose(): void;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36739. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36740. */
  36741. export class Analyser {
  36742. /**
  36743. * Gets or sets the smoothing
  36744. * @ignorenaming
  36745. */
  36746. SMOOTHING: number;
  36747. /**
  36748. * Gets or sets the FFT table size
  36749. * @ignorenaming
  36750. */
  36751. FFT_SIZE: number;
  36752. /**
  36753. * Gets or sets the bar graph amplitude
  36754. * @ignorenaming
  36755. */
  36756. BARGRAPHAMPLITUDE: number;
  36757. /**
  36758. * Gets or sets the position of the debug canvas
  36759. * @ignorenaming
  36760. */
  36761. DEBUGCANVASPOS: {
  36762. x: number;
  36763. y: number;
  36764. };
  36765. /**
  36766. * Gets or sets the debug canvas size
  36767. * @ignorenaming
  36768. */
  36769. DEBUGCANVASSIZE: {
  36770. width: number;
  36771. height: number;
  36772. };
  36773. private _byteFreqs;
  36774. private _byteTime;
  36775. private _floatFreqs;
  36776. private _webAudioAnalyser;
  36777. private _debugCanvas;
  36778. private _debugCanvasContext;
  36779. private _scene;
  36780. private _registerFunc;
  36781. private _audioEngine;
  36782. /**
  36783. * Creates a new analyser
  36784. * @param scene defines hosting scene
  36785. */
  36786. constructor(scene: Scene);
  36787. /**
  36788. * Get the number of data values you will have to play with for the visualization
  36789. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36790. * @returns a number
  36791. */
  36792. getFrequencyBinCount(): number;
  36793. /**
  36794. * Gets the current frequency data as a byte array
  36795. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36796. * @returns a Uint8Array
  36797. */
  36798. getByteFrequencyData(): Uint8Array;
  36799. /**
  36800. * Gets the current waveform as a byte array
  36801. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36802. * @returns a Uint8Array
  36803. */
  36804. getByteTimeDomainData(): Uint8Array;
  36805. /**
  36806. * Gets the current frequency data as a float array
  36807. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36808. * @returns a Float32Array
  36809. */
  36810. getFloatFrequencyData(): Float32Array;
  36811. /**
  36812. * Renders the debug canvas
  36813. */
  36814. drawDebugCanvas(): void;
  36815. /**
  36816. * Stops rendering the debug canvas and removes it
  36817. */
  36818. stopDebugCanvas(): void;
  36819. /**
  36820. * Connects two audio nodes
  36821. * @param inputAudioNode defines first node to connect
  36822. * @param outputAudioNode defines second node to connect
  36823. */
  36824. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36825. /**
  36826. * Releases all associated resources
  36827. */
  36828. dispose(): void;
  36829. }
  36830. }
  36831. declare module BABYLON {
  36832. /**
  36833. * This represents an audio engine and it is responsible
  36834. * to play, synchronize and analyse sounds throughout the application.
  36835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36836. */
  36837. export interface IAudioEngine extends IDisposable {
  36838. /**
  36839. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36840. */
  36841. readonly canUseWebAudio: boolean;
  36842. /**
  36843. * Gets the current AudioContext if available.
  36844. */
  36845. readonly audioContext: Nullable<AudioContext>;
  36846. /**
  36847. * The master gain node defines the global audio volume of your audio engine.
  36848. */
  36849. readonly masterGain: GainNode;
  36850. /**
  36851. * Gets whether or not mp3 are supported by your browser.
  36852. */
  36853. readonly isMP3supported: boolean;
  36854. /**
  36855. * Gets whether or not ogg are supported by your browser.
  36856. */
  36857. readonly isOGGsupported: boolean;
  36858. /**
  36859. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36860. * @ignoreNaming
  36861. */
  36862. WarnedWebAudioUnsupported: boolean;
  36863. /**
  36864. * Defines if the audio engine relies on a custom unlocked button.
  36865. * In this case, the embedded button will not be displayed.
  36866. */
  36867. useCustomUnlockedButton: boolean;
  36868. /**
  36869. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36870. */
  36871. readonly unlocked: boolean;
  36872. /**
  36873. * Event raised when audio has been unlocked on the browser.
  36874. */
  36875. onAudioUnlockedObservable: Observable<AudioEngine>;
  36876. /**
  36877. * Event raised when audio has been locked on the browser.
  36878. */
  36879. onAudioLockedObservable: Observable<AudioEngine>;
  36880. /**
  36881. * Flags the audio engine in Locked state.
  36882. * This happens due to new browser policies preventing audio to autoplay.
  36883. */
  36884. lock(): void;
  36885. /**
  36886. * Unlocks the audio engine once a user action has been done on the dom.
  36887. * This is helpful to resume play once browser policies have been satisfied.
  36888. */
  36889. unlock(): void;
  36890. /**
  36891. * Gets the global volume sets on the master gain.
  36892. * @returns the global volume if set or -1 otherwise
  36893. */
  36894. getGlobalVolume(): number;
  36895. /**
  36896. * Sets the global volume of your experience (sets on the master gain).
  36897. * @param newVolume Defines the new global volume of the application
  36898. */
  36899. setGlobalVolume(newVolume: number): void;
  36900. /**
  36901. * Connect the audio engine to an audio analyser allowing some amazing
  36902. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36904. * @param analyser The analyser to connect to the engine
  36905. */
  36906. connectToAnalyser(analyser: Analyser): void;
  36907. }
  36908. /**
  36909. * This represents the default audio engine used in babylon.
  36910. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36912. */
  36913. export class AudioEngine implements IAudioEngine {
  36914. private _audioContext;
  36915. private _audioContextInitialized;
  36916. private _muteButton;
  36917. private _hostElement;
  36918. /**
  36919. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36920. */
  36921. canUseWebAudio: boolean;
  36922. /**
  36923. * The master gain node defines the global audio volume of your audio engine.
  36924. */
  36925. masterGain: GainNode;
  36926. /**
  36927. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36928. * @ignoreNaming
  36929. */
  36930. WarnedWebAudioUnsupported: boolean;
  36931. /**
  36932. * Gets whether or not mp3 are supported by your browser.
  36933. */
  36934. isMP3supported: boolean;
  36935. /**
  36936. * Gets whether or not ogg are supported by your browser.
  36937. */
  36938. isOGGsupported: boolean;
  36939. /**
  36940. * Gets whether audio has been unlocked on the device.
  36941. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36942. * a user interaction has happened.
  36943. */
  36944. unlocked: boolean;
  36945. /**
  36946. * Defines if the audio engine relies on a custom unlocked button.
  36947. * In this case, the embedded button will not be displayed.
  36948. */
  36949. useCustomUnlockedButton: boolean;
  36950. /**
  36951. * Event raised when audio has been unlocked on the browser.
  36952. */
  36953. onAudioUnlockedObservable: Observable<AudioEngine>;
  36954. /**
  36955. * Event raised when audio has been locked on the browser.
  36956. */
  36957. onAudioLockedObservable: Observable<AudioEngine>;
  36958. /**
  36959. * Gets the current AudioContext if available.
  36960. */
  36961. get audioContext(): Nullable<AudioContext>;
  36962. private _connectedAnalyser;
  36963. /**
  36964. * Instantiates a new audio engine.
  36965. *
  36966. * There should be only one per page as some browsers restrict the number
  36967. * of audio contexts you can create.
  36968. * @param hostElement defines the host element where to display the mute icon if necessary
  36969. */
  36970. constructor(hostElement?: Nullable<HTMLElement>);
  36971. /**
  36972. * Flags the audio engine in Locked state.
  36973. * This happens due to new browser policies preventing audio to autoplay.
  36974. */
  36975. lock(): void;
  36976. /**
  36977. * Unlocks the audio engine once a user action has been done on the dom.
  36978. * This is helpful to resume play once browser policies have been satisfied.
  36979. */
  36980. unlock(): void;
  36981. private _resumeAudioContext;
  36982. private _initializeAudioContext;
  36983. private _tryToRun;
  36984. private _triggerRunningState;
  36985. private _triggerSuspendedState;
  36986. private _displayMuteButton;
  36987. private _moveButtonToTopLeft;
  36988. private _onResize;
  36989. private _hideMuteButton;
  36990. /**
  36991. * Destroy and release the resources associated with the audio ccontext.
  36992. */
  36993. dispose(): void;
  36994. /**
  36995. * Gets the global volume sets on the master gain.
  36996. * @returns the global volume if set or -1 otherwise
  36997. */
  36998. getGlobalVolume(): number;
  36999. /**
  37000. * Sets the global volume of your experience (sets on the master gain).
  37001. * @param newVolume Defines the new global volume of the application
  37002. */
  37003. setGlobalVolume(newVolume: number): void;
  37004. /**
  37005. * Connect the audio engine to an audio analyser allowing some amazing
  37006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37008. * @param analyser The analyser to connect to the engine
  37009. */
  37010. connectToAnalyser(analyser: Analyser): void;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. /**
  37015. * Interface used to present a loading screen while loading a scene
  37016. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37017. */
  37018. export interface ILoadingScreen {
  37019. /**
  37020. * Function called to display the loading screen
  37021. */
  37022. displayLoadingUI: () => void;
  37023. /**
  37024. * Function called to hide the loading screen
  37025. */
  37026. hideLoadingUI: () => void;
  37027. /**
  37028. * Gets or sets the color to use for the background
  37029. */
  37030. loadingUIBackgroundColor: string;
  37031. /**
  37032. * Gets or sets the text to display while loading
  37033. */
  37034. loadingUIText: string;
  37035. }
  37036. /**
  37037. * Class used for the default loading screen
  37038. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37039. */
  37040. export class DefaultLoadingScreen implements ILoadingScreen {
  37041. private _renderingCanvas;
  37042. private _loadingText;
  37043. private _loadingDivBackgroundColor;
  37044. private _loadingDiv;
  37045. private _loadingTextDiv;
  37046. /** Gets or sets the logo url to use for the default loading screen */
  37047. static DefaultLogoUrl: string;
  37048. /** Gets or sets the spinner url to use for the default loading screen */
  37049. static DefaultSpinnerUrl: string;
  37050. /**
  37051. * Creates a new default loading screen
  37052. * @param _renderingCanvas defines the canvas used to render the scene
  37053. * @param _loadingText defines the default text to display
  37054. * @param _loadingDivBackgroundColor defines the default background color
  37055. */
  37056. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37057. /**
  37058. * Function called to display the loading screen
  37059. */
  37060. displayLoadingUI(): void;
  37061. /**
  37062. * Function called to hide the loading screen
  37063. */
  37064. hideLoadingUI(): void;
  37065. /**
  37066. * Gets or sets the text to display while loading
  37067. */
  37068. set loadingUIText(text: string);
  37069. get loadingUIText(): string;
  37070. /**
  37071. * Gets or sets the color to use for the background
  37072. */
  37073. get loadingUIBackgroundColor(): string;
  37074. set loadingUIBackgroundColor(color: string);
  37075. private _resizeLoadingUI;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Interface for any object that can request an animation frame
  37081. */
  37082. export interface ICustomAnimationFrameRequester {
  37083. /**
  37084. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37085. */
  37086. renderFunction?: Function;
  37087. /**
  37088. * Called to request the next frame to render to
  37089. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37090. */
  37091. requestAnimationFrame: Function;
  37092. /**
  37093. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37094. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37095. */
  37096. requestID?: number;
  37097. }
  37098. }
  37099. declare module BABYLON {
  37100. /**
  37101. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37102. */
  37103. export class PerformanceMonitor {
  37104. private _enabled;
  37105. private _rollingFrameTime;
  37106. private _lastFrameTimeMs;
  37107. /**
  37108. * constructor
  37109. * @param frameSampleSize The number of samples required to saturate the sliding window
  37110. */
  37111. constructor(frameSampleSize?: number);
  37112. /**
  37113. * Samples current frame
  37114. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37115. */
  37116. sampleFrame(timeMs?: number): void;
  37117. /**
  37118. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37119. */
  37120. get averageFrameTime(): number;
  37121. /**
  37122. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37123. */
  37124. get averageFrameTimeVariance(): number;
  37125. /**
  37126. * Returns the frame time of the most recent frame
  37127. */
  37128. get instantaneousFrameTime(): number;
  37129. /**
  37130. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37131. */
  37132. get averageFPS(): number;
  37133. /**
  37134. * Returns the average framerate in frames per second using the most recent frame time
  37135. */
  37136. get instantaneousFPS(): number;
  37137. /**
  37138. * Returns true if enough samples have been taken to completely fill the sliding window
  37139. */
  37140. get isSaturated(): boolean;
  37141. /**
  37142. * Enables contributions to the sliding window sample set
  37143. */
  37144. enable(): void;
  37145. /**
  37146. * Disables contributions to the sliding window sample set
  37147. * Samples will not be interpolated over the disabled period
  37148. */
  37149. disable(): void;
  37150. /**
  37151. * Returns true if sampling is enabled
  37152. */
  37153. get isEnabled(): boolean;
  37154. /**
  37155. * Resets performance monitor
  37156. */
  37157. reset(): void;
  37158. }
  37159. /**
  37160. * RollingAverage
  37161. *
  37162. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37163. */
  37164. export class RollingAverage {
  37165. /**
  37166. * Current average
  37167. */
  37168. average: number;
  37169. /**
  37170. * Current variance
  37171. */
  37172. variance: number;
  37173. protected _samples: Array<number>;
  37174. protected _sampleCount: number;
  37175. protected _pos: number;
  37176. protected _m2: number;
  37177. /**
  37178. * constructor
  37179. * @param length The number of samples required to saturate the sliding window
  37180. */
  37181. constructor(length: number);
  37182. /**
  37183. * Adds a sample to the sample set
  37184. * @param v The sample value
  37185. */
  37186. add(v: number): void;
  37187. /**
  37188. * Returns previously added values or null if outside of history or outside the sliding window domain
  37189. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37190. * @return Value previously recorded with add() or null if outside of range
  37191. */
  37192. history(i: number): number;
  37193. /**
  37194. * Returns true if enough samples have been taken to completely fill the sliding window
  37195. * @return true if sample-set saturated
  37196. */
  37197. isSaturated(): boolean;
  37198. /**
  37199. * Resets the rolling average (equivalent to 0 samples taken so far)
  37200. */
  37201. reset(): void;
  37202. /**
  37203. * Wraps a value around the sample range boundaries
  37204. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37205. * @return Wrapped position in sample range
  37206. */
  37207. protected _wrapPosition(i: number): number;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /**
  37212. * This class is used to track a performance counter which is number based.
  37213. * The user has access to many properties which give statistics of different nature.
  37214. *
  37215. * The implementer can track two kinds of Performance Counter: time and count.
  37216. * 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.
  37217. * 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.
  37218. */
  37219. export class PerfCounter {
  37220. /**
  37221. * Gets or sets a global boolean to turn on and off all the counters
  37222. */
  37223. static Enabled: boolean;
  37224. /**
  37225. * Returns the smallest value ever
  37226. */
  37227. get min(): number;
  37228. /**
  37229. * Returns the biggest value ever
  37230. */
  37231. get max(): number;
  37232. /**
  37233. * Returns the average value since the performance counter is running
  37234. */
  37235. get average(): number;
  37236. /**
  37237. * Returns the average value of the last second the counter was monitored
  37238. */
  37239. get lastSecAverage(): number;
  37240. /**
  37241. * Returns the current value
  37242. */
  37243. get current(): number;
  37244. /**
  37245. * Gets the accumulated total
  37246. */
  37247. get total(): number;
  37248. /**
  37249. * Gets the total value count
  37250. */
  37251. get count(): number;
  37252. /**
  37253. * Creates a new counter
  37254. */
  37255. constructor();
  37256. /**
  37257. * Call this method to start monitoring a new frame.
  37258. * 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.
  37259. */
  37260. fetchNewFrame(): void;
  37261. /**
  37262. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37263. * @param newCount the count value to add to the monitored count
  37264. * @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.
  37265. */
  37266. addCount(newCount: number, fetchResult: boolean): void;
  37267. /**
  37268. * Start monitoring this performance counter
  37269. */
  37270. beginMonitoring(): void;
  37271. /**
  37272. * Compute the time lapsed since the previous beginMonitoring() call.
  37273. * @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
  37274. */
  37275. endMonitoring(newFrame?: boolean): void;
  37276. private _fetchResult;
  37277. private _startMonitoringTime;
  37278. private _min;
  37279. private _max;
  37280. private _average;
  37281. private _current;
  37282. private _totalValueCount;
  37283. private _totalAccumulated;
  37284. private _lastSecAverage;
  37285. private _lastSecAccumulated;
  37286. private _lastSecTime;
  37287. private _lastSecValueCount;
  37288. }
  37289. }
  37290. declare module BABYLON {
  37291. interface ThinEngine {
  37292. /** @hidden */
  37293. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37294. }
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * Defines the interface used by display changed events
  37299. */
  37300. export interface IDisplayChangedEventArgs {
  37301. /** Gets the vrDisplay object (if any) */
  37302. vrDisplay: Nullable<any>;
  37303. /** Gets a boolean indicating if webVR is supported */
  37304. vrSupported: boolean;
  37305. }
  37306. /**
  37307. * Defines the interface used by objects containing a viewport (like a camera)
  37308. */
  37309. interface IViewportOwnerLike {
  37310. /**
  37311. * Gets or sets the viewport
  37312. */
  37313. viewport: IViewportLike;
  37314. }
  37315. /**
  37316. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37317. */
  37318. export class Engine extends ThinEngine {
  37319. /** Defines that alpha blending is disabled */
  37320. static readonly ALPHA_DISABLE: number;
  37321. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37322. static readonly ALPHA_ADD: number;
  37323. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37324. static readonly ALPHA_COMBINE: number;
  37325. /** Defines that alpha blending to DEST - SRC * DEST */
  37326. static readonly ALPHA_SUBTRACT: number;
  37327. /** Defines that alpha blending to SRC * DEST */
  37328. static readonly ALPHA_MULTIPLY: number;
  37329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37330. static readonly ALPHA_MAXIMIZED: number;
  37331. /** Defines that alpha blending to SRC + DEST */
  37332. static readonly ALPHA_ONEONE: number;
  37333. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37334. static readonly ALPHA_PREMULTIPLIED: number;
  37335. /**
  37336. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37337. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37338. */
  37339. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37340. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37341. static readonly ALPHA_INTERPOLATE: number;
  37342. /**
  37343. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37344. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37345. */
  37346. static readonly ALPHA_SCREENMODE: number;
  37347. /** Defines that the ressource is not delayed*/
  37348. static readonly DELAYLOADSTATE_NONE: number;
  37349. /** Defines that the ressource was successfully delay loaded */
  37350. static readonly DELAYLOADSTATE_LOADED: number;
  37351. /** Defines that the ressource is currently delay loading */
  37352. static readonly DELAYLOADSTATE_LOADING: number;
  37353. /** Defines that the ressource is delayed and has not started loading */
  37354. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37356. static readonly NEVER: number;
  37357. /** 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 */
  37358. static readonly ALWAYS: number;
  37359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37360. static readonly LESS: number;
  37361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37362. static readonly EQUAL: number;
  37363. /** 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 */
  37364. static readonly LEQUAL: number;
  37365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37366. static readonly GREATER: number;
  37367. /** 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 */
  37368. static readonly GEQUAL: number;
  37369. /** 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 */
  37370. static readonly NOTEQUAL: number;
  37371. /** Passed to stencilOperation to specify that stencil value must be kept */
  37372. static readonly KEEP: number;
  37373. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37374. static readonly REPLACE: number;
  37375. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37376. static readonly INCR: number;
  37377. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37378. static readonly DECR: number;
  37379. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37380. static readonly INVERT: number;
  37381. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37382. static readonly INCR_WRAP: number;
  37383. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37384. static readonly DECR_WRAP: number;
  37385. /** Texture is not repeating outside of 0..1 UVs */
  37386. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37387. /** Texture is repeating outside of 0..1 UVs */
  37388. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37389. /** Texture is repeating and mirrored */
  37390. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37391. /** ALPHA */
  37392. static readonly TEXTUREFORMAT_ALPHA: number;
  37393. /** LUMINANCE */
  37394. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37395. /** LUMINANCE_ALPHA */
  37396. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37397. /** RGB */
  37398. static readonly TEXTUREFORMAT_RGB: number;
  37399. /** RGBA */
  37400. static readonly TEXTUREFORMAT_RGBA: number;
  37401. /** RED */
  37402. static readonly TEXTUREFORMAT_RED: number;
  37403. /** RED (2nd reference) */
  37404. static readonly TEXTUREFORMAT_R: number;
  37405. /** RG */
  37406. static readonly TEXTUREFORMAT_RG: number;
  37407. /** RED_INTEGER */
  37408. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37409. /** RED_INTEGER (2nd reference) */
  37410. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37411. /** RG_INTEGER */
  37412. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37413. /** RGB_INTEGER */
  37414. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37415. /** RGBA_INTEGER */
  37416. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37417. /** UNSIGNED_BYTE */
  37418. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37419. /** UNSIGNED_BYTE (2nd reference) */
  37420. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37421. /** FLOAT */
  37422. static readonly TEXTURETYPE_FLOAT: number;
  37423. /** HALF_FLOAT */
  37424. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37425. /** BYTE */
  37426. static readonly TEXTURETYPE_BYTE: number;
  37427. /** SHORT */
  37428. static readonly TEXTURETYPE_SHORT: number;
  37429. /** UNSIGNED_SHORT */
  37430. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37431. /** INT */
  37432. static readonly TEXTURETYPE_INT: number;
  37433. /** UNSIGNED_INT */
  37434. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37435. /** UNSIGNED_SHORT_4_4_4_4 */
  37436. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37437. /** UNSIGNED_SHORT_5_5_5_1 */
  37438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37439. /** UNSIGNED_SHORT_5_6_5 */
  37440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37441. /** UNSIGNED_INT_2_10_10_10_REV */
  37442. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37443. /** UNSIGNED_INT_24_8 */
  37444. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37445. /** UNSIGNED_INT_10F_11F_11F_REV */
  37446. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37447. /** UNSIGNED_INT_5_9_9_9_REV */
  37448. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37449. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37450. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37451. /** nearest is mag = nearest and min = nearest and mip = linear */
  37452. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37454. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37455. /** Trilinear is mag = linear and min = linear and mip = linear */
  37456. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37457. /** nearest is mag = nearest and min = nearest and mip = linear */
  37458. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37460. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37461. /** Trilinear is mag = linear and min = linear and mip = linear */
  37462. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37463. /** mag = nearest and min = nearest and mip = nearest */
  37464. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37465. /** mag = nearest and min = linear and mip = nearest */
  37466. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37467. /** mag = nearest and min = linear and mip = linear */
  37468. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37469. /** mag = nearest and min = linear and mip = none */
  37470. static readonly TEXTURE_NEAREST_LINEAR: number;
  37471. /** mag = nearest and min = nearest and mip = none */
  37472. static readonly TEXTURE_NEAREST_NEAREST: number;
  37473. /** mag = linear and min = nearest and mip = nearest */
  37474. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37475. /** mag = linear and min = nearest and mip = linear */
  37476. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37477. /** mag = linear and min = linear and mip = none */
  37478. static readonly TEXTURE_LINEAR_LINEAR: number;
  37479. /** mag = linear and min = nearest and mip = none */
  37480. static readonly TEXTURE_LINEAR_NEAREST: number;
  37481. /** Explicit coordinates mode */
  37482. static readonly TEXTURE_EXPLICIT_MODE: number;
  37483. /** Spherical coordinates mode */
  37484. static readonly TEXTURE_SPHERICAL_MODE: number;
  37485. /** Planar coordinates mode */
  37486. static readonly TEXTURE_PLANAR_MODE: number;
  37487. /** Cubic coordinates mode */
  37488. static readonly TEXTURE_CUBIC_MODE: number;
  37489. /** Projection coordinates mode */
  37490. static readonly TEXTURE_PROJECTION_MODE: number;
  37491. /** Skybox coordinates mode */
  37492. static readonly TEXTURE_SKYBOX_MODE: number;
  37493. /** Inverse Cubic coordinates mode */
  37494. static readonly TEXTURE_INVCUBIC_MODE: number;
  37495. /** Equirectangular coordinates mode */
  37496. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37497. /** Equirectangular Fixed coordinates mode */
  37498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37499. /** Equirectangular Fixed Mirrored coordinates mode */
  37500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37501. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37502. static readonly SCALEMODE_FLOOR: number;
  37503. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37504. static readonly SCALEMODE_NEAREST: number;
  37505. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37506. static readonly SCALEMODE_CEILING: number;
  37507. /**
  37508. * Returns the current npm package of the sdk
  37509. */
  37510. static get NpmPackage(): string;
  37511. /**
  37512. * Returns the current version of the framework
  37513. */
  37514. static get Version(): string;
  37515. /** Gets the list of created engines */
  37516. static get Instances(): Engine[];
  37517. /**
  37518. * Gets the latest created engine
  37519. */
  37520. static get LastCreatedEngine(): Nullable<Engine>;
  37521. /**
  37522. * Gets the latest created scene
  37523. */
  37524. static get LastCreatedScene(): Nullable<Scene>;
  37525. /**
  37526. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37527. * @param flag defines which part of the materials must be marked as dirty
  37528. * @param predicate defines a predicate used to filter which materials should be affected
  37529. */
  37530. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37531. /**
  37532. * Method called to create the default loading screen.
  37533. * This can be overriden in your own app.
  37534. * @param canvas The rendering canvas element
  37535. * @returns The loading screen
  37536. */
  37537. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37538. /**
  37539. * Method called to create the default rescale post process on each engine.
  37540. */
  37541. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37542. /**
  37543. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37544. **/
  37545. enableOfflineSupport: boolean;
  37546. /**
  37547. * 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)
  37548. **/
  37549. disableManifestCheck: boolean;
  37550. /**
  37551. * Gets the list of created scenes
  37552. */
  37553. scenes: Scene[];
  37554. /**
  37555. * Event raised when a new scene is created
  37556. */
  37557. onNewSceneAddedObservable: Observable<Scene>;
  37558. /**
  37559. * Gets the list of created postprocesses
  37560. */
  37561. postProcesses: PostProcess[];
  37562. /**
  37563. * Gets a boolean indicating if the pointer is currently locked
  37564. */
  37565. isPointerLock: boolean;
  37566. /**
  37567. * Observable event triggered each time the rendering canvas is resized
  37568. */
  37569. onResizeObservable: Observable<Engine>;
  37570. /**
  37571. * Observable event triggered each time the canvas loses focus
  37572. */
  37573. onCanvasBlurObservable: Observable<Engine>;
  37574. /**
  37575. * Observable event triggered each time the canvas gains focus
  37576. */
  37577. onCanvasFocusObservable: Observable<Engine>;
  37578. /**
  37579. * Observable event triggered each time the canvas receives pointerout event
  37580. */
  37581. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37582. /**
  37583. * Observable raised when the engine begins a new frame
  37584. */
  37585. onBeginFrameObservable: Observable<Engine>;
  37586. /**
  37587. * If set, will be used to request the next animation frame for the render loop
  37588. */
  37589. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37590. /**
  37591. * Observable raised when the engine ends the current frame
  37592. */
  37593. onEndFrameObservable: Observable<Engine>;
  37594. /**
  37595. * Observable raised when the engine is about to compile a shader
  37596. */
  37597. onBeforeShaderCompilationObservable: Observable<Engine>;
  37598. /**
  37599. * Observable raised when the engine has jsut compiled a shader
  37600. */
  37601. onAfterShaderCompilationObservable: Observable<Engine>;
  37602. /**
  37603. * Gets the audio engine
  37604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37605. * @ignorenaming
  37606. */
  37607. static audioEngine: IAudioEngine;
  37608. /**
  37609. * Default AudioEngine factory responsible of creating the Audio Engine.
  37610. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37611. */
  37612. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37613. /**
  37614. * Default offline support factory responsible of creating a tool used to store data locally.
  37615. * By default, this will create a Database object if the workload has been embedded.
  37616. */
  37617. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37618. private _loadingScreen;
  37619. private _pointerLockRequested;
  37620. private _rescalePostProcess;
  37621. private _deterministicLockstep;
  37622. private _lockstepMaxSteps;
  37623. private _timeStep;
  37624. protected get _supportsHardwareTextureRescaling(): boolean;
  37625. private _fps;
  37626. private _deltaTime;
  37627. /** @hidden */
  37628. _drawCalls: PerfCounter;
  37629. /** 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 */
  37630. canvasTabIndex: number;
  37631. /**
  37632. * Turn this value on if you want to pause FPS computation when in background
  37633. */
  37634. disablePerformanceMonitorInBackground: boolean;
  37635. private _performanceMonitor;
  37636. /**
  37637. * Gets the performance monitor attached to this engine
  37638. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37639. */
  37640. get performanceMonitor(): PerformanceMonitor;
  37641. private _onFocus;
  37642. private _onBlur;
  37643. private _onCanvasPointerOut;
  37644. private _onCanvasBlur;
  37645. private _onCanvasFocus;
  37646. private _onFullscreenChange;
  37647. private _onPointerLockChange;
  37648. /**
  37649. * Gets the HTML element used to attach event listeners
  37650. * @returns a HTML element
  37651. */
  37652. getInputElement(): Nullable<HTMLElement>;
  37653. /**
  37654. * Creates a new engine
  37655. * @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
  37656. * @param antialias defines enable antialiasing (default: false)
  37657. * @param options defines further options to be sent to the getContext() function
  37658. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37659. */
  37660. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37661. /**
  37662. * Gets current aspect ratio
  37663. * @param viewportOwner defines the camera to use to get the aspect ratio
  37664. * @param useScreen defines if screen size must be used (or the current render target if any)
  37665. * @returns a number defining the aspect ratio
  37666. */
  37667. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37668. /**
  37669. * Gets current screen aspect ratio
  37670. * @returns a number defining the aspect ratio
  37671. */
  37672. getScreenAspectRatio(): number;
  37673. /**
  37674. * Gets the client rect of the HTML canvas attached with the current webGL context
  37675. * @returns a client rectanglee
  37676. */
  37677. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37678. /**
  37679. * Gets the client rect of the HTML element used for events
  37680. * @returns a client rectanglee
  37681. */
  37682. getInputElementClientRect(): Nullable<ClientRect>;
  37683. /**
  37684. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37685. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37686. * @returns true if engine is in deterministic lock step mode
  37687. */
  37688. isDeterministicLockStep(): boolean;
  37689. /**
  37690. * Gets the max steps when engine is running in deterministic lock step
  37691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37692. * @returns the max steps
  37693. */
  37694. getLockstepMaxSteps(): number;
  37695. /**
  37696. * Returns the time in ms between steps when using deterministic lock step.
  37697. * @returns time step in (ms)
  37698. */
  37699. getTimeStep(): number;
  37700. /**
  37701. * Force the mipmap generation for the given render target texture
  37702. * @param texture defines the render target texture to use
  37703. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37704. */
  37705. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37706. /** States */
  37707. /**
  37708. * Set various states to the webGL context
  37709. * @param culling defines backface culling state
  37710. * @param zOffset defines the value to apply to zOffset (0 by default)
  37711. * @param force defines if states must be applied even if cache is up to date
  37712. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37713. */
  37714. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37715. /**
  37716. * Set the z offset to apply to current rendering
  37717. * @param value defines the offset to apply
  37718. */
  37719. setZOffset(value: number): void;
  37720. /**
  37721. * Gets the current value of the zOffset
  37722. * @returns the current zOffset state
  37723. */
  37724. getZOffset(): number;
  37725. /**
  37726. * Enable or disable depth buffering
  37727. * @param enable defines the state to set
  37728. */
  37729. setDepthBuffer(enable: boolean): void;
  37730. /**
  37731. * Gets a boolean indicating if depth writing is enabled
  37732. * @returns the current depth writing state
  37733. */
  37734. getDepthWrite(): boolean;
  37735. /**
  37736. * Enable or disable depth writing
  37737. * @param enable defines the state to set
  37738. */
  37739. setDepthWrite(enable: boolean): void;
  37740. /**
  37741. * Gets a boolean indicating if stencil buffer is enabled
  37742. * @returns the current stencil buffer state
  37743. */
  37744. getStencilBuffer(): boolean;
  37745. /**
  37746. * Enable or disable the stencil buffer
  37747. * @param enable defines if the stencil buffer must be enabled or disabled
  37748. */
  37749. setStencilBuffer(enable: boolean): void;
  37750. /**
  37751. * Gets the current stencil mask
  37752. * @returns a number defining the new stencil mask to use
  37753. */
  37754. getStencilMask(): number;
  37755. /**
  37756. * Sets the current stencil mask
  37757. * @param mask defines the new stencil mask to use
  37758. */
  37759. setStencilMask(mask: number): void;
  37760. /**
  37761. * Gets the current stencil function
  37762. * @returns a number defining the stencil function to use
  37763. */
  37764. getStencilFunction(): number;
  37765. /**
  37766. * Gets the current stencil reference value
  37767. * @returns a number defining the stencil reference value to use
  37768. */
  37769. getStencilFunctionReference(): number;
  37770. /**
  37771. * Gets the current stencil mask
  37772. * @returns a number defining the stencil mask to use
  37773. */
  37774. getStencilFunctionMask(): number;
  37775. /**
  37776. * Sets the current stencil function
  37777. * @param stencilFunc defines the new stencil function to use
  37778. */
  37779. setStencilFunction(stencilFunc: number): void;
  37780. /**
  37781. * Sets the current stencil reference
  37782. * @param reference defines the new stencil reference to use
  37783. */
  37784. setStencilFunctionReference(reference: number): void;
  37785. /**
  37786. * Sets the current stencil mask
  37787. * @param mask defines the new stencil mask to use
  37788. */
  37789. setStencilFunctionMask(mask: number): void;
  37790. /**
  37791. * Gets the current stencil operation when stencil fails
  37792. * @returns a number defining stencil operation to use when stencil fails
  37793. */
  37794. getStencilOperationFail(): number;
  37795. /**
  37796. * Gets the current stencil operation when depth fails
  37797. * @returns a number defining stencil operation to use when depth fails
  37798. */
  37799. getStencilOperationDepthFail(): number;
  37800. /**
  37801. * Gets the current stencil operation when stencil passes
  37802. * @returns a number defining stencil operation to use when stencil passes
  37803. */
  37804. getStencilOperationPass(): number;
  37805. /**
  37806. * Sets the stencil operation to use when stencil fails
  37807. * @param operation defines the stencil operation to use when stencil fails
  37808. */
  37809. setStencilOperationFail(operation: number): void;
  37810. /**
  37811. * Sets the stencil operation to use when depth fails
  37812. * @param operation defines the stencil operation to use when depth fails
  37813. */
  37814. setStencilOperationDepthFail(operation: number): void;
  37815. /**
  37816. * Sets the stencil operation to use when stencil passes
  37817. * @param operation defines the stencil operation to use when stencil passes
  37818. */
  37819. setStencilOperationPass(operation: number): void;
  37820. /**
  37821. * Sets a boolean indicating if the dithering state is enabled or disabled
  37822. * @param value defines the dithering state
  37823. */
  37824. setDitheringState(value: boolean): void;
  37825. /**
  37826. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37827. * @param value defines the rasterizer state
  37828. */
  37829. setRasterizerState(value: boolean): void;
  37830. /**
  37831. * Gets the current depth function
  37832. * @returns a number defining the depth function
  37833. */
  37834. getDepthFunction(): Nullable<number>;
  37835. /**
  37836. * Sets the current depth function
  37837. * @param depthFunc defines the function to use
  37838. */
  37839. setDepthFunction(depthFunc: number): void;
  37840. /**
  37841. * Sets the current depth function to GREATER
  37842. */
  37843. setDepthFunctionToGreater(): void;
  37844. /**
  37845. * Sets the current depth function to GEQUAL
  37846. */
  37847. setDepthFunctionToGreaterOrEqual(): void;
  37848. /**
  37849. * Sets the current depth function to LESS
  37850. */
  37851. setDepthFunctionToLess(): void;
  37852. /**
  37853. * Sets the current depth function to LEQUAL
  37854. */
  37855. setDepthFunctionToLessOrEqual(): void;
  37856. private _cachedStencilBuffer;
  37857. private _cachedStencilFunction;
  37858. private _cachedStencilMask;
  37859. private _cachedStencilOperationPass;
  37860. private _cachedStencilOperationFail;
  37861. private _cachedStencilOperationDepthFail;
  37862. private _cachedStencilReference;
  37863. /**
  37864. * Caches the the state of the stencil buffer
  37865. */
  37866. cacheStencilState(): void;
  37867. /**
  37868. * Restores the state of the stencil buffer
  37869. */
  37870. restoreStencilState(): void;
  37871. /**
  37872. * Directly set the WebGL Viewport
  37873. * @param x defines the x coordinate of the viewport (in screen space)
  37874. * @param y defines the y coordinate of the viewport (in screen space)
  37875. * @param width defines the width of the viewport (in screen space)
  37876. * @param height defines the height of the viewport (in screen space)
  37877. * @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
  37878. */
  37879. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37880. /**
  37881. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37882. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37883. * @param y defines the y-coordinate of the corner of the clear rectangle
  37884. * @param width defines the width of the clear rectangle
  37885. * @param height defines the height of the clear rectangle
  37886. * @param clearColor defines the clear color
  37887. */
  37888. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37889. /**
  37890. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37891. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37892. * @param y defines the y-coordinate of the corner of the clear rectangle
  37893. * @param width defines the width of the clear rectangle
  37894. * @param height defines the height of the clear rectangle
  37895. */
  37896. enableScissor(x: number, y: number, width: number, height: number): void;
  37897. /**
  37898. * Disable previously set scissor test rectangle
  37899. */
  37900. disableScissor(): void;
  37901. protected _reportDrawCall(): void;
  37902. /**
  37903. * Initializes a webVR display and starts listening to display change events
  37904. * The onVRDisplayChangedObservable will be notified upon these changes
  37905. * @returns The onVRDisplayChangedObservable
  37906. */
  37907. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37908. /** @hidden */
  37909. _prepareVRComponent(): void;
  37910. /** @hidden */
  37911. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37912. /** @hidden */
  37913. _submitVRFrame(): void;
  37914. /**
  37915. * Call this function to leave webVR mode
  37916. * Will do nothing if webVR is not supported or if there is no webVR device
  37917. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37918. */
  37919. disableVR(): void;
  37920. /**
  37921. * Gets a boolean indicating that the system is in VR mode and is presenting
  37922. * @returns true if VR mode is engaged
  37923. */
  37924. isVRPresenting(): boolean;
  37925. /** @hidden */
  37926. _requestVRFrame(): void;
  37927. /** @hidden */
  37928. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37929. /**
  37930. * Gets the source code of the vertex shader associated with a specific webGL program
  37931. * @param program defines the program to use
  37932. * @returns a string containing the source code of the vertex shader associated with the program
  37933. */
  37934. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37935. /**
  37936. * Gets the source code of the fragment shader associated with a specific webGL program
  37937. * @param program defines the program to use
  37938. * @returns a string containing the source code of the fragment shader associated with the program
  37939. */
  37940. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37941. /**
  37942. * Sets a depth stencil texture from a render target to the according uniform.
  37943. * @param channel The texture channel
  37944. * @param uniform The uniform to set
  37945. * @param texture The render target texture containing the depth stencil texture to apply
  37946. */
  37947. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37948. /**
  37949. * Sets a texture to the webGL context from a postprocess
  37950. * @param channel defines the channel to use
  37951. * @param postProcess defines the source postprocess
  37952. */
  37953. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37954. /**
  37955. * Binds the output of the passed in post process to the texture channel specified
  37956. * @param channel The channel the texture should be bound to
  37957. * @param postProcess The post process which's output should be bound
  37958. */
  37959. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37960. protected _rebuildBuffers(): void;
  37961. /** @hidden */
  37962. _renderFrame(): void;
  37963. _renderLoop(): void;
  37964. /** @hidden */
  37965. _renderViews(): boolean;
  37966. /**
  37967. * Toggle full screen mode
  37968. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37969. */
  37970. switchFullscreen(requestPointerLock: boolean): void;
  37971. /**
  37972. * Enters full screen mode
  37973. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37974. */
  37975. enterFullscreen(requestPointerLock: boolean): void;
  37976. /**
  37977. * Exits full screen mode
  37978. */
  37979. exitFullscreen(): void;
  37980. /**
  37981. * Enters Pointerlock mode
  37982. */
  37983. enterPointerlock(): void;
  37984. /**
  37985. * Exits Pointerlock mode
  37986. */
  37987. exitPointerlock(): void;
  37988. /**
  37989. * Begin a new frame
  37990. */
  37991. beginFrame(): void;
  37992. /**
  37993. * Enf the current frame
  37994. */
  37995. endFrame(): void;
  37996. resize(): void;
  37997. /**
  37998. * Force a specific size of the canvas
  37999. * @param width defines the new canvas' width
  38000. * @param height defines the new canvas' height
  38001. * @returns true if the size was changed
  38002. */
  38003. setSize(width: number, height: number): boolean;
  38004. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38005. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38006. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38007. _releaseTexture(texture: InternalTexture): void;
  38008. /**
  38009. * @hidden
  38010. * Rescales a texture
  38011. * @param source input texutre
  38012. * @param destination destination texture
  38013. * @param scene scene to use to render the resize
  38014. * @param internalFormat format to use when resizing
  38015. * @param onComplete callback to be called when resize has completed
  38016. */
  38017. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38018. /**
  38019. * Gets the current framerate
  38020. * @returns a number representing the framerate
  38021. */
  38022. getFps(): number;
  38023. /**
  38024. * Gets the time spent between current and previous frame
  38025. * @returns a number representing the delta time in ms
  38026. */
  38027. getDeltaTime(): number;
  38028. private _measureFps;
  38029. /** @hidden */
  38030. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38031. /**
  38032. * Updates the sample count of a render target texture
  38033. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38034. * @param texture defines the texture to update
  38035. * @param samples defines the sample count to set
  38036. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38037. */
  38038. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38039. /**
  38040. * Updates a depth texture Comparison Mode and Function.
  38041. * If the comparison Function is equal to 0, the mode will be set to none.
  38042. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38043. * @param texture The texture to set the comparison function for
  38044. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38045. */
  38046. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38047. /**
  38048. * Creates a webGL buffer to use with instanciation
  38049. * @param capacity defines the size of the buffer
  38050. * @returns the webGL buffer
  38051. */
  38052. createInstancesBuffer(capacity: number): DataBuffer;
  38053. /**
  38054. * Delete a webGL buffer used with instanciation
  38055. * @param buffer defines the webGL buffer to delete
  38056. */
  38057. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38058. private _clientWaitAsync;
  38059. /** @hidden */
  38060. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38061. dispose(): void;
  38062. private _disableTouchAction;
  38063. /**
  38064. * Display the loading screen
  38065. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38066. */
  38067. displayLoadingUI(): void;
  38068. /**
  38069. * Hide the loading screen
  38070. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38071. */
  38072. hideLoadingUI(): void;
  38073. /**
  38074. * Gets the current loading screen object
  38075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38076. */
  38077. get loadingScreen(): ILoadingScreen;
  38078. /**
  38079. * Sets the current loading screen object
  38080. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38081. */
  38082. set loadingScreen(loadingScreen: ILoadingScreen);
  38083. /**
  38084. * Sets the current loading screen text
  38085. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38086. */
  38087. set loadingUIText(text: string);
  38088. /**
  38089. * Sets the current loading screen background color
  38090. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38091. */
  38092. set loadingUIBackgroundColor(color: string);
  38093. /** Pointerlock and fullscreen */
  38094. /**
  38095. * Ask the browser to promote the current element to pointerlock mode
  38096. * @param element defines the DOM element to promote
  38097. */
  38098. static _RequestPointerlock(element: HTMLElement): void;
  38099. /**
  38100. * Asks the browser to exit pointerlock mode
  38101. */
  38102. static _ExitPointerlock(): void;
  38103. /**
  38104. * Ask the browser to promote the current element to fullscreen rendering mode
  38105. * @param element defines the DOM element to promote
  38106. */
  38107. static _RequestFullscreen(element: HTMLElement): void;
  38108. /**
  38109. * Asks the browser to exit fullscreen mode
  38110. */
  38111. static _ExitFullscreen(): void;
  38112. }
  38113. }
  38114. declare module BABYLON {
  38115. /**
  38116. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38117. * during the life time of the application.
  38118. */
  38119. export class EngineStore {
  38120. /** Gets the list of created engines */
  38121. static Instances: Engine[];
  38122. /** @hidden */
  38123. static _LastCreatedScene: Nullable<Scene>;
  38124. /**
  38125. * Gets the latest created engine
  38126. */
  38127. static get LastCreatedEngine(): Nullable<Engine>;
  38128. /**
  38129. * Gets the latest created scene
  38130. */
  38131. static get LastCreatedScene(): Nullable<Scene>;
  38132. /**
  38133. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38134. * @ignorenaming
  38135. */
  38136. static UseFallbackTexture: boolean;
  38137. /**
  38138. * Texture content used if a texture cannot loaded
  38139. * @ignorenaming
  38140. */
  38141. static FallbackTexture: string;
  38142. }
  38143. }
  38144. declare module BABYLON {
  38145. /**
  38146. * Helper class that provides a small promise polyfill
  38147. */
  38148. export class PromisePolyfill {
  38149. /**
  38150. * Static function used to check if the polyfill is required
  38151. * If this is the case then the function will inject the polyfill to window.Promise
  38152. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38153. */
  38154. static Apply(force?: boolean): void;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Interface for screenshot methods with describe argument called `size` as object with options
  38160. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38161. */
  38162. export interface IScreenshotSize {
  38163. /**
  38164. * number in pixels for canvas height
  38165. */
  38166. height?: number;
  38167. /**
  38168. * multiplier allowing render at a higher or lower resolution
  38169. * If value is defined then height and width will be ignored and taken from camera
  38170. */
  38171. precision?: number;
  38172. /**
  38173. * number in pixels for canvas width
  38174. */
  38175. width?: number;
  38176. }
  38177. }
  38178. declare module BABYLON {
  38179. interface IColor4Like {
  38180. r: float;
  38181. g: float;
  38182. b: float;
  38183. a: float;
  38184. }
  38185. /**
  38186. * Class containing a set of static utilities functions
  38187. */
  38188. export class Tools {
  38189. /**
  38190. * Gets or sets the base URL to use to load assets
  38191. */
  38192. static get BaseUrl(): string;
  38193. static set BaseUrl(value: string);
  38194. /**
  38195. * Enable/Disable Custom HTTP Request Headers globally.
  38196. * default = false
  38197. * @see CustomRequestHeaders
  38198. */
  38199. static UseCustomRequestHeaders: boolean;
  38200. /**
  38201. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38202. * i.e. when loading files, where the server/service expects an Authorization header
  38203. */
  38204. static CustomRequestHeaders: {
  38205. [key: string]: string;
  38206. };
  38207. /**
  38208. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38209. */
  38210. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38211. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38212. /**
  38213. * Default behaviour for cors in the application.
  38214. * It can be a string if the expected behavior is identical in the entire app.
  38215. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38216. */
  38217. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38218. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38219. /**
  38220. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38221. * @ignorenaming
  38222. */
  38223. static get UseFallbackTexture(): boolean;
  38224. static set UseFallbackTexture(value: boolean);
  38225. /**
  38226. * Use this object to register external classes like custom textures or material
  38227. * to allow the laoders to instantiate them
  38228. */
  38229. static get RegisteredExternalClasses(): {
  38230. [key: string]: Object;
  38231. };
  38232. static set RegisteredExternalClasses(classes: {
  38233. [key: string]: Object;
  38234. });
  38235. /**
  38236. * Texture content used if a texture cannot loaded
  38237. * @ignorenaming
  38238. */
  38239. static get fallbackTexture(): string;
  38240. static set fallbackTexture(value: string);
  38241. /**
  38242. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38243. * @param u defines the coordinate on X axis
  38244. * @param v defines the coordinate on Y axis
  38245. * @param width defines the width of the source data
  38246. * @param height defines the height of the source data
  38247. * @param pixels defines the source byte array
  38248. * @param color defines the output color
  38249. */
  38250. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38251. /**
  38252. * Interpolates between a and b via alpha
  38253. * @param a The lower value (returned when alpha = 0)
  38254. * @param b The upper value (returned when alpha = 1)
  38255. * @param alpha The interpolation-factor
  38256. * @return The mixed value
  38257. */
  38258. static Mix(a: number, b: number, alpha: number): number;
  38259. /**
  38260. * Tries to instantiate a new object from a given class name
  38261. * @param className defines the class name to instantiate
  38262. * @returns the new object or null if the system was not able to do the instantiation
  38263. */
  38264. static Instantiate(className: string): any;
  38265. /**
  38266. * Provides a slice function that will work even on IE
  38267. * @param data defines the array to slice
  38268. * @param start defines the start of the data (optional)
  38269. * @param end defines the end of the data (optional)
  38270. * @returns the new sliced array
  38271. */
  38272. static Slice<T>(data: T, start?: number, end?: number): T;
  38273. /**
  38274. * Polyfill for setImmediate
  38275. * @param action defines the action to execute after the current execution block
  38276. */
  38277. static SetImmediate(action: () => void): void;
  38278. /**
  38279. * Function indicating if a number is an exponent of 2
  38280. * @param value defines the value to test
  38281. * @returns true if the value is an exponent of 2
  38282. */
  38283. static IsExponentOfTwo(value: number): boolean;
  38284. private static _tmpFloatArray;
  38285. /**
  38286. * Returns the nearest 32-bit single precision float representation of a Number
  38287. * @param value A Number. If the parameter is of a different type, it will get converted
  38288. * to a number or to NaN if it cannot be converted
  38289. * @returns number
  38290. */
  38291. static FloatRound(value: number): number;
  38292. /**
  38293. * Extracts the filename from a path
  38294. * @param path defines the path to use
  38295. * @returns the filename
  38296. */
  38297. static GetFilename(path: string): string;
  38298. /**
  38299. * Extracts the "folder" part of a path (everything before the filename).
  38300. * @param uri The URI to extract the info from
  38301. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38302. * @returns The "folder" part of the path
  38303. */
  38304. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38305. /**
  38306. * Extracts text content from a DOM element hierarchy
  38307. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38308. */
  38309. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38310. /**
  38311. * Convert an angle in radians to degrees
  38312. * @param angle defines the angle to convert
  38313. * @returns the angle in degrees
  38314. */
  38315. static ToDegrees(angle: number): number;
  38316. /**
  38317. * Convert an angle in degrees to radians
  38318. * @param angle defines the angle to convert
  38319. * @returns the angle in radians
  38320. */
  38321. static ToRadians(angle: number): number;
  38322. /**
  38323. * Returns an array if obj is not an array
  38324. * @param obj defines the object to evaluate as an array
  38325. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38326. * @returns either obj directly if obj is an array or a new array containing obj
  38327. */
  38328. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38329. /**
  38330. * Gets the pointer prefix to use
  38331. * @param engine defines the engine we are finding the prefix for
  38332. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38333. */
  38334. static GetPointerPrefix(engine: Engine): string;
  38335. /**
  38336. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38337. * @param url define the url we are trying
  38338. * @param element define the dom element where to configure the cors policy
  38339. */
  38340. static SetCorsBehavior(url: string | string[], element: {
  38341. crossOrigin: string | null;
  38342. }): void;
  38343. /**
  38344. * Removes unwanted characters from an url
  38345. * @param url defines the url to clean
  38346. * @returns the cleaned url
  38347. */
  38348. static CleanUrl(url: string): string;
  38349. /**
  38350. * Gets or sets a function used to pre-process url before using them to load assets
  38351. */
  38352. static get PreprocessUrl(): (url: string) => string;
  38353. static set PreprocessUrl(processor: (url: string) => string);
  38354. /**
  38355. * Loads an image as an HTMLImageElement.
  38356. * @param input url string, ArrayBuffer, or Blob to load
  38357. * @param onLoad callback called when the image successfully loads
  38358. * @param onError callback called when the image fails to load
  38359. * @param offlineProvider offline provider for caching
  38360. * @param mimeType optional mime type
  38361. * @returns the HTMLImageElement of the loaded image
  38362. */
  38363. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38364. /**
  38365. * Loads a file from a url
  38366. * @param url url string, ArrayBuffer, or Blob to load
  38367. * @param onSuccess callback called when the file successfully loads
  38368. * @param onProgress callback called while file is loading (if the server supports this mode)
  38369. * @param offlineProvider defines the offline provider for caching
  38370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38371. * @param onError callback called when the file fails to load
  38372. * @returns a file request object
  38373. */
  38374. 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;
  38375. /**
  38376. * Loads a file from a url
  38377. * @param url the file url to load
  38378. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38379. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38380. */
  38381. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38382. /**
  38383. * Load a script (identified by an url). When the url returns, the
  38384. * content of this file is added into a new script element, attached to the DOM (body element)
  38385. * @param scriptUrl defines the url of the script to laod
  38386. * @param onSuccess defines the callback called when the script is loaded
  38387. * @param onError defines the callback to call if an error occurs
  38388. * @param scriptId defines the id of the script element
  38389. */
  38390. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38391. /**
  38392. * Load an asynchronous script (identified by an url). When the url returns, the
  38393. * content of this file is added into a new script element, attached to the DOM (body element)
  38394. * @param scriptUrl defines the url of the script to laod
  38395. * @param scriptId defines the id of the script element
  38396. * @returns a promise request object
  38397. */
  38398. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38399. /**
  38400. * Loads a file from a blob
  38401. * @param fileToLoad defines the blob to use
  38402. * @param callback defines the callback to call when data is loaded
  38403. * @param progressCallback defines the callback to call during loading process
  38404. * @returns a file request object
  38405. */
  38406. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38407. /**
  38408. * Reads a file from a File object
  38409. * @param file defines the file to load
  38410. * @param onSuccess defines the callback to call when data is loaded
  38411. * @param onProgress defines the callback to call during loading process
  38412. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38413. * @param onError defines the callback to call when an error occurs
  38414. * @returns a file request object
  38415. */
  38416. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38417. /**
  38418. * Creates a data url from a given string content
  38419. * @param content defines the content to convert
  38420. * @returns the new data url link
  38421. */
  38422. static FileAsURL(content: string): string;
  38423. /**
  38424. * Format the given number to a specific decimal format
  38425. * @param value defines the number to format
  38426. * @param decimals defines the number of decimals to use
  38427. * @returns the formatted string
  38428. */
  38429. static Format(value: number, decimals?: number): string;
  38430. /**
  38431. * Tries to copy an object by duplicating every property
  38432. * @param source defines the source object
  38433. * @param destination defines the target object
  38434. * @param doNotCopyList defines a list of properties to avoid
  38435. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38436. */
  38437. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38438. /**
  38439. * Gets a boolean indicating if the given object has no own property
  38440. * @param obj defines the object to test
  38441. * @returns true if object has no own property
  38442. */
  38443. static IsEmpty(obj: any): boolean;
  38444. /**
  38445. * Function used to register events at window level
  38446. * @param windowElement defines the Window object to use
  38447. * @param events defines the events to register
  38448. */
  38449. static RegisterTopRootEvents(windowElement: Window, events: {
  38450. name: string;
  38451. handler: Nullable<(e: FocusEvent) => any>;
  38452. }[]): void;
  38453. /**
  38454. * Function used to unregister events from window level
  38455. * @param windowElement defines the Window object to use
  38456. * @param events defines the events to unregister
  38457. */
  38458. static UnregisterTopRootEvents(windowElement: Window, events: {
  38459. name: string;
  38460. handler: Nullable<(e: FocusEvent) => any>;
  38461. }[]): void;
  38462. /**
  38463. * @ignore
  38464. */
  38465. static _ScreenshotCanvas: HTMLCanvasElement;
  38466. /**
  38467. * Dumps the current bound framebuffer
  38468. * @param width defines the rendering width
  38469. * @param height defines the rendering height
  38470. * @param engine defines the hosting engine
  38471. * @param successCallback defines the callback triggered once the data are available
  38472. * @param mimeType defines the mime type of the result
  38473. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38474. */
  38475. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38476. /**
  38477. * Converts the canvas data to blob.
  38478. * This acts as a polyfill for browsers not supporting the to blob function.
  38479. * @param canvas Defines the canvas to extract the data from
  38480. * @param successCallback Defines the callback triggered once the data are available
  38481. * @param mimeType Defines the mime type of the result
  38482. */
  38483. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38484. /**
  38485. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38486. * @param successCallback defines the callback triggered once the data are available
  38487. * @param mimeType defines the mime type of the result
  38488. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38489. */
  38490. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38491. /**
  38492. * Downloads a blob in the browser
  38493. * @param blob defines the blob to download
  38494. * @param fileName defines the name of the downloaded file
  38495. */
  38496. static Download(blob: Blob, fileName: string): void;
  38497. /**
  38498. * Captures a screenshot of the current rendering
  38499. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38500. * @param engine defines the rendering engine
  38501. * @param camera defines the source camera
  38502. * @param size This parameter can be set to a single number or to an object with the
  38503. * following (optional) properties: precision, width, height. If a single number is passed,
  38504. * it will be used for both width and height. If an object is passed, the screenshot size
  38505. * will be derived from the parameters. The precision property is a multiplier allowing
  38506. * rendering at a higher or lower resolution
  38507. * @param successCallback defines the callback receives a single parameter which contains the
  38508. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38509. * src parameter of an <img> to display it
  38510. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38511. * Check your browser for supported MIME types
  38512. */
  38513. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38514. /**
  38515. * Captures a screenshot of the current rendering
  38516. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38517. * @param engine defines the rendering engine
  38518. * @param camera defines the source camera
  38519. * @param size This parameter can be set to a single number or to an object with the
  38520. * following (optional) properties: precision, width, height. If a single number is passed,
  38521. * it will be used for both width and height. If an object is passed, the screenshot size
  38522. * will be derived from the parameters. The precision property is a multiplier allowing
  38523. * rendering at a higher or lower resolution
  38524. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38525. * Check your browser for supported MIME types
  38526. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38527. * to the src parameter of an <img> to display it
  38528. */
  38529. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38530. /**
  38531. * Generates an image screenshot from the specified camera.
  38532. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38533. * @param engine The engine to use for rendering
  38534. * @param camera The camera to use for rendering
  38535. * @param size This parameter can be set to a single number or to an object with the
  38536. * following (optional) properties: precision, width, height. If a single number is passed,
  38537. * it will be used for both width and height. If an object is passed, the screenshot size
  38538. * will be derived from the parameters. The precision property is a multiplier allowing
  38539. * rendering at a higher or lower resolution
  38540. * @param successCallback The callback receives a single parameter which contains the
  38541. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38542. * src parameter of an <img> to display it
  38543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38544. * Check your browser for supported MIME types
  38545. * @param samples Texture samples (default: 1)
  38546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38547. * @param fileName A name for for the downloaded file.
  38548. */
  38549. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38550. /**
  38551. * Generates an image screenshot from the specified camera.
  38552. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38553. * @param engine The engine to use for rendering
  38554. * @param camera The camera to use for rendering
  38555. * @param size This parameter can be set to a single number or to an object with the
  38556. * following (optional) properties: precision, width, height. If a single number is passed,
  38557. * it will be used for both width and height. If an object is passed, the screenshot size
  38558. * will be derived from the parameters. The precision property is a multiplier allowing
  38559. * rendering at a higher or lower resolution
  38560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38561. * Check your browser for supported MIME types
  38562. * @param samples Texture samples (default: 1)
  38563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38564. * @param fileName A name for for the downloaded file.
  38565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38566. * to the src parameter of an <img> to display it
  38567. */
  38568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38569. /**
  38570. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38571. * Be aware Math.random() could cause collisions, but:
  38572. * "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"
  38573. * @returns a pseudo random id
  38574. */
  38575. static RandomId(): string;
  38576. /**
  38577. * Test if the given uri is a base64 string
  38578. * @param uri The uri to test
  38579. * @return True if the uri is a base64 string or false otherwise
  38580. */
  38581. static IsBase64(uri: string): boolean;
  38582. /**
  38583. * Decode the given base64 uri.
  38584. * @param uri The uri to decode
  38585. * @return The decoded base64 data.
  38586. */
  38587. static DecodeBase64(uri: string): ArrayBuffer;
  38588. /**
  38589. * Gets the absolute url.
  38590. * @param url the input url
  38591. * @return the absolute url
  38592. */
  38593. static GetAbsoluteUrl(url: string): string;
  38594. /**
  38595. * No log
  38596. */
  38597. static readonly NoneLogLevel: number;
  38598. /**
  38599. * Only message logs
  38600. */
  38601. static readonly MessageLogLevel: number;
  38602. /**
  38603. * Only warning logs
  38604. */
  38605. static readonly WarningLogLevel: number;
  38606. /**
  38607. * Only error logs
  38608. */
  38609. static readonly ErrorLogLevel: number;
  38610. /**
  38611. * All logs
  38612. */
  38613. static readonly AllLogLevel: number;
  38614. /**
  38615. * Gets a value indicating the number of loading errors
  38616. * @ignorenaming
  38617. */
  38618. static get errorsCount(): number;
  38619. /**
  38620. * Callback called when a new log is added
  38621. */
  38622. static OnNewCacheEntry: (entry: string) => void;
  38623. /**
  38624. * Log a message to the console
  38625. * @param message defines the message to log
  38626. */
  38627. static Log(message: string): void;
  38628. /**
  38629. * Write a warning message to the console
  38630. * @param message defines the message to log
  38631. */
  38632. static Warn(message: string): void;
  38633. /**
  38634. * Write an error message to the console
  38635. * @param message defines the message to log
  38636. */
  38637. static Error(message: string): void;
  38638. /**
  38639. * Gets current log cache (list of logs)
  38640. */
  38641. static get LogCache(): string;
  38642. /**
  38643. * Clears the log cache
  38644. */
  38645. static ClearLogCache(): void;
  38646. /**
  38647. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38648. */
  38649. static set LogLevels(level: number);
  38650. /**
  38651. * Checks if the window object exists
  38652. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38653. */
  38654. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38655. /**
  38656. * No performance log
  38657. */
  38658. static readonly PerformanceNoneLogLevel: number;
  38659. /**
  38660. * Use user marks to log performance
  38661. */
  38662. static readonly PerformanceUserMarkLogLevel: number;
  38663. /**
  38664. * Log performance to the console
  38665. */
  38666. static readonly PerformanceConsoleLogLevel: number;
  38667. private static _performance;
  38668. /**
  38669. * Sets the current performance log level
  38670. */
  38671. static set PerformanceLogLevel(level: number);
  38672. private static _StartPerformanceCounterDisabled;
  38673. private static _EndPerformanceCounterDisabled;
  38674. private static _StartUserMark;
  38675. private static _EndUserMark;
  38676. private static _StartPerformanceConsole;
  38677. private static _EndPerformanceConsole;
  38678. /**
  38679. * Starts a performance counter
  38680. */
  38681. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38682. /**
  38683. * Ends a specific performance coutner
  38684. */
  38685. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38686. /**
  38687. * Gets either window.performance.now() if supported or Date.now() else
  38688. */
  38689. static get Now(): number;
  38690. /**
  38691. * This method will return the name of the class used to create the instance of the given object.
  38692. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38693. * @param object the object to get the class name from
  38694. * @param isType defines if the object is actually a type
  38695. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38696. */
  38697. static GetClassName(object: any, isType?: boolean): string;
  38698. /**
  38699. * Gets the first element of an array satisfying a given predicate
  38700. * @param array defines the array to browse
  38701. * @param predicate defines the predicate to use
  38702. * @returns null if not found or the element
  38703. */
  38704. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38705. /**
  38706. * This method will return the name of the full name of the class, including its owning module (if any).
  38707. * 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).
  38708. * @param object the object to get the class name from
  38709. * @param isType defines if the object is actually a type
  38710. * @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.
  38711. * @ignorenaming
  38712. */
  38713. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38714. /**
  38715. * Returns a promise that resolves after the given amount of time.
  38716. * @param delay Number of milliseconds to delay
  38717. * @returns Promise that resolves after the given amount of time
  38718. */
  38719. static DelayAsync(delay: number): Promise<void>;
  38720. /**
  38721. * Utility function to detect if the current user agent is Safari
  38722. * @returns whether or not the current user agent is safari
  38723. */
  38724. static IsSafari(): boolean;
  38725. }
  38726. /**
  38727. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38728. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38729. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38730. * @param name The name of the class, case should be preserved
  38731. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38732. */
  38733. export function className(name: string, module?: string): (target: Object) => void;
  38734. /**
  38735. * An implementation of a loop for asynchronous functions.
  38736. */
  38737. export class AsyncLoop {
  38738. /**
  38739. * Defines the number of iterations for the loop
  38740. */
  38741. iterations: number;
  38742. /**
  38743. * Defines the current index of the loop.
  38744. */
  38745. index: number;
  38746. private _done;
  38747. private _fn;
  38748. private _successCallback;
  38749. /**
  38750. * Constructor.
  38751. * @param iterations the number of iterations.
  38752. * @param func the function to run each iteration
  38753. * @param successCallback the callback that will be called upon succesful execution
  38754. * @param offset starting offset.
  38755. */
  38756. constructor(
  38757. /**
  38758. * Defines the number of iterations for the loop
  38759. */
  38760. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38761. /**
  38762. * Execute the next iteration. Must be called after the last iteration was finished.
  38763. */
  38764. executeNext(): void;
  38765. /**
  38766. * Break the loop and run the success callback.
  38767. */
  38768. breakLoop(): void;
  38769. /**
  38770. * Create and run an async loop.
  38771. * @param iterations the number of iterations.
  38772. * @param fn the function to run each iteration
  38773. * @param successCallback the callback that will be called upon succesful execution
  38774. * @param offset starting offset.
  38775. * @returns the created async loop object
  38776. */
  38777. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38778. /**
  38779. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38780. * @param iterations total number of iterations
  38781. * @param syncedIterations number of synchronous iterations in each async iteration.
  38782. * @param fn the function to call each iteration.
  38783. * @param callback a success call back that will be called when iterating stops.
  38784. * @param breakFunction a break condition (optional)
  38785. * @param timeout timeout settings for the setTimeout function. default - 0.
  38786. * @returns the created async loop object
  38787. */
  38788. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38794. * The underlying implementation relies on an associative array to ensure the best performances.
  38795. * The value can be anything including 'null' but except 'undefined'
  38796. */
  38797. export class StringDictionary<T> {
  38798. /**
  38799. * This will clear this dictionary and copy the content from the 'source' one.
  38800. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38801. * @param source the dictionary to take the content from and copy to this dictionary
  38802. */
  38803. copyFrom(source: StringDictionary<T>): void;
  38804. /**
  38805. * Get a value based from its key
  38806. * @param key the given key to get the matching value from
  38807. * @return the value if found, otherwise undefined is returned
  38808. */
  38809. get(key: string): T | undefined;
  38810. /**
  38811. * Get a value from its key or add it if it doesn't exist.
  38812. * This method will ensure you that a given key/data will be present in the dictionary.
  38813. * @param key the given key to get the matching value from
  38814. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38815. * The factory will only be invoked if there's no data for the given key.
  38816. * @return the value corresponding to the key.
  38817. */
  38818. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38819. /**
  38820. * Get a value from its key if present in the dictionary otherwise add it
  38821. * @param key the key to get the value from
  38822. * @param val if there's no such key/value pair in the dictionary add it with this value
  38823. * @return the value corresponding to the key
  38824. */
  38825. getOrAdd(key: string, val: T): T;
  38826. /**
  38827. * Check if there's a given key in the dictionary
  38828. * @param key the key to check for
  38829. * @return true if the key is present, false otherwise
  38830. */
  38831. contains(key: string): boolean;
  38832. /**
  38833. * Add a new key and its corresponding value
  38834. * @param key the key to add
  38835. * @param value the value corresponding to the key
  38836. * @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
  38837. */
  38838. add(key: string, value: T): boolean;
  38839. /**
  38840. * Update a specific value associated to a key
  38841. * @param key defines the key to use
  38842. * @param value defines the value to store
  38843. * @returns true if the value was updated (or false if the key was not found)
  38844. */
  38845. set(key: string, value: T): boolean;
  38846. /**
  38847. * Get the element of the given key and remove it from the dictionary
  38848. * @param key defines the key to search
  38849. * @returns the value associated with the key or null if not found
  38850. */
  38851. getAndRemove(key: string): Nullable<T>;
  38852. /**
  38853. * Remove a key/value from the dictionary.
  38854. * @param key the key to remove
  38855. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38856. */
  38857. remove(key: string): boolean;
  38858. /**
  38859. * Clear the whole content of the dictionary
  38860. */
  38861. clear(): void;
  38862. /**
  38863. * Gets the current count
  38864. */
  38865. get count(): number;
  38866. /**
  38867. * Execute a callback on each key/val of the dictionary.
  38868. * Note that you can remove any element in this dictionary in the callback implementation
  38869. * @param callback the callback to execute on a given key/value pair
  38870. */
  38871. forEach(callback: (key: string, val: T) => void): void;
  38872. /**
  38873. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38874. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38875. * Note that you can remove any element in this dictionary in the callback implementation
  38876. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38877. * @returns the first item
  38878. */
  38879. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38880. private _count;
  38881. private _data;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /** @hidden */
  38886. export interface ICollisionCoordinator {
  38887. createCollider(): Collider;
  38888. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38889. init(scene: Scene): void;
  38890. }
  38891. /** @hidden */
  38892. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38893. private _scene;
  38894. private _scaledPosition;
  38895. private _scaledVelocity;
  38896. private _finalPosition;
  38897. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38898. createCollider(): Collider;
  38899. init(scene: Scene): void;
  38900. private _collideWithWorld;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * Class used to manage all inputs for the scene.
  38906. */
  38907. export class InputManager {
  38908. /** The distance in pixel that you have to move to prevent some events */
  38909. static DragMovementThreshold: number;
  38910. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38911. static LongPressDelay: number;
  38912. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38913. static DoubleClickDelay: number;
  38914. /** If you need to check double click without raising a single click at first click, enable this flag */
  38915. static ExclusiveDoubleClickMode: boolean;
  38916. /** 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. */
  38917. private _alreadyAttached;
  38918. private _wheelEventName;
  38919. private _onPointerMove;
  38920. private _onPointerDown;
  38921. private _onPointerUp;
  38922. private _initClickEvent;
  38923. private _initActionManager;
  38924. private _delayedSimpleClick;
  38925. private _delayedSimpleClickTimeout;
  38926. private _previousDelayedSimpleClickTimeout;
  38927. private _meshPickProceed;
  38928. private _previousButtonPressed;
  38929. private _currentPickResult;
  38930. private _previousPickResult;
  38931. private _totalPointersPressed;
  38932. private _doubleClickOccured;
  38933. private _pointerOverMesh;
  38934. private _pickedDownMesh;
  38935. private _pickedUpMesh;
  38936. private _pointerX;
  38937. private _pointerY;
  38938. private _unTranslatedPointerX;
  38939. private _unTranslatedPointerY;
  38940. private _startingPointerPosition;
  38941. private _previousStartingPointerPosition;
  38942. private _startingPointerTime;
  38943. private _previousStartingPointerTime;
  38944. private _pointerCaptures;
  38945. private _meshUnderPointerId;
  38946. private _onKeyDown;
  38947. private _onKeyUp;
  38948. private _onCanvasFocusObserver;
  38949. private _onCanvasBlurObserver;
  38950. private _scene;
  38951. /**
  38952. * Creates a new InputManager
  38953. * @param scene defines the hosting scene
  38954. */
  38955. constructor(scene: Scene);
  38956. /**
  38957. * Gets the mesh that is currently under the pointer
  38958. */
  38959. get meshUnderPointer(): Nullable<AbstractMesh>;
  38960. /**
  38961. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  38962. * @param pointerId the pointer id to use
  38963. * @returns The mesh under this pointer id or null if not found
  38964. */
  38965. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  38966. /**
  38967. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38968. */
  38969. get unTranslatedPointer(): Vector2;
  38970. /**
  38971. * Gets or sets the current on-screen X position of the pointer
  38972. */
  38973. get pointerX(): number;
  38974. set pointerX(value: number);
  38975. /**
  38976. * Gets or sets the current on-screen Y position of the pointer
  38977. */
  38978. get pointerY(): number;
  38979. set pointerY(value: number);
  38980. private _updatePointerPosition;
  38981. private _processPointerMove;
  38982. private _setRayOnPointerInfo;
  38983. private _checkPrePointerObservable;
  38984. /**
  38985. * Use this method to simulate a pointer move on a mesh
  38986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38989. */
  38990. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38991. /**
  38992. * Use this method to simulate a pointer down on a mesh
  38993. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38994. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38995. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38996. */
  38997. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38998. private _processPointerDown;
  38999. /** @hidden */
  39000. _isPointerSwiping(): boolean;
  39001. /**
  39002. * Use this method to simulate a pointer up on a mesh
  39003. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39004. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39005. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39006. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39007. */
  39008. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39009. private _processPointerUp;
  39010. /**
  39011. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39012. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39013. * @returns true if the pointer was captured
  39014. */
  39015. isPointerCaptured(pointerId?: number): boolean;
  39016. /**
  39017. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39018. * @param attachUp defines if you want to attach events to pointerup
  39019. * @param attachDown defines if you want to attach events to pointerdown
  39020. * @param attachMove defines if you want to attach events to pointermove
  39021. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39022. */
  39023. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39024. /**
  39025. * Detaches all event handlers
  39026. */
  39027. detachControl(): void;
  39028. /**
  39029. * Force the value of meshUnderPointer
  39030. * @param mesh defines the mesh to use
  39031. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39032. */
  39033. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39034. /**
  39035. * Gets the mesh under the pointer
  39036. * @returns a Mesh or null if no mesh is under the pointer
  39037. */
  39038. getPointerOverMesh(): Nullable<AbstractMesh>;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /**
  39043. * This class defines the direct association between an animation and a target
  39044. */
  39045. export class TargetedAnimation {
  39046. /**
  39047. * Animation to perform
  39048. */
  39049. animation: Animation;
  39050. /**
  39051. * Target to animate
  39052. */
  39053. target: any;
  39054. /**
  39055. * Returns the string "TargetedAnimation"
  39056. * @returns "TargetedAnimation"
  39057. */
  39058. getClassName(): string;
  39059. /**
  39060. * Serialize the object
  39061. * @returns the JSON object representing the current entity
  39062. */
  39063. serialize(): any;
  39064. }
  39065. /**
  39066. * Use this class to create coordinated animations on multiple targets
  39067. */
  39068. export class AnimationGroup implements IDisposable {
  39069. /** The name of the animation group */
  39070. name: string;
  39071. private _scene;
  39072. private _targetedAnimations;
  39073. private _animatables;
  39074. private _from;
  39075. private _to;
  39076. private _isStarted;
  39077. private _isPaused;
  39078. private _speedRatio;
  39079. private _loopAnimation;
  39080. private _isAdditive;
  39081. /**
  39082. * Gets or sets the unique id of the node
  39083. */
  39084. uniqueId: number;
  39085. /**
  39086. * This observable will notify when one animation have ended
  39087. */
  39088. onAnimationEndObservable: Observable<TargetedAnimation>;
  39089. /**
  39090. * Observer raised when one animation loops
  39091. */
  39092. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39093. /**
  39094. * Observer raised when all animations have looped
  39095. */
  39096. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39097. /**
  39098. * This observable will notify when all animations have ended.
  39099. */
  39100. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39101. /**
  39102. * This observable will notify when all animations have paused.
  39103. */
  39104. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39105. /**
  39106. * This observable will notify when all animations are playing.
  39107. */
  39108. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39109. /**
  39110. * Gets the first frame
  39111. */
  39112. get from(): number;
  39113. /**
  39114. * Gets the last frame
  39115. */
  39116. get to(): number;
  39117. /**
  39118. * Define if the animations are started
  39119. */
  39120. get isStarted(): boolean;
  39121. /**
  39122. * Gets a value indicating that the current group is playing
  39123. */
  39124. get isPlaying(): boolean;
  39125. /**
  39126. * Gets or sets the speed ratio to use for all animations
  39127. */
  39128. get speedRatio(): number;
  39129. /**
  39130. * Gets or sets the speed ratio to use for all animations
  39131. */
  39132. set speedRatio(value: number);
  39133. /**
  39134. * Gets or sets if all animations should loop or not
  39135. */
  39136. get loopAnimation(): boolean;
  39137. set loopAnimation(value: boolean);
  39138. /**
  39139. * Gets or sets if all animations should be evaluated additively
  39140. */
  39141. get isAdditive(): boolean;
  39142. set isAdditive(value: boolean);
  39143. /**
  39144. * Gets the targeted animations for this animation group
  39145. */
  39146. get targetedAnimations(): Array<TargetedAnimation>;
  39147. /**
  39148. * returning the list of animatables controlled by this animation group.
  39149. */
  39150. get animatables(): Array<Animatable>;
  39151. /**
  39152. * Gets the list of target animations
  39153. */
  39154. get children(): TargetedAnimation[];
  39155. /**
  39156. * Instantiates a new Animation Group.
  39157. * This helps managing several animations at once.
  39158. * @see https://doc.babylonjs.com/how_to/group
  39159. * @param name Defines the name of the group
  39160. * @param scene Defines the scene the group belongs to
  39161. */
  39162. constructor(
  39163. /** The name of the animation group */
  39164. name: string, scene?: Nullable<Scene>);
  39165. /**
  39166. * Add an animation (with its target) in the group
  39167. * @param animation defines the animation we want to add
  39168. * @param target defines the target of the animation
  39169. * @returns the TargetedAnimation object
  39170. */
  39171. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39172. /**
  39173. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39174. * It can add constant keys at begin or end
  39175. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39176. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39177. * @returns the animation group
  39178. */
  39179. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39180. private _animationLoopCount;
  39181. private _animationLoopFlags;
  39182. private _processLoop;
  39183. /**
  39184. * Start all animations on given targets
  39185. * @param loop defines if animations must loop
  39186. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39187. * @param from defines the from key (optional)
  39188. * @param to defines the to key (optional)
  39189. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39190. * @returns the current animation group
  39191. */
  39192. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39193. /**
  39194. * Pause all animations
  39195. * @returns the animation group
  39196. */
  39197. pause(): AnimationGroup;
  39198. /**
  39199. * Play all animations to initial state
  39200. * This function will start() the animations if they were not started or will restart() them if they were paused
  39201. * @param loop defines if animations must loop
  39202. * @returns the animation group
  39203. */
  39204. play(loop?: boolean): AnimationGroup;
  39205. /**
  39206. * Reset all animations to initial state
  39207. * @returns the animation group
  39208. */
  39209. reset(): AnimationGroup;
  39210. /**
  39211. * Restart animations from key 0
  39212. * @returns the animation group
  39213. */
  39214. restart(): AnimationGroup;
  39215. /**
  39216. * Stop all animations
  39217. * @returns the animation group
  39218. */
  39219. stop(): AnimationGroup;
  39220. /**
  39221. * Set animation weight for all animatables
  39222. * @param weight defines the weight to use
  39223. * @return the animationGroup
  39224. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39225. */
  39226. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39227. /**
  39228. * Synchronize and normalize all animatables with a source animatable
  39229. * @param root defines the root animatable to synchronize with
  39230. * @return the animationGroup
  39231. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39232. */
  39233. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39234. /**
  39235. * Goes to a specific frame in this animation group
  39236. * @param frame the frame number to go to
  39237. * @return the animationGroup
  39238. */
  39239. goToFrame(frame: number): AnimationGroup;
  39240. /**
  39241. * Dispose all associated resources
  39242. */
  39243. dispose(): void;
  39244. private _checkAnimationGroupEnded;
  39245. /**
  39246. * Clone the current animation group and returns a copy
  39247. * @param newName defines the name of the new group
  39248. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39249. * @returns the new aniamtion group
  39250. */
  39251. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39252. /**
  39253. * Serializes the animationGroup to an object
  39254. * @returns Serialized object
  39255. */
  39256. serialize(): any;
  39257. /**
  39258. * Returns a new AnimationGroup object parsed from the source provided.
  39259. * @param parsedAnimationGroup defines the source
  39260. * @param scene defines the scene that will receive the animationGroup
  39261. * @returns a new AnimationGroup
  39262. */
  39263. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39264. /**
  39265. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39266. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39267. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39268. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39269. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39270. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39271. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39272. */
  39273. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39274. /**
  39275. * Returns the string "AnimationGroup"
  39276. * @returns "AnimationGroup"
  39277. */
  39278. getClassName(): string;
  39279. /**
  39280. * Creates a detailled string about the object
  39281. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39282. * @returns a string representing the object
  39283. */
  39284. toString(fullDetails?: boolean): string;
  39285. }
  39286. }
  39287. declare module BABYLON {
  39288. /**
  39289. * Define an interface for all classes that will hold resources
  39290. */
  39291. export interface IDisposable {
  39292. /**
  39293. * Releases all held resources
  39294. */
  39295. dispose(): void;
  39296. }
  39297. /** Interface defining initialization parameters for Scene class */
  39298. export interface SceneOptions {
  39299. /**
  39300. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39301. * It will improve performance when the number of geometries becomes important.
  39302. */
  39303. useGeometryUniqueIdsMap?: boolean;
  39304. /**
  39305. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39306. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39307. */
  39308. useMaterialMeshMap?: boolean;
  39309. /**
  39310. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39311. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39312. */
  39313. useClonedMeshMap?: boolean;
  39314. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39315. virtual?: boolean;
  39316. }
  39317. /**
  39318. * Represents a scene to be rendered by the engine.
  39319. * @see https://doc.babylonjs.com/features/scene
  39320. */
  39321. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39322. /** The fog is deactivated */
  39323. static readonly FOGMODE_NONE: number;
  39324. /** The fog density is following an exponential function */
  39325. static readonly FOGMODE_EXP: number;
  39326. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39327. static readonly FOGMODE_EXP2: number;
  39328. /** The fog density is following a linear function. */
  39329. static readonly FOGMODE_LINEAR: number;
  39330. /**
  39331. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39332. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39333. */
  39334. static MinDeltaTime: number;
  39335. /**
  39336. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39337. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39338. */
  39339. static MaxDeltaTime: number;
  39340. /**
  39341. * Factory used to create the default material.
  39342. * @param name The name of the material to create
  39343. * @param scene The scene to create the material for
  39344. * @returns The default material
  39345. */
  39346. static DefaultMaterialFactory(scene: Scene): Material;
  39347. /**
  39348. * Factory used to create the a collision coordinator.
  39349. * @returns The collision coordinator
  39350. */
  39351. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39352. /** @hidden */
  39353. _inputManager: InputManager;
  39354. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39355. cameraToUseForPointers: Nullable<Camera>;
  39356. /** @hidden */
  39357. readonly _isScene: boolean;
  39358. /** @hidden */
  39359. _blockEntityCollection: boolean;
  39360. /**
  39361. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39362. */
  39363. autoClear: boolean;
  39364. /**
  39365. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39366. */
  39367. autoClearDepthAndStencil: boolean;
  39368. /**
  39369. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39370. */
  39371. clearColor: Color4;
  39372. /**
  39373. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39374. */
  39375. ambientColor: Color3;
  39376. /**
  39377. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39378. * It should only be one of the following (if not the default embedded one):
  39379. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39380. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39381. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39382. * The material properties need to be setup according to the type of texture in use.
  39383. */
  39384. environmentBRDFTexture: BaseTexture;
  39385. /**
  39386. * Texture used in all pbr material as the reflection texture.
  39387. * As in the majority of the scene they are the same (exception for multi room and so on),
  39388. * this is easier to reference from here than from all the materials.
  39389. */
  39390. get environmentTexture(): Nullable<BaseTexture>;
  39391. /**
  39392. * Texture used in all pbr material as the reflection texture.
  39393. * As in the majority of the scene they are the same (exception for multi room and so on),
  39394. * this is easier to set here than in all the materials.
  39395. */
  39396. set environmentTexture(value: Nullable<BaseTexture>);
  39397. /** @hidden */
  39398. protected _environmentIntensity: number;
  39399. /**
  39400. * Intensity of the environment in all pbr material.
  39401. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39402. * As in the majority of the scene they are the same (exception for multi room and so on),
  39403. * this is easier to reference from here than from all the materials.
  39404. */
  39405. get environmentIntensity(): number;
  39406. /**
  39407. * Intensity of the environment in all pbr material.
  39408. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39409. * As in the majority of the scene they are the same (exception for multi room and so on),
  39410. * this is easier to set here than in all the materials.
  39411. */
  39412. set environmentIntensity(value: number);
  39413. /** @hidden */
  39414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39415. /**
  39416. * Default image processing configuration used either in the rendering
  39417. * Forward main pass or through the imageProcessingPostProcess if present.
  39418. * As in the majority of the scene they are the same (exception for multi camera),
  39419. * this is easier to reference from here than from all the materials and post process.
  39420. *
  39421. * No setter as we it is a shared configuration, you can set the values instead.
  39422. */
  39423. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39424. private _forceWireframe;
  39425. /**
  39426. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39427. */
  39428. set forceWireframe(value: boolean);
  39429. get forceWireframe(): boolean;
  39430. private _skipFrustumClipping;
  39431. /**
  39432. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39433. */
  39434. set skipFrustumClipping(value: boolean);
  39435. get skipFrustumClipping(): boolean;
  39436. private _forcePointsCloud;
  39437. /**
  39438. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39439. */
  39440. set forcePointsCloud(value: boolean);
  39441. get forcePointsCloud(): boolean;
  39442. /**
  39443. * Gets or sets the active clipplane 1
  39444. */
  39445. clipPlane: Nullable<Plane>;
  39446. /**
  39447. * Gets or sets the active clipplane 2
  39448. */
  39449. clipPlane2: Nullable<Plane>;
  39450. /**
  39451. * Gets or sets the active clipplane 3
  39452. */
  39453. clipPlane3: Nullable<Plane>;
  39454. /**
  39455. * Gets or sets the active clipplane 4
  39456. */
  39457. clipPlane4: Nullable<Plane>;
  39458. /**
  39459. * Gets or sets the active clipplane 5
  39460. */
  39461. clipPlane5: Nullable<Plane>;
  39462. /**
  39463. * Gets or sets the active clipplane 6
  39464. */
  39465. clipPlane6: Nullable<Plane>;
  39466. /**
  39467. * Gets or sets a boolean indicating if animations are enabled
  39468. */
  39469. animationsEnabled: boolean;
  39470. private _animationPropertiesOverride;
  39471. /**
  39472. * Gets or sets the animation properties override
  39473. */
  39474. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39475. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39476. /**
  39477. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39478. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39479. */
  39480. useConstantAnimationDeltaTime: boolean;
  39481. /**
  39482. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39483. * Please note that it requires to run a ray cast through the scene on every frame
  39484. */
  39485. constantlyUpdateMeshUnderPointer: boolean;
  39486. /**
  39487. * Defines the HTML cursor to use when hovering over interactive elements
  39488. */
  39489. hoverCursor: string;
  39490. /**
  39491. * Defines the HTML default cursor to use (empty by default)
  39492. */
  39493. defaultCursor: string;
  39494. /**
  39495. * Defines whether cursors are handled by the scene.
  39496. */
  39497. doNotHandleCursors: boolean;
  39498. /**
  39499. * This is used to call preventDefault() on pointer down
  39500. * in order to block unwanted artifacts like system double clicks
  39501. */
  39502. preventDefaultOnPointerDown: boolean;
  39503. /**
  39504. * This is used to call preventDefault() on pointer up
  39505. * in order to block unwanted artifacts like system double clicks
  39506. */
  39507. preventDefaultOnPointerUp: boolean;
  39508. /**
  39509. * Gets or sets user defined metadata
  39510. */
  39511. metadata: any;
  39512. /**
  39513. * For internal use only. Please do not use.
  39514. */
  39515. reservedDataStore: any;
  39516. /**
  39517. * Gets the name of the plugin used to load this scene (null by default)
  39518. */
  39519. loadingPluginName: string;
  39520. /**
  39521. * Use this array to add regular expressions used to disable offline support for specific urls
  39522. */
  39523. disableOfflineSupportExceptionRules: RegExp[];
  39524. /**
  39525. * An event triggered when the scene is disposed.
  39526. */
  39527. onDisposeObservable: Observable<Scene>;
  39528. private _onDisposeObserver;
  39529. /** Sets a function to be executed when this scene is disposed. */
  39530. set onDispose(callback: () => void);
  39531. /**
  39532. * An event triggered before rendering the scene (right after animations and physics)
  39533. */
  39534. onBeforeRenderObservable: Observable<Scene>;
  39535. private _onBeforeRenderObserver;
  39536. /** Sets a function to be executed before rendering this scene */
  39537. set beforeRender(callback: Nullable<() => void>);
  39538. /**
  39539. * An event triggered after rendering the scene
  39540. */
  39541. onAfterRenderObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39544. */
  39545. onAfterRenderCameraObservable: Observable<Camera>;
  39546. private _onAfterRenderObserver;
  39547. /** Sets a function to be executed after rendering this scene */
  39548. set afterRender(callback: Nullable<() => void>);
  39549. /**
  39550. * An event triggered before animating the scene
  39551. */
  39552. onBeforeAnimationsObservable: Observable<Scene>;
  39553. /**
  39554. * An event triggered after animations processing
  39555. */
  39556. onAfterAnimationsObservable: Observable<Scene>;
  39557. /**
  39558. * An event triggered before draw calls are ready to be sent
  39559. */
  39560. onBeforeDrawPhaseObservable: Observable<Scene>;
  39561. /**
  39562. * An event triggered after draw calls have been sent
  39563. */
  39564. onAfterDrawPhaseObservable: Observable<Scene>;
  39565. /**
  39566. * An event triggered when the scene is ready
  39567. */
  39568. onReadyObservable: Observable<Scene>;
  39569. /**
  39570. * An event triggered before rendering a camera
  39571. */
  39572. onBeforeCameraRenderObservable: Observable<Camera>;
  39573. private _onBeforeCameraRenderObserver;
  39574. /** Sets a function to be executed before rendering a camera*/
  39575. set beforeCameraRender(callback: () => void);
  39576. /**
  39577. * An event triggered after rendering a camera
  39578. */
  39579. onAfterCameraRenderObservable: Observable<Camera>;
  39580. private _onAfterCameraRenderObserver;
  39581. /** Sets a function to be executed after rendering a camera*/
  39582. set afterCameraRender(callback: () => void);
  39583. /**
  39584. * An event triggered when active meshes evaluation is about to start
  39585. */
  39586. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39587. /**
  39588. * An event triggered when active meshes evaluation is done
  39589. */
  39590. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39591. /**
  39592. * An event triggered when particles rendering is about to start
  39593. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39594. */
  39595. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39596. /**
  39597. * An event triggered when particles rendering is done
  39598. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39599. */
  39600. onAfterParticlesRenderingObservable: Observable<Scene>;
  39601. /**
  39602. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39603. */
  39604. onDataLoadedObservable: Observable<Scene>;
  39605. /**
  39606. * An event triggered when a camera is created
  39607. */
  39608. onNewCameraAddedObservable: Observable<Camera>;
  39609. /**
  39610. * An event triggered when a camera is removed
  39611. */
  39612. onCameraRemovedObservable: Observable<Camera>;
  39613. /**
  39614. * An event triggered when a light is created
  39615. */
  39616. onNewLightAddedObservable: Observable<Light>;
  39617. /**
  39618. * An event triggered when a light is removed
  39619. */
  39620. onLightRemovedObservable: Observable<Light>;
  39621. /**
  39622. * An event triggered when a geometry is created
  39623. */
  39624. onNewGeometryAddedObservable: Observable<Geometry>;
  39625. /**
  39626. * An event triggered when a geometry is removed
  39627. */
  39628. onGeometryRemovedObservable: Observable<Geometry>;
  39629. /**
  39630. * An event triggered when a transform node is created
  39631. */
  39632. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39633. /**
  39634. * An event triggered when a transform node is removed
  39635. */
  39636. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39637. /**
  39638. * An event triggered when a mesh is created
  39639. */
  39640. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39641. /**
  39642. * An event triggered when a mesh is removed
  39643. */
  39644. onMeshRemovedObservable: Observable<AbstractMesh>;
  39645. /**
  39646. * An event triggered when a skeleton is created
  39647. */
  39648. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39649. /**
  39650. * An event triggered when a skeleton is removed
  39651. */
  39652. onSkeletonRemovedObservable: Observable<Skeleton>;
  39653. /**
  39654. * An event triggered when a material is created
  39655. */
  39656. onNewMaterialAddedObservable: Observable<Material>;
  39657. /**
  39658. * An event triggered when a material is removed
  39659. */
  39660. onMaterialRemovedObservable: Observable<Material>;
  39661. /**
  39662. * An event triggered when a texture is created
  39663. */
  39664. onNewTextureAddedObservable: Observable<BaseTexture>;
  39665. /**
  39666. * An event triggered when a texture is removed
  39667. */
  39668. onTextureRemovedObservable: Observable<BaseTexture>;
  39669. /**
  39670. * An event triggered when render targets are about to be rendered
  39671. * Can happen multiple times per frame.
  39672. */
  39673. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39674. /**
  39675. * An event triggered when render targets were rendered.
  39676. * Can happen multiple times per frame.
  39677. */
  39678. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39679. /**
  39680. * An event triggered before calculating deterministic simulation step
  39681. */
  39682. onBeforeStepObservable: Observable<Scene>;
  39683. /**
  39684. * An event triggered after calculating deterministic simulation step
  39685. */
  39686. onAfterStepObservable: Observable<Scene>;
  39687. /**
  39688. * An event triggered when the activeCamera property is updated
  39689. */
  39690. onActiveCameraChanged: Observable<Scene>;
  39691. /**
  39692. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39693. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39694. * 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)
  39695. */
  39696. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39697. /**
  39698. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39699. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39700. * 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)
  39701. */
  39702. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39703. /**
  39704. * This Observable will when a mesh has been imported into the scene.
  39705. */
  39706. onMeshImportedObservable: Observable<AbstractMesh>;
  39707. /**
  39708. * This Observable will when an animation file has been imported into the scene.
  39709. */
  39710. onAnimationFileImportedObservable: Observable<Scene>;
  39711. /**
  39712. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39713. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39714. */
  39715. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39716. /** @hidden */
  39717. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39718. /**
  39719. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39720. */
  39721. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39722. /**
  39723. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39724. */
  39725. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39726. /**
  39727. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39728. */
  39729. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39730. /** Callback called when a pointer move is detected */
  39731. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39732. /** Callback called when a pointer down is detected */
  39733. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39734. /** Callback called when a pointer up is detected */
  39735. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39736. /** Callback called when a pointer pick is detected */
  39737. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39738. /**
  39739. * 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).
  39740. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39741. */
  39742. onPrePointerObservable: Observable<PointerInfoPre>;
  39743. /**
  39744. * Observable event triggered each time an input event is received from the rendering canvas
  39745. */
  39746. onPointerObservable: Observable<PointerInfo>;
  39747. /**
  39748. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39749. */
  39750. get unTranslatedPointer(): Vector2;
  39751. /**
  39752. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39753. */
  39754. static get DragMovementThreshold(): number;
  39755. static set DragMovementThreshold(value: number);
  39756. /**
  39757. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39758. */
  39759. static get LongPressDelay(): number;
  39760. static set LongPressDelay(value: number);
  39761. /**
  39762. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39763. */
  39764. static get DoubleClickDelay(): number;
  39765. static set DoubleClickDelay(value: number);
  39766. /** If you need to check double click without raising a single click at first click, enable this flag */
  39767. static get ExclusiveDoubleClickMode(): boolean;
  39768. static set ExclusiveDoubleClickMode(value: boolean);
  39769. /** @hidden */
  39770. _mirroredCameraPosition: Nullable<Vector3>;
  39771. /**
  39772. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39773. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39774. */
  39775. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39776. /**
  39777. * Observable event triggered each time an keyboard event is received from the hosting window
  39778. */
  39779. onKeyboardObservable: Observable<KeyboardInfo>;
  39780. private _useRightHandedSystem;
  39781. /**
  39782. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39783. */
  39784. set useRightHandedSystem(value: boolean);
  39785. get useRightHandedSystem(): boolean;
  39786. private _timeAccumulator;
  39787. private _currentStepId;
  39788. private _currentInternalStep;
  39789. /**
  39790. * Sets the step Id used by deterministic lock step
  39791. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39792. * @param newStepId defines the step Id
  39793. */
  39794. setStepId(newStepId: number): void;
  39795. /**
  39796. * Gets the step Id used by deterministic lock step
  39797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39798. * @returns the step Id
  39799. */
  39800. getStepId(): number;
  39801. /**
  39802. * Gets the internal step used by deterministic lock step
  39803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39804. * @returns the internal step
  39805. */
  39806. getInternalStep(): number;
  39807. private _fogEnabled;
  39808. /**
  39809. * Gets or sets a boolean indicating if fog is enabled on this scene
  39810. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39811. * (Default is true)
  39812. */
  39813. set fogEnabled(value: boolean);
  39814. get fogEnabled(): boolean;
  39815. private _fogMode;
  39816. /**
  39817. * Gets or sets the fog mode to use
  39818. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39819. * | mode | value |
  39820. * | --- | --- |
  39821. * | FOGMODE_NONE | 0 |
  39822. * | FOGMODE_EXP | 1 |
  39823. * | FOGMODE_EXP2 | 2 |
  39824. * | FOGMODE_LINEAR | 3 |
  39825. */
  39826. set fogMode(value: number);
  39827. get fogMode(): number;
  39828. /**
  39829. * Gets or sets the fog color to use
  39830. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39831. * (Default is Color3(0.2, 0.2, 0.3))
  39832. */
  39833. fogColor: Color3;
  39834. /**
  39835. * Gets or sets the fog density to use
  39836. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39837. * (Default is 0.1)
  39838. */
  39839. fogDensity: number;
  39840. /**
  39841. * Gets or sets the fog start distance to use
  39842. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39843. * (Default is 0)
  39844. */
  39845. fogStart: number;
  39846. /**
  39847. * Gets or sets the fog end distance to use
  39848. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39849. * (Default is 1000)
  39850. */
  39851. fogEnd: number;
  39852. /**
  39853. * Flag indicating that the frame buffer binding is handled by another component
  39854. */
  39855. prePass: boolean;
  39856. private _shadowsEnabled;
  39857. /**
  39858. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39859. */
  39860. set shadowsEnabled(value: boolean);
  39861. get shadowsEnabled(): boolean;
  39862. private _lightsEnabled;
  39863. /**
  39864. * Gets or sets a boolean indicating if lights are enabled on this scene
  39865. */
  39866. set lightsEnabled(value: boolean);
  39867. get lightsEnabled(): boolean;
  39868. /** All of the active cameras added to this scene. */
  39869. activeCameras: Camera[];
  39870. /** @hidden */
  39871. _activeCamera: Nullable<Camera>;
  39872. /** Gets or sets the current active camera */
  39873. get activeCamera(): Nullable<Camera>;
  39874. set activeCamera(value: Nullable<Camera>);
  39875. private _defaultMaterial;
  39876. /** The default material used on meshes when no material is affected */
  39877. get defaultMaterial(): Material;
  39878. /** The default material used on meshes when no material is affected */
  39879. set defaultMaterial(value: Material);
  39880. private _texturesEnabled;
  39881. /**
  39882. * Gets or sets a boolean indicating if textures are enabled on this scene
  39883. */
  39884. set texturesEnabled(value: boolean);
  39885. get texturesEnabled(): boolean;
  39886. /**
  39887. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39888. */
  39889. physicsEnabled: boolean;
  39890. /**
  39891. * Gets or sets a boolean indicating if particles are enabled on this scene
  39892. */
  39893. particlesEnabled: boolean;
  39894. /**
  39895. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39896. */
  39897. spritesEnabled: boolean;
  39898. private _skeletonsEnabled;
  39899. /**
  39900. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39901. */
  39902. set skeletonsEnabled(value: boolean);
  39903. get skeletonsEnabled(): boolean;
  39904. /**
  39905. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39906. */
  39907. lensFlaresEnabled: boolean;
  39908. /**
  39909. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39910. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39911. */
  39912. collisionsEnabled: boolean;
  39913. private _collisionCoordinator;
  39914. /** @hidden */
  39915. get collisionCoordinator(): ICollisionCoordinator;
  39916. /**
  39917. * Defines the gravity applied to this scene (used only for collisions)
  39918. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39919. */
  39920. gravity: Vector3;
  39921. /**
  39922. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39923. */
  39924. postProcessesEnabled: boolean;
  39925. /**
  39926. * Gets the current postprocess manager
  39927. */
  39928. postProcessManager: PostProcessManager;
  39929. /**
  39930. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39931. */
  39932. renderTargetsEnabled: boolean;
  39933. /**
  39934. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39935. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39936. */
  39937. dumpNextRenderTargets: boolean;
  39938. /**
  39939. * The list of user defined render targets added to the scene
  39940. */
  39941. customRenderTargets: RenderTargetTexture[];
  39942. /**
  39943. * Defines if texture loading must be delayed
  39944. * If true, textures will only be loaded when they need to be rendered
  39945. */
  39946. useDelayedTextureLoading: boolean;
  39947. /**
  39948. * Gets the list of meshes imported to the scene through SceneLoader
  39949. */
  39950. importedMeshesFiles: String[];
  39951. /**
  39952. * Gets or sets a boolean indicating if probes are enabled on this scene
  39953. */
  39954. probesEnabled: boolean;
  39955. /**
  39956. * Gets or sets the current offline provider to use to store scene data
  39957. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39958. */
  39959. offlineProvider: IOfflineProvider;
  39960. /**
  39961. * Gets or sets the action manager associated with the scene
  39962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39963. */
  39964. actionManager: AbstractActionManager;
  39965. private _meshesForIntersections;
  39966. /**
  39967. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39968. */
  39969. proceduralTexturesEnabled: boolean;
  39970. private _engine;
  39971. private _totalVertices;
  39972. /** @hidden */
  39973. _activeIndices: PerfCounter;
  39974. /** @hidden */
  39975. _activeParticles: PerfCounter;
  39976. /** @hidden */
  39977. _activeBones: PerfCounter;
  39978. private _animationRatio;
  39979. /** @hidden */
  39980. _animationTimeLast: number;
  39981. /** @hidden */
  39982. _animationTime: number;
  39983. /**
  39984. * Gets or sets a general scale for animation speed
  39985. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39986. */
  39987. animationTimeScale: number;
  39988. /** @hidden */
  39989. _cachedMaterial: Nullable<Material>;
  39990. /** @hidden */
  39991. _cachedEffect: Nullable<Effect>;
  39992. /** @hidden */
  39993. _cachedVisibility: Nullable<number>;
  39994. private _renderId;
  39995. private _frameId;
  39996. private _executeWhenReadyTimeoutId;
  39997. private _intermediateRendering;
  39998. private _viewUpdateFlag;
  39999. private _projectionUpdateFlag;
  40000. /** @hidden */
  40001. _toBeDisposed: Nullable<IDisposable>[];
  40002. private _activeRequests;
  40003. /** @hidden */
  40004. _pendingData: any[];
  40005. private _isDisposed;
  40006. /**
  40007. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40008. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40009. */
  40010. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40011. private _activeMeshes;
  40012. private _processedMaterials;
  40013. private _renderTargets;
  40014. /** @hidden */
  40015. _activeParticleSystems: SmartArray<IParticleSystem>;
  40016. private _activeSkeletons;
  40017. private _softwareSkinnedMeshes;
  40018. private _renderingManager;
  40019. /** @hidden */
  40020. _activeAnimatables: Animatable[];
  40021. private _transformMatrix;
  40022. private _sceneUbo;
  40023. /** @hidden */
  40024. _viewMatrix: Matrix;
  40025. private _projectionMatrix;
  40026. /** @hidden */
  40027. _forcedViewPosition: Nullable<Vector3>;
  40028. /** @hidden */
  40029. _frustumPlanes: Plane[];
  40030. /**
  40031. * Gets the list of frustum planes (built from the active camera)
  40032. */
  40033. get frustumPlanes(): Plane[];
  40034. /**
  40035. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40036. * This is useful if there are more lights that the maximum simulteanous authorized
  40037. */
  40038. requireLightSorting: boolean;
  40039. /** @hidden */
  40040. readonly useMaterialMeshMap: boolean;
  40041. /** @hidden */
  40042. readonly useClonedMeshMap: boolean;
  40043. private _externalData;
  40044. private _uid;
  40045. /**
  40046. * @hidden
  40047. * Backing store of defined scene components.
  40048. */
  40049. _components: ISceneComponent[];
  40050. /**
  40051. * @hidden
  40052. * Backing store of defined scene components.
  40053. */
  40054. _serializableComponents: ISceneSerializableComponent[];
  40055. /**
  40056. * List of components to register on the next registration step.
  40057. */
  40058. private _transientComponents;
  40059. /**
  40060. * Registers the transient components if needed.
  40061. */
  40062. private _registerTransientComponents;
  40063. /**
  40064. * @hidden
  40065. * Add a component to the scene.
  40066. * Note that the ccomponent could be registered on th next frame if this is called after
  40067. * the register component stage.
  40068. * @param component Defines the component to add to the scene
  40069. */
  40070. _addComponent(component: ISceneComponent): void;
  40071. /**
  40072. * @hidden
  40073. * Gets a component from the scene.
  40074. * @param name defines the name of the component to retrieve
  40075. * @returns the component or null if not present
  40076. */
  40077. _getComponent(name: string): Nullable<ISceneComponent>;
  40078. /**
  40079. * @hidden
  40080. * Defines the actions happening before camera updates.
  40081. */
  40082. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40083. /**
  40084. * @hidden
  40085. * Defines the actions happening before clear the canvas.
  40086. */
  40087. _beforeClearStage: Stage<SimpleStageAction>;
  40088. /**
  40089. * @hidden
  40090. * Defines the actions when collecting render targets for the frame.
  40091. */
  40092. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40093. /**
  40094. * @hidden
  40095. * Defines the actions happening for one camera in the frame.
  40096. */
  40097. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40098. /**
  40099. * @hidden
  40100. * Defines the actions happening during the per mesh ready checks.
  40101. */
  40102. _isReadyForMeshStage: Stage<MeshStageAction>;
  40103. /**
  40104. * @hidden
  40105. * Defines the actions happening before evaluate active mesh checks.
  40106. */
  40107. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40108. /**
  40109. * @hidden
  40110. * Defines the actions happening during the evaluate sub mesh checks.
  40111. */
  40112. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40113. /**
  40114. * @hidden
  40115. * Defines the actions happening during the active mesh stage.
  40116. */
  40117. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40118. /**
  40119. * @hidden
  40120. * Defines the actions happening during the per camera render target step.
  40121. */
  40122. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40123. /**
  40124. * @hidden
  40125. * Defines the actions happening just before the active camera is drawing.
  40126. */
  40127. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40128. /**
  40129. * @hidden
  40130. * Defines the actions happening just before a render target is drawing.
  40131. */
  40132. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40133. /**
  40134. * @hidden
  40135. * Defines the actions happening just before a rendering group is drawing.
  40136. */
  40137. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40138. /**
  40139. * @hidden
  40140. * Defines the actions happening just before a mesh is drawing.
  40141. */
  40142. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40143. /**
  40144. * @hidden
  40145. * Defines the actions happening just after a mesh has been drawn.
  40146. */
  40147. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40148. /**
  40149. * @hidden
  40150. * Defines the actions happening just after a rendering group has been drawn.
  40151. */
  40152. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40153. /**
  40154. * @hidden
  40155. * Defines the actions happening just after the active camera has been drawn.
  40156. */
  40157. _afterCameraDrawStage: Stage<CameraStageAction>;
  40158. /**
  40159. * @hidden
  40160. * Defines the actions happening just after a render target has been drawn.
  40161. */
  40162. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40163. /**
  40164. * @hidden
  40165. * Defines the actions happening just after rendering all cameras and computing intersections.
  40166. */
  40167. _afterRenderStage: Stage<SimpleStageAction>;
  40168. /**
  40169. * @hidden
  40170. * Defines the actions happening when a pointer move event happens.
  40171. */
  40172. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40173. /**
  40174. * @hidden
  40175. * Defines the actions happening when a pointer down event happens.
  40176. */
  40177. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40178. /**
  40179. * @hidden
  40180. * Defines the actions happening when a pointer up event happens.
  40181. */
  40182. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40183. /**
  40184. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40185. */
  40186. private geometriesByUniqueId;
  40187. /**
  40188. * Creates a new Scene
  40189. * @param engine defines the engine to use to render this scene
  40190. * @param options defines the scene options
  40191. */
  40192. constructor(engine: Engine, options?: SceneOptions);
  40193. /**
  40194. * Gets a string identifying the name of the class
  40195. * @returns "Scene" string
  40196. */
  40197. getClassName(): string;
  40198. private _defaultMeshCandidates;
  40199. /**
  40200. * @hidden
  40201. */
  40202. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40203. private _defaultSubMeshCandidates;
  40204. /**
  40205. * @hidden
  40206. */
  40207. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40208. /**
  40209. * Sets the default candidate providers for the scene.
  40210. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40211. * and getCollidingSubMeshCandidates to their default function
  40212. */
  40213. setDefaultCandidateProviders(): void;
  40214. /**
  40215. * Gets the mesh that is currently under the pointer
  40216. */
  40217. get meshUnderPointer(): Nullable<AbstractMesh>;
  40218. /**
  40219. * Gets or sets the current on-screen X position of the pointer
  40220. */
  40221. get pointerX(): number;
  40222. set pointerX(value: number);
  40223. /**
  40224. * Gets or sets the current on-screen Y position of the pointer
  40225. */
  40226. get pointerY(): number;
  40227. set pointerY(value: number);
  40228. /**
  40229. * Gets the cached material (ie. the latest rendered one)
  40230. * @returns the cached material
  40231. */
  40232. getCachedMaterial(): Nullable<Material>;
  40233. /**
  40234. * Gets the cached effect (ie. the latest rendered one)
  40235. * @returns the cached effect
  40236. */
  40237. getCachedEffect(): Nullable<Effect>;
  40238. /**
  40239. * Gets the cached visibility state (ie. the latest rendered one)
  40240. * @returns the cached visibility state
  40241. */
  40242. getCachedVisibility(): Nullable<number>;
  40243. /**
  40244. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40245. * @param material defines the current material
  40246. * @param effect defines the current effect
  40247. * @param visibility defines the current visibility state
  40248. * @returns true if one parameter is not cached
  40249. */
  40250. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40251. /**
  40252. * Gets the engine associated with the scene
  40253. * @returns an Engine
  40254. */
  40255. getEngine(): Engine;
  40256. /**
  40257. * Gets the total number of vertices rendered per frame
  40258. * @returns the total number of vertices rendered per frame
  40259. */
  40260. getTotalVertices(): number;
  40261. /**
  40262. * Gets the performance counter for total vertices
  40263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40264. */
  40265. get totalVerticesPerfCounter(): PerfCounter;
  40266. /**
  40267. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40268. * @returns the total number of active indices rendered per frame
  40269. */
  40270. getActiveIndices(): number;
  40271. /**
  40272. * Gets the performance counter for active indices
  40273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40274. */
  40275. get totalActiveIndicesPerfCounter(): PerfCounter;
  40276. /**
  40277. * Gets the total number of active particles rendered per frame
  40278. * @returns the total number of active particles rendered per frame
  40279. */
  40280. getActiveParticles(): number;
  40281. /**
  40282. * Gets the performance counter for active particles
  40283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40284. */
  40285. get activeParticlesPerfCounter(): PerfCounter;
  40286. /**
  40287. * Gets the total number of active bones rendered per frame
  40288. * @returns the total number of active bones rendered per frame
  40289. */
  40290. getActiveBones(): number;
  40291. /**
  40292. * Gets the performance counter for active bones
  40293. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40294. */
  40295. get activeBonesPerfCounter(): PerfCounter;
  40296. /**
  40297. * Gets the array of active meshes
  40298. * @returns an array of AbstractMesh
  40299. */
  40300. getActiveMeshes(): SmartArray<AbstractMesh>;
  40301. /**
  40302. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40303. * @returns a number
  40304. */
  40305. getAnimationRatio(): number;
  40306. /**
  40307. * Gets an unique Id for the current render phase
  40308. * @returns a number
  40309. */
  40310. getRenderId(): number;
  40311. /**
  40312. * Gets an unique Id for the current frame
  40313. * @returns a number
  40314. */
  40315. getFrameId(): number;
  40316. /** Call this function if you want to manually increment the render Id*/
  40317. incrementRenderId(): void;
  40318. private _createUbo;
  40319. /**
  40320. * Use this method to simulate a pointer move on a mesh
  40321. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40322. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40323. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40324. * @returns the current scene
  40325. */
  40326. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40327. /**
  40328. * Use this method to simulate a pointer down on a mesh
  40329. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40330. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40331. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40332. * @returns the current scene
  40333. */
  40334. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40335. /**
  40336. * Use this method to simulate a pointer up on a mesh
  40337. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40338. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40339. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40340. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40341. * @returns the current scene
  40342. */
  40343. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40344. /**
  40345. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40346. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40347. * @returns true if the pointer was captured
  40348. */
  40349. isPointerCaptured(pointerId?: number): boolean;
  40350. /**
  40351. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40352. * @param attachUp defines if you want to attach events to pointerup
  40353. * @param attachDown defines if you want to attach events to pointerdown
  40354. * @param attachMove defines if you want to attach events to pointermove
  40355. */
  40356. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40357. /** Detaches all event handlers*/
  40358. detachControl(): void;
  40359. /**
  40360. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40361. * Delay loaded resources are not taking in account
  40362. * @return true if all required resources are ready
  40363. */
  40364. isReady(): boolean;
  40365. /** Resets all cached information relative to material (including effect and visibility) */
  40366. resetCachedMaterial(): void;
  40367. /**
  40368. * Registers a function to be called before every frame render
  40369. * @param func defines the function to register
  40370. */
  40371. registerBeforeRender(func: () => void): void;
  40372. /**
  40373. * Unregisters a function called before every frame render
  40374. * @param func defines the function to unregister
  40375. */
  40376. unregisterBeforeRender(func: () => void): void;
  40377. /**
  40378. * Registers a function to be called after every frame render
  40379. * @param func defines the function to register
  40380. */
  40381. registerAfterRender(func: () => void): void;
  40382. /**
  40383. * Unregisters a function called after every frame render
  40384. * @param func defines the function to unregister
  40385. */
  40386. unregisterAfterRender(func: () => void): void;
  40387. private _executeOnceBeforeRender;
  40388. /**
  40389. * The provided function will run before render once and will be disposed afterwards.
  40390. * A timeout delay can be provided so that the function will be executed in N ms.
  40391. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40392. * @param func The function to be executed.
  40393. * @param timeout optional delay in ms
  40394. */
  40395. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40396. /** @hidden */
  40397. _addPendingData(data: any): void;
  40398. /** @hidden */
  40399. _removePendingData(data: any): void;
  40400. /**
  40401. * Returns the number of items waiting to be loaded
  40402. * @returns the number of items waiting to be loaded
  40403. */
  40404. getWaitingItemsCount(): number;
  40405. /**
  40406. * Returns a boolean indicating if the scene is still loading data
  40407. */
  40408. get isLoading(): boolean;
  40409. /**
  40410. * Registers a function to be executed when the scene is ready
  40411. * @param {Function} func - the function to be executed
  40412. */
  40413. executeWhenReady(func: () => void): void;
  40414. /**
  40415. * Returns a promise that resolves when the scene is ready
  40416. * @returns A promise that resolves when the scene is ready
  40417. */
  40418. whenReadyAsync(): Promise<void>;
  40419. /** @hidden */
  40420. _checkIsReady(): void;
  40421. /**
  40422. * Gets all animatable attached to the scene
  40423. */
  40424. get animatables(): Animatable[];
  40425. /**
  40426. * Resets the last animation time frame.
  40427. * Useful to override when animations start running when loading a scene for the first time.
  40428. */
  40429. resetLastAnimationTimeFrame(): void;
  40430. /**
  40431. * Gets the current view matrix
  40432. * @returns a Matrix
  40433. */
  40434. getViewMatrix(): Matrix;
  40435. /**
  40436. * Gets the current projection matrix
  40437. * @returns a Matrix
  40438. */
  40439. getProjectionMatrix(): Matrix;
  40440. /**
  40441. * Gets the current transform matrix
  40442. * @returns a Matrix made of View * Projection
  40443. */
  40444. getTransformMatrix(): Matrix;
  40445. /**
  40446. * Sets the current transform matrix
  40447. * @param viewL defines the View matrix to use
  40448. * @param projectionL defines the Projection matrix to use
  40449. * @param viewR defines the right View matrix to use (if provided)
  40450. * @param projectionR defines the right Projection matrix to use (if provided)
  40451. */
  40452. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40453. /**
  40454. * Gets the uniform buffer used to store scene data
  40455. * @returns a UniformBuffer
  40456. */
  40457. getSceneUniformBuffer(): UniformBuffer;
  40458. /**
  40459. * Gets an unique (relatively to the current scene) Id
  40460. * @returns an unique number for the scene
  40461. */
  40462. getUniqueId(): number;
  40463. /**
  40464. * Add a mesh to the list of scene's meshes
  40465. * @param newMesh defines the mesh to add
  40466. * @param recursive if all child meshes should also be added to the scene
  40467. */
  40468. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40469. /**
  40470. * Remove a mesh for the list of scene's meshes
  40471. * @param toRemove defines the mesh to remove
  40472. * @param recursive if all child meshes should also be removed from the scene
  40473. * @returns the index where the mesh was in the mesh list
  40474. */
  40475. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40476. /**
  40477. * Add a transform node to the list of scene's transform nodes
  40478. * @param newTransformNode defines the transform node to add
  40479. */
  40480. addTransformNode(newTransformNode: TransformNode): void;
  40481. /**
  40482. * Remove a transform node for the list of scene's transform nodes
  40483. * @param toRemove defines the transform node to remove
  40484. * @returns the index where the transform node was in the transform node list
  40485. */
  40486. removeTransformNode(toRemove: TransformNode): number;
  40487. /**
  40488. * Remove a skeleton for the list of scene's skeletons
  40489. * @param toRemove defines the skeleton to remove
  40490. * @returns the index where the skeleton was in the skeleton list
  40491. */
  40492. removeSkeleton(toRemove: Skeleton): number;
  40493. /**
  40494. * Remove a morph target for the list of scene's morph targets
  40495. * @param toRemove defines the morph target to remove
  40496. * @returns the index where the morph target was in the morph target list
  40497. */
  40498. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40499. /**
  40500. * Remove a light for the list of scene's lights
  40501. * @param toRemove defines the light to remove
  40502. * @returns the index where the light was in the light list
  40503. */
  40504. removeLight(toRemove: Light): number;
  40505. /**
  40506. * Remove a camera for the list of scene's cameras
  40507. * @param toRemove defines the camera to remove
  40508. * @returns the index where the camera was in the camera list
  40509. */
  40510. removeCamera(toRemove: Camera): number;
  40511. /**
  40512. * Remove a particle system for the list of scene's particle systems
  40513. * @param toRemove defines the particle system to remove
  40514. * @returns the index where the particle system was in the particle system list
  40515. */
  40516. removeParticleSystem(toRemove: IParticleSystem): number;
  40517. /**
  40518. * Remove a animation for the list of scene's animations
  40519. * @param toRemove defines the animation to remove
  40520. * @returns the index where the animation was in the animation list
  40521. */
  40522. removeAnimation(toRemove: Animation): number;
  40523. /**
  40524. * Will stop the animation of the given target
  40525. * @param target - the target
  40526. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40527. * @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)
  40528. */
  40529. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40530. /**
  40531. * Removes the given animation group from this scene.
  40532. * @param toRemove The animation group to remove
  40533. * @returns The index of the removed animation group
  40534. */
  40535. removeAnimationGroup(toRemove: AnimationGroup): number;
  40536. /**
  40537. * Removes the given multi-material from this scene.
  40538. * @param toRemove The multi-material to remove
  40539. * @returns The index of the removed multi-material
  40540. */
  40541. removeMultiMaterial(toRemove: MultiMaterial): number;
  40542. /**
  40543. * Removes the given material from this scene.
  40544. * @param toRemove The material to remove
  40545. * @returns The index of the removed material
  40546. */
  40547. removeMaterial(toRemove: Material): number;
  40548. /**
  40549. * Removes the given action manager from this scene.
  40550. * @param toRemove The action manager to remove
  40551. * @returns The index of the removed action manager
  40552. */
  40553. removeActionManager(toRemove: AbstractActionManager): number;
  40554. /**
  40555. * Removes the given texture from this scene.
  40556. * @param toRemove The texture to remove
  40557. * @returns The index of the removed texture
  40558. */
  40559. removeTexture(toRemove: BaseTexture): number;
  40560. /**
  40561. * Adds the given light to this scene
  40562. * @param newLight The light to add
  40563. */
  40564. addLight(newLight: Light): void;
  40565. /**
  40566. * Sorts the list list based on light priorities
  40567. */
  40568. sortLightsByPriority(): void;
  40569. /**
  40570. * Adds the given camera to this scene
  40571. * @param newCamera The camera to add
  40572. */
  40573. addCamera(newCamera: Camera): void;
  40574. /**
  40575. * Adds the given skeleton to this scene
  40576. * @param newSkeleton The skeleton to add
  40577. */
  40578. addSkeleton(newSkeleton: Skeleton): void;
  40579. /**
  40580. * Adds the given particle system to this scene
  40581. * @param newParticleSystem The particle system to add
  40582. */
  40583. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40584. /**
  40585. * Adds the given animation to this scene
  40586. * @param newAnimation The animation to add
  40587. */
  40588. addAnimation(newAnimation: Animation): void;
  40589. /**
  40590. * Adds the given animation group to this scene.
  40591. * @param newAnimationGroup The animation group to add
  40592. */
  40593. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40594. /**
  40595. * Adds the given multi-material to this scene
  40596. * @param newMultiMaterial The multi-material to add
  40597. */
  40598. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40599. /**
  40600. * Adds the given material to this scene
  40601. * @param newMaterial The material to add
  40602. */
  40603. addMaterial(newMaterial: Material): void;
  40604. /**
  40605. * Adds the given morph target to this scene
  40606. * @param newMorphTargetManager The morph target to add
  40607. */
  40608. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40609. /**
  40610. * Adds the given geometry to this scene
  40611. * @param newGeometry The geometry to add
  40612. */
  40613. addGeometry(newGeometry: Geometry): void;
  40614. /**
  40615. * Adds the given action manager to this scene
  40616. * @param newActionManager The action manager to add
  40617. */
  40618. addActionManager(newActionManager: AbstractActionManager): void;
  40619. /**
  40620. * Adds the given texture to this scene.
  40621. * @param newTexture The texture to add
  40622. */
  40623. addTexture(newTexture: BaseTexture): void;
  40624. /**
  40625. * Switch active camera
  40626. * @param newCamera defines the new active camera
  40627. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40628. */
  40629. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40630. /**
  40631. * sets the active camera of the scene using its ID
  40632. * @param id defines the camera's ID
  40633. * @return the new active camera or null if none found.
  40634. */
  40635. setActiveCameraByID(id: string): Nullable<Camera>;
  40636. /**
  40637. * sets the active camera of the scene using its name
  40638. * @param name defines the camera's name
  40639. * @returns the new active camera or null if none found.
  40640. */
  40641. setActiveCameraByName(name: string): Nullable<Camera>;
  40642. /**
  40643. * get an animation group using its name
  40644. * @param name defines the material's name
  40645. * @return the animation group or null if none found.
  40646. */
  40647. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40648. /**
  40649. * Get a material using its unique id
  40650. * @param uniqueId defines the material's unique id
  40651. * @return the material or null if none found.
  40652. */
  40653. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40654. /**
  40655. * get a material using its id
  40656. * @param id defines the material's ID
  40657. * @return the material or null if none found.
  40658. */
  40659. getMaterialByID(id: string): Nullable<Material>;
  40660. /**
  40661. * Gets a the last added material using a given id
  40662. * @param id defines the material's ID
  40663. * @return the last material with the given id or null if none found.
  40664. */
  40665. getLastMaterialByID(id: string): Nullable<Material>;
  40666. /**
  40667. * Gets a material using its name
  40668. * @param name defines the material's name
  40669. * @return the material or null if none found.
  40670. */
  40671. getMaterialByName(name: string): Nullable<Material>;
  40672. /**
  40673. * Get a texture using its unique id
  40674. * @param uniqueId defines the texture's unique id
  40675. * @return the texture or null if none found.
  40676. */
  40677. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40678. /**
  40679. * Gets a camera using its id
  40680. * @param id defines the id to look for
  40681. * @returns the camera or null if not found
  40682. */
  40683. getCameraByID(id: string): Nullable<Camera>;
  40684. /**
  40685. * Gets a camera using its unique id
  40686. * @param uniqueId defines the unique id to look for
  40687. * @returns the camera or null if not found
  40688. */
  40689. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40690. /**
  40691. * Gets a camera using its name
  40692. * @param name defines the camera's name
  40693. * @return the camera or null if none found.
  40694. */
  40695. getCameraByName(name: string): Nullable<Camera>;
  40696. /**
  40697. * Gets a bone using its id
  40698. * @param id defines the bone's id
  40699. * @return the bone or null if not found
  40700. */
  40701. getBoneByID(id: string): Nullable<Bone>;
  40702. /**
  40703. * Gets a bone using its id
  40704. * @param name defines the bone's name
  40705. * @return the bone or null if not found
  40706. */
  40707. getBoneByName(name: string): Nullable<Bone>;
  40708. /**
  40709. * Gets a light node using its name
  40710. * @param name defines the the light's name
  40711. * @return the light or null if none found.
  40712. */
  40713. getLightByName(name: string): Nullable<Light>;
  40714. /**
  40715. * Gets a light node using its id
  40716. * @param id defines the light's id
  40717. * @return the light or null if none found.
  40718. */
  40719. getLightByID(id: string): Nullable<Light>;
  40720. /**
  40721. * Gets a light node using its scene-generated unique ID
  40722. * @param uniqueId defines the light's unique id
  40723. * @return the light or null if none found.
  40724. */
  40725. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40726. /**
  40727. * Gets a particle system by id
  40728. * @param id defines the particle system id
  40729. * @return the corresponding system or null if none found
  40730. */
  40731. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40732. /**
  40733. * Gets a geometry using its ID
  40734. * @param id defines the geometry's id
  40735. * @return the geometry or null if none found.
  40736. */
  40737. getGeometryByID(id: string): Nullable<Geometry>;
  40738. private _getGeometryByUniqueID;
  40739. /**
  40740. * Add a new geometry to this scene
  40741. * @param geometry defines the geometry to be added to the scene.
  40742. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40743. * @return a boolean defining if the geometry was added or not
  40744. */
  40745. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40746. /**
  40747. * Removes an existing geometry
  40748. * @param geometry defines the geometry to be removed from the scene
  40749. * @return a boolean defining if the geometry was removed or not
  40750. */
  40751. removeGeometry(geometry: Geometry): boolean;
  40752. /**
  40753. * Gets the list of geometries attached to the scene
  40754. * @returns an array of Geometry
  40755. */
  40756. getGeometries(): Geometry[];
  40757. /**
  40758. * Gets the first added mesh found of a given ID
  40759. * @param id defines the id to search for
  40760. * @return the mesh found or null if not found at all
  40761. */
  40762. getMeshByID(id: string): Nullable<AbstractMesh>;
  40763. /**
  40764. * Gets a list of meshes using their id
  40765. * @param id defines the id to search for
  40766. * @returns a list of meshes
  40767. */
  40768. getMeshesByID(id: string): Array<AbstractMesh>;
  40769. /**
  40770. * Gets the first added transform node found of a given ID
  40771. * @param id defines the id to search for
  40772. * @return the found transform node or null if not found at all.
  40773. */
  40774. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40775. /**
  40776. * Gets a transform node with its auto-generated unique id
  40777. * @param uniqueId efines the unique id to search for
  40778. * @return the found transform node or null if not found at all.
  40779. */
  40780. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40781. /**
  40782. * Gets a list of transform nodes using their id
  40783. * @param id defines the id to search for
  40784. * @returns a list of transform nodes
  40785. */
  40786. getTransformNodesByID(id: string): Array<TransformNode>;
  40787. /**
  40788. * Gets a mesh with its auto-generated unique id
  40789. * @param uniqueId defines the unique id to search for
  40790. * @return the found mesh or null if not found at all.
  40791. */
  40792. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40793. /**
  40794. * Gets a the last added mesh using a given id
  40795. * @param id defines the id to search for
  40796. * @return the found mesh or null if not found at all.
  40797. */
  40798. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40799. /**
  40800. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40801. * @param id defines the id to search for
  40802. * @return the found node or null if not found at all
  40803. */
  40804. getLastEntryByID(id: string): Nullable<Node>;
  40805. /**
  40806. * Gets a node (Mesh, Camera, Light) using a given id
  40807. * @param id defines the id to search for
  40808. * @return the found node or null if not found at all
  40809. */
  40810. getNodeByID(id: string): Nullable<Node>;
  40811. /**
  40812. * Gets a node (Mesh, Camera, Light) using a given name
  40813. * @param name defines the name to search for
  40814. * @return the found node or null if not found at all.
  40815. */
  40816. getNodeByName(name: string): Nullable<Node>;
  40817. /**
  40818. * Gets a mesh using a given name
  40819. * @param name defines the name to search for
  40820. * @return the found mesh or null if not found at all.
  40821. */
  40822. getMeshByName(name: string): Nullable<AbstractMesh>;
  40823. /**
  40824. * Gets a transform node using a given name
  40825. * @param name defines the name to search for
  40826. * @return the found transform node or null if not found at all.
  40827. */
  40828. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40829. /**
  40830. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40831. * @param id defines the id to search for
  40832. * @return the found skeleton or null if not found at all.
  40833. */
  40834. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40835. /**
  40836. * Gets a skeleton using a given auto generated unique id
  40837. * @param uniqueId defines the unique id to search for
  40838. * @return the found skeleton or null if not found at all.
  40839. */
  40840. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40841. /**
  40842. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40843. * @param id defines the id to search for
  40844. * @return the found skeleton or null if not found at all.
  40845. */
  40846. getSkeletonById(id: string): Nullable<Skeleton>;
  40847. /**
  40848. * Gets a skeleton using a given name
  40849. * @param name defines the name to search for
  40850. * @return the found skeleton or null if not found at all.
  40851. */
  40852. getSkeletonByName(name: string): Nullable<Skeleton>;
  40853. /**
  40854. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40855. * @param id defines the id to search for
  40856. * @return the found morph target manager or null if not found at all.
  40857. */
  40858. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40859. /**
  40860. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40861. * @param id defines the id to search for
  40862. * @return the found morph target or null if not found at all.
  40863. */
  40864. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40865. /**
  40866. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40867. * @param name defines the name to search for
  40868. * @return the found morph target or null if not found at all.
  40869. */
  40870. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40871. /**
  40872. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40873. * @param name defines the name to search for
  40874. * @return the found post process or null if not found at all.
  40875. */
  40876. getPostProcessByName(name: string): Nullable<PostProcess>;
  40877. /**
  40878. * Gets a boolean indicating if the given mesh is active
  40879. * @param mesh defines the mesh to look for
  40880. * @returns true if the mesh is in the active list
  40881. */
  40882. isActiveMesh(mesh: AbstractMesh): boolean;
  40883. /**
  40884. * Return a unique id as a string which can serve as an identifier for the scene
  40885. */
  40886. get uid(): string;
  40887. /**
  40888. * Add an externaly attached data from its key.
  40889. * This method call will fail and return false, if such key already exists.
  40890. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40891. * @param key the unique key that identifies the data
  40892. * @param data the data object to associate to the key for this Engine instance
  40893. * @return true if no such key were already present and the data was added successfully, false otherwise
  40894. */
  40895. addExternalData<T>(key: string, data: T): boolean;
  40896. /**
  40897. * Get an externaly attached data from its key
  40898. * @param key the unique key that identifies the data
  40899. * @return the associated data, if present (can be null), or undefined if not present
  40900. */
  40901. getExternalData<T>(key: string): Nullable<T>;
  40902. /**
  40903. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40904. * @param key the unique key that identifies the data
  40905. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40906. * @return the associated data, can be null if the factory returned null.
  40907. */
  40908. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40909. /**
  40910. * Remove an externaly attached data from the Engine instance
  40911. * @param key the unique key that identifies the data
  40912. * @return true if the data was successfully removed, false if it doesn't exist
  40913. */
  40914. removeExternalData(key: string): boolean;
  40915. private _evaluateSubMesh;
  40916. /**
  40917. * Clear the processed materials smart array preventing retention point in material dispose.
  40918. */
  40919. freeProcessedMaterials(): void;
  40920. private _preventFreeActiveMeshesAndRenderingGroups;
  40921. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40922. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40923. * when disposing several meshes in a row or a hierarchy of meshes.
  40924. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40925. */
  40926. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40927. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40928. /**
  40929. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40930. */
  40931. freeActiveMeshes(): void;
  40932. /**
  40933. * Clear the info related to rendering groups preventing retention points during dispose.
  40934. */
  40935. freeRenderingGroups(): void;
  40936. /** @hidden */
  40937. _isInIntermediateRendering(): boolean;
  40938. /**
  40939. * Lambda returning the list of potentially active meshes.
  40940. */
  40941. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40942. /**
  40943. * Lambda returning the list of potentially active sub meshes.
  40944. */
  40945. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40946. /**
  40947. * Lambda returning the list of potentially intersecting sub meshes.
  40948. */
  40949. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40950. /**
  40951. * Lambda returning the list of potentially colliding sub meshes.
  40952. */
  40953. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40954. private _activeMeshesFrozen;
  40955. private _skipEvaluateActiveMeshesCompletely;
  40956. /**
  40957. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40958. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40959. * @returns the current scene
  40960. */
  40961. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40962. /**
  40963. * Use this function to restart evaluating active meshes on every frame
  40964. * @returns the current scene
  40965. */
  40966. unfreezeActiveMeshes(): Scene;
  40967. private _evaluateActiveMeshes;
  40968. private _activeMesh;
  40969. /**
  40970. * Update the transform matrix to update from the current active camera
  40971. * @param force defines a boolean used to force the update even if cache is up to date
  40972. */
  40973. updateTransformMatrix(force?: boolean): void;
  40974. private _bindFrameBuffer;
  40975. /** @hidden */
  40976. _allowPostProcessClearColor: boolean;
  40977. /** @hidden */
  40978. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40979. private _processSubCameras;
  40980. private _checkIntersections;
  40981. /** @hidden */
  40982. _advancePhysicsEngineStep(step: number): void;
  40983. /**
  40984. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40985. */
  40986. getDeterministicFrameTime: () => number;
  40987. /** @hidden */
  40988. _animate(): void;
  40989. /** Execute all animations (for a frame) */
  40990. animate(): void;
  40991. /**
  40992. * Render the scene
  40993. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40994. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40995. */
  40996. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40997. /**
  40998. * Freeze all materials
  40999. * A frozen material will not be updatable but should be faster to render
  41000. */
  41001. freezeMaterials(): void;
  41002. /**
  41003. * Unfreeze all materials
  41004. * A frozen material will not be updatable but should be faster to render
  41005. */
  41006. unfreezeMaterials(): void;
  41007. /**
  41008. * Releases all held ressources
  41009. */
  41010. dispose(): void;
  41011. /**
  41012. * Gets if the scene is already disposed
  41013. */
  41014. get isDisposed(): boolean;
  41015. /**
  41016. * Call this function to reduce memory footprint of the scene.
  41017. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41018. */
  41019. clearCachedVertexData(): void;
  41020. /**
  41021. * This function will remove the local cached buffer data from texture.
  41022. * It will save memory but will prevent the texture from being rebuilt
  41023. */
  41024. cleanCachedTextureBuffer(): void;
  41025. /**
  41026. * Get the world extend vectors with an optional filter
  41027. *
  41028. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41029. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41030. */
  41031. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41032. min: Vector3;
  41033. max: Vector3;
  41034. };
  41035. /**
  41036. * Creates a ray that can be used to pick in the scene
  41037. * @param x defines the x coordinate of the origin (on-screen)
  41038. * @param y defines the y coordinate of the origin (on-screen)
  41039. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41040. * @param camera defines the camera to use for the picking
  41041. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41042. * @returns a Ray
  41043. */
  41044. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41045. /**
  41046. * Creates a ray that can be used to pick in the scene
  41047. * @param x defines the x coordinate of the origin (on-screen)
  41048. * @param y defines the y coordinate of the origin (on-screen)
  41049. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41050. * @param result defines the ray where to store the picking ray
  41051. * @param camera defines the camera to use for the picking
  41052. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41053. * @returns the current scene
  41054. */
  41055. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41056. /**
  41057. * Creates a ray that can be used to pick in the scene
  41058. * @param x defines the x coordinate of the origin (on-screen)
  41059. * @param y defines the y coordinate of the origin (on-screen)
  41060. * @param camera defines the camera to use for the picking
  41061. * @returns a Ray
  41062. */
  41063. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41064. /**
  41065. * Creates a ray that can be used to pick in the scene
  41066. * @param x defines the x coordinate of the origin (on-screen)
  41067. * @param y defines the y coordinate of the origin (on-screen)
  41068. * @param result defines the ray where to store the picking ray
  41069. * @param camera defines the camera to use for the picking
  41070. * @returns the current scene
  41071. */
  41072. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41073. /** Launch a ray to try to pick a mesh in the scene
  41074. * @param x position on screen
  41075. * @param y position on screen
  41076. * @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
  41077. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41078. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41080. * @returns a PickingInfo
  41081. */
  41082. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41083. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41084. * @param x position on screen
  41085. * @param y position on screen
  41086. * @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
  41087. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41088. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41089. * @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)
  41090. */
  41091. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41092. /** Use the given ray to pick a mesh in the scene
  41093. * @param ray The ray to use to pick meshes
  41094. * @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
  41095. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41097. * @returns a PickingInfo
  41098. */
  41099. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41100. /**
  41101. * Launch a ray to try to pick a mesh in the scene
  41102. * @param x X position on screen
  41103. * @param y Y position on screen
  41104. * @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
  41105. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41106. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41107. * @returns an array of PickingInfo
  41108. */
  41109. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41110. /**
  41111. * Launch a ray to try to pick a mesh in the scene
  41112. * @param ray Ray to use
  41113. * @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
  41114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41115. * @returns an array of PickingInfo
  41116. */
  41117. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41118. /**
  41119. * Force the value of meshUnderPointer
  41120. * @param mesh defines the mesh to use
  41121. * @param pointerId optional pointer id when using more than one pointer
  41122. */
  41123. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41124. /**
  41125. * Gets the mesh under the pointer
  41126. * @returns a Mesh or null if no mesh is under the pointer
  41127. */
  41128. getPointerOverMesh(): Nullable<AbstractMesh>;
  41129. /** @hidden */
  41130. _rebuildGeometries(): void;
  41131. /** @hidden */
  41132. _rebuildTextures(): void;
  41133. private _getByTags;
  41134. /**
  41135. * Get a list of meshes by tags
  41136. * @param tagsQuery defines the tags query to use
  41137. * @param forEach defines a predicate used to filter results
  41138. * @returns an array of Mesh
  41139. */
  41140. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41141. /**
  41142. * Get a list of cameras by tags
  41143. * @param tagsQuery defines the tags query to use
  41144. * @param forEach defines a predicate used to filter results
  41145. * @returns an array of Camera
  41146. */
  41147. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41148. /**
  41149. * Get a list of lights by tags
  41150. * @param tagsQuery defines the tags query to use
  41151. * @param forEach defines a predicate used to filter results
  41152. * @returns an array of Light
  41153. */
  41154. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41155. /**
  41156. * Get a list of materials by tags
  41157. * @param tagsQuery defines the tags query to use
  41158. * @param forEach defines a predicate used to filter results
  41159. * @returns an array of Material
  41160. */
  41161. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41162. /**
  41163. * Get a list of transform nodes by tags
  41164. * @param tagsQuery defines the tags query to use
  41165. * @param forEach defines a predicate used to filter results
  41166. * @returns an array of TransformNode
  41167. */
  41168. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41169. /**
  41170. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41171. * This allowed control for front to back rendering or reversly depending of the special needs.
  41172. *
  41173. * @param renderingGroupId The rendering group id corresponding to its index
  41174. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41175. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41176. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41177. */
  41178. 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;
  41179. /**
  41180. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41181. *
  41182. * @param renderingGroupId The rendering group id corresponding to its index
  41183. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41184. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41185. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41186. */
  41187. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41188. /**
  41189. * Gets the current auto clear configuration for one rendering group of the rendering
  41190. * manager.
  41191. * @param index the rendering group index to get the information for
  41192. * @returns The auto clear setup for the requested rendering group
  41193. */
  41194. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41195. private _blockMaterialDirtyMechanism;
  41196. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41197. get blockMaterialDirtyMechanism(): boolean;
  41198. set blockMaterialDirtyMechanism(value: boolean);
  41199. /**
  41200. * Will flag all materials as dirty to trigger new shader compilation
  41201. * @param flag defines the flag used to specify which material part must be marked as dirty
  41202. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41203. */
  41204. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41205. /** @hidden */
  41206. _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;
  41207. /** @hidden */
  41208. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41209. /** @hidden */
  41210. _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;
  41211. /** @hidden */
  41212. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41213. /** @hidden */
  41214. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41215. /** @hidden */
  41216. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41217. }
  41218. }
  41219. declare module BABYLON {
  41220. /**
  41221. * Set of assets to keep when moving a scene into an asset container.
  41222. */
  41223. export class KeepAssets extends AbstractScene {
  41224. }
  41225. /**
  41226. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41227. */
  41228. export class InstantiatedEntries {
  41229. /**
  41230. * List of new root nodes (eg. nodes with no parent)
  41231. */
  41232. rootNodes: TransformNode[];
  41233. /**
  41234. * List of new skeletons
  41235. */
  41236. skeletons: Skeleton[];
  41237. /**
  41238. * List of new animation groups
  41239. */
  41240. animationGroups: AnimationGroup[];
  41241. }
  41242. /**
  41243. * Container with a set of assets that can be added or removed from a scene.
  41244. */
  41245. export class AssetContainer extends AbstractScene {
  41246. private _wasAddedToScene;
  41247. /**
  41248. * The scene the AssetContainer belongs to.
  41249. */
  41250. scene: Scene;
  41251. /**
  41252. * Instantiates an AssetContainer.
  41253. * @param scene The scene the AssetContainer belongs to.
  41254. */
  41255. constructor(scene: Scene);
  41256. /**
  41257. * Instantiate or clone all meshes and add the new ones to the scene.
  41258. * Skeletons and animation groups will all be cloned
  41259. * @param nameFunction defines an optional function used to get new names for clones
  41260. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41261. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41262. */
  41263. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41264. /**
  41265. * Adds all the assets from the container to the scene.
  41266. */
  41267. addAllToScene(): void;
  41268. /**
  41269. * Removes all the assets in the container from the scene
  41270. */
  41271. removeAllFromScene(): void;
  41272. /**
  41273. * Disposes all the assets in the container
  41274. */
  41275. dispose(): void;
  41276. private _moveAssets;
  41277. /**
  41278. * Removes all the assets contained in the scene and adds them to the container.
  41279. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41280. */
  41281. moveAllFromScene(keepAssets?: KeepAssets): void;
  41282. /**
  41283. * 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.
  41284. * @returns the root mesh
  41285. */
  41286. createRootMesh(): Mesh;
  41287. /**
  41288. * Merge animations (direct and animation groups) from this asset container into a scene
  41289. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41290. * @param animatables set of animatables to retarget to a node from the scene
  41291. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41292. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41293. */
  41294. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Defines how the parser contract is defined.
  41300. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41301. */
  41302. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41303. /**
  41304. * Defines how the individual parser contract is defined.
  41305. * These parser can parse an individual asset
  41306. */
  41307. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41308. /**
  41309. * Base class of the scene acting as a container for the different elements composing a scene.
  41310. * This class is dynamically extended by the different components of the scene increasing
  41311. * flexibility and reducing coupling
  41312. */
  41313. export abstract class AbstractScene {
  41314. /**
  41315. * Stores the list of available parsers in the application.
  41316. */
  41317. private static _BabylonFileParsers;
  41318. /**
  41319. * Stores the list of available individual parsers in the application.
  41320. */
  41321. private static _IndividualBabylonFileParsers;
  41322. /**
  41323. * Adds a parser in the list of available ones
  41324. * @param name Defines the name of the parser
  41325. * @param parser Defines the parser to add
  41326. */
  41327. static AddParser(name: string, parser: BabylonFileParser): void;
  41328. /**
  41329. * Gets a general parser from the list of avaialble ones
  41330. * @param name Defines the name of the parser
  41331. * @returns the requested parser or null
  41332. */
  41333. static GetParser(name: string): Nullable<BabylonFileParser>;
  41334. /**
  41335. * Adds n individual parser in the list of available ones
  41336. * @param name Defines the name of the parser
  41337. * @param parser Defines the parser to add
  41338. */
  41339. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41340. /**
  41341. * Gets an individual parser from the list of avaialble ones
  41342. * @param name Defines the name of the parser
  41343. * @returns the requested parser or null
  41344. */
  41345. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41346. /**
  41347. * Parser json data and populate both a scene and its associated container object
  41348. * @param jsonData Defines the data to parse
  41349. * @param scene Defines the scene to parse the data for
  41350. * @param container Defines the container attached to the parsing sequence
  41351. * @param rootUrl Defines the root url of the data
  41352. */
  41353. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41354. /**
  41355. * Gets the list of root nodes (ie. nodes with no parent)
  41356. */
  41357. rootNodes: Node[];
  41358. /** All of the cameras added to this scene
  41359. * @see https://doc.babylonjs.com/babylon101/cameras
  41360. */
  41361. cameras: Camera[];
  41362. /**
  41363. * All of the lights added to this scene
  41364. * @see https://doc.babylonjs.com/babylon101/lights
  41365. */
  41366. lights: Light[];
  41367. /**
  41368. * All of the (abstract) meshes added to this scene
  41369. */
  41370. meshes: AbstractMesh[];
  41371. /**
  41372. * The list of skeletons added to the scene
  41373. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41374. */
  41375. skeletons: Skeleton[];
  41376. /**
  41377. * All of the particle systems added to this scene
  41378. * @see https://doc.babylonjs.com/babylon101/particles
  41379. */
  41380. particleSystems: IParticleSystem[];
  41381. /**
  41382. * Gets a list of Animations associated with the scene
  41383. */
  41384. animations: Animation[];
  41385. /**
  41386. * All of the animation groups added to this scene
  41387. * @see https://doc.babylonjs.com/how_to/group
  41388. */
  41389. animationGroups: AnimationGroup[];
  41390. /**
  41391. * All of the multi-materials added to this scene
  41392. * @see https://doc.babylonjs.com/how_to/multi_materials
  41393. */
  41394. multiMaterials: MultiMaterial[];
  41395. /**
  41396. * All of the materials added to this scene
  41397. * In the context of a Scene, it is not supposed to be modified manually.
  41398. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41399. * Note also that the order of the Material within the array is not significant and might change.
  41400. * @see https://doc.babylonjs.com/babylon101/materials
  41401. */
  41402. materials: Material[];
  41403. /**
  41404. * The list of morph target managers added to the scene
  41405. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41406. */
  41407. morphTargetManagers: MorphTargetManager[];
  41408. /**
  41409. * The list of geometries used in the scene.
  41410. */
  41411. geometries: Geometry[];
  41412. /**
  41413. * All of the tranform nodes added to this scene
  41414. * In the context of a Scene, it is not supposed to be modified manually.
  41415. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41416. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41417. * @see https://doc.babylonjs.com/how_to/transformnode
  41418. */
  41419. transformNodes: TransformNode[];
  41420. /**
  41421. * ActionManagers available on the scene.
  41422. */
  41423. actionManagers: AbstractActionManager[];
  41424. /**
  41425. * Textures to keep.
  41426. */
  41427. textures: BaseTexture[];
  41428. /** @hidden */
  41429. protected _environmentTexture: Nullable<BaseTexture>;
  41430. /**
  41431. * Texture used in all pbr material as the reflection texture.
  41432. * As in the majority of the scene they are the same (exception for multi room and so on),
  41433. * this is easier to reference from here than from all the materials.
  41434. */
  41435. get environmentTexture(): Nullable<BaseTexture>;
  41436. set environmentTexture(value: Nullable<BaseTexture>);
  41437. /**
  41438. * The list of postprocesses added to the scene
  41439. */
  41440. postProcesses: PostProcess[];
  41441. /**
  41442. * @returns all meshes, lights, cameras, transformNodes and bones
  41443. */
  41444. getNodes(): Array<Node>;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * Interface used to define options for Sound class
  41450. */
  41451. export interface ISoundOptions {
  41452. /**
  41453. * Does the sound autoplay once loaded.
  41454. */
  41455. autoplay?: boolean;
  41456. /**
  41457. * Does the sound loop after it finishes playing once.
  41458. */
  41459. loop?: boolean;
  41460. /**
  41461. * Sound's volume
  41462. */
  41463. volume?: number;
  41464. /**
  41465. * Is it a spatial sound?
  41466. */
  41467. spatialSound?: boolean;
  41468. /**
  41469. * Maximum distance to hear that sound
  41470. */
  41471. maxDistance?: number;
  41472. /**
  41473. * Uses user defined attenuation function
  41474. */
  41475. useCustomAttenuation?: boolean;
  41476. /**
  41477. * Define the roll off factor of spatial sounds.
  41478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41479. */
  41480. rolloffFactor?: number;
  41481. /**
  41482. * Define the reference distance the sound should be heard perfectly.
  41483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41484. */
  41485. refDistance?: number;
  41486. /**
  41487. * Define the distance attenuation model the sound will follow.
  41488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41489. */
  41490. distanceModel?: string;
  41491. /**
  41492. * Defines the playback speed (1 by default)
  41493. */
  41494. playbackRate?: number;
  41495. /**
  41496. * Defines if the sound is from a streaming source
  41497. */
  41498. streaming?: boolean;
  41499. /**
  41500. * Defines an optional length (in seconds) inside the sound file
  41501. */
  41502. length?: number;
  41503. /**
  41504. * Defines an optional offset (in seconds) inside the sound file
  41505. */
  41506. offset?: number;
  41507. /**
  41508. * If true, URLs will not be required to state the audio file codec to use.
  41509. */
  41510. skipCodecCheck?: boolean;
  41511. }
  41512. /**
  41513. * Defines a sound that can be played in the application.
  41514. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41516. */
  41517. export class Sound {
  41518. /**
  41519. * The name of the sound in the scene.
  41520. */
  41521. name: string;
  41522. /**
  41523. * Does the sound autoplay once loaded.
  41524. */
  41525. autoplay: boolean;
  41526. /**
  41527. * Does the sound loop after it finishes playing once.
  41528. */
  41529. loop: boolean;
  41530. /**
  41531. * Does the sound use a custom attenuation curve to simulate the falloff
  41532. * happening when the source gets further away from the camera.
  41533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41534. */
  41535. useCustomAttenuation: boolean;
  41536. /**
  41537. * The sound track id this sound belongs to.
  41538. */
  41539. soundTrackId: number;
  41540. /**
  41541. * Is this sound currently played.
  41542. */
  41543. isPlaying: boolean;
  41544. /**
  41545. * Is this sound currently paused.
  41546. */
  41547. isPaused: boolean;
  41548. /**
  41549. * Does this sound enables spatial sound.
  41550. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41551. */
  41552. spatialSound: boolean;
  41553. /**
  41554. * Define the reference distance the sound should be heard perfectly.
  41555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41556. */
  41557. refDistance: number;
  41558. /**
  41559. * Define the roll off factor of spatial sounds.
  41560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41561. */
  41562. rolloffFactor: number;
  41563. /**
  41564. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41566. */
  41567. maxDistance: number;
  41568. /**
  41569. * Define the distance attenuation model the sound will follow.
  41570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41571. */
  41572. distanceModel: string;
  41573. /**
  41574. * @hidden
  41575. * Back Compat
  41576. **/
  41577. onended: () => any;
  41578. /**
  41579. * Gets or sets an object used to store user defined information for the sound.
  41580. */
  41581. metadata: any;
  41582. /**
  41583. * Observable event when the current playing sound finishes.
  41584. */
  41585. onEndedObservable: Observable<Sound>;
  41586. private _panningModel;
  41587. private _playbackRate;
  41588. private _streaming;
  41589. private _startTime;
  41590. private _startOffset;
  41591. private _position;
  41592. /** @hidden */
  41593. _positionInEmitterSpace: boolean;
  41594. private _localDirection;
  41595. private _volume;
  41596. private _isReadyToPlay;
  41597. private _isDirectional;
  41598. private _readyToPlayCallback;
  41599. private _audioBuffer;
  41600. private _soundSource;
  41601. private _streamingSource;
  41602. private _soundPanner;
  41603. private _soundGain;
  41604. private _inputAudioNode;
  41605. private _outputAudioNode;
  41606. private _coneInnerAngle;
  41607. private _coneOuterAngle;
  41608. private _coneOuterGain;
  41609. private _scene;
  41610. private _connectedTransformNode;
  41611. private _customAttenuationFunction;
  41612. private _registerFunc;
  41613. private _isOutputConnected;
  41614. private _htmlAudioElement;
  41615. private _urlType;
  41616. private _length?;
  41617. private _offset?;
  41618. /** @hidden */
  41619. static _SceneComponentInitialization: (scene: Scene) => void;
  41620. /**
  41621. * Create a sound and attach it to a scene
  41622. * @param name Name of your sound
  41623. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41624. * @param scene defines the scene the sound belongs to
  41625. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41626. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41627. */
  41628. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41629. /**
  41630. * Release the sound and its associated resources
  41631. */
  41632. dispose(): void;
  41633. /**
  41634. * Gets if the sounds is ready to be played or not.
  41635. * @returns true if ready, otherwise false
  41636. */
  41637. isReady(): boolean;
  41638. private _soundLoaded;
  41639. /**
  41640. * Sets the data of the sound from an audiobuffer
  41641. * @param audioBuffer The audioBuffer containing the data
  41642. */
  41643. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41644. /**
  41645. * Updates the current sounds options such as maxdistance, loop...
  41646. * @param options A JSON object containing values named as the object properties
  41647. */
  41648. updateOptions(options: ISoundOptions): void;
  41649. private _createSpatialParameters;
  41650. private _updateSpatialParameters;
  41651. /**
  41652. * Switch the panning model to HRTF:
  41653. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41655. */
  41656. switchPanningModelToHRTF(): void;
  41657. /**
  41658. * Switch the panning model to Equal Power:
  41659. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41661. */
  41662. switchPanningModelToEqualPower(): void;
  41663. private _switchPanningModel;
  41664. /**
  41665. * Connect this sound to a sound track audio node like gain...
  41666. * @param soundTrackAudioNode the sound track audio node to connect to
  41667. */
  41668. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41669. /**
  41670. * Transform this sound into a directional source
  41671. * @param coneInnerAngle Size of the inner cone in degree
  41672. * @param coneOuterAngle Size of the outer cone in degree
  41673. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41674. */
  41675. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41676. /**
  41677. * Gets or sets the inner angle for the directional cone.
  41678. */
  41679. get directionalConeInnerAngle(): number;
  41680. /**
  41681. * Gets or sets the inner angle for the directional cone.
  41682. */
  41683. set directionalConeInnerAngle(value: number);
  41684. /**
  41685. * Gets or sets the outer angle for the directional cone.
  41686. */
  41687. get directionalConeOuterAngle(): number;
  41688. /**
  41689. * Gets or sets the outer angle for the directional cone.
  41690. */
  41691. set directionalConeOuterAngle(value: number);
  41692. /**
  41693. * Sets the position of the emitter if spatial sound is enabled
  41694. * @param newPosition Defines the new posisiton
  41695. */
  41696. setPosition(newPosition: Vector3): void;
  41697. /**
  41698. * Sets the local direction of the emitter if spatial sound is enabled
  41699. * @param newLocalDirection Defines the new local direction
  41700. */
  41701. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41702. private _updateDirection;
  41703. /** @hidden */
  41704. updateDistanceFromListener(): void;
  41705. /**
  41706. * Sets a new custom attenuation function for the sound.
  41707. * @param callback Defines the function used for the attenuation
  41708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41709. */
  41710. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41711. /**
  41712. * Play the sound
  41713. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41714. * @param offset (optional) Start the sound at a specific time in seconds
  41715. * @param length (optional) Sound duration (in seconds)
  41716. */
  41717. play(time?: number, offset?: number, length?: number): void;
  41718. private _onended;
  41719. /**
  41720. * Stop the sound
  41721. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41722. */
  41723. stop(time?: number): void;
  41724. /**
  41725. * Put the sound in pause
  41726. */
  41727. pause(): void;
  41728. /**
  41729. * Sets a dedicated volume for this sounds
  41730. * @param newVolume Define the new volume of the sound
  41731. * @param time Define time for gradual change to new volume
  41732. */
  41733. setVolume(newVolume: number, time?: number): void;
  41734. /**
  41735. * Set the sound play back rate
  41736. * @param newPlaybackRate Define the playback rate the sound should be played at
  41737. */
  41738. setPlaybackRate(newPlaybackRate: number): void;
  41739. /**
  41740. * Gets the volume of the sound.
  41741. * @returns the volume of the sound
  41742. */
  41743. getVolume(): number;
  41744. /**
  41745. * Attach the sound to a dedicated mesh
  41746. * @param transformNode The transform node to connect the sound with
  41747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41748. */
  41749. attachToMesh(transformNode: TransformNode): void;
  41750. /**
  41751. * Detach the sound from the previously attached mesh
  41752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41753. */
  41754. detachFromMesh(): void;
  41755. private _onRegisterAfterWorldMatrixUpdate;
  41756. /**
  41757. * Clone the current sound in the scene.
  41758. * @returns the new sound clone
  41759. */
  41760. clone(): Nullable<Sound>;
  41761. /**
  41762. * Gets the current underlying audio buffer containing the data
  41763. * @returns the audio buffer
  41764. */
  41765. getAudioBuffer(): Nullable<AudioBuffer>;
  41766. /**
  41767. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41768. * @returns the source node
  41769. */
  41770. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41771. /**
  41772. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41773. * @returns the gain node
  41774. */
  41775. getSoundGain(): Nullable<GainNode>;
  41776. /**
  41777. * Serializes the Sound in a JSON representation
  41778. * @returns the JSON representation of the sound
  41779. */
  41780. serialize(): any;
  41781. /**
  41782. * Parse a JSON representation of a sound to innstantiate in a given scene
  41783. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41784. * @param scene Define the scene the new parsed sound should be created in
  41785. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41786. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41787. * @returns the newly parsed sound
  41788. */
  41789. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41790. }
  41791. }
  41792. declare module BABYLON {
  41793. /**
  41794. * This defines an action helpful to play a defined sound on a triggered action.
  41795. */
  41796. export class PlaySoundAction extends Action {
  41797. private _sound;
  41798. /**
  41799. * Instantiate the action
  41800. * @param triggerOptions defines the trigger options
  41801. * @param sound defines the sound to play
  41802. * @param condition defines the trigger related conditions
  41803. */
  41804. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41805. /** @hidden */
  41806. _prepare(): void;
  41807. /**
  41808. * Execute the action and play the sound.
  41809. */
  41810. execute(): void;
  41811. /**
  41812. * Serializes the actions and its related information.
  41813. * @param parent defines the object to serialize in
  41814. * @returns the serialized object
  41815. */
  41816. serialize(parent: any): any;
  41817. }
  41818. /**
  41819. * This defines an action helpful to stop a defined sound on a triggered action.
  41820. */
  41821. export class StopSoundAction extends Action {
  41822. private _sound;
  41823. /**
  41824. * Instantiate the action
  41825. * @param triggerOptions defines the trigger options
  41826. * @param sound defines the sound to stop
  41827. * @param condition defines the trigger related conditions
  41828. */
  41829. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41830. /** @hidden */
  41831. _prepare(): void;
  41832. /**
  41833. * Execute the action and stop the sound.
  41834. */
  41835. execute(): void;
  41836. /**
  41837. * Serializes the actions and its related information.
  41838. * @param parent defines the object to serialize in
  41839. * @returns the serialized object
  41840. */
  41841. serialize(parent: any): any;
  41842. }
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * This defines an action responsible to change the value of a property
  41847. * by interpolating between its current value and the newly set one once triggered.
  41848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41849. */
  41850. export class InterpolateValueAction extends Action {
  41851. /**
  41852. * Defines the path of the property where the value should be interpolated
  41853. */
  41854. propertyPath: string;
  41855. /**
  41856. * Defines the target value at the end of the interpolation.
  41857. */
  41858. value: any;
  41859. /**
  41860. * Defines the time it will take for the property to interpolate to the value.
  41861. */
  41862. duration: number;
  41863. /**
  41864. * Defines if the other scene animations should be stopped when the action has been triggered
  41865. */
  41866. stopOtherAnimations?: boolean;
  41867. /**
  41868. * Defines a callback raised once the interpolation animation has been done.
  41869. */
  41870. onInterpolationDone?: () => void;
  41871. /**
  41872. * Observable triggered once the interpolation animation has been done.
  41873. */
  41874. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41875. private _target;
  41876. private _effectiveTarget;
  41877. private _property;
  41878. /**
  41879. * Instantiate the action
  41880. * @param triggerOptions defines the trigger options
  41881. * @param target defines the object containing the value to interpolate
  41882. * @param propertyPath defines the path to the property in the target object
  41883. * @param value defines the target value at the end of the interpolation
  41884. * @param duration deines the time it will take for the property to interpolate to the value.
  41885. * @param condition defines the trigger related conditions
  41886. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41887. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41888. */
  41889. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41890. /** @hidden */
  41891. _prepare(): void;
  41892. /**
  41893. * Execute the action starts the value interpolation.
  41894. */
  41895. execute(): void;
  41896. /**
  41897. * Serializes the actions and its related information.
  41898. * @param parent defines the object to serialize in
  41899. * @returns the serialized object
  41900. */
  41901. serialize(parent: any): any;
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * Options allowed during the creation of a sound track.
  41907. */
  41908. export interface ISoundTrackOptions {
  41909. /**
  41910. * The volume the sound track should take during creation
  41911. */
  41912. volume?: number;
  41913. /**
  41914. * Define if the sound track is the main sound track of the scene
  41915. */
  41916. mainTrack?: boolean;
  41917. }
  41918. /**
  41919. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41920. * It will be also used in a future release to apply effects on a specific track.
  41921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41922. */
  41923. export class SoundTrack {
  41924. /**
  41925. * The unique identifier of the sound track in the scene.
  41926. */
  41927. id: number;
  41928. /**
  41929. * The list of sounds included in the sound track.
  41930. */
  41931. soundCollection: Array<Sound>;
  41932. private _outputAudioNode;
  41933. private _scene;
  41934. private _connectedAnalyser;
  41935. private _options;
  41936. private _isInitialized;
  41937. /**
  41938. * Creates a new sound track.
  41939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41940. * @param scene Define the scene the sound track belongs to
  41941. * @param options
  41942. */
  41943. constructor(scene: Scene, options?: ISoundTrackOptions);
  41944. private _initializeSoundTrackAudioGraph;
  41945. /**
  41946. * Release the sound track and its associated resources
  41947. */
  41948. dispose(): void;
  41949. /**
  41950. * Adds a sound to this sound track
  41951. * @param sound define the cound to add
  41952. * @ignoreNaming
  41953. */
  41954. AddSound(sound: Sound): void;
  41955. /**
  41956. * Removes a sound to this sound track
  41957. * @param sound define the cound to remove
  41958. * @ignoreNaming
  41959. */
  41960. RemoveSound(sound: Sound): void;
  41961. /**
  41962. * Set a global volume for the full sound track.
  41963. * @param newVolume Define the new volume of the sound track
  41964. */
  41965. setVolume(newVolume: number): void;
  41966. /**
  41967. * Switch the panning model to HRTF:
  41968. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41970. */
  41971. switchPanningModelToHRTF(): void;
  41972. /**
  41973. * Switch the panning model to Equal Power:
  41974. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41976. */
  41977. switchPanningModelToEqualPower(): void;
  41978. /**
  41979. * Connect the sound track to an audio analyser allowing some amazing
  41980. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41981. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41982. * @param analyser The analyser to connect to the engine
  41983. */
  41984. connectToAnalyser(analyser: Analyser): void;
  41985. }
  41986. }
  41987. declare module BABYLON {
  41988. interface AbstractScene {
  41989. /**
  41990. * The list of sounds used in the scene.
  41991. */
  41992. sounds: Nullable<Array<Sound>>;
  41993. }
  41994. interface Scene {
  41995. /**
  41996. * @hidden
  41997. * Backing field
  41998. */
  41999. _mainSoundTrack: SoundTrack;
  42000. /**
  42001. * The main sound track played by the scene.
  42002. * It cotains your primary collection of sounds.
  42003. */
  42004. mainSoundTrack: SoundTrack;
  42005. /**
  42006. * The list of sound tracks added to the scene
  42007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42008. */
  42009. soundTracks: Nullable<Array<SoundTrack>>;
  42010. /**
  42011. * Gets a sound using a given name
  42012. * @param name defines the name to search for
  42013. * @return the found sound or null if not found at all.
  42014. */
  42015. getSoundByName(name: string): Nullable<Sound>;
  42016. /**
  42017. * Gets or sets if audio support is enabled
  42018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42019. */
  42020. audioEnabled: boolean;
  42021. /**
  42022. * Gets or sets if audio will be output to headphones
  42023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42024. */
  42025. headphone: boolean;
  42026. /**
  42027. * Gets or sets custom audio listener position provider
  42028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42029. */
  42030. audioListenerPositionProvider: Nullable<() => Vector3>;
  42031. /**
  42032. * Gets or sets a refresh rate when using 3D audio positioning
  42033. */
  42034. audioPositioningRefreshRate: number;
  42035. }
  42036. /**
  42037. * Defines the sound scene component responsible to manage any sounds
  42038. * in a given scene.
  42039. */
  42040. export class AudioSceneComponent implements ISceneSerializableComponent {
  42041. private static _CameraDirectionLH;
  42042. private static _CameraDirectionRH;
  42043. /**
  42044. * The component name helpfull to identify the component in the list of scene components.
  42045. */
  42046. readonly name: string;
  42047. /**
  42048. * The scene the component belongs to.
  42049. */
  42050. scene: Scene;
  42051. private _audioEnabled;
  42052. /**
  42053. * Gets whether audio is enabled or not.
  42054. * Please use related enable/disable method to switch state.
  42055. */
  42056. get audioEnabled(): boolean;
  42057. private _headphone;
  42058. /**
  42059. * Gets whether audio is outputing to headphone or not.
  42060. * Please use the according Switch methods to change output.
  42061. */
  42062. get headphone(): boolean;
  42063. /**
  42064. * Gets or sets a refresh rate when using 3D audio positioning
  42065. */
  42066. audioPositioningRefreshRate: number;
  42067. private _audioListenerPositionProvider;
  42068. /**
  42069. * Gets the current audio listener position provider
  42070. */
  42071. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42072. /**
  42073. * Sets a custom listener position for all sounds in the scene
  42074. * By default, this is the position of the first active camera
  42075. */
  42076. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42077. /**
  42078. * Creates a new instance of the component for the given scene
  42079. * @param scene Defines the scene to register the component in
  42080. */
  42081. constructor(scene: Scene);
  42082. /**
  42083. * Registers the component in a given scene
  42084. */
  42085. register(): void;
  42086. /**
  42087. * Rebuilds the elements related to this component in case of
  42088. * context lost for instance.
  42089. */
  42090. rebuild(): void;
  42091. /**
  42092. * Serializes the component data to the specified json object
  42093. * @param serializationObject The object to serialize to
  42094. */
  42095. serialize(serializationObject: any): void;
  42096. /**
  42097. * Adds all the elements from the container to the scene
  42098. * @param container the container holding the elements
  42099. */
  42100. addFromContainer(container: AbstractScene): void;
  42101. /**
  42102. * Removes all the elements in the container from the scene
  42103. * @param container contains the elements to remove
  42104. * @param dispose if the removed element should be disposed (default: false)
  42105. */
  42106. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42107. /**
  42108. * Disposes the component and the associated ressources.
  42109. */
  42110. dispose(): void;
  42111. /**
  42112. * Disables audio in the associated scene.
  42113. */
  42114. disableAudio(): void;
  42115. /**
  42116. * Enables audio in the associated scene.
  42117. */
  42118. enableAudio(): void;
  42119. /**
  42120. * Switch audio to headphone output.
  42121. */
  42122. switchAudioModeForHeadphones(): void;
  42123. /**
  42124. * Switch audio to normal speakers.
  42125. */
  42126. switchAudioModeForNormalSpeakers(): void;
  42127. private _cachedCameraDirection;
  42128. private _cachedCameraPosition;
  42129. private _lastCheck;
  42130. private _afterRender;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Wraps one or more Sound objects and selects one with random weight for playback.
  42136. */
  42137. export class WeightedSound {
  42138. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42139. loop: boolean;
  42140. private _coneInnerAngle;
  42141. private _coneOuterAngle;
  42142. private _volume;
  42143. /** A Sound is currently playing. */
  42144. isPlaying: boolean;
  42145. /** A Sound is currently paused. */
  42146. isPaused: boolean;
  42147. private _sounds;
  42148. private _weights;
  42149. private _currentIndex?;
  42150. /**
  42151. * Creates a new WeightedSound from the list of sounds given.
  42152. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42153. * @param sounds Array of Sounds that will be selected from.
  42154. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42155. */
  42156. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42157. /**
  42158. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42159. */
  42160. get directionalConeInnerAngle(): number;
  42161. /**
  42162. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42163. */
  42164. set directionalConeInnerAngle(value: number);
  42165. /**
  42166. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42167. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42168. */
  42169. get directionalConeOuterAngle(): number;
  42170. /**
  42171. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42172. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42173. */
  42174. set directionalConeOuterAngle(value: number);
  42175. /**
  42176. * Playback volume.
  42177. */
  42178. get volume(): number;
  42179. /**
  42180. * Playback volume.
  42181. */
  42182. set volume(value: number);
  42183. private _onended;
  42184. /**
  42185. * Suspend playback
  42186. */
  42187. pause(): void;
  42188. /**
  42189. * Stop playback
  42190. */
  42191. stop(): void;
  42192. /**
  42193. * Start playback.
  42194. * @param startOffset Position the clip head at a specific time in seconds.
  42195. */
  42196. play(startOffset?: number): void;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42202. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42203. */
  42204. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42205. /**
  42206. * Gets the name of the behavior.
  42207. */
  42208. get name(): string;
  42209. /**
  42210. * The easing function used by animations
  42211. */
  42212. static EasingFunction: BackEase;
  42213. /**
  42214. * The easing mode used by animations
  42215. */
  42216. static EasingMode: number;
  42217. /**
  42218. * The duration of the animation, in milliseconds
  42219. */
  42220. transitionDuration: number;
  42221. /**
  42222. * Length of the distance animated by the transition when lower radius is reached
  42223. */
  42224. lowerRadiusTransitionRange: number;
  42225. /**
  42226. * Length of the distance animated by the transition when upper radius is reached
  42227. */
  42228. upperRadiusTransitionRange: number;
  42229. private _autoTransitionRange;
  42230. /**
  42231. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42232. */
  42233. get autoTransitionRange(): boolean;
  42234. /**
  42235. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42236. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42237. */
  42238. set autoTransitionRange(value: boolean);
  42239. private _attachedCamera;
  42240. private _onAfterCheckInputsObserver;
  42241. private _onMeshTargetChangedObserver;
  42242. /**
  42243. * Initializes the behavior.
  42244. */
  42245. init(): void;
  42246. /**
  42247. * Attaches the behavior to its arc rotate camera.
  42248. * @param camera Defines the camera to attach the behavior to
  42249. */
  42250. attach(camera: ArcRotateCamera): void;
  42251. /**
  42252. * Detaches the behavior from its current arc rotate camera.
  42253. */
  42254. detach(): void;
  42255. private _radiusIsAnimating;
  42256. private _radiusBounceTransition;
  42257. private _animatables;
  42258. private _cachedWheelPrecision;
  42259. /**
  42260. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42261. * @param radiusLimit The limit to check against.
  42262. * @return Bool to indicate if at limit.
  42263. */
  42264. private _isRadiusAtLimit;
  42265. /**
  42266. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42267. * @param radiusDelta The delta by which to animate to. Can be negative.
  42268. */
  42269. private _applyBoundRadiusAnimation;
  42270. /**
  42271. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42272. */
  42273. protected _clearAnimationLocks(): void;
  42274. /**
  42275. * Stops and removes all animations that have been applied to the camera
  42276. */
  42277. stopAllAnimations(): void;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * 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.
  42283. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42284. */
  42285. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42286. /**
  42287. * Gets the name of the behavior.
  42288. */
  42289. get name(): string;
  42290. private _mode;
  42291. private _radiusScale;
  42292. private _positionScale;
  42293. private _defaultElevation;
  42294. private _elevationReturnTime;
  42295. private _elevationReturnWaitTime;
  42296. private _zoomStopsAnimation;
  42297. private _framingTime;
  42298. /**
  42299. * The easing function used by animations
  42300. */
  42301. static EasingFunction: ExponentialEase;
  42302. /**
  42303. * The easing mode used by animations
  42304. */
  42305. static EasingMode: number;
  42306. /**
  42307. * Sets the current mode used by the behavior
  42308. */
  42309. set mode(mode: number);
  42310. /**
  42311. * Gets current mode used by the behavior.
  42312. */
  42313. get mode(): number;
  42314. /**
  42315. * Sets the scale applied to the radius (1 by default)
  42316. */
  42317. set radiusScale(radius: number);
  42318. /**
  42319. * Gets the scale applied to the radius
  42320. */
  42321. get radiusScale(): number;
  42322. /**
  42323. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42324. */
  42325. set positionScale(scale: number);
  42326. /**
  42327. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42328. */
  42329. get positionScale(): number;
  42330. /**
  42331. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42332. * behaviour is triggered, in radians.
  42333. */
  42334. set defaultElevation(elevation: number);
  42335. /**
  42336. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42337. * behaviour is triggered, in radians.
  42338. */
  42339. get defaultElevation(): number;
  42340. /**
  42341. * Sets the time (in milliseconds) taken to return to the default beta position.
  42342. * Negative value indicates camera should not return to default.
  42343. */
  42344. set elevationReturnTime(speed: number);
  42345. /**
  42346. * Gets the time (in milliseconds) taken to return to the default beta position.
  42347. * Negative value indicates camera should not return to default.
  42348. */
  42349. get elevationReturnTime(): number;
  42350. /**
  42351. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42352. */
  42353. set elevationReturnWaitTime(time: number);
  42354. /**
  42355. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42356. */
  42357. get elevationReturnWaitTime(): number;
  42358. /**
  42359. * Sets the flag that indicates if user zooming should stop animation.
  42360. */
  42361. set zoomStopsAnimation(flag: boolean);
  42362. /**
  42363. * Gets the flag that indicates if user zooming should stop animation.
  42364. */
  42365. get zoomStopsAnimation(): boolean;
  42366. /**
  42367. * Sets the transition time when framing the mesh, in milliseconds
  42368. */
  42369. set framingTime(time: number);
  42370. /**
  42371. * Gets the transition time when framing the mesh, in milliseconds
  42372. */
  42373. get framingTime(): number;
  42374. /**
  42375. * Define if the behavior should automatically change the configured
  42376. * camera limits and sensibilities.
  42377. */
  42378. autoCorrectCameraLimitsAndSensibility: boolean;
  42379. private _onPrePointerObservableObserver;
  42380. private _onAfterCheckInputsObserver;
  42381. private _onMeshTargetChangedObserver;
  42382. private _attachedCamera;
  42383. private _isPointerDown;
  42384. private _lastInteractionTime;
  42385. /**
  42386. * Initializes the behavior.
  42387. */
  42388. init(): void;
  42389. /**
  42390. * Attaches the behavior to its arc rotate camera.
  42391. * @param camera Defines the camera to attach the behavior to
  42392. */
  42393. attach(camera: ArcRotateCamera): void;
  42394. /**
  42395. * Detaches the behavior from its current arc rotate camera.
  42396. */
  42397. detach(): void;
  42398. private _animatables;
  42399. private _betaIsAnimating;
  42400. private _betaTransition;
  42401. private _radiusTransition;
  42402. private _vectorTransition;
  42403. /**
  42404. * Targets the given mesh and updates zoom level accordingly.
  42405. * @param mesh The mesh to target.
  42406. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42407. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42408. */
  42409. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42410. /**
  42411. * Targets the given mesh with its children and updates zoom level accordingly.
  42412. * @param mesh The mesh to target.
  42413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42415. */
  42416. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42417. /**
  42418. * Targets the given meshes with their children and updates zoom level accordingly.
  42419. * @param meshes The mesh to target.
  42420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42422. */
  42423. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42424. /**
  42425. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42426. * @param minimumWorld Determines the smaller position of the bounding box extend
  42427. * @param maximumWorld Determines the bigger position of the bounding box extend
  42428. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42429. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42430. */
  42431. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42432. /**
  42433. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42434. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42435. * frustum width.
  42436. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42437. * to fully enclose the mesh in the viewing frustum.
  42438. */
  42439. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42440. /**
  42441. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42442. * is automatically returned to its default position (expected to be above ground plane).
  42443. */
  42444. private _maintainCameraAboveGround;
  42445. /**
  42446. * Returns the frustum slope based on the canvas ratio and camera FOV
  42447. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42448. */
  42449. private _getFrustumSlope;
  42450. /**
  42451. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42452. */
  42453. private _clearAnimationLocks;
  42454. /**
  42455. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42456. */
  42457. private _applyUserInteraction;
  42458. /**
  42459. * Stops and removes all animations that have been applied to the camera
  42460. */
  42461. stopAllAnimations(): void;
  42462. /**
  42463. * Gets a value indicating if the user is moving the camera
  42464. */
  42465. get isUserIsMoving(): boolean;
  42466. /**
  42467. * The camera can move all the way towards the mesh.
  42468. */
  42469. static IgnoreBoundsSizeMode: number;
  42470. /**
  42471. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42472. */
  42473. static FitFrustumSidesMode: number;
  42474. }
  42475. }
  42476. declare module BABYLON {
  42477. /**
  42478. * Base class for Camera Pointer Inputs.
  42479. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42480. * for example usage.
  42481. */
  42482. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42483. /**
  42484. * Defines the camera the input is attached to.
  42485. */
  42486. abstract camera: Camera;
  42487. /**
  42488. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42489. */
  42490. protected _altKey: boolean;
  42491. protected _ctrlKey: boolean;
  42492. protected _metaKey: boolean;
  42493. protected _shiftKey: boolean;
  42494. /**
  42495. * Which mouse buttons were pressed at time of last mouse event.
  42496. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42497. */
  42498. protected _buttonsPressed: number;
  42499. /**
  42500. * Defines the buttons associated with the input to handle camera move.
  42501. */
  42502. buttons: number[];
  42503. /**
  42504. * Attach the input controls to a specific dom element to get the input from.
  42505. * @param element Defines the element the controls should be listened from
  42506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42507. */
  42508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42509. /**
  42510. * Detach the current controls from the specified dom element.
  42511. * @param element Defines the element to stop listening the inputs from
  42512. */
  42513. detachControl(element: Nullable<HTMLElement>): void;
  42514. /**
  42515. * Gets the class name of the current input.
  42516. * @returns the class name
  42517. */
  42518. getClassName(): string;
  42519. /**
  42520. * Get the friendly name associated with the input class.
  42521. * @returns the input friendly name
  42522. */
  42523. getSimpleName(): string;
  42524. /**
  42525. * Called on pointer POINTERDOUBLETAP event.
  42526. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42527. */
  42528. protected onDoubleTap(type: string): void;
  42529. /**
  42530. * Called on pointer POINTERMOVE event if only a single touch is active.
  42531. * Override this method to provide functionality.
  42532. */
  42533. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42534. /**
  42535. * Called on pointer POINTERMOVE event if multiple touches are active.
  42536. * Override this method to provide functionality.
  42537. */
  42538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42539. /**
  42540. * Called on JS contextmenu event.
  42541. * Override this method to provide functionality.
  42542. */
  42543. protected onContextMenu(evt: PointerEvent): void;
  42544. /**
  42545. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42546. * press.
  42547. * Override this method to provide functionality.
  42548. */
  42549. protected onButtonDown(evt: PointerEvent): void;
  42550. /**
  42551. * Called each time a new POINTERUP event occurs. Ie, for each button
  42552. * release.
  42553. * Override this method to provide functionality.
  42554. */
  42555. protected onButtonUp(evt: PointerEvent): void;
  42556. /**
  42557. * Called when window becomes inactive.
  42558. * Override this method to provide functionality.
  42559. */
  42560. protected onLostFocus(): void;
  42561. private _pointerInput;
  42562. private _observer;
  42563. private _onLostFocus;
  42564. private pointA;
  42565. private pointB;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Manage the pointers inputs to control an arc rotate camera.
  42571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42572. */
  42573. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42574. /**
  42575. * Defines the camera the input is attached to.
  42576. */
  42577. camera: ArcRotateCamera;
  42578. /**
  42579. * Gets the class name of the current input.
  42580. * @returns the class name
  42581. */
  42582. getClassName(): string;
  42583. /**
  42584. * Defines the buttons associated with the input to handle camera move.
  42585. */
  42586. buttons: number[];
  42587. /**
  42588. * Defines the pointer angular sensibility along the X axis or how fast is
  42589. * the camera rotating.
  42590. */
  42591. angularSensibilityX: number;
  42592. /**
  42593. * Defines the pointer angular sensibility along the Y axis or how fast is
  42594. * the camera rotating.
  42595. */
  42596. angularSensibilityY: number;
  42597. /**
  42598. * Defines the pointer pinch precision or how fast is the camera zooming.
  42599. */
  42600. pinchPrecision: number;
  42601. /**
  42602. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42603. * from 0.
  42604. * It defines the percentage of current camera.radius to use as delta when
  42605. * pinch zoom is used.
  42606. */
  42607. pinchDeltaPercentage: number;
  42608. /**
  42609. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42610. * that any object in the plane at the camera's target point will scale
  42611. * perfectly with finger motion.
  42612. * Overrides pinchDeltaPercentage and pinchPrecision.
  42613. */
  42614. useNaturalPinchZoom: boolean;
  42615. /**
  42616. * Defines the pointer panning sensibility or how fast is the camera moving.
  42617. */
  42618. panningSensibility: number;
  42619. /**
  42620. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42621. */
  42622. multiTouchPanning: boolean;
  42623. /**
  42624. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42625. * zoom (pinch) through multitouch.
  42626. */
  42627. multiTouchPanAndZoom: boolean;
  42628. /**
  42629. * Revers pinch action direction.
  42630. */
  42631. pinchInwards: boolean;
  42632. private _isPanClick;
  42633. private _twoFingerActivityCount;
  42634. private _isPinching;
  42635. /**
  42636. * Called on pointer POINTERMOVE event if only a single touch is active.
  42637. */
  42638. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42639. /**
  42640. * Called on pointer POINTERDOUBLETAP event.
  42641. */
  42642. protected onDoubleTap(type: string): void;
  42643. /**
  42644. * Called on pointer POINTERMOVE event if multiple touches are active.
  42645. */
  42646. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42647. /**
  42648. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42649. * press.
  42650. */
  42651. protected onButtonDown(evt: PointerEvent): void;
  42652. /**
  42653. * Called each time a new POINTERUP event occurs. Ie, for each button
  42654. * release.
  42655. */
  42656. protected onButtonUp(evt: PointerEvent): void;
  42657. /**
  42658. * Called when window becomes inactive.
  42659. */
  42660. protected onLostFocus(): void;
  42661. }
  42662. }
  42663. declare module BABYLON {
  42664. /**
  42665. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42666. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42667. */
  42668. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42669. /**
  42670. * Defines the camera the input is attached to.
  42671. */
  42672. camera: ArcRotateCamera;
  42673. /**
  42674. * Defines the list of key codes associated with the up action (increase alpha)
  42675. */
  42676. keysUp: number[];
  42677. /**
  42678. * Defines the list of key codes associated with the down action (decrease alpha)
  42679. */
  42680. keysDown: number[];
  42681. /**
  42682. * Defines the list of key codes associated with the left action (increase beta)
  42683. */
  42684. keysLeft: number[];
  42685. /**
  42686. * Defines the list of key codes associated with the right action (decrease beta)
  42687. */
  42688. keysRight: number[];
  42689. /**
  42690. * Defines the list of key codes associated with the reset action.
  42691. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42692. */
  42693. keysReset: number[];
  42694. /**
  42695. * Defines the panning sensibility of the inputs.
  42696. * (How fast is the camera panning)
  42697. */
  42698. panningSensibility: number;
  42699. /**
  42700. * Defines the zooming sensibility of the inputs.
  42701. * (How fast is the camera zooming)
  42702. */
  42703. zoomingSensibility: number;
  42704. /**
  42705. * Defines whether maintaining the alt key down switch the movement mode from
  42706. * orientation to zoom.
  42707. */
  42708. useAltToZoom: boolean;
  42709. /**
  42710. * Rotation speed of the camera
  42711. */
  42712. angularSpeed: number;
  42713. private _keys;
  42714. private _ctrlPressed;
  42715. private _altPressed;
  42716. private _onCanvasBlurObserver;
  42717. private _onKeyboardObserver;
  42718. private _engine;
  42719. private _scene;
  42720. /**
  42721. * Attach the input controls to a specific dom element to get the input from.
  42722. * @param element Defines the element the controls should be listened from
  42723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42724. */
  42725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42726. /**
  42727. * Detach the current controls from the specified dom element.
  42728. * @param element Defines the element to stop listening the inputs from
  42729. */
  42730. detachControl(element: Nullable<HTMLElement>): void;
  42731. /**
  42732. * Update the current camera state depending on the inputs that have been used this frame.
  42733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42734. */
  42735. checkInputs(): void;
  42736. /**
  42737. * Gets the class name of the current intput.
  42738. * @returns the class name
  42739. */
  42740. getClassName(): string;
  42741. /**
  42742. * Get the friendly name associated with the input class.
  42743. * @returns the input friendly name
  42744. */
  42745. getSimpleName(): string;
  42746. }
  42747. }
  42748. declare module BABYLON {
  42749. /**
  42750. * Manage the mouse wheel inputs to control an arc rotate camera.
  42751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42752. */
  42753. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42754. /**
  42755. * Defines the camera the input is attached to.
  42756. */
  42757. camera: ArcRotateCamera;
  42758. /**
  42759. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42760. */
  42761. wheelPrecision: number;
  42762. /**
  42763. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42764. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42765. */
  42766. wheelDeltaPercentage: number;
  42767. private _wheel;
  42768. private _observer;
  42769. private computeDeltaFromMouseWheelLegacyEvent;
  42770. /**
  42771. * Attach the input controls to a specific dom element to get the input from.
  42772. * @param element Defines the element the controls should be listened from
  42773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42774. */
  42775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42776. /**
  42777. * Detach the current controls from the specified dom element.
  42778. * @param element Defines the element to stop listening the inputs from
  42779. */
  42780. detachControl(element: Nullable<HTMLElement>): void;
  42781. /**
  42782. * Gets the class name of the current intput.
  42783. * @returns the class name
  42784. */
  42785. getClassName(): string;
  42786. /**
  42787. * Get the friendly name associated with the input class.
  42788. * @returns the input friendly name
  42789. */
  42790. getSimpleName(): string;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. /**
  42795. * Default Inputs manager for the ArcRotateCamera.
  42796. * It groups all the default supported inputs for ease of use.
  42797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42798. */
  42799. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42800. /**
  42801. * Instantiates a new ArcRotateCameraInputsManager.
  42802. * @param camera Defines the camera the inputs belong to
  42803. */
  42804. constructor(camera: ArcRotateCamera);
  42805. /**
  42806. * Add mouse wheel input support to the input manager.
  42807. * @returns the current input manager
  42808. */
  42809. addMouseWheel(): ArcRotateCameraInputsManager;
  42810. /**
  42811. * Add pointers input support to the input manager.
  42812. * @returns the current input manager
  42813. */
  42814. addPointers(): ArcRotateCameraInputsManager;
  42815. /**
  42816. * Add keyboard input support to the input manager.
  42817. * @returns the current input manager
  42818. */
  42819. addKeyboard(): ArcRotateCameraInputsManager;
  42820. }
  42821. }
  42822. declare module BABYLON {
  42823. /**
  42824. * This represents an orbital type of camera.
  42825. *
  42826. * 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.
  42827. * 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.
  42828. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42829. */
  42830. export class ArcRotateCamera extends TargetCamera {
  42831. /**
  42832. * Defines the rotation angle of the camera along the longitudinal axis.
  42833. */
  42834. alpha: number;
  42835. /**
  42836. * Defines the rotation angle of the camera along the latitudinal axis.
  42837. */
  42838. beta: number;
  42839. /**
  42840. * Defines the radius of the camera from it s target point.
  42841. */
  42842. radius: number;
  42843. protected _target: Vector3;
  42844. protected _targetHost: Nullable<AbstractMesh>;
  42845. /**
  42846. * Defines the target point of the camera.
  42847. * The camera looks towards it form the radius distance.
  42848. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42849. */
  42850. get target(): Vector3;
  42851. set target(value: Vector3);
  42852. /**
  42853. * Define the current local position of the camera in the scene
  42854. */
  42855. get position(): Vector3;
  42856. set position(newPosition: Vector3);
  42857. protected _upToYMatrix: Matrix;
  42858. protected _YToUpMatrix: Matrix;
  42859. /**
  42860. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42861. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42862. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42863. */
  42864. set upVector(vec: Vector3);
  42865. get upVector(): Vector3;
  42866. /**
  42867. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42868. */
  42869. setMatUp(): void;
  42870. /**
  42871. * Current inertia value on the longitudinal axis.
  42872. * The bigger this number the longer it will take for the camera to stop.
  42873. */
  42874. inertialAlphaOffset: number;
  42875. /**
  42876. * Current inertia value on the latitudinal axis.
  42877. * The bigger this number the longer it will take for the camera to stop.
  42878. */
  42879. inertialBetaOffset: number;
  42880. /**
  42881. * Current inertia value on the radius axis.
  42882. * The bigger this number the longer it will take for the camera to stop.
  42883. */
  42884. inertialRadiusOffset: number;
  42885. /**
  42886. * Minimum allowed angle on the longitudinal axis.
  42887. * This can help limiting how the Camera is able to move in the scene.
  42888. */
  42889. lowerAlphaLimit: Nullable<number>;
  42890. /**
  42891. * Maximum allowed angle on the longitudinal axis.
  42892. * This can help limiting how the Camera is able to move in the scene.
  42893. */
  42894. upperAlphaLimit: Nullable<number>;
  42895. /**
  42896. * Minimum allowed angle on the latitudinal axis.
  42897. * This can help limiting how the Camera is able to move in the scene.
  42898. */
  42899. lowerBetaLimit: number;
  42900. /**
  42901. * Maximum allowed angle on the latitudinal axis.
  42902. * This can help limiting how the Camera is able to move in the scene.
  42903. */
  42904. upperBetaLimit: number;
  42905. /**
  42906. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42907. * This can help limiting how the Camera is able to move in the scene.
  42908. */
  42909. lowerRadiusLimit: Nullable<number>;
  42910. /**
  42911. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42912. * This can help limiting how the Camera is able to move in the scene.
  42913. */
  42914. upperRadiusLimit: Nullable<number>;
  42915. /**
  42916. * Defines the current inertia value used during panning of the camera along the X axis.
  42917. */
  42918. inertialPanningX: number;
  42919. /**
  42920. * Defines the current inertia value used during panning of the camera along the Y axis.
  42921. */
  42922. inertialPanningY: number;
  42923. /**
  42924. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42925. * Basically if your fingers moves away from more than this distance you will be considered
  42926. * in pinch mode.
  42927. */
  42928. pinchToPanMaxDistance: number;
  42929. /**
  42930. * Defines the maximum distance the camera can pan.
  42931. * This could help keeping the cammera always in your scene.
  42932. */
  42933. panningDistanceLimit: Nullable<number>;
  42934. /**
  42935. * Defines the target of the camera before paning.
  42936. */
  42937. panningOriginTarget: Vector3;
  42938. /**
  42939. * Defines the value of the inertia used during panning.
  42940. * 0 would mean stop inertia and one would mean no decelleration at all.
  42941. */
  42942. panningInertia: number;
  42943. /**
  42944. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42945. */
  42946. get angularSensibilityX(): number;
  42947. set angularSensibilityX(value: number);
  42948. /**
  42949. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42950. */
  42951. get angularSensibilityY(): number;
  42952. set angularSensibilityY(value: number);
  42953. /**
  42954. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42955. */
  42956. get pinchPrecision(): number;
  42957. set pinchPrecision(value: number);
  42958. /**
  42959. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42960. * It will be used instead of pinchDeltaPrecision if different from 0.
  42961. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42962. */
  42963. get pinchDeltaPercentage(): number;
  42964. set pinchDeltaPercentage(value: number);
  42965. /**
  42966. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42967. * and pinch delta percentage.
  42968. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42969. * that any object in the plane at the camera's target point will scale
  42970. * perfectly with finger motion.
  42971. */
  42972. get useNaturalPinchZoom(): boolean;
  42973. set useNaturalPinchZoom(value: boolean);
  42974. /**
  42975. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42976. */
  42977. get panningSensibility(): number;
  42978. set panningSensibility(value: number);
  42979. /**
  42980. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42981. */
  42982. get keysUp(): number[];
  42983. set keysUp(value: number[]);
  42984. /**
  42985. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42986. */
  42987. get keysDown(): number[];
  42988. set keysDown(value: number[]);
  42989. /**
  42990. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42991. */
  42992. get keysLeft(): number[];
  42993. set keysLeft(value: number[]);
  42994. /**
  42995. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42996. */
  42997. get keysRight(): number[];
  42998. set keysRight(value: number[]);
  42999. /**
  43000. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43001. */
  43002. get wheelPrecision(): number;
  43003. set wheelPrecision(value: number);
  43004. /**
  43005. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43006. * It will be used instead of pinchDeltaPrecision if different from 0.
  43007. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43008. */
  43009. get wheelDeltaPercentage(): number;
  43010. set wheelDeltaPercentage(value: number);
  43011. /**
  43012. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43013. */
  43014. zoomOnFactor: number;
  43015. /**
  43016. * Defines a screen offset for the camera position.
  43017. */
  43018. targetScreenOffset: Vector2;
  43019. /**
  43020. * Allows the camera to be completely reversed.
  43021. * If false the camera can not arrive upside down.
  43022. */
  43023. allowUpsideDown: boolean;
  43024. /**
  43025. * Define if double tap/click is used to restore the previously saved state of the camera.
  43026. */
  43027. useInputToRestoreState: boolean;
  43028. /** @hidden */
  43029. _viewMatrix: Matrix;
  43030. /** @hidden */
  43031. _useCtrlForPanning: boolean;
  43032. /** @hidden */
  43033. _panningMouseButton: number;
  43034. /**
  43035. * Defines the input associated to the camera.
  43036. */
  43037. inputs: ArcRotateCameraInputsManager;
  43038. /** @hidden */
  43039. _reset: () => void;
  43040. /**
  43041. * Defines the allowed panning axis.
  43042. */
  43043. panningAxis: Vector3;
  43044. protected _localDirection: Vector3;
  43045. protected _transformedDirection: Vector3;
  43046. private _bouncingBehavior;
  43047. /**
  43048. * Gets the bouncing behavior of the camera if it has been enabled.
  43049. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43050. */
  43051. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43052. /**
  43053. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43054. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43055. */
  43056. get useBouncingBehavior(): boolean;
  43057. set useBouncingBehavior(value: boolean);
  43058. private _framingBehavior;
  43059. /**
  43060. * Gets the framing behavior of the camera if it has been enabled.
  43061. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43062. */
  43063. get framingBehavior(): Nullable<FramingBehavior>;
  43064. /**
  43065. * Defines if the framing behavior of the camera is enabled on the camera.
  43066. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43067. */
  43068. get useFramingBehavior(): boolean;
  43069. set useFramingBehavior(value: boolean);
  43070. private _autoRotationBehavior;
  43071. /**
  43072. * Gets the auto rotation behavior of the camera if it has been enabled.
  43073. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43074. */
  43075. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43076. /**
  43077. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43078. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43079. */
  43080. get useAutoRotationBehavior(): boolean;
  43081. set useAutoRotationBehavior(value: boolean);
  43082. /**
  43083. * Observable triggered when the mesh target has been changed on the camera.
  43084. */
  43085. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43086. /**
  43087. * Event raised when the camera is colliding with a mesh.
  43088. */
  43089. onCollide: (collidedMesh: AbstractMesh) => void;
  43090. /**
  43091. * Defines whether the camera should check collision with the objects oh the scene.
  43092. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43093. */
  43094. checkCollisions: boolean;
  43095. /**
  43096. * Defines the collision radius of the camera.
  43097. * This simulates a sphere around the camera.
  43098. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43099. */
  43100. collisionRadius: Vector3;
  43101. protected _collider: Collider;
  43102. protected _previousPosition: Vector3;
  43103. protected _collisionVelocity: Vector3;
  43104. protected _newPosition: Vector3;
  43105. protected _previousAlpha: number;
  43106. protected _previousBeta: number;
  43107. protected _previousRadius: number;
  43108. protected _collisionTriggered: boolean;
  43109. protected _targetBoundingCenter: Nullable<Vector3>;
  43110. private _computationVector;
  43111. /**
  43112. * Instantiates a new ArcRotateCamera in a given scene
  43113. * @param name Defines the name of the camera
  43114. * @param alpha Defines the camera rotation along the logitudinal axis
  43115. * @param beta Defines the camera rotation along the latitudinal axis
  43116. * @param radius Defines the camera distance from its target
  43117. * @param target Defines the camera target
  43118. * @param scene Defines the scene the camera belongs to
  43119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43120. */
  43121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43122. /** @hidden */
  43123. _initCache(): void;
  43124. /** @hidden */
  43125. _updateCache(ignoreParentClass?: boolean): void;
  43126. protected _getTargetPosition(): Vector3;
  43127. private _storedAlpha;
  43128. private _storedBeta;
  43129. private _storedRadius;
  43130. private _storedTarget;
  43131. private _storedTargetScreenOffset;
  43132. /**
  43133. * Stores the current state of the camera (alpha, beta, radius and target)
  43134. * @returns the camera itself
  43135. */
  43136. storeState(): Camera;
  43137. /**
  43138. * @hidden
  43139. * Restored camera state. You must call storeState() first
  43140. */
  43141. _restoreStateValues(): boolean;
  43142. /** @hidden */
  43143. _isSynchronizedViewMatrix(): boolean;
  43144. /**
  43145. * Attached controls to the current camera.
  43146. * @param element Defines the element the controls should be listened from
  43147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43148. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43149. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43150. */
  43151. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43152. /**
  43153. * Detach the current controls from the camera.
  43154. * The camera will stop reacting to inputs.
  43155. * @param element Defines the element to stop listening the inputs from
  43156. */
  43157. detachControl(element: HTMLElement): void;
  43158. /** @hidden */
  43159. _checkInputs(): void;
  43160. protected _checkLimits(): void;
  43161. /**
  43162. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43163. */
  43164. rebuildAnglesAndRadius(): void;
  43165. /**
  43166. * Use a position to define the current camera related information like alpha, beta and radius
  43167. * @param position Defines the position to set the camera at
  43168. */
  43169. setPosition(position: Vector3): void;
  43170. /**
  43171. * Defines the target the camera should look at.
  43172. * This will automatically adapt alpha beta and radius to fit within the new target.
  43173. * @param target Defines the new target as a Vector or a mesh
  43174. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43175. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43176. */
  43177. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43178. /** @hidden */
  43179. _getViewMatrix(): Matrix;
  43180. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43181. /**
  43182. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43183. * @param meshes Defines the mesh to zoom on
  43184. * @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)
  43185. */
  43186. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43187. /**
  43188. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43189. * The target will be changed but the radius
  43190. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43191. * @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)
  43192. */
  43193. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43194. min: Vector3;
  43195. max: Vector3;
  43196. distance: number;
  43197. }, doNotUpdateMaxZ?: boolean): void;
  43198. /**
  43199. * @override
  43200. * Override Camera.createRigCamera
  43201. */
  43202. createRigCamera(name: string, cameraIndex: number): Camera;
  43203. /**
  43204. * @hidden
  43205. * @override
  43206. * Override Camera._updateRigCameras
  43207. */
  43208. _updateRigCameras(): void;
  43209. /**
  43210. * Destroy the camera and release the current resources hold by it.
  43211. */
  43212. dispose(): void;
  43213. /**
  43214. * Gets the current object class name.
  43215. * @return the class name
  43216. */
  43217. getClassName(): string;
  43218. }
  43219. }
  43220. declare module BABYLON {
  43221. /**
  43222. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43223. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43224. */
  43225. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43226. /**
  43227. * Gets the name of the behavior.
  43228. */
  43229. get name(): string;
  43230. private _zoomStopsAnimation;
  43231. private _idleRotationSpeed;
  43232. private _idleRotationWaitTime;
  43233. private _idleRotationSpinupTime;
  43234. /**
  43235. * Sets the flag that indicates if user zooming should stop animation.
  43236. */
  43237. set zoomStopsAnimation(flag: boolean);
  43238. /**
  43239. * Gets the flag that indicates if user zooming should stop animation.
  43240. */
  43241. get zoomStopsAnimation(): boolean;
  43242. /**
  43243. * Sets the default speed at which the camera rotates around the model.
  43244. */
  43245. set idleRotationSpeed(speed: number);
  43246. /**
  43247. * Gets the default speed at which the camera rotates around the model.
  43248. */
  43249. get idleRotationSpeed(): number;
  43250. /**
  43251. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43252. */
  43253. set idleRotationWaitTime(time: number);
  43254. /**
  43255. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43256. */
  43257. get idleRotationWaitTime(): number;
  43258. /**
  43259. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43260. */
  43261. set idleRotationSpinupTime(time: number);
  43262. /**
  43263. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43264. */
  43265. get idleRotationSpinupTime(): number;
  43266. /**
  43267. * Gets a value indicating if the camera is currently rotating because of this behavior
  43268. */
  43269. get rotationInProgress(): boolean;
  43270. private _onPrePointerObservableObserver;
  43271. private _onAfterCheckInputsObserver;
  43272. private _attachedCamera;
  43273. private _isPointerDown;
  43274. private _lastFrameTime;
  43275. private _lastInteractionTime;
  43276. private _cameraRotationSpeed;
  43277. /**
  43278. * Initializes the behavior.
  43279. */
  43280. init(): void;
  43281. /**
  43282. * Attaches the behavior to its arc rotate camera.
  43283. * @param camera Defines the camera to attach the behavior to
  43284. */
  43285. attach(camera: ArcRotateCamera): void;
  43286. /**
  43287. * Detaches the behavior from its current arc rotate camera.
  43288. */
  43289. detach(): void;
  43290. /**
  43291. * Returns true if user is scrolling.
  43292. * @return true if user is scrolling.
  43293. */
  43294. private _userIsZooming;
  43295. private _lastFrameRadius;
  43296. private _shouldAnimationStopForInteraction;
  43297. /**
  43298. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43299. */
  43300. private _applyUserInteraction;
  43301. private _userIsMoving;
  43302. }
  43303. }
  43304. declare module BABYLON {
  43305. /**
  43306. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43307. */
  43308. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43309. private ui;
  43310. /**
  43311. * The name of the behavior
  43312. */
  43313. name: string;
  43314. /**
  43315. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43316. */
  43317. distanceAwayFromFace: number;
  43318. /**
  43319. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43320. */
  43321. distanceAwayFromBottomOfFace: number;
  43322. private _faceVectors;
  43323. private _target;
  43324. private _scene;
  43325. private _onRenderObserver;
  43326. private _tmpMatrix;
  43327. private _tmpVector;
  43328. /**
  43329. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43330. * @param ui The transform node that should be attched to the mesh
  43331. */
  43332. constructor(ui: TransformNode);
  43333. /**
  43334. * Initializes the behavior
  43335. */
  43336. init(): void;
  43337. private _closestFace;
  43338. private _zeroVector;
  43339. private _lookAtTmpMatrix;
  43340. private _lookAtToRef;
  43341. /**
  43342. * Attaches the AttachToBoxBehavior to the passed in mesh
  43343. * @param target The mesh that the specified node will be attached to
  43344. */
  43345. attach(target: Mesh): void;
  43346. /**
  43347. * Detaches the behavior from the mesh
  43348. */
  43349. detach(): void;
  43350. }
  43351. }
  43352. declare module BABYLON {
  43353. /**
  43354. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43355. */
  43356. export class FadeInOutBehavior implements Behavior<Mesh> {
  43357. /**
  43358. * Time in milliseconds to delay before fading in (Default: 0)
  43359. */
  43360. delay: number;
  43361. /**
  43362. * Time in milliseconds for the mesh to fade in (Default: 300)
  43363. */
  43364. fadeInTime: number;
  43365. private _millisecondsPerFrame;
  43366. private _hovered;
  43367. private _hoverValue;
  43368. private _ownerNode;
  43369. /**
  43370. * Instatiates the FadeInOutBehavior
  43371. */
  43372. constructor();
  43373. /**
  43374. * The name of the behavior
  43375. */
  43376. get name(): string;
  43377. /**
  43378. * Initializes the behavior
  43379. */
  43380. init(): void;
  43381. /**
  43382. * Attaches the fade behavior on the passed in mesh
  43383. * @param ownerNode The mesh that will be faded in/out once attached
  43384. */
  43385. attach(ownerNode: Mesh): void;
  43386. /**
  43387. * Detaches the behavior from the mesh
  43388. */
  43389. detach(): void;
  43390. /**
  43391. * Triggers the mesh to begin fading in or out
  43392. * @param value if the object should fade in or out (true to fade in)
  43393. */
  43394. fadeIn(value: boolean): void;
  43395. private _update;
  43396. private _setAllVisibility;
  43397. }
  43398. }
  43399. declare module BABYLON {
  43400. /**
  43401. * Class containing a set of static utilities functions for managing Pivots
  43402. * @hidden
  43403. */
  43404. export class PivotTools {
  43405. private static _PivotCached;
  43406. private static _OldPivotPoint;
  43407. private static _PivotTranslation;
  43408. private static _PivotTmpVector;
  43409. private static _PivotPostMultiplyPivotMatrix;
  43410. /** @hidden */
  43411. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43412. /** @hidden */
  43413. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * Class containing static functions to help procedurally build meshes
  43419. */
  43420. export class PlaneBuilder {
  43421. /**
  43422. * Creates a plane mesh
  43423. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43424. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43425. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43427. * * 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
  43428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43429. * @param name defines the name of the mesh
  43430. * @param options defines the options used to create the mesh
  43431. * @param scene defines the hosting scene
  43432. * @returns the plane mesh
  43433. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43434. */
  43435. static CreatePlane(name: string, options: {
  43436. size?: number;
  43437. width?: number;
  43438. height?: number;
  43439. sideOrientation?: number;
  43440. frontUVs?: Vector4;
  43441. backUVs?: Vector4;
  43442. updatable?: boolean;
  43443. sourcePlane?: Plane;
  43444. }, scene?: Nullable<Scene>): Mesh;
  43445. }
  43446. }
  43447. declare module BABYLON {
  43448. /**
  43449. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43450. */
  43451. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43452. private static _AnyMouseID;
  43453. /**
  43454. * Abstract mesh the behavior is set on
  43455. */
  43456. attachedNode: AbstractMesh;
  43457. private _dragPlane;
  43458. private _scene;
  43459. private _pointerObserver;
  43460. private _beforeRenderObserver;
  43461. private static _planeScene;
  43462. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43463. /**
  43464. * 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)
  43465. */
  43466. maxDragAngle: number;
  43467. /**
  43468. * @hidden
  43469. */
  43470. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43471. /**
  43472. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43473. */
  43474. currentDraggingPointerID: number;
  43475. /**
  43476. * The last position where the pointer hit the drag plane in world space
  43477. */
  43478. lastDragPosition: Vector3;
  43479. /**
  43480. * If the behavior is currently in a dragging state
  43481. */
  43482. dragging: boolean;
  43483. /**
  43484. * 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)
  43485. */
  43486. dragDeltaRatio: number;
  43487. /**
  43488. * If the drag plane orientation should be updated during the dragging (Default: true)
  43489. */
  43490. updateDragPlane: boolean;
  43491. private _debugMode;
  43492. private _moving;
  43493. /**
  43494. * Fires each time the attached mesh is dragged with the pointer
  43495. * * delta between last drag position and current drag position in world space
  43496. * * dragDistance along the drag axis
  43497. * * dragPlaneNormal normal of the current drag plane used during the drag
  43498. * * dragPlanePoint in world space where the drag intersects the drag plane
  43499. */
  43500. onDragObservable: Observable<{
  43501. delta: Vector3;
  43502. dragPlanePoint: Vector3;
  43503. dragPlaneNormal: Vector3;
  43504. dragDistance: number;
  43505. pointerId: number;
  43506. }>;
  43507. /**
  43508. * Fires each time a drag begins (eg. mouse down on mesh)
  43509. */
  43510. onDragStartObservable: Observable<{
  43511. dragPlanePoint: Vector3;
  43512. pointerId: number;
  43513. }>;
  43514. /**
  43515. * Fires each time a drag ends (eg. mouse release after drag)
  43516. */
  43517. onDragEndObservable: Observable<{
  43518. dragPlanePoint: Vector3;
  43519. pointerId: number;
  43520. }>;
  43521. /**
  43522. * If the attached mesh should be moved when dragged
  43523. */
  43524. moveAttached: boolean;
  43525. /**
  43526. * If the drag behavior will react to drag events (Default: true)
  43527. */
  43528. enabled: boolean;
  43529. /**
  43530. * If pointer events should start and release the drag (Default: true)
  43531. */
  43532. startAndReleaseDragOnPointerEvents: boolean;
  43533. /**
  43534. * If camera controls should be detached during the drag
  43535. */
  43536. detachCameraControls: boolean;
  43537. /**
  43538. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43539. */
  43540. useObjectOrientationForDragging: boolean;
  43541. private _options;
  43542. /**
  43543. * Gets the options used by the behavior
  43544. */
  43545. get options(): {
  43546. dragAxis?: Vector3;
  43547. dragPlaneNormal?: Vector3;
  43548. };
  43549. /**
  43550. * Sets the options used by the behavior
  43551. */
  43552. set options(options: {
  43553. dragAxis?: Vector3;
  43554. dragPlaneNormal?: Vector3;
  43555. });
  43556. /**
  43557. * Creates a pointer drag behavior that can be attached to a mesh
  43558. * @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)
  43559. */
  43560. constructor(options?: {
  43561. dragAxis?: Vector3;
  43562. dragPlaneNormal?: Vector3;
  43563. });
  43564. /**
  43565. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43566. */
  43567. validateDrag: (targetPosition: Vector3) => boolean;
  43568. /**
  43569. * The name of the behavior
  43570. */
  43571. get name(): string;
  43572. /**
  43573. * Initializes the behavior
  43574. */
  43575. init(): void;
  43576. private _tmpVector;
  43577. private _alternatePickedPoint;
  43578. private _worldDragAxis;
  43579. private _targetPosition;
  43580. private _attachedElement;
  43581. /**
  43582. * Attaches the drag behavior the passed in mesh
  43583. * @param ownerNode The mesh that will be dragged around once attached
  43584. * @param predicate Predicate to use for pick filtering
  43585. */
  43586. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43587. /**
  43588. * Force relase the drag action by code.
  43589. */
  43590. releaseDrag(): void;
  43591. private _startDragRay;
  43592. private _lastPointerRay;
  43593. /**
  43594. * Simulates the start of a pointer drag event on the behavior
  43595. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43596. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43597. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43598. */
  43599. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43600. private _startDrag;
  43601. private _dragDelta;
  43602. private _moveDrag;
  43603. private _pickWithRayOnDragPlane;
  43604. private _pointA;
  43605. private _pointC;
  43606. private _localAxis;
  43607. private _lookAt;
  43608. private _updateDragPlanePosition;
  43609. /**
  43610. * Detaches the behavior from the mesh
  43611. */
  43612. detach(): void;
  43613. }
  43614. }
  43615. declare module BABYLON {
  43616. /**
  43617. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43618. */
  43619. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43620. private _dragBehaviorA;
  43621. private _dragBehaviorB;
  43622. private _startDistance;
  43623. private _initialScale;
  43624. private _targetScale;
  43625. private _ownerNode;
  43626. private _sceneRenderObserver;
  43627. /**
  43628. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43629. */
  43630. constructor();
  43631. /**
  43632. * The name of the behavior
  43633. */
  43634. get name(): string;
  43635. /**
  43636. * Initializes the behavior
  43637. */
  43638. init(): void;
  43639. private _getCurrentDistance;
  43640. /**
  43641. * Attaches the scale behavior the passed in mesh
  43642. * @param ownerNode The mesh that will be scaled around once attached
  43643. */
  43644. attach(ownerNode: Mesh): void;
  43645. /**
  43646. * Detaches the behavior from the mesh
  43647. */
  43648. detach(): void;
  43649. }
  43650. }
  43651. declare module BABYLON {
  43652. /**
  43653. * 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
  43654. */
  43655. export class SixDofDragBehavior implements Behavior<Mesh> {
  43656. private static _virtualScene;
  43657. private _ownerNode;
  43658. private _sceneRenderObserver;
  43659. private _scene;
  43660. private _targetPosition;
  43661. private _virtualOriginMesh;
  43662. private _virtualDragMesh;
  43663. private _pointerObserver;
  43664. private _moving;
  43665. private _startingOrientation;
  43666. private _attachedElement;
  43667. /**
  43668. * 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)
  43669. */
  43670. private zDragFactor;
  43671. /**
  43672. * If the object should rotate to face the drag origin
  43673. */
  43674. rotateDraggedObject: boolean;
  43675. /**
  43676. * If the behavior is currently in a dragging state
  43677. */
  43678. dragging: boolean;
  43679. /**
  43680. * 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)
  43681. */
  43682. dragDeltaRatio: number;
  43683. /**
  43684. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43685. */
  43686. currentDraggingPointerID: number;
  43687. /**
  43688. * If camera controls should be detached during the drag
  43689. */
  43690. detachCameraControls: boolean;
  43691. /**
  43692. * Fires each time a drag starts
  43693. */
  43694. onDragStartObservable: Observable<{}>;
  43695. /**
  43696. * Fires each time a drag ends (eg. mouse release after drag)
  43697. */
  43698. onDragEndObservable: Observable<{}>;
  43699. /**
  43700. * 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
  43701. */
  43702. constructor();
  43703. /**
  43704. * The name of the behavior
  43705. */
  43706. get name(): string;
  43707. /**
  43708. * Initializes the behavior
  43709. */
  43710. init(): void;
  43711. /**
  43712. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43713. */
  43714. private get _pointerCamera();
  43715. /**
  43716. * Attaches the scale behavior the passed in mesh
  43717. * @param ownerNode The mesh that will be scaled around once attached
  43718. */
  43719. attach(ownerNode: Mesh): void;
  43720. /**
  43721. * Detaches the behavior from the mesh
  43722. */
  43723. detach(): void;
  43724. }
  43725. }
  43726. declare module BABYLON {
  43727. /**
  43728. * Class used to apply inverse kinematics to bones
  43729. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43730. */
  43731. export class BoneIKController {
  43732. private static _tmpVecs;
  43733. private static _tmpQuat;
  43734. private static _tmpMats;
  43735. /**
  43736. * Gets or sets the target mesh
  43737. */
  43738. targetMesh: AbstractMesh;
  43739. /** Gets or sets the mesh used as pole */
  43740. poleTargetMesh: AbstractMesh;
  43741. /**
  43742. * Gets or sets the bone used as pole
  43743. */
  43744. poleTargetBone: Nullable<Bone>;
  43745. /**
  43746. * Gets or sets the target position
  43747. */
  43748. targetPosition: Vector3;
  43749. /**
  43750. * Gets or sets the pole target position
  43751. */
  43752. poleTargetPosition: Vector3;
  43753. /**
  43754. * Gets or sets the pole target local offset
  43755. */
  43756. poleTargetLocalOffset: Vector3;
  43757. /**
  43758. * Gets or sets the pole angle
  43759. */
  43760. poleAngle: number;
  43761. /**
  43762. * Gets or sets the mesh associated with the controller
  43763. */
  43764. mesh: AbstractMesh;
  43765. /**
  43766. * 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)
  43767. */
  43768. slerpAmount: number;
  43769. private _bone1Quat;
  43770. private _bone1Mat;
  43771. private _bone2Ang;
  43772. private _bone1;
  43773. private _bone2;
  43774. private _bone1Length;
  43775. private _bone2Length;
  43776. private _maxAngle;
  43777. private _maxReach;
  43778. private _rightHandedSystem;
  43779. private _bendAxis;
  43780. private _slerping;
  43781. private _adjustRoll;
  43782. /**
  43783. * Gets or sets maximum allowed angle
  43784. */
  43785. get maxAngle(): number;
  43786. set maxAngle(value: number);
  43787. /**
  43788. * Creates a new BoneIKController
  43789. * @param mesh defines the mesh to control
  43790. * @param bone defines the bone to control
  43791. * @param options defines options to set up the controller
  43792. */
  43793. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43794. targetMesh?: AbstractMesh;
  43795. poleTargetMesh?: AbstractMesh;
  43796. poleTargetBone?: Bone;
  43797. poleTargetLocalOffset?: Vector3;
  43798. poleAngle?: number;
  43799. bendAxis?: Vector3;
  43800. maxAngle?: number;
  43801. slerpAmount?: number;
  43802. });
  43803. private _setMaxAngle;
  43804. /**
  43805. * Force the controller to update the bones
  43806. */
  43807. update(): void;
  43808. }
  43809. }
  43810. declare module BABYLON {
  43811. /**
  43812. * Class used to make a bone look toward a point in space
  43813. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43814. */
  43815. export class BoneLookController {
  43816. private static _tmpVecs;
  43817. private static _tmpQuat;
  43818. private static _tmpMats;
  43819. /**
  43820. * The target Vector3 that the bone will look at
  43821. */
  43822. target: Vector3;
  43823. /**
  43824. * The mesh that the bone is attached to
  43825. */
  43826. mesh: AbstractMesh;
  43827. /**
  43828. * The bone that will be looking to the target
  43829. */
  43830. bone: Bone;
  43831. /**
  43832. * The up axis of the coordinate system that is used when the bone is rotated
  43833. */
  43834. upAxis: Vector3;
  43835. /**
  43836. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43837. */
  43838. upAxisSpace: Space;
  43839. /**
  43840. * Used to make an adjustment to the yaw of the bone
  43841. */
  43842. adjustYaw: number;
  43843. /**
  43844. * Used to make an adjustment to the pitch of the bone
  43845. */
  43846. adjustPitch: number;
  43847. /**
  43848. * Used to make an adjustment to the roll of the bone
  43849. */
  43850. adjustRoll: number;
  43851. /**
  43852. * 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)
  43853. */
  43854. slerpAmount: number;
  43855. private _minYaw;
  43856. private _maxYaw;
  43857. private _minPitch;
  43858. private _maxPitch;
  43859. private _minYawSin;
  43860. private _minYawCos;
  43861. private _maxYawSin;
  43862. private _maxYawCos;
  43863. private _midYawConstraint;
  43864. private _minPitchTan;
  43865. private _maxPitchTan;
  43866. private _boneQuat;
  43867. private _slerping;
  43868. private _transformYawPitch;
  43869. private _transformYawPitchInv;
  43870. private _firstFrameSkipped;
  43871. private _yawRange;
  43872. private _fowardAxis;
  43873. /**
  43874. * Gets or sets the minimum yaw angle that the bone can look to
  43875. */
  43876. get minYaw(): number;
  43877. set minYaw(value: number);
  43878. /**
  43879. * Gets or sets the maximum yaw angle that the bone can look to
  43880. */
  43881. get maxYaw(): number;
  43882. set maxYaw(value: number);
  43883. /**
  43884. * Gets or sets the minimum pitch angle that the bone can look to
  43885. */
  43886. get minPitch(): number;
  43887. set minPitch(value: number);
  43888. /**
  43889. * Gets or sets the maximum pitch angle that the bone can look to
  43890. */
  43891. get maxPitch(): number;
  43892. set maxPitch(value: number);
  43893. /**
  43894. * Create a BoneLookController
  43895. * @param mesh the mesh that the bone belongs to
  43896. * @param bone the bone that will be looking to the target
  43897. * @param target the target Vector3 to look at
  43898. * @param options optional settings:
  43899. * * maxYaw: the maximum angle the bone will yaw to
  43900. * * minYaw: the minimum angle the bone will yaw to
  43901. * * maxPitch: the maximum angle the bone will pitch to
  43902. * * minPitch: the minimum angle the bone will yaw to
  43903. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43904. * * upAxis: the up axis of the coordinate system
  43905. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43906. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43907. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43908. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43909. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43910. * * adjustRoll: used to make an adjustment to the roll of the bone
  43911. **/
  43912. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43913. maxYaw?: number;
  43914. minYaw?: number;
  43915. maxPitch?: number;
  43916. minPitch?: number;
  43917. slerpAmount?: number;
  43918. upAxis?: Vector3;
  43919. upAxisSpace?: Space;
  43920. yawAxis?: Vector3;
  43921. pitchAxis?: Vector3;
  43922. adjustYaw?: number;
  43923. adjustPitch?: number;
  43924. adjustRoll?: number;
  43925. });
  43926. /**
  43927. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43928. */
  43929. update(): void;
  43930. private _getAngleDiff;
  43931. private _getAngleBetween;
  43932. private _isAngleBetween;
  43933. }
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Manage the gamepad inputs to control an arc rotate camera.
  43938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43939. */
  43940. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43941. /**
  43942. * Defines the camera the input is attached to.
  43943. */
  43944. camera: ArcRotateCamera;
  43945. /**
  43946. * Defines the gamepad the input is gathering event from.
  43947. */
  43948. gamepad: Nullable<Gamepad>;
  43949. /**
  43950. * Defines the gamepad rotation sensiblity.
  43951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43952. */
  43953. gamepadRotationSensibility: number;
  43954. /**
  43955. * Defines the gamepad move sensiblity.
  43956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43957. */
  43958. gamepadMoveSensibility: number;
  43959. private _yAxisScale;
  43960. /**
  43961. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43962. */
  43963. get invertYAxis(): boolean;
  43964. set invertYAxis(value: boolean);
  43965. private _onGamepadConnectedObserver;
  43966. private _onGamepadDisconnectedObserver;
  43967. /**
  43968. * Attach the input controls to a specific dom element to get the input from.
  43969. * @param element Defines the element the controls should be listened from
  43970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43971. */
  43972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43973. /**
  43974. * Detach the current controls from the specified dom element.
  43975. * @param element Defines the element to stop listening the inputs from
  43976. */
  43977. detachControl(element: Nullable<HTMLElement>): void;
  43978. /**
  43979. * Update the current camera state depending on the inputs that have been used this frame.
  43980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43981. */
  43982. checkInputs(): void;
  43983. /**
  43984. * Gets the class name of the current intput.
  43985. * @returns the class name
  43986. */
  43987. getClassName(): string;
  43988. /**
  43989. * Get the friendly name associated with the input class.
  43990. * @returns the input friendly name
  43991. */
  43992. getSimpleName(): string;
  43993. }
  43994. }
  43995. declare module BABYLON {
  43996. interface ArcRotateCameraInputsManager {
  43997. /**
  43998. * Add orientation input support to the input manager.
  43999. * @returns the current input manager
  44000. */
  44001. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44002. }
  44003. /**
  44004. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44006. */
  44007. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44008. /**
  44009. * Defines the camera the input is attached to.
  44010. */
  44011. camera: ArcRotateCamera;
  44012. /**
  44013. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44014. */
  44015. alphaCorrection: number;
  44016. /**
  44017. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44018. */
  44019. gammaCorrection: number;
  44020. private _alpha;
  44021. private _gamma;
  44022. private _dirty;
  44023. private _deviceOrientationHandler;
  44024. /**
  44025. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44026. */
  44027. constructor();
  44028. /**
  44029. * Attach the input controls to a specific dom element to get the input from.
  44030. * @param element Defines the element the controls should be listened from
  44031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44032. */
  44033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44034. /** @hidden */
  44035. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44036. /**
  44037. * Update the current camera state depending on the inputs that have been used this frame.
  44038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44039. */
  44040. checkInputs(): void;
  44041. /**
  44042. * Detach the current controls from the specified dom element.
  44043. * @param element Defines the element to stop listening the inputs from
  44044. */
  44045. detachControl(element: Nullable<HTMLElement>): void;
  44046. /**
  44047. * Gets the class name of the current intput.
  44048. * @returns the class name
  44049. */
  44050. getClassName(): string;
  44051. /**
  44052. * Get the friendly name associated with the input class.
  44053. * @returns the input friendly name
  44054. */
  44055. getSimpleName(): string;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. /**
  44060. * Listen to mouse events to control the camera.
  44061. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44062. */
  44063. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44064. /**
  44065. * Defines the camera the input is attached to.
  44066. */
  44067. camera: FlyCamera;
  44068. /**
  44069. * Defines if touch is enabled. (Default is true.)
  44070. */
  44071. touchEnabled: boolean;
  44072. /**
  44073. * Defines the buttons associated with the input to handle camera rotation.
  44074. */
  44075. buttons: number[];
  44076. /**
  44077. * Assign buttons for Yaw control.
  44078. */
  44079. buttonsYaw: number[];
  44080. /**
  44081. * Assign buttons for Pitch control.
  44082. */
  44083. buttonsPitch: number[];
  44084. /**
  44085. * Assign buttons for Roll control.
  44086. */
  44087. buttonsRoll: number[];
  44088. /**
  44089. * Detect if any button is being pressed while mouse is moved.
  44090. * -1 = Mouse locked.
  44091. * 0 = Left button.
  44092. * 1 = Middle Button.
  44093. * 2 = Right Button.
  44094. */
  44095. activeButton: number;
  44096. /**
  44097. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44098. * Higher values reduce its sensitivity.
  44099. */
  44100. angularSensibility: number;
  44101. private _mousemoveCallback;
  44102. private _observer;
  44103. private _rollObserver;
  44104. private previousPosition;
  44105. private noPreventDefault;
  44106. private element;
  44107. /**
  44108. * Listen to mouse events to control the camera.
  44109. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44111. */
  44112. constructor(touchEnabled?: boolean);
  44113. /**
  44114. * Attach the mouse control to the HTML DOM element.
  44115. * @param element Defines the element that listens to the input events.
  44116. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44117. */
  44118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44119. /**
  44120. * Detach the current controls from the specified dom element.
  44121. * @param element Defines the element to stop listening the inputs from
  44122. */
  44123. detachControl(element: Nullable<HTMLElement>): void;
  44124. /**
  44125. * Gets the class name of the current input.
  44126. * @returns the class name.
  44127. */
  44128. getClassName(): string;
  44129. /**
  44130. * Get the friendly name associated with the input class.
  44131. * @returns the input's friendly name.
  44132. */
  44133. getSimpleName(): string;
  44134. private _pointerInput;
  44135. private _onMouseMove;
  44136. /**
  44137. * Rotate camera by mouse offset.
  44138. */
  44139. private rotateCamera;
  44140. }
  44141. }
  44142. declare module BABYLON {
  44143. /**
  44144. * Default Inputs manager for the FlyCamera.
  44145. * It groups all the default supported inputs for ease of use.
  44146. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44147. */
  44148. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44149. /**
  44150. * Instantiates a new FlyCameraInputsManager.
  44151. * @param camera Defines the camera the inputs belong to.
  44152. */
  44153. constructor(camera: FlyCamera);
  44154. /**
  44155. * Add keyboard input support to the input manager.
  44156. * @returns the new FlyCameraKeyboardMoveInput().
  44157. */
  44158. addKeyboard(): FlyCameraInputsManager;
  44159. /**
  44160. * Add mouse input support to the input manager.
  44161. * @param touchEnabled Enable touch screen support.
  44162. * @returns the new FlyCameraMouseInput().
  44163. */
  44164. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44165. }
  44166. }
  44167. declare module BABYLON {
  44168. /**
  44169. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44170. * such as in a 3D Space Shooter or a Flight Simulator.
  44171. */
  44172. export class FlyCamera extends TargetCamera {
  44173. /**
  44174. * Define the collision ellipsoid of the camera.
  44175. * This is helpful for simulating a camera body, like a player's body.
  44176. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44177. */
  44178. ellipsoid: Vector3;
  44179. /**
  44180. * Define an offset for the position of the ellipsoid around the camera.
  44181. * This can be helpful if the camera is attached away from the player's body center,
  44182. * such as at its head.
  44183. */
  44184. ellipsoidOffset: Vector3;
  44185. /**
  44186. * Enable or disable collisions of the camera with the rest of the scene objects.
  44187. */
  44188. checkCollisions: boolean;
  44189. /**
  44190. * Enable or disable gravity on the camera.
  44191. */
  44192. applyGravity: boolean;
  44193. /**
  44194. * Define the current direction the camera is moving to.
  44195. */
  44196. cameraDirection: Vector3;
  44197. /**
  44198. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44199. * This overrides and empties cameraRotation.
  44200. */
  44201. rotationQuaternion: Quaternion;
  44202. /**
  44203. * Track Roll to maintain the wanted Rolling when looking around.
  44204. */
  44205. _trackRoll: number;
  44206. /**
  44207. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44208. */
  44209. rollCorrect: number;
  44210. /**
  44211. * Mimic a banked turn, Rolling the camera when Yawing.
  44212. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44213. */
  44214. bankedTurn: boolean;
  44215. /**
  44216. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44217. */
  44218. bankedTurnLimit: number;
  44219. /**
  44220. * Value of 0 disables the banked Roll.
  44221. * Value of 1 is equal to the Yaw angle in radians.
  44222. */
  44223. bankedTurnMultiplier: number;
  44224. /**
  44225. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44226. */
  44227. inputs: FlyCameraInputsManager;
  44228. /**
  44229. * Gets the input sensibility for mouse input.
  44230. * Higher values reduce sensitivity.
  44231. */
  44232. get angularSensibility(): number;
  44233. /**
  44234. * Sets the input sensibility for a mouse input.
  44235. * Higher values reduce sensitivity.
  44236. */
  44237. set angularSensibility(value: number);
  44238. /**
  44239. * Get the keys for camera movement forward.
  44240. */
  44241. get keysForward(): number[];
  44242. /**
  44243. * Set the keys for camera movement forward.
  44244. */
  44245. set keysForward(value: number[]);
  44246. /**
  44247. * Get the keys for camera movement backward.
  44248. */
  44249. get keysBackward(): number[];
  44250. set keysBackward(value: number[]);
  44251. /**
  44252. * Get the keys for camera movement up.
  44253. */
  44254. get keysUp(): number[];
  44255. /**
  44256. * Set the keys for camera movement up.
  44257. */
  44258. set keysUp(value: number[]);
  44259. /**
  44260. * Get the keys for camera movement down.
  44261. */
  44262. get keysDown(): number[];
  44263. /**
  44264. * Set the keys for camera movement down.
  44265. */
  44266. set keysDown(value: number[]);
  44267. /**
  44268. * Get the keys for camera movement left.
  44269. */
  44270. get keysLeft(): number[];
  44271. /**
  44272. * Set the keys for camera movement left.
  44273. */
  44274. set keysLeft(value: number[]);
  44275. /**
  44276. * Set the keys for camera movement right.
  44277. */
  44278. get keysRight(): number[];
  44279. /**
  44280. * Set the keys for camera movement right.
  44281. */
  44282. set keysRight(value: number[]);
  44283. /**
  44284. * Event raised when the camera collides with a mesh in the scene.
  44285. */
  44286. onCollide: (collidedMesh: AbstractMesh) => void;
  44287. private _collider;
  44288. private _needMoveForGravity;
  44289. private _oldPosition;
  44290. private _diffPosition;
  44291. private _newPosition;
  44292. /** @hidden */
  44293. _localDirection: Vector3;
  44294. /** @hidden */
  44295. _transformedDirection: Vector3;
  44296. /**
  44297. * Instantiates a FlyCamera.
  44298. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44299. * such as in a 3D Space Shooter or a Flight Simulator.
  44300. * @param name Define the name of the camera in the scene.
  44301. * @param position Define the starting position of the camera in the scene.
  44302. * @param scene Define the scene the camera belongs to.
  44303. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44304. */
  44305. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44306. /**
  44307. * Attach a control to the HTML DOM element.
  44308. * @param element Defines the element that listens to the input events.
  44309. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44310. */
  44311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44312. /**
  44313. * Detach a control from the HTML DOM element.
  44314. * The camera will stop reacting to that input.
  44315. * @param element Defines the element that listens to the input events.
  44316. */
  44317. detachControl(element: HTMLElement): void;
  44318. private _collisionMask;
  44319. /**
  44320. * Get the mask that the camera ignores in collision events.
  44321. */
  44322. get collisionMask(): number;
  44323. /**
  44324. * Set the mask that the camera ignores in collision events.
  44325. */
  44326. set collisionMask(mask: number);
  44327. /** @hidden */
  44328. _collideWithWorld(displacement: Vector3): void;
  44329. /** @hidden */
  44330. private _onCollisionPositionChange;
  44331. /** @hidden */
  44332. _checkInputs(): void;
  44333. /** @hidden */
  44334. _decideIfNeedsToMove(): boolean;
  44335. /** @hidden */
  44336. _updatePosition(): void;
  44337. /**
  44338. * Restore the Roll to its target value at the rate specified.
  44339. * @param rate - Higher means slower restoring.
  44340. * @hidden
  44341. */
  44342. restoreRoll(rate: number): void;
  44343. /**
  44344. * Destroy the camera and release the current resources held by it.
  44345. */
  44346. dispose(): void;
  44347. /**
  44348. * Get the current object class name.
  44349. * @returns the class name.
  44350. */
  44351. getClassName(): string;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Listen to keyboard events to control the camera.
  44357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44358. */
  44359. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44360. /**
  44361. * Defines the camera the input is attached to.
  44362. */
  44363. camera: FlyCamera;
  44364. /**
  44365. * The list of keyboard keys used to control the forward move of the camera.
  44366. */
  44367. keysForward: number[];
  44368. /**
  44369. * The list of keyboard keys used to control the backward move of the camera.
  44370. */
  44371. keysBackward: number[];
  44372. /**
  44373. * The list of keyboard keys used to control the forward move of the camera.
  44374. */
  44375. keysUp: number[];
  44376. /**
  44377. * The list of keyboard keys used to control the backward move of the camera.
  44378. */
  44379. keysDown: number[];
  44380. /**
  44381. * The list of keyboard keys used to control the right strafe move of the camera.
  44382. */
  44383. keysRight: number[];
  44384. /**
  44385. * The list of keyboard keys used to control the left strafe move of the camera.
  44386. */
  44387. keysLeft: number[];
  44388. private _keys;
  44389. private _onCanvasBlurObserver;
  44390. private _onKeyboardObserver;
  44391. private _engine;
  44392. private _scene;
  44393. /**
  44394. * Attach the input controls to a specific dom element to get the input from.
  44395. * @param element Defines the element the controls should be listened from
  44396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44397. */
  44398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44399. /**
  44400. * Detach the current controls from the specified dom element.
  44401. * @param element Defines the element to stop listening the inputs from
  44402. */
  44403. detachControl(element: Nullable<HTMLElement>): void;
  44404. /**
  44405. * Gets the class name of the current intput.
  44406. * @returns the class name
  44407. */
  44408. getClassName(): string;
  44409. /** @hidden */
  44410. _onLostFocus(e: FocusEvent): void;
  44411. /**
  44412. * Get the friendly name associated with the input class.
  44413. * @returns the input friendly name
  44414. */
  44415. getSimpleName(): string;
  44416. /**
  44417. * Update the current camera state depending on the inputs that have been used this frame.
  44418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44419. */
  44420. checkInputs(): void;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * Manage the mouse wheel inputs to control a follow camera.
  44426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44427. */
  44428. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44429. /**
  44430. * Defines the camera the input is attached to.
  44431. */
  44432. camera: FollowCamera;
  44433. /**
  44434. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44435. */
  44436. axisControlRadius: boolean;
  44437. /**
  44438. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44439. */
  44440. axisControlHeight: boolean;
  44441. /**
  44442. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44443. */
  44444. axisControlRotation: boolean;
  44445. /**
  44446. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44447. * relation to mouseWheel events.
  44448. */
  44449. wheelPrecision: number;
  44450. /**
  44451. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44452. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44453. */
  44454. wheelDeltaPercentage: number;
  44455. private _wheel;
  44456. private _observer;
  44457. /**
  44458. * Attach the input controls to a specific dom element to get the input from.
  44459. * @param element Defines the element the controls should be listened from
  44460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44461. */
  44462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44463. /**
  44464. * Detach the current controls from the specified dom element.
  44465. * @param element Defines the element to stop listening the inputs from
  44466. */
  44467. detachControl(element: Nullable<HTMLElement>): void;
  44468. /**
  44469. * Gets the class name of the current intput.
  44470. * @returns the class name
  44471. */
  44472. getClassName(): string;
  44473. /**
  44474. * Get the friendly name associated with the input class.
  44475. * @returns the input friendly name
  44476. */
  44477. getSimpleName(): string;
  44478. }
  44479. }
  44480. declare module BABYLON {
  44481. /**
  44482. * Manage the pointers inputs to control an follow camera.
  44483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44484. */
  44485. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44486. /**
  44487. * Defines the camera the input is attached to.
  44488. */
  44489. camera: FollowCamera;
  44490. /**
  44491. * Gets the class name of the current input.
  44492. * @returns the class name
  44493. */
  44494. getClassName(): string;
  44495. /**
  44496. * Defines the pointer angular sensibility along the X axis or how fast is
  44497. * the camera rotating.
  44498. * A negative number will reverse the axis direction.
  44499. */
  44500. angularSensibilityX: number;
  44501. /**
  44502. * Defines the pointer angular sensibility along the Y axis or how fast is
  44503. * the camera rotating.
  44504. * A negative number will reverse the axis direction.
  44505. */
  44506. angularSensibilityY: number;
  44507. /**
  44508. * Defines the pointer pinch precision or how fast is the camera zooming.
  44509. * A negative number will reverse the axis direction.
  44510. */
  44511. pinchPrecision: number;
  44512. /**
  44513. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44514. * from 0.
  44515. * It defines the percentage of current camera.radius to use as delta when
  44516. * pinch zoom is used.
  44517. */
  44518. pinchDeltaPercentage: number;
  44519. /**
  44520. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44521. */
  44522. axisXControlRadius: boolean;
  44523. /**
  44524. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44525. */
  44526. axisXControlHeight: boolean;
  44527. /**
  44528. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44529. */
  44530. axisXControlRotation: boolean;
  44531. /**
  44532. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44533. */
  44534. axisYControlRadius: boolean;
  44535. /**
  44536. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44537. */
  44538. axisYControlHeight: boolean;
  44539. /**
  44540. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44541. */
  44542. axisYControlRotation: boolean;
  44543. /**
  44544. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44545. */
  44546. axisPinchControlRadius: boolean;
  44547. /**
  44548. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44549. */
  44550. axisPinchControlHeight: boolean;
  44551. /**
  44552. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44553. */
  44554. axisPinchControlRotation: boolean;
  44555. /**
  44556. * Log error messages if basic misconfiguration has occurred.
  44557. */
  44558. warningEnable: boolean;
  44559. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44560. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44561. private _warningCounter;
  44562. private _warning;
  44563. }
  44564. }
  44565. declare module BABYLON {
  44566. /**
  44567. * Default Inputs manager for the FollowCamera.
  44568. * It groups all the default supported inputs for ease of use.
  44569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44570. */
  44571. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44572. /**
  44573. * Instantiates a new FollowCameraInputsManager.
  44574. * @param camera Defines the camera the inputs belong to
  44575. */
  44576. constructor(camera: FollowCamera);
  44577. /**
  44578. * Add keyboard input support to the input manager.
  44579. * @returns the current input manager
  44580. */
  44581. addKeyboard(): FollowCameraInputsManager;
  44582. /**
  44583. * Add mouse wheel input support to the input manager.
  44584. * @returns the current input manager
  44585. */
  44586. addMouseWheel(): FollowCameraInputsManager;
  44587. /**
  44588. * Add pointers input support to the input manager.
  44589. * @returns the current input manager
  44590. */
  44591. addPointers(): FollowCameraInputsManager;
  44592. /**
  44593. * Add orientation input support to the input manager.
  44594. * @returns the current input manager
  44595. */
  44596. addVRDeviceOrientation(): FollowCameraInputsManager;
  44597. }
  44598. }
  44599. declare module BABYLON {
  44600. /**
  44601. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44602. * an arc rotate version arcFollowCamera are available.
  44603. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44604. */
  44605. export class FollowCamera extends TargetCamera {
  44606. /**
  44607. * Distance the follow camera should follow an object at
  44608. */
  44609. radius: number;
  44610. /**
  44611. * Minimum allowed distance of the camera to the axis of rotation
  44612. * (The camera can not get closer).
  44613. * This can help limiting how the Camera is able to move in the scene.
  44614. */
  44615. lowerRadiusLimit: Nullable<number>;
  44616. /**
  44617. * Maximum allowed distance of the camera to the axis of rotation
  44618. * (The camera can not get further).
  44619. * This can help limiting how the Camera is able to move in the scene.
  44620. */
  44621. upperRadiusLimit: Nullable<number>;
  44622. /**
  44623. * Define a rotation offset between the camera and the object it follows
  44624. */
  44625. rotationOffset: number;
  44626. /**
  44627. * Minimum allowed angle to camera position relative to target object.
  44628. * This can help limiting how the Camera is able to move in the scene.
  44629. */
  44630. lowerRotationOffsetLimit: Nullable<number>;
  44631. /**
  44632. * Maximum allowed angle to camera position relative to target object.
  44633. * This can help limiting how the Camera is able to move in the scene.
  44634. */
  44635. upperRotationOffsetLimit: Nullable<number>;
  44636. /**
  44637. * Define a height offset between the camera and the object it follows.
  44638. * It can help following an object from the top (like a car chaing a plane)
  44639. */
  44640. heightOffset: number;
  44641. /**
  44642. * Minimum allowed height of camera position relative to target object.
  44643. * This can help limiting how the Camera is able to move in the scene.
  44644. */
  44645. lowerHeightOffsetLimit: Nullable<number>;
  44646. /**
  44647. * Maximum allowed height of camera position relative to target object.
  44648. * This can help limiting how the Camera is able to move in the scene.
  44649. */
  44650. upperHeightOffsetLimit: Nullable<number>;
  44651. /**
  44652. * Define how fast the camera can accelerate to follow it s target.
  44653. */
  44654. cameraAcceleration: number;
  44655. /**
  44656. * Define the speed limit of the camera following an object.
  44657. */
  44658. maxCameraSpeed: number;
  44659. /**
  44660. * Define the target of the camera.
  44661. */
  44662. lockedTarget: Nullable<AbstractMesh>;
  44663. /**
  44664. * Defines the input associated with the camera.
  44665. */
  44666. inputs: FollowCameraInputsManager;
  44667. /**
  44668. * Instantiates the follow camera.
  44669. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44670. * @param name Define the name of the camera in the scene
  44671. * @param position Define the position of the camera
  44672. * @param scene Define the scene the camera belong to
  44673. * @param lockedTarget Define the target of the camera
  44674. */
  44675. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44676. private _follow;
  44677. /**
  44678. * Attached controls to the current camera.
  44679. * @param element Defines the element the controls should be listened from
  44680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44681. */
  44682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44683. /**
  44684. * Detach the current controls from the camera.
  44685. * The camera will stop reacting to inputs.
  44686. * @param element Defines the element to stop listening the inputs from
  44687. */
  44688. detachControl(element: HTMLElement): void;
  44689. /** @hidden */
  44690. _checkInputs(): void;
  44691. private _checkLimits;
  44692. /**
  44693. * Gets the camera class name.
  44694. * @returns the class name
  44695. */
  44696. getClassName(): string;
  44697. }
  44698. /**
  44699. * Arc Rotate version of the follow camera.
  44700. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44701. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44702. */
  44703. export class ArcFollowCamera extends TargetCamera {
  44704. /** The longitudinal angle of the camera */
  44705. alpha: number;
  44706. /** The latitudinal angle of the camera */
  44707. beta: number;
  44708. /** The radius of the camera from its target */
  44709. radius: number;
  44710. private _cartesianCoordinates;
  44711. /** Define the camera target (the mesh it should follow) */
  44712. private _meshTarget;
  44713. /**
  44714. * Instantiates a new ArcFollowCamera
  44715. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44716. * @param name Define the name of the camera
  44717. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44718. * @param beta Define the rotation angle of the camera around the elevation axis
  44719. * @param radius Define the radius of the camera from its target point
  44720. * @param target Define the target of the camera
  44721. * @param scene Define the scene the camera belongs to
  44722. */
  44723. constructor(name: string,
  44724. /** The longitudinal angle of the camera */
  44725. alpha: number,
  44726. /** The latitudinal angle of the camera */
  44727. beta: number,
  44728. /** The radius of the camera from its target */
  44729. radius: number,
  44730. /** Define the camera target (the mesh it should follow) */
  44731. target: Nullable<AbstractMesh>, scene: Scene);
  44732. private _follow;
  44733. /** @hidden */
  44734. _checkInputs(): void;
  44735. /**
  44736. * Returns the class name of the object.
  44737. * It is mostly used internally for serialization purposes.
  44738. */
  44739. getClassName(): string;
  44740. }
  44741. }
  44742. declare module BABYLON {
  44743. /**
  44744. * Manage the keyboard inputs to control the movement of a follow camera.
  44745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44746. */
  44747. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44748. /**
  44749. * Defines the camera the input is attached to.
  44750. */
  44751. camera: FollowCamera;
  44752. /**
  44753. * Defines the list of key codes associated with the up action (increase heightOffset)
  44754. */
  44755. keysHeightOffsetIncr: number[];
  44756. /**
  44757. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44758. */
  44759. keysHeightOffsetDecr: number[];
  44760. /**
  44761. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44762. */
  44763. keysHeightOffsetModifierAlt: boolean;
  44764. /**
  44765. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44766. */
  44767. keysHeightOffsetModifierCtrl: boolean;
  44768. /**
  44769. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44770. */
  44771. keysHeightOffsetModifierShift: boolean;
  44772. /**
  44773. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44774. */
  44775. keysRotationOffsetIncr: number[];
  44776. /**
  44777. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44778. */
  44779. keysRotationOffsetDecr: number[];
  44780. /**
  44781. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44782. */
  44783. keysRotationOffsetModifierAlt: boolean;
  44784. /**
  44785. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44786. */
  44787. keysRotationOffsetModifierCtrl: boolean;
  44788. /**
  44789. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44790. */
  44791. keysRotationOffsetModifierShift: boolean;
  44792. /**
  44793. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44794. */
  44795. keysRadiusIncr: number[];
  44796. /**
  44797. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44798. */
  44799. keysRadiusDecr: number[];
  44800. /**
  44801. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44802. */
  44803. keysRadiusModifierAlt: boolean;
  44804. /**
  44805. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44806. */
  44807. keysRadiusModifierCtrl: boolean;
  44808. /**
  44809. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44810. */
  44811. keysRadiusModifierShift: boolean;
  44812. /**
  44813. * Defines the rate of change of heightOffset.
  44814. */
  44815. heightSensibility: number;
  44816. /**
  44817. * Defines the rate of change of rotationOffset.
  44818. */
  44819. rotationSensibility: number;
  44820. /**
  44821. * Defines the rate of change of radius.
  44822. */
  44823. radiusSensibility: number;
  44824. private _keys;
  44825. private _ctrlPressed;
  44826. private _altPressed;
  44827. private _shiftPressed;
  44828. private _onCanvasBlurObserver;
  44829. private _onKeyboardObserver;
  44830. private _engine;
  44831. private _scene;
  44832. /**
  44833. * Attach the input controls to a specific dom element to get the input from.
  44834. * @param element Defines the element the controls should be listened from
  44835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44836. */
  44837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44838. /**
  44839. * Detach the current controls from the specified dom element.
  44840. * @param element Defines the element to stop listening the inputs from
  44841. */
  44842. detachControl(element: Nullable<HTMLElement>): void;
  44843. /**
  44844. * Update the current camera state depending on the inputs that have been used this frame.
  44845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44846. */
  44847. checkInputs(): void;
  44848. /**
  44849. * Gets the class name of the current input.
  44850. * @returns the class name
  44851. */
  44852. getClassName(): string;
  44853. /**
  44854. * Get the friendly name associated with the input class.
  44855. * @returns the input friendly name
  44856. */
  44857. getSimpleName(): string;
  44858. /**
  44859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44860. * allow modification of the heightOffset value.
  44861. */
  44862. private _modifierHeightOffset;
  44863. /**
  44864. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44865. * allow modification of the rotationOffset value.
  44866. */
  44867. private _modifierRotationOffset;
  44868. /**
  44869. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44870. * allow modification of the radius value.
  44871. */
  44872. private _modifierRadius;
  44873. }
  44874. }
  44875. declare module BABYLON {
  44876. interface FreeCameraInputsManager {
  44877. /**
  44878. * @hidden
  44879. */
  44880. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44881. /**
  44882. * Add orientation input support to the input manager.
  44883. * @returns the current input manager
  44884. */
  44885. addDeviceOrientation(): FreeCameraInputsManager;
  44886. }
  44887. /**
  44888. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44889. * Screen rotation is taken into account.
  44890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44891. */
  44892. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44893. private _camera;
  44894. private _screenOrientationAngle;
  44895. private _constantTranform;
  44896. private _screenQuaternion;
  44897. private _alpha;
  44898. private _beta;
  44899. private _gamma;
  44900. /**
  44901. * Can be used to detect if a device orientation sensor is available on a device
  44902. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44903. * @returns a promise that will resolve on orientation change
  44904. */
  44905. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44906. /**
  44907. * @hidden
  44908. */
  44909. _onDeviceOrientationChangedObservable: Observable<void>;
  44910. /**
  44911. * Instantiates a new input
  44912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44913. */
  44914. constructor();
  44915. /**
  44916. * Define the camera controlled by the input.
  44917. */
  44918. get camera(): FreeCamera;
  44919. set camera(camera: FreeCamera);
  44920. /**
  44921. * Attach the input controls to a specific dom element to get the input from.
  44922. * @param element Defines the element the controls should be listened from
  44923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44924. */
  44925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44926. private _orientationChanged;
  44927. private _deviceOrientation;
  44928. /**
  44929. * Detach the current controls from the specified dom element.
  44930. * @param element Defines the element to stop listening the inputs from
  44931. */
  44932. detachControl(element: Nullable<HTMLElement>): void;
  44933. /**
  44934. * Update the current camera state depending on the inputs that have been used this frame.
  44935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44936. */
  44937. checkInputs(): void;
  44938. /**
  44939. * Gets the class name of the current intput.
  44940. * @returns the class name
  44941. */
  44942. getClassName(): string;
  44943. /**
  44944. * Get the friendly name associated with the input class.
  44945. * @returns the input friendly name
  44946. */
  44947. getSimpleName(): string;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. /**
  44952. * Manage the gamepad inputs to control a free camera.
  44953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44954. */
  44955. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44956. /**
  44957. * Define the camera the input is attached to.
  44958. */
  44959. camera: FreeCamera;
  44960. /**
  44961. * Define the Gamepad controlling the input
  44962. */
  44963. gamepad: Nullable<Gamepad>;
  44964. /**
  44965. * Defines the gamepad rotation sensiblity.
  44966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44967. */
  44968. gamepadAngularSensibility: number;
  44969. /**
  44970. * Defines the gamepad move sensiblity.
  44971. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44972. */
  44973. gamepadMoveSensibility: number;
  44974. private _yAxisScale;
  44975. /**
  44976. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44977. */
  44978. get invertYAxis(): boolean;
  44979. set invertYAxis(value: boolean);
  44980. private _onGamepadConnectedObserver;
  44981. private _onGamepadDisconnectedObserver;
  44982. private _cameraTransform;
  44983. private _deltaTransform;
  44984. private _vector3;
  44985. private _vector2;
  44986. /**
  44987. * Attach the input controls to a specific dom element to get the input from.
  44988. * @param element Defines the element the controls should be listened from
  44989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44990. */
  44991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44992. /**
  44993. * Detach the current controls from the specified dom element.
  44994. * @param element Defines the element to stop listening the inputs from
  44995. */
  44996. detachControl(element: Nullable<HTMLElement>): void;
  44997. /**
  44998. * Update the current camera state depending on the inputs that have been used this frame.
  44999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45000. */
  45001. checkInputs(): void;
  45002. /**
  45003. * Gets the class name of the current intput.
  45004. * @returns the class name
  45005. */
  45006. getClassName(): string;
  45007. /**
  45008. * Get the friendly name associated with the input class.
  45009. * @returns the input friendly name
  45010. */
  45011. getSimpleName(): string;
  45012. }
  45013. }
  45014. declare module BABYLON {
  45015. /**
  45016. * Defines the potential axis of a Joystick
  45017. */
  45018. export enum JoystickAxis {
  45019. /** X axis */
  45020. X = 0,
  45021. /** Y axis */
  45022. Y = 1,
  45023. /** Z axis */
  45024. Z = 2
  45025. }
  45026. /**
  45027. * Represents the different customization options available
  45028. * for VirtualJoystick
  45029. */
  45030. interface VirtualJoystickCustomizations {
  45031. /**
  45032. * Size of the joystick's puck
  45033. */
  45034. puckSize: number;
  45035. /**
  45036. * Size of the joystick's container
  45037. */
  45038. containerSize: number;
  45039. /**
  45040. * Color of the joystick && puck
  45041. */
  45042. color: string;
  45043. /**
  45044. * Image URL for the joystick's puck
  45045. */
  45046. puckImage?: string;
  45047. /**
  45048. * Image URL for the joystick's container
  45049. */
  45050. containerImage?: string;
  45051. /**
  45052. * Defines the unmoving position of the joystick container
  45053. */
  45054. position?: {
  45055. x: number;
  45056. y: number;
  45057. };
  45058. /**
  45059. * Defines whether or not the joystick container is always visible
  45060. */
  45061. alwaysVisible: boolean;
  45062. /**
  45063. * Defines whether or not to limit the movement of the puck to the joystick's container
  45064. */
  45065. limitToContainer: boolean;
  45066. }
  45067. /**
  45068. * Class used to define virtual joystick (used in touch mode)
  45069. */
  45070. export class VirtualJoystick {
  45071. /**
  45072. * Gets or sets a boolean indicating that left and right values must be inverted
  45073. */
  45074. reverseLeftRight: boolean;
  45075. /**
  45076. * Gets or sets a boolean indicating that up and down values must be inverted
  45077. */
  45078. reverseUpDown: boolean;
  45079. /**
  45080. * Gets the offset value for the position (ie. the change of the position value)
  45081. */
  45082. deltaPosition: Vector3;
  45083. /**
  45084. * Gets a boolean indicating if the virtual joystick was pressed
  45085. */
  45086. pressed: boolean;
  45087. /**
  45088. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45089. */
  45090. static Canvas: Nullable<HTMLCanvasElement>;
  45091. /**
  45092. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45093. */
  45094. limitToContainer: boolean;
  45095. private static _globalJoystickIndex;
  45096. private static _alwaysVisibleSticks;
  45097. private static vjCanvasContext;
  45098. private static vjCanvasWidth;
  45099. private static vjCanvasHeight;
  45100. private static halfWidth;
  45101. private static _GetDefaultOptions;
  45102. private _action;
  45103. private _axisTargetedByLeftAndRight;
  45104. private _axisTargetedByUpAndDown;
  45105. private _joystickSensibility;
  45106. private _inversedSensibility;
  45107. private _joystickPointerID;
  45108. private _joystickColor;
  45109. private _joystickPointerPos;
  45110. private _joystickPreviousPointerPos;
  45111. private _joystickPointerStartPos;
  45112. private _deltaJoystickVector;
  45113. private _leftJoystick;
  45114. private _touches;
  45115. private _joystickPosition;
  45116. private _alwaysVisible;
  45117. private _puckImage;
  45118. private _containerImage;
  45119. private _joystickPuckSize;
  45120. private _joystickContainerSize;
  45121. private _clearPuckSize;
  45122. private _clearContainerSize;
  45123. private _clearPuckSizeOffset;
  45124. private _clearContainerSizeOffset;
  45125. private _onPointerDownHandlerRef;
  45126. private _onPointerMoveHandlerRef;
  45127. private _onPointerUpHandlerRef;
  45128. private _onResize;
  45129. /**
  45130. * Creates a new virtual joystick
  45131. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45132. * @param customizations Defines the options we want to customize the VirtualJoystick
  45133. */
  45134. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45135. /**
  45136. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45137. * @param newJoystickSensibility defines the new sensibility
  45138. */
  45139. setJoystickSensibility(newJoystickSensibility: number): void;
  45140. private _onPointerDown;
  45141. private _onPointerMove;
  45142. private _onPointerUp;
  45143. /**
  45144. * Change the color of the virtual joystick
  45145. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45146. */
  45147. setJoystickColor(newColor: string): void;
  45148. /**
  45149. * Size of the joystick's container
  45150. */
  45151. set containerSize(newSize: number);
  45152. get containerSize(): number;
  45153. /**
  45154. * Size of the joystick's puck
  45155. */
  45156. set puckSize(newSize: number);
  45157. get puckSize(): number;
  45158. /**
  45159. * Clears the set position of the joystick
  45160. */
  45161. clearPosition(): void;
  45162. /**
  45163. * Defines whether or not the joystick container is always visible
  45164. */
  45165. set alwaysVisible(value: boolean);
  45166. get alwaysVisible(): boolean;
  45167. /**
  45168. * Sets the constant position of the Joystick container
  45169. * @param x X axis coordinate
  45170. * @param y Y axis coordinate
  45171. */
  45172. setPosition(x: number, y: number): void;
  45173. /**
  45174. * Defines a callback to call when the joystick is touched
  45175. * @param action defines the callback
  45176. */
  45177. setActionOnTouch(action: () => any): void;
  45178. /**
  45179. * Defines which axis you'd like to control for left & right
  45180. * @param axis defines the axis to use
  45181. */
  45182. setAxisForLeftRight(axis: JoystickAxis): void;
  45183. /**
  45184. * Defines which axis you'd like to control for up & down
  45185. * @param axis defines the axis to use
  45186. */
  45187. setAxisForUpDown(axis: JoystickAxis): void;
  45188. /**
  45189. * Clears the canvas from the previous puck / container draw
  45190. */
  45191. private _clearPreviousDraw;
  45192. /**
  45193. * Loads `urlPath` to be used for the container's image
  45194. * @param urlPath defines the urlPath of an image to use
  45195. */
  45196. setContainerImage(urlPath: string): void;
  45197. /**
  45198. * Loads `urlPath` to be used for the puck's image
  45199. * @param urlPath defines the urlPath of an image to use
  45200. */
  45201. setPuckImage(urlPath: string): void;
  45202. /**
  45203. * Draws the Virtual Joystick's container
  45204. */
  45205. private _drawContainer;
  45206. /**
  45207. * Draws the Virtual Joystick's puck
  45208. */
  45209. private _drawPuck;
  45210. private _drawVirtualJoystick;
  45211. /**
  45212. * Release internal HTML canvas
  45213. */
  45214. releaseCanvas(): void;
  45215. }
  45216. }
  45217. declare module BABYLON {
  45218. interface FreeCameraInputsManager {
  45219. /**
  45220. * Add virtual joystick input support to the input manager.
  45221. * @returns the current input manager
  45222. */
  45223. addVirtualJoystick(): FreeCameraInputsManager;
  45224. }
  45225. /**
  45226. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45227. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45228. */
  45229. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45230. /**
  45231. * Defines the camera the input is attached to.
  45232. */
  45233. camera: FreeCamera;
  45234. private _leftjoystick;
  45235. private _rightjoystick;
  45236. /**
  45237. * Gets the left stick of the virtual joystick.
  45238. * @returns The virtual Joystick
  45239. */
  45240. getLeftJoystick(): VirtualJoystick;
  45241. /**
  45242. * Gets the right stick of the virtual joystick.
  45243. * @returns The virtual Joystick
  45244. */
  45245. getRightJoystick(): VirtualJoystick;
  45246. /**
  45247. * Update the current camera state depending on the inputs that have been used this frame.
  45248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45249. */
  45250. checkInputs(): void;
  45251. /**
  45252. * Attach the input controls to a specific dom element to get the input from.
  45253. * @param element Defines the element the controls should be listened from
  45254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45255. */
  45256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45257. /**
  45258. * Detach the current controls from the specified dom element.
  45259. * @param element Defines the element to stop listening the inputs from
  45260. */
  45261. detachControl(element: Nullable<HTMLElement>): void;
  45262. /**
  45263. * Gets the class name of the current intput.
  45264. * @returns the class name
  45265. */
  45266. getClassName(): string;
  45267. /**
  45268. * Get the friendly name associated with the input class.
  45269. * @returns the input friendly name
  45270. */
  45271. getSimpleName(): string;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * This represents a FPS type of camera controlled by touch.
  45277. * This is like a universal camera minus the Gamepad controls.
  45278. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45279. */
  45280. export class TouchCamera extends FreeCamera {
  45281. /**
  45282. * Defines the touch sensibility for rotation.
  45283. * The higher the faster.
  45284. */
  45285. get touchAngularSensibility(): number;
  45286. set touchAngularSensibility(value: number);
  45287. /**
  45288. * Defines the touch sensibility for move.
  45289. * The higher the faster.
  45290. */
  45291. get touchMoveSensibility(): number;
  45292. set touchMoveSensibility(value: number);
  45293. /**
  45294. * Instantiates a new touch camera.
  45295. * This represents a FPS type of camera controlled by touch.
  45296. * This is like a universal camera minus the Gamepad controls.
  45297. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45298. * @param name Define the name of the camera in the scene
  45299. * @param position Define the start position of the camera in the scene
  45300. * @param scene Define the scene the camera belongs to
  45301. */
  45302. constructor(name: string, position: Vector3, scene: Scene);
  45303. /**
  45304. * Gets the current object class name.
  45305. * @return the class name
  45306. */
  45307. getClassName(): string;
  45308. /** @hidden */
  45309. _setupInputs(): void;
  45310. }
  45311. }
  45312. declare module BABYLON {
  45313. /**
  45314. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45315. * being tilted forward or back and left or right.
  45316. */
  45317. export class DeviceOrientationCamera extends FreeCamera {
  45318. private _initialQuaternion;
  45319. private _quaternionCache;
  45320. private _tmpDragQuaternion;
  45321. private _disablePointerInputWhenUsingDeviceOrientation;
  45322. /**
  45323. * Creates a new device orientation camera
  45324. * @param name The name of the camera
  45325. * @param position The start position camera
  45326. * @param scene The scene the camera belongs to
  45327. */
  45328. constructor(name: string, position: Vector3, scene: Scene);
  45329. /**
  45330. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45331. */
  45332. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45333. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45334. private _dragFactor;
  45335. /**
  45336. * Enabled turning on the y axis when the orientation sensor is active
  45337. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45338. */
  45339. enableHorizontalDragging(dragFactor?: number): void;
  45340. /**
  45341. * Gets the current instance class name ("DeviceOrientationCamera").
  45342. * This helps avoiding instanceof at run time.
  45343. * @returns the class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * @hidden
  45348. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45349. */
  45350. _checkInputs(): void;
  45351. /**
  45352. * Reset the camera to its default orientation on the specified axis only.
  45353. * @param axis The axis to reset
  45354. */
  45355. resetToCurrentRotation(axis?: Axis): void;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /**
  45360. * Defines supported buttons for XBox360 compatible gamepads
  45361. */
  45362. export enum Xbox360Button {
  45363. /** A */
  45364. A = 0,
  45365. /** B */
  45366. B = 1,
  45367. /** X */
  45368. X = 2,
  45369. /** Y */
  45370. Y = 3,
  45371. /** Left button */
  45372. LB = 4,
  45373. /** Right button */
  45374. RB = 5,
  45375. /** Back */
  45376. Back = 8,
  45377. /** Start */
  45378. Start = 9,
  45379. /** Left stick */
  45380. LeftStick = 10,
  45381. /** Right stick */
  45382. RightStick = 11
  45383. }
  45384. /** Defines values for XBox360 DPad */
  45385. export enum Xbox360Dpad {
  45386. /** Up */
  45387. Up = 12,
  45388. /** Down */
  45389. Down = 13,
  45390. /** Left */
  45391. Left = 14,
  45392. /** Right */
  45393. Right = 15
  45394. }
  45395. /**
  45396. * Defines a XBox360 gamepad
  45397. */
  45398. export class Xbox360Pad extends Gamepad {
  45399. private _leftTrigger;
  45400. private _rightTrigger;
  45401. private _onlefttriggerchanged;
  45402. private _onrighttriggerchanged;
  45403. private _onbuttondown;
  45404. private _onbuttonup;
  45405. private _ondpaddown;
  45406. private _ondpadup;
  45407. /** Observable raised when a button is pressed */
  45408. onButtonDownObservable: Observable<Xbox360Button>;
  45409. /** Observable raised when a button is released */
  45410. onButtonUpObservable: Observable<Xbox360Button>;
  45411. /** Observable raised when a pad is pressed */
  45412. onPadDownObservable: Observable<Xbox360Dpad>;
  45413. /** Observable raised when a pad is released */
  45414. onPadUpObservable: Observable<Xbox360Dpad>;
  45415. private _buttonA;
  45416. private _buttonB;
  45417. private _buttonX;
  45418. private _buttonY;
  45419. private _buttonBack;
  45420. private _buttonStart;
  45421. private _buttonLB;
  45422. private _buttonRB;
  45423. private _buttonLeftStick;
  45424. private _buttonRightStick;
  45425. private _dPadUp;
  45426. private _dPadDown;
  45427. private _dPadLeft;
  45428. private _dPadRight;
  45429. private _isXboxOnePad;
  45430. /**
  45431. * Creates a new XBox360 gamepad object
  45432. * @param id defines the id of this gamepad
  45433. * @param index defines its index
  45434. * @param gamepad defines the internal HTML gamepad object
  45435. * @param xboxOne defines if it is a XBox One gamepad
  45436. */
  45437. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45438. /**
  45439. * Defines the callback to call when left trigger is pressed
  45440. * @param callback defines the callback to use
  45441. */
  45442. onlefttriggerchanged(callback: (value: number) => void): void;
  45443. /**
  45444. * Defines the callback to call when right trigger is pressed
  45445. * @param callback defines the callback to use
  45446. */
  45447. onrighttriggerchanged(callback: (value: number) => void): void;
  45448. /**
  45449. * Gets the left trigger value
  45450. */
  45451. get leftTrigger(): number;
  45452. /**
  45453. * Sets the left trigger value
  45454. */
  45455. set leftTrigger(newValue: number);
  45456. /**
  45457. * Gets the right trigger value
  45458. */
  45459. get rightTrigger(): number;
  45460. /**
  45461. * Sets the right trigger value
  45462. */
  45463. set rightTrigger(newValue: number);
  45464. /**
  45465. * Defines the callback to call when a button is pressed
  45466. * @param callback defines the callback to use
  45467. */
  45468. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45469. /**
  45470. * Defines the callback to call when a button is released
  45471. * @param callback defines the callback to use
  45472. */
  45473. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45474. /**
  45475. * Defines the callback to call when a pad is pressed
  45476. * @param callback defines the callback to use
  45477. */
  45478. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45479. /**
  45480. * Defines the callback to call when a pad is released
  45481. * @param callback defines the callback to use
  45482. */
  45483. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45484. private _setButtonValue;
  45485. private _setDPadValue;
  45486. /**
  45487. * Gets the value of the `A` button
  45488. */
  45489. get buttonA(): number;
  45490. /**
  45491. * Sets the value of the `A` button
  45492. */
  45493. set buttonA(value: number);
  45494. /**
  45495. * Gets the value of the `B` button
  45496. */
  45497. get buttonB(): number;
  45498. /**
  45499. * Sets the value of the `B` button
  45500. */
  45501. set buttonB(value: number);
  45502. /**
  45503. * Gets the value of the `X` button
  45504. */
  45505. get buttonX(): number;
  45506. /**
  45507. * Sets the value of the `X` button
  45508. */
  45509. set buttonX(value: number);
  45510. /**
  45511. * Gets the value of the `Y` button
  45512. */
  45513. get buttonY(): number;
  45514. /**
  45515. * Sets the value of the `Y` button
  45516. */
  45517. set buttonY(value: number);
  45518. /**
  45519. * Gets the value of the `Start` button
  45520. */
  45521. get buttonStart(): number;
  45522. /**
  45523. * Sets the value of the `Start` button
  45524. */
  45525. set buttonStart(value: number);
  45526. /**
  45527. * Gets the value of the `Back` button
  45528. */
  45529. get buttonBack(): number;
  45530. /**
  45531. * Sets the value of the `Back` button
  45532. */
  45533. set buttonBack(value: number);
  45534. /**
  45535. * Gets the value of the `Left` button
  45536. */
  45537. get buttonLB(): number;
  45538. /**
  45539. * Sets the value of the `Left` button
  45540. */
  45541. set buttonLB(value: number);
  45542. /**
  45543. * Gets the value of the `Right` button
  45544. */
  45545. get buttonRB(): number;
  45546. /**
  45547. * Sets the value of the `Right` button
  45548. */
  45549. set buttonRB(value: number);
  45550. /**
  45551. * Gets the value of the Left joystick
  45552. */
  45553. get buttonLeftStick(): number;
  45554. /**
  45555. * Sets the value of the Left joystick
  45556. */
  45557. set buttonLeftStick(value: number);
  45558. /**
  45559. * Gets the value of the Right joystick
  45560. */
  45561. get buttonRightStick(): number;
  45562. /**
  45563. * Sets the value of the Right joystick
  45564. */
  45565. set buttonRightStick(value: number);
  45566. /**
  45567. * Gets the value of D-pad up
  45568. */
  45569. get dPadUp(): number;
  45570. /**
  45571. * Sets the value of D-pad up
  45572. */
  45573. set dPadUp(value: number);
  45574. /**
  45575. * Gets the value of D-pad down
  45576. */
  45577. get dPadDown(): number;
  45578. /**
  45579. * Sets the value of D-pad down
  45580. */
  45581. set dPadDown(value: number);
  45582. /**
  45583. * Gets the value of D-pad left
  45584. */
  45585. get dPadLeft(): number;
  45586. /**
  45587. * Sets the value of D-pad left
  45588. */
  45589. set dPadLeft(value: number);
  45590. /**
  45591. * Gets the value of D-pad right
  45592. */
  45593. get dPadRight(): number;
  45594. /**
  45595. * Sets the value of D-pad right
  45596. */
  45597. set dPadRight(value: number);
  45598. /**
  45599. * Force the gamepad to synchronize with device values
  45600. */
  45601. update(): void;
  45602. /**
  45603. * Disposes the gamepad
  45604. */
  45605. dispose(): void;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * Defines supported buttons for DualShock compatible gamepads
  45611. */
  45612. export enum DualShockButton {
  45613. /** Cross */
  45614. Cross = 0,
  45615. /** Circle */
  45616. Circle = 1,
  45617. /** Square */
  45618. Square = 2,
  45619. /** Triangle */
  45620. Triangle = 3,
  45621. /** L1 */
  45622. L1 = 4,
  45623. /** R1 */
  45624. R1 = 5,
  45625. /** Share */
  45626. Share = 8,
  45627. /** Options */
  45628. Options = 9,
  45629. /** Left stick */
  45630. LeftStick = 10,
  45631. /** Right stick */
  45632. RightStick = 11
  45633. }
  45634. /** Defines values for DualShock DPad */
  45635. export enum DualShockDpad {
  45636. /** Up */
  45637. Up = 12,
  45638. /** Down */
  45639. Down = 13,
  45640. /** Left */
  45641. Left = 14,
  45642. /** Right */
  45643. Right = 15
  45644. }
  45645. /**
  45646. * Defines a DualShock gamepad
  45647. */
  45648. export class DualShockPad extends Gamepad {
  45649. private _leftTrigger;
  45650. private _rightTrigger;
  45651. private _onlefttriggerchanged;
  45652. private _onrighttriggerchanged;
  45653. private _onbuttondown;
  45654. private _onbuttonup;
  45655. private _ondpaddown;
  45656. private _ondpadup;
  45657. /** Observable raised when a button is pressed */
  45658. onButtonDownObservable: Observable<DualShockButton>;
  45659. /** Observable raised when a button is released */
  45660. onButtonUpObservable: Observable<DualShockButton>;
  45661. /** Observable raised when a pad is pressed */
  45662. onPadDownObservable: Observable<DualShockDpad>;
  45663. /** Observable raised when a pad is released */
  45664. onPadUpObservable: Observable<DualShockDpad>;
  45665. private _buttonCross;
  45666. private _buttonCircle;
  45667. private _buttonSquare;
  45668. private _buttonTriangle;
  45669. private _buttonShare;
  45670. private _buttonOptions;
  45671. private _buttonL1;
  45672. private _buttonR1;
  45673. private _buttonLeftStick;
  45674. private _buttonRightStick;
  45675. private _dPadUp;
  45676. private _dPadDown;
  45677. private _dPadLeft;
  45678. private _dPadRight;
  45679. /**
  45680. * Creates a new DualShock gamepad object
  45681. * @param id defines the id of this gamepad
  45682. * @param index defines its index
  45683. * @param gamepad defines the internal HTML gamepad object
  45684. */
  45685. constructor(id: string, index: number, gamepad: any);
  45686. /**
  45687. * Defines the callback to call when left trigger is pressed
  45688. * @param callback defines the callback to use
  45689. */
  45690. onlefttriggerchanged(callback: (value: number) => void): void;
  45691. /**
  45692. * Defines the callback to call when right trigger is pressed
  45693. * @param callback defines the callback to use
  45694. */
  45695. onrighttriggerchanged(callback: (value: number) => void): void;
  45696. /**
  45697. * Gets the left trigger value
  45698. */
  45699. get leftTrigger(): number;
  45700. /**
  45701. * Sets the left trigger value
  45702. */
  45703. set leftTrigger(newValue: number);
  45704. /**
  45705. * Gets the right trigger value
  45706. */
  45707. get rightTrigger(): number;
  45708. /**
  45709. * Sets the right trigger value
  45710. */
  45711. set rightTrigger(newValue: number);
  45712. /**
  45713. * Defines the callback to call when a button is pressed
  45714. * @param callback defines the callback to use
  45715. */
  45716. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45717. /**
  45718. * Defines the callback to call when a button is released
  45719. * @param callback defines the callback to use
  45720. */
  45721. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45722. /**
  45723. * Defines the callback to call when a pad is pressed
  45724. * @param callback defines the callback to use
  45725. */
  45726. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45727. /**
  45728. * Defines the callback to call when a pad is released
  45729. * @param callback defines the callback to use
  45730. */
  45731. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45732. private _setButtonValue;
  45733. private _setDPadValue;
  45734. /**
  45735. * Gets the value of the `Cross` button
  45736. */
  45737. get buttonCross(): number;
  45738. /**
  45739. * Sets the value of the `Cross` button
  45740. */
  45741. set buttonCross(value: number);
  45742. /**
  45743. * Gets the value of the `Circle` button
  45744. */
  45745. get buttonCircle(): number;
  45746. /**
  45747. * Sets the value of the `Circle` button
  45748. */
  45749. set buttonCircle(value: number);
  45750. /**
  45751. * Gets the value of the `Square` button
  45752. */
  45753. get buttonSquare(): number;
  45754. /**
  45755. * Sets the value of the `Square` button
  45756. */
  45757. set buttonSquare(value: number);
  45758. /**
  45759. * Gets the value of the `Triangle` button
  45760. */
  45761. get buttonTriangle(): number;
  45762. /**
  45763. * Sets the value of the `Triangle` button
  45764. */
  45765. set buttonTriangle(value: number);
  45766. /**
  45767. * Gets the value of the `Options` button
  45768. */
  45769. get buttonOptions(): number;
  45770. /**
  45771. * Sets the value of the `Options` button
  45772. */
  45773. set buttonOptions(value: number);
  45774. /**
  45775. * Gets the value of the `Share` button
  45776. */
  45777. get buttonShare(): number;
  45778. /**
  45779. * Sets the value of the `Share` button
  45780. */
  45781. set buttonShare(value: number);
  45782. /**
  45783. * Gets the value of the `L1` button
  45784. */
  45785. get buttonL1(): number;
  45786. /**
  45787. * Sets the value of the `L1` button
  45788. */
  45789. set buttonL1(value: number);
  45790. /**
  45791. * Gets the value of the `R1` button
  45792. */
  45793. get buttonR1(): number;
  45794. /**
  45795. * Sets the value of the `R1` button
  45796. */
  45797. set buttonR1(value: number);
  45798. /**
  45799. * Gets the value of the Left joystick
  45800. */
  45801. get buttonLeftStick(): number;
  45802. /**
  45803. * Sets the value of the Left joystick
  45804. */
  45805. set buttonLeftStick(value: number);
  45806. /**
  45807. * Gets the value of the Right joystick
  45808. */
  45809. get buttonRightStick(): number;
  45810. /**
  45811. * Sets the value of the Right joystick
  45812. */
  45813. set buttonRightStick(value: number);
  45814. /**
  45815. * Gets the value of D-pad up
  45816. */
  45817. get dPadUp(): number;
  45818. /**
  45819. * Sets the value of D-pad up
  45820. */
  45821. set dPadUp(value: number);
  45822. /**
  45823. * Gets the value of D-pad down
  45824. */
  45825. get dPadDown(): number;
  45826. /**
  45827. * Sets the value of D-pad down
  45828. */
  45829. set dPadDown(value: number);
  45830. /**
  45831. * Gets the value of D-pad left
  45832. */
  45833. get dPadLeft(): number;
  45834. /**
  45835. * Sets the value of D-pad left
  45836. */
  45837. set dPadLeft(value: number);
  45838. /**
  45839. * Gets the value of D-pad right
  45840. */
  45841. get dPadRight(): number;
  45842. /**
  45843. * Sets the value of D-pad right
  45844. */
  45845. set dPadRight(value: number);
  45846. /**
  45847. * Force the gamepad to synchronize with device values
  45848. */
  45849. update(): void;
  45850. /**
  45851. * Disposes the gamepad
  45852. */
  45853. dispose(): void;
  45854. }
  45855. }
  45856. declare module BABYLON {
  45857. /**
  45858. * Manager for handling gamepads
  45859. */
  45860. export class GamepadManager {
  45861. private _scene?;
  45862. private _babylonGamepads;
  45863. private _oneGamepadConnected;
  45864. /** @hidden */
  45865. _isMonitoring: boolean;
  45866. private _gamepadEventSupported;
  45867. private _gamepadSupport?;
  45868. /**
  45869. * observable to be triggered when the gamepad controller has been connected
  45870. */
  45871. onGamepadConnectedObservable: Observable<Gamepad>;
  45872. /**
  45873. * observable to be triggered when the gamepad controller has been disconnected
  45874. */
  45875. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45876. private _onGamepadConnectedEvent;
  45877. private _onGamepadDisconnectedEvent;
  45878. /**
  45879. * Initializes the gamepad manager
  45880. * @param _scene BabylonJS scene
  45881. */
  45882. constructor(_scene?: Scene | undefined);
  45883. /**
  45884. * The gamepads in the game pad manager
  45885. */
  45886. get gamepads(): Gamepad[];
  45887. /**
  45888. * Get the gamepad controllers based on type
  45889. * @param type The type of gamepad controller
  45890. * @returns Nullable gamepad
  45891. */
  45892. getGamepadByType(type?: number): Nullable<Gamepad>;
  45893. /**
  45894. * Disposes the gamepad manager
  45895. */
  45896. dispose(): void;
  45897. private _addNewGamepad;
  45898. private _startMonitoringGamepads;
  45899. private _stopMonitoringGamepads;
  45900. /** @hidden */
  45901. _checkGamepadsStatus(): void;
  45902. private _updateGamepadObjects;
  45903. }
  45904. }
  45905. declare module BABYLON {
  45906. interface Scene {
  45907. /** @hidden */
  45908. _gamepadManager: Nullable<GamepadManager>;
  45909. /**
  45910. * Gets the gamepad manager associated with the scene
  45911. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45912. */
  45913. gamepadManager: GamepadManager;
  45914. }
  45915. /**
  45916. * Interface representing a free camera inputs manager
  45917. */
  45918. interface FreeCameraInputsManager {
  45919. /**
  45920. * Adds gamepad input support to the FreeCameraInputsManager.
  45921. * @returns the FreeCameraInputsManager
  45922. */
  45923. addGamepad(): FreeCameraInputsManager;
  45924. }
  45925. /**
  45926. * Interface representing an arc rotate camera inputs manager
  45927. */
  45928. interface ArcRotateCameraInputsManager {
  45929. /**
  45930. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45931. * @returns the camera inputs manager
  45932. */
  45933. addGamepad(): ArcRotateCameraInputsManager;
  45934. }
  45935. /**
  45936. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45937. */
  45938. export class GamepadSystemSceneComponent implements ISceneComponent {
  45939. /**
  45940. * The component name helpfull to identify the component in the list of scene components.
  45941. */
  45942. readonly name: string;
  45943. /**
  45944. * The scene the component belongs to.
  45945. */
  45946. scene: Scene;
  45947. /**
  45948. * Creates a new instance of the component for the given scene
  45949. * @param scene Defines the scene to register the component in
  45950. */
  45951. constructor(scene: Scene);
  45952. /**
  45953. * Registers the component in a given scene
  45954. */
  45955. register(): void;
  45956. /**
  45957. * Rebuilds the elements related to this component in case of
  45958. * context lost for instance.
  45959. */
  45960. rebuild(): void;
  45961. /**
  45962. * Disposes the component and the associated ressources
  45963. */
  45964. dispose(): void;
  45965. private _beforeCameraUpdate;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * 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,
  45971. * which still works and will still be found in many Playgrounds.
  45972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45973. */
  45974. export class UniversalCamera extends TouchCamera {
  45975. /**
  45976. * Defines the gamepad rotation sensiblity.
  45977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45978. */
  45979. get gamepadAngularSensibility(): number;
  45980. set gamepadAngularSensibility(value: number);
  45981. /**
  45982. * Defines the gamepad move sensiblity.
  45983. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45984. */
  45985. get gamepadMoveSensibility(): number;
  45986. set gamepadMoveSensibility(value: number);
  45987. /**
  45988. * 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,
  45989. * which still works and will still be found in many Playgrounds.
  45990. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45991. * @param name Define the name of the camera in the scene
  45992. * @param position Define the start position of the camera in the scene
  45993. * @param scene Define the scene the camera belongs to
  45994. */
  45995. constructor(name: string, position: Vector3, scene: Scene);
  45996. /**
  45997. * Gets the current object class name.
  45998. * @return the class name
  45999. */
  46000. getClassName(): string;
  46001. }
  46002. }
  46003. declare module BABYLON {
  46004. /**
  46005. * This represents a FPS type of camera. This is only here for back compat purpose.
  46006. * Please use the UniversalCamera instead as both are identical.
  46007. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46008. */
  46009. export class GamepadCamera extends UniversalCamera {
  46010. /**
  46011. * Instantiates a new Gamepad Camera
  46012. * This represents a FPS type of camera. This is only here for back compat purpose.
  46013. * Please use the UniversalCamera instead as both are identical.
  46014. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46015. * @param name Define the name of the camera in the scene
  46016. * @param position Define the start position of the camera in the scene
  46017. * @param scene Define the scene the camera belongs to
  46018. */
  46019. constructor(name: string, position: Vector3, scene: Scene);
  46020. /**
  46021. * Gets the current object class name.
  46022. * @return the class name
  46023. */
  46024. getClassName(): string;
  46025. }
  46026. }
  46027. declare module BABYLON {
  46028. /** @hidden */
  46029. export var passPixelShader: {
  46030. name: string;
  46031. shader: string;
  46032. };
  46033. }
  46034. declare module BABYLON {
  46035. /** @hidden */
  46036. export var passCubePixelShader: {
  46037. name: string;
  46038. shader: string;
  46039. };
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * PassPostProcess which produces an output the same as it's input
  46044. */
  46045. export class PassPostProcess extends PostProcess {
  46046. /**
  46047. * Gets a string identifying the name of the class
  46048. * @returns "PassPostProcess" string
  46049. */
  46050. getClassName(): string;
  46051. /**
  46052. * Creates the PassPostProcess
  46053. * @param name The name of the effect.
  46054. * @param options The required width/height ratio to downsize to before computing the render pass.
  46055. * @param camera The camera to apply the render pass to.
  46056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46057. * @param engine The engine which the post process will be applied. (default: current engine)
  46058. * @param reusable If the post process can be reused on the same frame. (default: false)
  46059. * @param textureType The type of texture to be used when performing the post processing.
  46060. * @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)
  46061. */
  46062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46063. /** @hidden */
  46064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46065. }
  46066. /**
  46067. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46068. */
  46069. export class PassCubePostProcess extends PostProcess {
  46070. private _face;
  46071. /**
  46072. * Gets or sets the cube face to display.
  46073. * * 0 is +X
  46074. * * 1 is -X
  46075. * * 2 is +Y
  46076. * * 3 is -Y
  46077. * * 4 is +Z
  46078. * * 5 is -Z
  46079. */
  46080. get face(): number;
  46081. set face(value: number);
  46082. /**
  46083. * Gets a string identifying the name of the class
  46084. * @returns "PassCubePostProcess" string
  46085. */
  46086. getClassName(): string;
  46087. /**
  46088. * Creates the PassCubePostProcess
  46089. * @param name The name of the effect.
  46090. * @param options The required width/height ratio to downsize to before computing the render pass.
  46091. * @param camera The camera to apply the render pass to.
  46092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46093. * @param engine The engine which the post process will be applied. (default: current engine)
  46094. * @param reusable If the post process can be reused on the same frame. (default: false)
  46095. * @param textureType The type of texture to be used when performing the post processing.
  46096. * @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)
  46097. */
  46098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46099. /** @hidden */
  46100. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46101. }
  46102. }
  46103. declare module BABYLON {
  46104. /** @hidden */
  46105. export var anaglyphPixelShader: {
  46106. name: string;
  46107. shader: string;
  46108. };
  46109. }
  46110. declare module BABYLON {
  46111. /**
  46112. * Postprocess used to generate anaglyphic rendering
  46113. */
  46114. export class AnaglyphPostProcess extends PostProcess {
  46115. private _passedProcess;
  46116. /**
  46117. * Gets a string identifying the name of the class
  46118. * @returns "AnaglyphPostProcess" string
  46119. */
  46120. getClassName(): string;
  46121. /**
  46122. * Creates a new AnaglyphPostProcess
  46123. * @param name defines postprocess name
  46124. * @param options defines creation options or target ratio scale
  46125. * @param rigCameras defines cameras using this postprocess
  46126. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46127. * @param engine defines hosting engine
  46128. * @param reusable defines if the postprocess will be reused multiple times per frame
  46129. */
  46130. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46131. }
  46132. }
  46133. declare module BABYLON {
  46134. /**
  46135. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46136. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46137. */
  46138. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46139. /**
  46140. * Creates a new AnaglyphArcRotateCamera
  46141. * @param name defines camera name
  46142. * @param alpha defines alpha angle (in radians)
  46143. * @param beta defines beta angle (in radians)
  46144. * @param radius defines radius
  46145. * @param target defines camera target
  46146. * @param interaxialDistance defines distance between each color axis
  46147. * @param scene defines the hosting scene
  46148. */
  46149. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46150. /**
  46151. * Gets camera class name
  46152. * @returns AnaglyphArcRotateCamera
  46153. */
  46154. getClassName(): string;
  46155. }
  46156. }
  46157. declare module BABYLON {
  46158. /**
  46159. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46160. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46161. */
  46162. export class AnaglyphFreeCamera extends FreeCamera {
  46163. /**
  46164. * Creates a new AnaglyphFreeCamera
  46165. * @param name defines camera name
  46166. * @param position defines initial position
  46167. * @param interaxialDistance defines distance between each color axis
  46168. * @param scene defines the hosting scene
  46169. */
  46170. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46171. /**
  46172. * Gets camera class name
  46173. * @returns AnaglyphFreeCamera
  46174. */
  46175. getClassName(): string;
  46176. }
  46177. }
  46178. declare module BABYLON {
  46179. /**
  46180. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46181. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46182. */
  46183. export class AnaglyphGamepadCamera extends GamepadCamera {
  46184. /**
  46185. * Creates a new AnaglyphGamepadCamera
  46186. * @param name defines camera name
  46187. * @param position defines initial position
  46188. * @param interaxialDistance defines distance between each color axis
  46189. * @param scene defines the hosting scene
  46190. */
  46191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46192. /**
  46193. * Gets camera class name
  46194. * @returns AnaglyphGamepadCamera
  46195. */
  46196. getClassName(): string;
  46197. }
  46198. }
  46199. declare module BABYLON {
  46200. /**
  46201. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46202. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46203. */
  46204. export class AnaglyphUniversalCamera extends UniversalCamera {
  46205. /**
  46206. * Creates a new AnaglyphUniversalCamera
  46207. * @param name defines camera name
  46208. * @param position defines initial position
  46209. * @param interaxialDistance defines distance between each color axis
  46210. * @param scene defines the hosting scene
  46211. */
  46212. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46213. /**
  46214. * Gets camera class name
  46215. * @returns AnaglyphUniversalCamera
  46216. */
  46217. getClassName(): string;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46223. * @see https://doc.babylonjs.com/features/cameras
  46224. */
  46225. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46226. /**
  46227. * Creates a new StereoscopicArcRotateCamera
  46228. * @param name defines camera name
  46229. * @param alpha defines alpha angle (in radians)
  46230. * @param beta defines beta angle (in radians)
  46231. * @param radius defines radius
  46232. * @param target defines camera target
  46233. * @param interaxialDistance defines distance between each color axis
  46234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46235. * @param scene defines the hosting scene
  46236. */
  46237. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46238. /**
  46239. * Gets camera class name
  46240. * @returns StereoscopicArcRotateCamera
  46241. */
  46242. getClassName(): string;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46248. * @see https://doc.babylonjs.com/features/cameras
  46249. */
  46250. export class StereoscopicFreeCamera extends FreeCamera {
  46251. /**
  46252. * Creates a new StereoscopicFreeCamera
  46253. * @param name defines camera name
  46254. * @param position defines initial position
  46255. * @param interaxialDistance defines distance between each color axis
  46256. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46257. * @param scene defines the hosting scene
  46258. */
  46259. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46260. /**
  46261. * Gets camera class name
  46262. * @returns StereoscopicFreeCamera
  46263. */
  46264. getClassName(): string;
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /**
  46269. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46270. * @see https://doc.babylonjs.com/features/cameras
  46271. */
  46272. export class StereoscopicGamepadCamera extends GamepadCamera {
  46273. /**
  46274. * Creates a new StereoscopicGamepadCamera
  46275. * @param name defines camera name
  46276. * @param position defines initial position
  46277. * @param interaxialDistance defines distance between each color axis
  46278. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46279. * @param scene defines the hosting scene
  46280. */
  46281. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46282. /**
  46283. * Gets camera class name
  46284. * @returns StereoscopicGamepadCamera
  46285. */
  46286. getClassName(): string;
  46287. }
  46288. }
  46289. declare module BABYLON {
  46290. /**
  46291. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46292. * @see https://doc.babylonjs.com/features/cameras
  46293. */
  46294. export class StereoscopicUniversalCamera extends UniversalCamera {
  46295. /**
  46296. * Creates a new StereoscopicUniversalCamera
  46297. * @param name defines camera name
  46298. * @param position defines initial position
  46299. * @param interaxialDistance defines distance between each color axis
  46300. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46301. * @param scene defines the hosting scene
  46302. */
  46303. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46304. /**
  46305. * Gets camera class name
  46306. * @returns StereoscopicUniversalCamera
  46307. */
  46308. getClassName(): string;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /**
  46313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46314. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46315. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46316. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46317. */
  46318. export class VirtualJoysticksCamera extends FreeCamera {
  46319. /**
  46320. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46321. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46322. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46323. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46324. * @param name Define the name of the camera in the scene
  46325. * @param position Define the start position of the camera in the scene
  46326. * @param scene Define the scene the camera belongs to
  46327. */
  46328. constructor(name: string, position: Vector3, scene: Scene);
  46329. /**
  46330. * Gets the current object class name.
  46331. * @return the class name
  46332. */
  46333. getClassName(): string;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * This represents all the required metrics to create a VR camera.
  46339. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46340. */
  46341. export class VRCameraMetrics {
  46342. /**
  46343. * Define the horizontal resolution off the screen.
  46344. */
  46345. hResolution: number;
  46346. /**
  46347. * Define the vertical resolution off the screen.
  46348. */
  46349. vResolution: number;
  46350. /**
  46351. * Define the horizontal screen size.
  46352. */
  46353. hScreenSize: number;
  46354. /**
  46355. * Define the vertical screen size.
  46356. */
  46357. vScreenSize: number;
  46358. /**
  46359. * Define the vertical screen center position.
  46360. */
  46361. vScreenCenter: number;
  46362. /**
  46363. * Define the distance of the eyes to the screen.
  46364. */
  46365. eyeToScreenDistance: number;
  46366. /**
  46367. * Define the distance between both lenses
  46368. */
  46369. lensSeparationDistance: number;
  46370. /**
  46371. * Define the distance between both viewer's eyes.
  46372. */
  46373. interpupillaryDistance: number;
  46374. /**
  46375. * Define the distortion factor of the VR postprocess.
  46376. * Please, touch with care.
  46377. */
  46378. distortionK: number[];
  46379. /**
  46380. * Define the chromatic aberration correction factors for the VR post process.
  46381. */
  46382. chromaAbCorrection: number[];
  46383. /**
  46384. * Define the scale factor of the post process.
  46385. * The smaller the better but the slower.
  46386. */
  46387. postProcessScaleFactor: number;
  46388. /**
  46389. * Define an offset for the lens center.
  46390. */
  46391. lensCenterOffset: number;
  46392. /**
  46393. * Define if the current vr camera should compensate the distortion of the lense or not.
  46394. */
  46395. compensateDistortion: boolean;
  46396. /**
  46397. * Defines if multiview should be enabled when rendering (Default: false)
  46398. */
  46399. multiviewEnabled: boolean;
  46400. /**
  46401. * Gets the rendering aspect ratio based on the provided resolutions.
  46402. */
  46403. get aspectRatio(): number;
  46404. /**
  46405. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46406. */
  46407. get aspectRatioFov(): number;
  46408. /**
  46409. * @hidden
  46410. */
  46411. get leftHMatrix(): Matrix;
  46412. /**
  46413. * @hidden
  46414. */
  46415. get rightHMatrix(): Matrix;
  46416. /**
  46417. * @hidden
  46418. */
  46419. get leftPreViewMatrix(): Matrix;
  46420. /**
  46421. * @hidden
  46422. */
  46423. get rightPreViewMatrix(): Matrix;
  46424. /**
  46425. * Get the default VRMetrics based on the most generic setup.
  46426. * @returns the default vr metrics
  46427. */
  46428. static GetDefault(): VRCameraMetrics;
  46429. }
  46430. }
  46431. declare module BABYLON {
  46432. /** @hidden */
  46433. export var vrDistortionCorrectionPixelShader: {
  46434. name: string;
  46435. shader: string;
  46436. };
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * VRDistortionCorrectionPostProcess used for mobile VR
  46441. */
  46442. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46443. private _isRightEye;
  46444. private _distortionFactors;
  46445. private _postProcessScaleFactor;
  46446. private _lensCenterOffset;
  46447. private _scaleIn;
  46448. private _scaleFactor;
  46449. private _lensCenter;
  46450. /**
  46451. * Gets a string identifying the name of the class
  46452. * @returns "VRDistortionCorrectionPostProcess" string
  46453. */
  46454. getClassName(): string;
  46455. /**
  46456. * Initializes the VRDistortionCorrectionPostProcess
  46457. * @param name The name of the effect.
  46458. * @param camera The camera to apply the render pass to.
  46459. * @param isRightEye If this is for the right eye distortion
  46460. * @param vrMetrics All the required metrics for the VR camera
  46461. */
  46462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46463. }
  46464. }
  46465. declare module BABYLON {
  46466. /**
  46467. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46468. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46469. */
  46470. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46471. /**
  46472. * Creates a new VRDeviceOrientationArcRotateCamera
  46473. * @param name defines camera name
  46474. * @param alpha defines the camera rotation along the logitudinal axis
  46475. * @param beta defines the camera rotation along the latitudinal axis
  46476. * @param radius defines the camera distance from its target
  46477. * @param target defines the camera target
  46478. * @param scene defines the scene the camera belongs to
  46479. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46480. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46481. */
  46482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46483. /**
  46484. * Gets camera class name
  46485. * @returns VRDeviceOrientationArcRotateCamera
  46486. */
  46487. getClassName(): string;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Camera used to simulate VR rendering (based on FreeCamera)
  46493. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46494. */
  46495. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46496. /**
  46497. * Creates a new VRDeviceOrientationFreeCamera
  46498. * @param name defines camera name
  46499. * @param position defines the start position of the camera
  46500. * @param scene defines the scene the camera belongs to
  46501. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46502. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46503. */
  46504. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46505. /**
  46506. * Gets camera class name
  46507. * @returns VRDeviceOrientationFreeCamera
  46508. */
  46509. getClassName(): string;
  46510. }
  46511. }
  46512. declare module BABYLON {
  46513. /**
  46514. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46515. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46516. */
  46517. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46518. /**
  46519. * Creates a new VRDeviceOrientationGamepadCamera
  46520. * @param name defines camera name
  46521. * @param position defines the start position of the camera
  46522. * @param scene defines the scene the camera belongs to
  46523. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46524. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46525. */
  46526. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46527. /**
  46528. * Gets camera class name
  46529. * @returns VRDeviceOrientationGamepadCamera
  46530. */
  46531. getClassName(): string;
  46532. }
  46533. }
  46534. declare module BABYLON {
  46535. /**
  46536. * A class extending Texture allowing drawing on a texture
  46537. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46538. */
  46539. export class DynamicTexture extends Texture {
  46540. private _generateMipMaps;
  46541. private _canvas;
  46542. private _context;
  46543. /**
  46544. * Creates a DynamicTexture
  46545. * @param name defines the name of the texture
  46546. * @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
  46547. * @param scene defines the scene where you want the texture
  46548. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46549. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46550. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46551. */
  46552. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46553. /**
  46554. * Get the current class name of the texture useful for serialization or dynamic coding.
  46555. * @returns "DynamicTexture"
  46556. */
  46557. getClassName(): string;
  46558. /**
  46559. * Gets the current state of canRescale
  46560. */
  46561. get canRescale(): boolean;
  46562. private _recreate;
  46563. /**
  46564. * Scales the texture
  46565. * @param ratio the scale factor to apply to both width and height
  46566. */
  46567. scale(ratio: number): void;
  46568. /**
  46569. * Resizes the texture
  46570. * @param width the new width
  46571. * @param height the new height
  46572. */
  46573. scaleTo(width: number, height: number): void;
  46574. /**
  46575. * Gets the context of the canvas used by the texture
  46576. * @returns the canvas context of the dynamic texture
  46577. */
  46578. getContext(): CanvasRenderingContext2D;
  46579. /**
  46580. * Clears the texture
  46581. */
  46582. clear(): void;
  46583. /**
  46584. * Updates the texture
  46585. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46586. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46587. */
  46588. update(invertY?: boolean, premulAlpha?: boolean): void;
  46589. /**
  46590. * Draws text onto the texture
  46591. * @param text defines the text to be drawn
  46592. * @param x defines the placement of the text from the left
  46593. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46594. * @param font defines the font to be used with font-style, font-size, font-name
  46595. * @param color defines the color used for the text
  46596. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46597. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46598. * @param update defines whether texture is immediately update (default is true)
  46599. */
  46600. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46601. /**
  46602. * Clones the texture
  46603. * @returns the clone of the texture.
  46604. */
  46605. clone(): DynamicTexture;
  46606. /**
  46607. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46608. * @returns a serialized dynamic texture object
  46609. */
  46610. serialize(): any;
  46611. private _IsCanvasElement;
  46612. /** @hidden */
  46613. _rebuild(): void;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * Class containing static functions to help procedurally build meshes
  46619. */
  46620. export class GroundBuilder {
  46621. /**
  46622. * Creates a ground mesh
  46623. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46624. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46626. * @param name defines the name of the mesh
  46627. * @param options defines the options used to create the mesh
  46628. * @param scene defines the hosting scene
  46629. * @returns the ground mesh
  46630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46631. */
  46632. static CreateGround(name: string, options: {
  46633. width?: number;
  46634. height?: number;
  46635. subdivisions?: number;
  46636. subdivisionsX?: number;
  46637. subdivisionsY?: number;
  46638. updatable?: boolean;
  46639. }, scene: any): Mesh;
  46640. /**
  46641. * Creates a tiled ground mesh
  46642. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46643. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46644. * * 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
  46645. * * 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
  46646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46647. * @param name defines the name of the mesh
  46648. * @param options defines the options used to create the mesh
  46649. * @param scene defines the hosting scene
  46650. * @returns the tiled ground mesh
  46651. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46652. */
  46653. static CreateTiledGround(name: string, options: {
  46654. xmin: number;
  46655. zmin: number;
  46656. xmax: number;
  46657. zmax: number;
  46658. subdivisions?: {
  46659. w: number;
  46660. h: number;
  46661. };
  46662. precision?: {
  46663. w: number;
  46664. h: number;
  46665. };
  46666. updatable?: boolean;
  46667. }, scene?: Nullable<Scene>): Mesh;
  46668. /**
  46669. * Creates a ground mesh from a height map
  46670. * * The parameter `url` sets the URL of the height map image resource.
  46671. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46672. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46673. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46674. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46675. * * 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.
  46676. * * 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).
  46677. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46679. * @param name defines the name of the mesh
  46680. * @param url defines the url to the height map
  46681. * @param options defines the options used to create the mesh
  46682. * @param scene defines the hosting scene
  46683. * @returns the ground mesh
  46684. * @see https://doc.babylonjs.com/babylon101/height_map
  46685. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46686. */
  46687. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46688. width?: number;
  46689. height?: number;
  46690. subdivisions?: number;
  46691. minHeight?: number;
  46692. maxHeight?: number;
  46693. colorFilter?: Color3;
  46694. alphaFilter?: number;
  46695. updatable?: boolean;
  46696. onReady?: (mesh: GroundMesh) => void;
  46697. }, scene?: Nullable<Scene>): GroundMesh;
  46698. }
  46699. }
  46700. declare module BABYLON {
  46701. /**
  46702. * Class containing static functions to help procedurally build meshes
  46703. */
  46704. export class TorusBuilder {
  46705. /**
  46706. * Creates a torus mesh
  46707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46711. * * 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
  46712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46713. * @param name defines the name of the mesh
  46714. * @param options defines the options used to create the mesh
  46715. * @param scene defines the hosting scene
  46716. * @returns the torus mesh
  46717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46718. */
  46719. static CreateTorus(name: string, options: {
  46720. diameter?: number;
  46721. thickness?: number;
  46722. tessellation?: number;
  46723. updatable?: boolean;
  46724. sideOrientation?: number;
  46725. frontUVs?: Vector4;
  46726. backUVs?: Vector4;
  46727. }, scene: any): Mesh;
  46728. }
  46729. }
  46730. declare module BABYLON {
  46731. /**
  46732. * Class containing static functions to help procedurally build meshes
  46733. */
  46734. export class CylinderBuilder {
  46735. /**
  46736. * Creates a cylinder or a cone mesh
  46737. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46738. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46739. * * 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.
  46740. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46741. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46742. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46743. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46744. * * 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).
  46745. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46746. * * 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).
  46747. * * 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
  46748. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46749. * * 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
  46750. * * 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.
  46751. * * If `enclose` is false, a ring surface is one element.
  46752. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46753. * * 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
  46754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46755. * * 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
  46756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46757. * @param name defines the name of the mesh
  46758. * @param options defines the options used to create the mesh
  46759. * @param scene defines the hosting scene
  46760. * @returns the cylinder mesh
  46761. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46762. */
  46763. static CreateCylinder(name: string, options: {
  46764. height?: number;
  46765. diameterTop?: number;
  46766. diameterBottom?: number;
  46767. diameter?: number;
  46768. tessellation?: number;
  46769. subdivisions?: number;
  46770. arc?: number;
  46771. faceColors?: Color4[];
  46772. faceUV?: Vector4[];
  46773. updatable?: boolean;
  46774. hasRings?: boolean;
  46775. enclose?: boolean;
  46776. cap?: number;
  46777. sideOrientation?: number;
  46778. frontUVs?: Vector4;
  46779. backUVs?: Vector4;
  46780. }, scene: any): Mesh;
  46781. }
  46782. }
  46783. declare module BABYLON {
  46784. /**
  46785. * States of the webXR experience
  46786. */
  46787. export enum WebXRState {
  46788. /**
  46789. * Transitioning to being in XR mode
  46790. */
  46791. ENTERING_XR = 0,
  46792. /**
  46793. * Transitioning to non XR mode
  46794. */
  46795. EXITING_XR = 1,
  46796. /**
  46797. * In XR mode and presenting
  46798. */
  46799. IN_XR = 2,
  46800. /**
  46801. * Not entered XR mode
  46802. */
  46803. NOT_IN_XR = 3
  46804. }
  46805. /**
  46806. * Abstraction of the XR render target
  46807. */
  46808. export interface WebXRRenderTarget extends IDisposable {
  46809. /**
  46810. * xrpresent context of the canvas which can be used to display/mirror xr content
  46811. */
  46812. canvasContext: WebGLRenderingContext;
  46813. /**
  46814. * xr layer for the canvas
  46815. */
  46816. xrLayer: Nullable<XRWebGLLayer>;
  46817. /**
  46818. * Initializes the xr layer for the session
  46819. * @param xrSession xr session
  46820. * @returns a promise that will resolve once the XR Layer has been created
  46821. */
  46822. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46823. }
  46824. }
  46825. declare module BABYLON {
  46826. /**
  46827. * COnfiguration object for WebXR output canvas
  46828. */
  46829. export class WebXRManagedOutputCanvasOptions {
  46830. /**
  46831. * An optional canvas in case you wish to create it yourself and provide it here.
  46832. * If not provided, a new canvas will be created
  46833. */
  46834. canvasElement?: HTMLCanvasElement;
  46835. /**
  46836. * Options for this XR Layer output
  46837. */
  46838. canvasOptions?: XRWebGLLayerOptions;
  46839. /**
  46840. * CSS styling for a newly created canvas (if not provided)
  46841. */
  46842. newCanvasCssStyle?: string;
  46843. /**
  46844. * Get the default values of the configuration object
  46845. * @param engine defines the engine to use (can be null)
  46846. * @returns default values of this configuration object
  46847. */
  46848. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46849. }
  46850. /**
  46851. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46852. */
  46853. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46854. private _options;
  46855. private _canvas;
  46856. private _engine;
  46857. private _originalCanvasSize;
  46858. /**
  46859. * Rendering context of the canvas which can be used to display/mirror xr content
  46860. */
  46861. canvasContext: WebGLRenderingContext;
  46862. /**
  46863. * xr layer for the canvas
  46864. */
  46865. xrLayer: Nullable<XRWebGLLayer>;
  46866. /**
  46867. * Obseervers registered here will be triggered when the xr layer was initialized
  46868. */
  46869. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46870. /**
  46871. * Initializes the canvas to be added/removed upon entering/exiting xr
  46872. * @param _xrSessionManager The XR Session manager
  46873. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46874. */
  46875. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46876. /**
  46877. * Disposes of the object
  46878. */
  46879. dispose(): void;
  46880. /**
  46881. * Initializes the xr layer for the session
  46882. * @param xrSession xr session
  46883. * @returns a promise that will resolve once the XR Layer has been created
  46884. */
  46885. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46886. private _addCanvas;
  46887. private _removeCanvas;
  46888. private _setCanvasSize;
  46889. private _setManagedOutputCanvas;
  46890. }
  46891. }
  46892. declare module BABYLON {
  46893. /**
  46894. * Manages an XRSession to work with Babylon's engine
  46895. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46896. */
  46897. export class WebXRSessionManager implements IDisposable {
  46898. /** The scene which the session should be created for */
  46899. scene: Scene;
  46900. private _referenceSpace;
  46901. private _rttProvider;
  46902. private _sessionEnded;
  46903. private _xrNavigator;
  46904. private baseLayer;
  46905. /**
  46906. * The base reference space from which the session started. good if you want to reset your
  46907. * reference space
  46908. */
  46909. baseReferenceSpace: XRReferenceSpace;
  46910. /**
  46911. * Current XR frame
  46912. */
  46913. currentFrame: Nullable<XRFrame>;
  46914. /** WebXR timestamp updated every frame */
  46915. currentTimestamp: number;
  46916. /**
  46917. * Used just in case of a failure to initialize an immersive session.
  46918. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46919. */
  46920. defaultHeightCompensation: number;
  46921. /**
  46922. * Fires every time a new xrFrame arrives which can be used to update the camera
  46923. */
  46924. onXRFrameObservable: Observable<XRFrame>;
  46925. /**
  46926. * Fires when the reference space changed
  46927. */
  46928. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46929. /**
  46930. * Fires when the xr session is ended either by the device or manually done
  46931. */
  46932. onXRSessionEnded: Observable<any>;
  46933. /**
  46934. * Fires when the xr session is ended either by the device or manually done
  46935. */
  46936. onXRSessionInit: Observable<XRSession>;
  46937. /**
  46938. * Underlying xr session
  46939. */
  46940. session: XRSession;
  46941. /**
  46942. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46943. * or get the offset the player is currently at.
  46944. */
  46945. viewerReferenceSpace: XRReferenceSpace;
  46946. /**
  46947. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46948. * @param scene The scene which the session should be created for
  46949. */
  46950. constructor(
  46951. /** The scene which the session should be created for */
  46952. scene: Scene);
  46953. /**
  46954. * The current reference space used in this session. This reference space can constantly change!
  46955. * It is mainly used to offset the camera's position.
  46956. */
  46957. get referenceSpace(): XRReferenceSpace;
  46958. /**
  46959. * Set a new reference space and triggers the observable
  46960. */
  46961. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46962. /**
  46963. * Disposes of the session manager
  46964. */
  46965. dispose(): void;
  46966. /**
  46967. * Stops the xrSession and restores the render loop
  46968. * @returns Promise which resolves after it exits XR
  46969. */
  46970. exitXRAsync(): Promise<void>;
  46971. /**
  46972. * Gets the correct render target texture to be rendered this frame for this eye
  46973. * @param eye the eye for which to get the render target
  46974. * @returns the render target for the specified eye
  46975. */
  46976. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46977. /**
  46978. * Creates a WebXRRenderTarget object for the XR session
  46979. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46980. * @param options optional options to provide when creating a new render target
  46981. * @returns a WebXR render target to which the session can render
  46982. */
  46983. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46984. /**
  46985. * Initializes the manager
  46986. * After initialization enterXR can be called to start an XR session
  46987. * @returns Promise which resolves after it is initialized
  46988. */
  46989. initializeAsync(): Promise<void>;
  46990. /**
  46991. * Initializes an xr session
  46992. * @param xrSessionMode mode to initialize
  46993. * @param xrSessionInit defines optional and required values to pass to the session builder
  46994. * @returns a promise which will resolve once the session has been initialized
  46995. */
  46996. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46997. /**
  46998. * Checks if a session would be supported for the creation options specified
  46999. * @param sessionMode session mode to check if supported eg. immersive-vr
  47000. * @returns A Promise that resolves to true if supported and false if not
  47001. */
  47002. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47003. /**
  47004. * Resets the reference space to the one started the session
  47005. */
  47006. resetReferenceSpace(): void;
  47007. /**
  47008. * Starts rendering to the xr layer
  47009. */
  47010. runXRRenderLoop(): void;
  47011. /**
  47012. * Sets the reference space on the xr session
  47013. * @param referenceSpaceType space to set
  47014. * @returns a promise that will resolve once the reference space has been set
  47015. */
  47016. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47017. /**
  47018. * Updates the render state of the session
  47019. * @param state state to set
  47020. * @returns a promise that resolves once the render state has been updated
  47021. */
  47022. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47023. /**
  47024. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47025. * @param sessionMode defines the session to test
  47026. * @returns a promise with boolean as final value
  47027. */
  47028. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47029. private _createRenderTargetTexture;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * WebXR Camera which holds the views for the xrSession
  47035. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47036. */
  47037. export class WebXRCamera extends FreeCamera {
  47038. private _xrSessionManager;
  47039. private _firstFrame;
  47040. private _referenceQuaternion;
  47041. private _referencedPosition;
  47042. private _xrInvPositionCache;
  47043. private _xrInvQuaternionCache;
  47044. /**
  47045. * Observable raised before camera teleportation
  47046. */
  47047. onBeforeCameraTeleport: Observable<Vector3>;
  47048. /**
  47049. * Observable raised after camera teleportation
  47050. */
  47051. onAfterCameraTeleport: Observable<Vector3>;
  47052. /**
  47053. * Should position compensation execute on first frame.
  47054. * This is used when copying the position from a native (non XR) camera
  47055. */
  47056. compensateOnFirstFrame: boolean;
  47057. /**
  47058. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47059. * @param name the name of the camera
  47060. * @param scene the scene to add the camera to
  47061. * @param _xrSessionManager a constructed xr session manager
  47062. */
  47063. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47064. /**
  47065. * Return the user's height, unrelated to the current ground.
  47066. * This will be the y position of this camera, when ground level is 0.
  47067. */
  47068. get realWorldHeight(): number;
  47069. /** @hidden */
  47070. _updateForDualEyeDebugging(): void;
  47071. /**
  47072. * Sets this camera's transformation based on a non-vr camera
  47073. * @param otherCamera the non-vr camera to copy the transformation from
  47074. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47075. */
  47076. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47077. /**
  47078. * Gets the current instance class name ("WebXRCamera").
  47079. * @returns the class name
  47080. */
  47081. getClassName(): string;
  47082. private _rotate180;
  47083. private _updateFromXRSession;
  47084. private _updateNumberOfRigCameras;
  47085. private _updateReferenceSpace;
  47086. private _updateReferenceSpaceOffset;
  47087. }
  47088. }
  47089. declare module BABYLON {
  47090. /**
  47091. * Defining the interface required for a (webxr) feature
  47092. */
  47093. export interface IWebXRFeature extends IDisposable {
  47094. /**
  47095. * Is this feature attached
  47096. */
  47097. attached: boolean;
  47098. /**
  47099. * Should auto-attach be disabled?
  47100. */
  47101. disableAutoAttach: boolean;
  47102. /**
  47103. * Attach the feature to the session
  47104. * Will usually be called by the features manager
  47105. *
  47106. * @param force should attachment be forced (even when already attached)
  47107. * @returns true if successful.
  47108. */
  47109. attach(force?: boolean): boolean;
  47110. /**
  47111. * Detach the feature from the session
  47112. * Will usually be called by the features manager
  47113. *
  47114. * @returns true if successful.
  47115. */
  47116. detach(): boolean;
  47117. /**
  47118. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47119. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47120. *
  47121. * @returns whether or not the feature is compatible in this environment
  47122. */
  47123. isCompatible(): boolean;
  47124. /**
  47125. * Was this feature disposed;
  47126. */
  47127. isDisposed: boolean;
  47128. /**
  47129. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47130. */
  47131. xrNativeFeatureName?: string;
  47132. /**
  47133. * A list of (Babylon WebXR) features this feature depends on
  47134. */
  47135. dependsOn?: string[];
  47136. }
  47137. /**
  47138. * A list of the currently available features without referencing them
  47139. */
  47140. export class WebXRFeatureName {
  47141. /**
  47142. * The name of the anchor system feature
  47143. */
  47144. static readonly ANCHOR_SYSTEM: string;
  47145. /**
  47146. * The name of the background remover feature
  47147. */
  47148. static readonly BACKGROUND_REMOVER: string;
  47149. /**
  47150. * The name of the hit test feature
  47151. */
  47152. static readonly HIT_TEST: string;
  47153. /**
  47154. * physics impostors for xr controllers feature
  47155. */
  47156. static readonly PHYSICS_CONTROLLERS: string;
  47157. /**
  47158. * The name of the plane detection feature
  47159. */
  47160. static readonly PLANE_DETECTION: string;
  47161. /**
  47162. * The name of the pointer selection feature
  47163. */
  47164. static readonly POINTER_SELECTION: string;
  47165. /**
  47166. * The name of the teleportation feature
  47167. */
  47168. static readonly TELEPORTATION: string;
  47169. /**
  47170. * The name of the feature points feature.
  47171. */
  47172. static readonly FEATURE_POINTS: string;
  47173. /**
  47174. * The name of the hand tracking feature.
  47175. */
  47176. static readonly HAND_TRACKING: string;
  47177. }
  47178. /**
  47179. * Defining the constructor of a feature. Used to register the modules.
  47180. */
  47181. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47182. /**
  47183. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47184. * It is mainly used in AR sessions.
  47185. *
  47186. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47187. */
  47188. export class WebXRFeaturesManager implements IDisposable {
  47189. private _xrSessionManager;
  47190. private static readonly _AvailableFeatures;
  47191. private _features;
  47192. /**
  47193. * constructs a new features manages.
  47194. *
  47195. * @param _xrSessionManager an instance of WebXRSessionManager
  47196. */
  47197. constructor(_xrSessionManager: WebXRSessionManager);
  47198. /**
  47199. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47200. * Mainly used internally.
  47201. *
  47202. * @param featureName the name of the feature to register
  47203. * @param constructorFunction the function used to construct the module
  47204. * @param version the (babylon) version of the module
  47205. * @param stable is that a stable version of this module
  47206. */
  47207. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47208. /**
  47209. * Returns a constructor of a specific feature.
  47210. *
  47211. * @param featureName the name of the feature to construct
  47212. * @param version the version of the feature to load
  47213. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47214. * @param options optional options provided to the module.
  47215. * @returns a function that, when called, will return a new instance of this feature
  47216. */
  47217. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47218. /**
  47219. * Can be used to return the list of features currently registered
  47220. *
  47221. * @returns an Array of available features
  47222. */
  47223. static GetAvailableFeatures(): string[];
  47224. /**
  47225. * Gets the versions available for a specific feature
  47226. * @param featureName the name of the feature
  47227. * @returns an array with the available versions
  47228. */
  47229. static GetAvailableVersions(featureName: string): string[];
  47230. /**
  47231. * Return the latest unstable version of this feature
  47232. * @param featureName the name of the feature to search
  47233. * @returns the version number. if not found will return -1
  47234. */
  47235. static GetLatestVersionOfFeature(featureName: string): number;
  47236. /**
  47237. * Return the latest stable version of this feature
  47238. * @param featureName the name of the feature to search
  47239. * @returns the version number. if not found will return -1
  47240. */
  47241. static GetStableVersionOfFeature(featureName: string): number;
  47242. /**
  47243. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47244. * Can be used during a session to start a feature
  47245. * @param featureName the name of feature to attach
  47246. */
  47247. attachFeature(featureName: string): void;
  47248. /**
  47249. * Can be used inside a session or when the session ends to detach a specific feature
  47250. * @param featureName the name of the feature to detach
  47251. */
  47252. detachFeature(featureName: string): void;
  47253. /**
  47254. * Used to disable an already-enabled feature
  47255. * The feature will be disposed and will be recreated once enabled.
  47256. * @param featureName the feature to disable
  47257. * @returns true if disable was successful
  47258. */
  47259. disableFeature(featureName: string | {
  47260. Name: string;
  47261. }): boolean;
  47262. /**
  47263. * dispose this features manager
  47264. */
  47265. dispose(): void;
  47266. /**
  47267. * 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.
  47268. * 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.
  47269. *
  47270. * @param featureName the name of the feature to load or the class of the feature
  47271. * @param version optional version to load. if not provided the latest version will be enabled
  47272. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47273. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47274. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47275. * @returns a new constructed feature or throws an error if feature not found.
  47276. */
  47277. enableFeature(featureName: string | {
  47278. Name: string;
  47279. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47280. /**
  47281. * get the implementation of an enabled feature.
  47282. * @param featureName the name of the feature to load
  47283. * @returns the feature class, if found
  47284. */
  47285. getEnabledFeature(featureName: string): IWebXRFeature;
  47286. /**
  47287. * Get the list of enabled features
  47288. * @returns an array of enabled features
  47289. */
  47290. getEnabledFeatures(): string[];
  47291. /**
  47292. * This function will exten the session creation configuration object with enabled features.
  47293. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47294. * according to the defined "required" variable, provided during enableFeature call
  47295. * @param xrSessionInit the xr Session init object to extend
  47296. *
  47297. * @returns an extended XRSessionInit object
  47298. */
  47299. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47300. }
  47301. }
  47302. declare module BABYLON {
  47303. /**
  47304. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47305. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47306. */
  47307. export class WebXRExperienceHelper implements IDisposable {
  47308. private scene;
  47309. private _nonVRCamera;
  47310. private _originalSceneAutoClear;
  47311. private _supported;
  47312. /**
  47313. * Camera used to render xr content
  47314. */
  47315. camera: WebXRCamera;
  47316. /** A features manager for this xr session */
  47317. featuresManager: WebXRFeaturesManager;
  47318. /**
  47319. * Observers registered here will be triggered after the camera's initial transformation is set
  47320. * This can be used to set a different ground level or an extra rotation.
  47321. *
  47322. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47323. * to the position set after this observable is done executing.
  47324. */
  47325. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47326. /**
  47327. * Fires when the state of the experience helper has changed
  47328. */
  47329. onStateChangedObservable: Observable<WebXRState>;
  47330. /** Session manager used to keep track of xr session */
  47331. sessionManager: WebXRSessionManager;
  47332. /**
  47333. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47334. */
  47335. state: WebXRState;
  47336. /**
  47337. * Creates a WebXRExperienceHelper
  47338. * @param scene The scene the helper should be created in
  47339. */
  47340. private constructor();
  47341. /**
  47342. * Creates the experience helper
  47343. * @param scene the scene to attach the experience helper to
  47344. * @returns a promise for the experience helper
  47345. */
  47346. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47347. /**
  47348. * Disposes of the experience helper
  47349. */
  47350. dispose(): void;
  47351. /**
  47352. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47353. * @param sessionMode options for the XR session
  47354. * @param referenceSpaceType frame of reference of the XR session
  47355. * @param renderTarget the output canvas that will be used to enter XR mode
  47356. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47357. * @returns promise that resolves after xr mode has entered
  47358. */
  47359. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47360. /**
  47361. * Exits XR mode and returns the scene to its original state
  47362. * @returns promise that resolves after xr mode has exited
  47363. */
  47364. exitXRAsync(): Promise<void>;
  47365. private _nonXRToXRCamera;
  47366. private _setState;
  47367. }
  47368. }
  47369. declare module BABYLON {
  47370. /**
  47371. * X-Y values for axes in WebXR
  47372. */
  47373. export interface IWebXRMotionControllerAxesValue {
  47374. /**
  47375. * The value of the x axis
  47376. */
  47377. x: number;
  47378. /**
  47379. * The value of the y-axis
  47380. */
  47381. y: number;
  47382. }
  47383. /**
  47384. * changed / previous values for the values of this component
  47385. */
  47386. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47387. /**
  47388. * current (this frame) value
  47389. */
  47390. current: T;
  47391. /**
  47392. * previous (last change) value
  47393. */
  47394. previous: T;
  47395. }
  47396. /**
  47397. * Represents changes in the component between current frame and last values recorded
  47398. */
  47399. export interface IWebXRMotionControllerComponentChanges {
  47400. /**
  47401. * will be populated with previous and current values if axes changed
  47402. */
  47403. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47404. /**
  47405. * will be populated with previous and current values if pressed changed
  47406. */
  47407. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47408. /**
  47409. * will be populated with previous and current values if touched changed
  47410. */
  47411. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47412. /**
  47413. * will be populated with previous and current values if value changed
  47414. */
  47415. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47416. }
  47417. /**
  47418. * This class represents a single component (for example button or thumbstick) of a motion controller
  47419. */
  47420. export class WebXRControllerComponent implements IDisposable {
  47421. /**
  47422. * the id of this component
  47423. */
  47424. id: string;
  47425. /**
  47426. * the type of the component
  47427. */
  47428. type: MotionControllerComponentType;
  47429. private _buttonIndex;
  47430. private _axesIndices;
  47431. private _axes;
  47432. private _changes;
  47433. private _currentValue;
  47434. private _hasChanges;
  47435. private _pressed;
  47436. private _touched;
  47437. /**
  47438. * button component type
  47439. */
  47440. static BUTTON_TYPE: MotionControllerComponentType;
  47441. /**
  47442. * squeeze component type
  47443. */
  47444. static SQUEEZE_TYPE: MotionControllerComponentType;
  47445. /**
  47446. * Thumbstick component type
  47447. */
  47448. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47449. /**
  47450. * Touchpad component type
  47451. */
  47452. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47453. /**
  47454. * trigger component type
  47455. */
  47456. static TRIGGER_TYPE: MotionControllerComponentType;
  47457. /**
  47458. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47459. * the axes data changes
  47460. */
  47461. onAxisValueChangedObservable: Observable<{
  47462. x: number;
  47463. y: number;
  47464. }>;
  47465. /**
  47466. * Observers registered here will be triggered when the state of a button changes
  47467. * State change is either pressed / touched / value
  47468. */
  47469. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47470. /**
  47471. * Creates a new component for a motion controller.
  47472. * It is created by the motion controller itself
  47473. *
  47474. * @param id the id of this component
  47475. * @param type the type of the component
  47476. * @param _buttonIndex index in the buttons array of the gamepad
  47477. * @param _axesIndices indices of the values in the axes array of the gamepad
  47478. */
  47479. constructor(
  47480. /**
  47481. * the id of this component
  47482. */
  47483. id: string,
  47484. /**
  47485. * the type of the component
  47486. */
  47487. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47488. /**
  47489. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47490. */
  47491. get axes(): IWebXRMotionControllerAxesValue;
  47492. /**
  47493. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47494. */
  47495. get changes(): IWebXRMotionControllerComponentChanges;
  47496. /**
  47497. * Return whether or not the component changed the last frame
  47498. */
  47499. get hasChanges(): boolean;
  47500. /**
  47501. * is the button currently pressed
  47502. */
  47503. get pressed(): boolean;
  47504. /**
  47505. * is the button currently touched
  47506. */
  47507. get touched(): boolean;
  47508. /**
  47509. * Get the current value of this component
  47510. */
  47511. get value(): number;
  47512. /**
  47513. * Dispose this component
  47514. */
  47515. dispose(): void;
  47516. /**
  47517. * Are there axes correlating to this component
  47518. * @return true is axes data is available
  47519. */
  47520. isAxes(): boolean;
  47521. /**
  47522. * Is this component a button (hence - pressable)
  47523. * @returns true if can be pressed
  47524. */
  47525. isButton(): boolean;
  47526. /**
  47527. * update this component using the gamepad object it is in. Called on every frame
  47528. * @param nativeController the native gamepad controller object
  47529. */
  47530. update(nativeController: IMinimalMotionControllerObject): void;
  47531. }
  47532. }
  47533. declare module BABYLON {
  47534. /**
  47535. * Interface used to represent data loading progression
  47536. */
  47537. export interface ISceneLoaderProgressEvent {
  47538. /**
  47539. * Defines if data length to load can be evaluated
  47540. */
  47541. readonly lengthComputable: boolean;
  47542. /**
  47543. * Defines the loaded data length
  47544. */
  47545. readonly loaded: number;
  47546. /**
  47547. * Defines the data length to load
  47548. */
  47549. readonly total: number;
  47550. }
  47551. /**
  47552. * Interface used by SceneLoader plugins to define supported file extensions
  47553. */
  47554. export interface ISceneLoaderPluginExtensions {
  47555. /**
  47556. * Defines the list of supported extensions
  47557. */
  47558. [extension: string]: {
  47559. isBinary: boolean;
  47560. };
  47561. }
  47562. /**
  47563. * Interface used by SceneLoader plugin factory
  47564. */
  47565. export interface ISceneLoaderPluginFactory {
  47566. /**
  47567. * Defines the name of the factory
  47568. */
  47569. name: string;
  47570. /**
  47571. * Function called to create a new plugin
  47572. * @return the new plugin
  47573. */
  47574. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47575. /**
  47576. * The callback that returns true if the data can be directly loaded.
  47577. * @param data string containing the file data
  47578. * @returns if the data can be loaded directly
  47579. */
  47580. canDirectLoad?(data: string): boolean;
  47581. }
  47582. /**
  47583. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47584. */
  47585. export interface ISceneLoaderPluginBase {
  47586. /**
  47587. * The friendly name of this plugin.
  47588. */
  47589. name: string;
  47590. /**
  47591. * The file extensions supported by this plugin.
  47592. */
  47593. extensions: string | ISceneLoaderPluginExtensions;
  47594. /**
  47595. * The callback called when loading from a url.
  47596. * @param scene scene loading this url
  47597. * @param url url to load
  47598. * @param onSuccess callback called when the file successfully loads
  47599. * @param onProgress callback called while file is loading (if the server supports this mode)
  47600. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47601. * @param onError callback called when the file fails to load
  47602. * @returns a file request object
  47603. */
  47604. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47605. /**
  47606. * The callback called when loading from a file object.
  47607. * @param scene scene loading this file
  47608. * @param file defines the file to load
  47609. * @param onSuccess defines the callback to call when data is loaded
  47610. * @param onProgress defines the callback to call during loading process
  47611. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47612. * @param onError defines the callback to call when an error occurs
  47613. * @returns a file request object
  47614. */
  47615. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47616. /**
  47617. * The callback that returns true if the data can be directly loaded.
  47618. * @param data string containing the file data
  47619. * @returns if the data can be loaded directly
  47620. */
  47621. canDirectLoad?(data: string): boolean;
  47622. /**
  47623. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47624. * @param scene scene loading this data
  47625. * @param data string containing the data
  47626. * @returns data to pass to the plugin
  47627. */
  47628. directLoad?(scene: Scene, data: string): any;
  47629. /**
  47630. * The callback that allows custom handling of the root url based on the response url.
  47631. * @param rootUrl the original root url
  47632. * @param responseURL the response url if available
  47633. * @returns the new root url
  47634. */
  47635. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47636. }
  47637. /**
  47638. * Interface used to define a SceneLoader plugin
  47639. */
  47640. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47641. /**
  47642. * Import meshes into a scene.
  47643. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47644. * @param scene The scene to import into
  47645. * @param data The data to import
  47646. * @param rootUrl The root url for scene and resources
  47647. * @param meshes The meshes array to import into
  47648. * @param particleSystems The particle systems array to import into
  47649. * @param skeletons The skeletons array to import into
  47650. * @param onError The callback when import fails
  47651. * @returns True if successful or false otherwise
  47652. */
  47653. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47654. /**
  47655. * Load into a scene.
  47656. * @param scene The scene to load into
  47657. * @param data The data to import
  47658. * @param rootUrl The root url for scene and resources
  47659. * @param onError The callback when import fails
  47660. * @returns True if successful or false otherwise
  47661. */
  47662. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47663. /**
  47664. * Load into an asset container.
  47665. * @param scene The scene to load into
  47666. * @param data The data to import
  47667. * @param rootUrl The root url for scene and resources
  47668. * @param onError The callback when import fails
  47669. * @returns The loaded asset container
  47670. */
  47671. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47672. }
  47673. /**
  47674. * Interface used to define an async SceneLoader plugin
  47675. */
  47676. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47677. /**
  47678. * Import meshes into a scene.
  47679. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47680. * @param scene The scene to import into
  47681. * @param data The data to import
  47682. * @param rootUrl The root url for scene and resources
  47683. * @param onProgress The callback when the load progresses
  47684. * @param fileName Defines the name of the file to load
  47685. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47686. */
  47687. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47688. meshes: AbstractMesh[];
  47689. particleSystems: IParticleSystem[];
  47690. skeletons: Skeleton[];
  47691. animationGroups: AnimationGroup[];
  47692. }>;
  47693. /**
  47694. * Load into a scene.
  47695. * @param scene The scene to load into
  47696. * @param data The data to import
  47697. * @param rootUrl The root url for scene and resources
  47698. * @param onProgress The callback when the load progresses
  47699. * @param fileName Defines the name of the file to load
  47700. * @returns Nothing
  47701. */
  47702. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47703. /**
  47704. * Load into an asset container.
  47705. * @param scene The scene to load into
  47706. * @param data The data to import
  47707. * @param rootUrl The root url for scene and resources
  47708. * @param onProgress The callback when the load progresses
  47709. * @param fileName Defines the name of the file to load
  47710. * @returns The loaded asset container
  47711. */
  47712. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47713. }
  47714. /**
  47715. * Mode that determines how to handle old animation groups before loading new ones.
  47716. */
  47717. export enum SceneLoaderAnimationGroupLoadingMode {
  47718. /**
  47719. * Reset all old animations to initial state then dispose them.
  47720. */
  47721. Clean = 0,
  47722. /**
  47723. * Stop all old animations.
  47724. */
  47725. Stop = 1,
  47726. /**
  47727. * Restart old animations from first frame.
  47728. */
  47729. Sync = 2,
  47730. /**
  47731. * Old animations remains untouched.
  47732. */
  47733. NoSync = 3
  47734. }
  47735. /**
  47736. * Defines a plugin registered by the SceneLoader
  47737. */
  47738. interface IRegisteredPlugin {
  47739. /**
  47740. * Defines the plugin to use
  47741. */
  47742. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47743. /**
  47744. * Defines if the plugin supports binary data
  47745. */
  47746. isBinary: boolean;
  47747. }
  47748. /**
  47749. * Class used to load scene from various file formats using registered plugins
  47750. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47751. */
  47752. export class SceneLoader {
  47753. /**
  47754. * No logging while loading
  47755. */
  47756. static readonly NO_LOGGING: number;
  47757. /**
  47758. * Minimal logging while loading
  47759. */
  47760. static readonly MINIMAL_LOGGING: number;
  47761. /**
  47762. * Summary logging while loading
  47763. */
  47764. static readonly SUMMARY_LOGGING: number;
  47765. /**
  47766. * Detailled logging while loading
  47767. */
  47768. static readonly DETAILED_LOGGING: number;
  47769. /**
  47770. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47771. */
  47772. static get ForceFullSceneLoadingForIncremental(): boolean;
  47773. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47774. /**
  47775. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47776. */
  47777. static get ShowLoadingScreen(): boolean;
  47778. static set ShowLoadingScreen(value: boolean);
  47779. /**
  47780. * Defines the current logging level (while loading the scene)
  47781. * @ignorenaming
  47782. */
  47783. static get loggingLevel(): number;
  47784. static set loggingLevel(value: number);
  47785. /**
  47786. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47787. */
  47788. static get CleanBoneMatrixWeights(): boolean;
  47789. static set CleanBoneMatrixWeights(value: boolean);
  47790. /**
  47791. * Event raised when a plugin is used to load a scene
  47792. */
  47793. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47794. private static _registeredPlugins;
  47795. private static _showingLoadingScreen;
  47796. /**
  47797. * Gets the default plugin (used to load Babylon files)
  47798. * @returns the .babylon plugin
  47799. */
  47800. static GetDefaultPlugin(): IRegisteredPlugin;
  47801. private static _GetPluginForExtension;
  47802. private static _GetPluginForDirectLoad;
  47803. private static _GetPluginForFilename;
  47804. private static _GetDirectLoad;
  47805. private static _LoadData;
  47806. private static _GetFileInfo;
  47807. /**
  47808. * Gets a plugin that can load the given extension
  47809. * @param extension defines the extension to load
  47810. * @returns a plugin or null if none works
  47811. */
  47812. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47813. /**
  47814. * Gets a boolean indicating that the given extension can be loaded
  47815. * @param extension defines the extension to load
  47816. * @returns true if the extension is supported
  47817. */
  47818. static IsPluginForExtensionAvailable(extension: string): boolean;
  47819. /**
  47820. * Adds a new plugin to the list of registered plugins
  47821. * @param plugin defines the plugin to add
  47822. */
  47823. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47824. /**
  47825. * Import meshes into a scene
  47826. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47827. * @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)
  47828. * @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)
  47829. * @param scene the instance of BABYLON.Scene to append to
  47830. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47831. * @param onProgress a callback with a progress event for each file being loaded
  47832. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47833. * @param pluginExtension the extension used to determine the plugin
  47834. * @returns The loaded plugin
  47835. */
  47836. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47837. /**
  47838. * Import meshes into a scene
  47839. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47840. * @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)
  47841. * @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)
  47842. * @param scene the instance of BABYLON.Scene to append to
  47843. * @param onProgress a callback with a progress event for each file being loaded
  47844. * @param pluginExtension the extension used to determine the plugin
  47845. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47846. */
  47847. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47848. meshes: AbstractMesh[];
  47849. particleSystems: IParticleSystem[];
  47850. skeletons: Skeleton[];
  47851. animationGroups: AnimationGroup[];
  47852. }>;
  47853. /**
  47854. * Load a scene
  47855. * @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)
  47856. * @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)
  47857. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47858. * @param onSuccess a callback with the scene when import succeeds
  47859. * @param onProgress a callback with a progress event for each file being loaded
  47860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47861. * @param pluginExtension the extension used to determine the plugin
  47862. * @returns The loaded plugin
  47863. */
  47864. 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>;
  47865. /**
  47866. * Load a scene
  47867. * @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)
  47868. * @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)
  47869. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47870. * @param onProgress a callback with a progress event for each file being loaded
  47871. * @param pluginExtension the extension used to determine the plugin
  47872. * @returns The loaded scene
  47873. */
  47874. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47875. /**
  47876. * Append a scene
  47877. * @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)
  47878. * @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)
  47879. * @param scene is the instance of BABYLON.Scene to append to
  47880. * @param onSuccess a callback with the scene when import succeeds
  47881. * @param onProgress a callback with a progress event for each file being loaded
  47882. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47883. * @param pluginExtension the extension used to determine the plugin
  47884. * @returns The loaded plugin
  47885. */
  47886. 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>;
  47887. /**
  47888. * Append a scene
  47889. * @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)
  47890. * @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)
  47891. * @param scene is the instance of BABYLON.Scene to append to
  47892. * @param onProgress a callback with a progress event for each file being loaded
  47893. * @param pluginExtension the extension used to determine the plugin
  47894. * @returns The given scene
  47895. */
  47896. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47897. /**
  47898. * Load a scene into an asset container
  47899. * @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)
  47900. * @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)
  47901. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47902. * @param onSuccess a callback with the scene when import succeeds
  47903. * @param onProgress a callback with a progress event for each file being loaded
  47904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47905. * @param pluginExtension the extension used to determine the plugin
  47906. * @returns The loaded plugin
  47907. */
  47908. 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>;
  47909. /**
  47910. * Load a scene into an asset container
  47911. * @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)
  47912. * @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)
  47913. * @param scene is the instance of Scene to append to
  47914. * @param onProgress a callback with a progress event for each file being loaded
  47915. * @param pluginExtension the extension used to determine the plugin
  47916. * @returns The loaded asset container
  47917. */
  47918. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47919. /**
  47920. * Import animations from a file into a scene
  47921. * @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)
  47922. * @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)
  47923. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47924. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47925. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47926. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47927. * @param onSuccess a callback with the scene when import succeeds
  47928. * @param onProgress a callback with a progress event for each file being loaded
  47929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47930. * @param pluginExtension the extension used to determine the plugin
  47931. */
  47932. 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;
  47933. /**
  47934. * Import animations from a file into a scene
  47935. * @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)
  47936. * @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)
  47937. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47938. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47939. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47940. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47941. * @param onSuccess a callback with the scene when import succeeds
  47942. * @param onProgress a callback with a progress event for each file being loaded
  47943. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47944. * @param pluginExtension the extension used to determine the plugin
  47945. * @returns the updated scene with imported animations
  47946. */
  47947. 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>;
  47948. }
  47949. }
  47950. declare module BABYLON {
  47951. /**
  47952. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47953. */
  47954. export type MotionControllerHandedness = "none" | "left" | "right";
  47955. /**
  47956. * The type of components available in motion controllers.
  47957. * This is not the name of the component.
  47958. */
  47959. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47960. /**
  47961. * The state of a controller component
  47962. */
  47963. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47964. /**
  47965. * The schema of motion controller layout.
  47966. * No object will be initialized using this interface
  47967. * This is used just to define the profile.
  47968. */
  47969. export interface IMotionControllerLayout {
  47970. /**
  47971. * Path to load the assets. Usually relative to the base path
  47972. */
  47973. assetPath: string;
  47974. /**
  47975. * Available components (unsorted)
  47976. */
  47977. components: {
  47978. /**
  47979. * A map of component Ids
  47980. */
  47981. [componentId: string]: {
  47982. /**
  47983. * The type of input the component outputs
  47984. */
  47985. type: MotionControllerComponentType;
  47986. /**
  47987. * The indices of this component in the gamepad object
  47988. */
  47989. gamepadIndices: {
  47990. /**
  47991. * Index of button
  47992. */
  47993. button?: number;
  47994. /**
  47995. * If available, index of x-axis
  47996. */
  47997. xAxis?: number;
  47998. /**
  47999. * If available, index of y-axis
  48000. */
  48001. yAxis?: number;
  48002. };
  48003. /**
  48004. * The mesh's root node name
  48005. */
  48006. rootNodeName: string;
  48007. /**
  48008. * Animation definitions for this model
  48009. */
  48010. visualResponses: {
  48011. [stateKey: string]: {
  48012. /**
  48013. * What property will be animated
  48014. */
  48015. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48016. /**
  48017. * What states influence this visual response
  48018. */
  48019. states: MotionControllerComponentStateType[];
  48020. /**
  48021. * Type of animation - movement or visibility
  48022. */
  48023. valueNodeProperty: "transform" | "visibility";
  48024. /**
  48025. * Base node name to move. Its position will be calculated according to the min and max nodes
  48026. */
  48027. valueNodeName?: string;
  48028. /**
  48029. * Minimum movement node
  48030. */
  48031. minNodeName?: string;
  48032. /**
  48033. * Max movement node
  48034. */
  48035. maxNodeName?: string;
  48036. };
  48037. };
  48038. /**
  48039. * If touch enabled, what is the name of node to display user feedback
  48040. */
  48041. touchPointNodeName?: string;
  48042. };
  48043. };
  48044. /**
  48045. * Is it xr standard mapping or not
  48046. */
  48047. gamepadMapping: "" | "xr-standard";
  48048. /**
  48049. * Base root node of this entire model
  48050. */
  48051. rootNodeName: string;
  48052. /**
  48053. * Defines the main button component id
  48054. */
  48055. selectComponentId: string;
  48056. }
  48057. /**
  48058. * A definition for the layout map in the input profile
  48059. */
  48060. export interface IMotionControllerLayoutMap {
  48061. /**
  48062. * Layouts with handedness type as a key
  48063. */
  48064. [handedness: string]: IMotionControllerLayout;
  48065. }
  48066. /**
  48067. * The XR Input profile schema
  48068. * Profiles can be found here:
  48069. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48070. */
  48071. export interface IMotionControllerProfile {
  48072. /**
  48073. * fallback profiles for this profileId
  48074. */
  48075. fallbackProfileIds: string[];
  48076. /**
  48077. * The layout map, with handedness as key
  48078. */
  48079. layouts: IMotionControllerLayoutMap;
  48080. /**
  48081. * The id of this profile
  48082. * correlates to the profile(s) in the xrInput.profiles array
  48083. */
  48084. profileId: string;
  48085. }
  48086. /**
  48087. * A helper-interface for the 3 meshes needed for controller button animation
  48088. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48089. */
  48090. export interface IMotionControllerButtonMeshMap {
  48091. /**
  48092. * the mesh that defines the pressed value mesh position.
  48093. * This is used to find the max-position of this button
  48094. */
  48095. pressedMesh: AbstractMesh;
  48096. /**
  48097. * the mesh that defines the unpressed value mesh position.
  48098. * This is used to find the min (or initial) position of this button
  48099. */
  48100. unpressedMesh: AbstractMesh;
  48101. /**
  48102. * The mesh that will be changed when value changes
  48103. */
  48104. valueMesh: AbstractMesh;
  48105. }
  48106. /**
  48107. * A helper-interface for the 3 meshes needed for controller axis animation.
  48108. * This will be expanded when touchpad animations are fully supported
  48109. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48110. */
  48111. export interface IMotionControllerMeshMap {
  48112. /**
  48113. * the mesh that defines the maximum value mesh position.
  48114. */
  48115. maxMesh?: AbstractMesh;
  48116. /**
  48117. * the mesh that defines the minimum value mesh position.
  48118. */
  48119. minMesh?: AbstractMesh;
  48120. /**
  48121. * The mesh that will be changed when axis value changes
  48122. */
  48123. valueMesh?: AbstractMesh;
  48124. }
  48125. /**
  48126. * The elements needed for change-detection of the gamepad objects in motion controllers
  48127. */
  48128. export interface IMinimalMotionControllerObject {
  48129. /**
  48130. * Available axes of this controller
  48131. */
  48132. axes: number[];
  48133. /**
  48134. * An array of available buttons
  48135. */
  48136. buttons: Array<{
  48137. /**
  48138. * Value of the button/trigger
  48139. */
  48140. value: number;
  48141. /**
  48142. * If the button/trigger is currently touched
  48143. */
  48144. touched: boolean;
  48145. /**
  48146. * If the button/trigger is currently pressed
  48147. */
  48148. pressed: boolean;
  48149. }>;
  48150. /**
  48151. * EXPERIMENTAL haptic support.
  48152. */
  48153. hapticActuators?: Array<{
  48154. pulse: (value: number, duration: number) => Promise<boolean>;
  48155. }>;
  48156. }
  48157. /**
  48158. * An Abstract Motion controller
  48159. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48160. * Each component has an observable to check for changes in value and state
  48161. */
  48162. export abstract class WebXRAbstractMotionController implements IDisposable {
  48163. protected scene: Scene;
  48164. protected layout: IMotionControllerLayout;
  48165. /**
  48166. * The gamepad object correlating to this controller
  48167. */
  48168. gamepadObject: IMinimalMotionControllerObject;
  48169. /**
  48170. * handedness (left/right/none) of this controller
  48171. */
  48172. handedness: MotionControllerHandedness;
  48173. private _initComponent;
  48174. private _modelReady;
  48175. /**
  48176. * A map of components (WebXRControllerComponent) in this motion controller
  48177. * Components have a ComponentType and can also have both button and axis definitions
  48178. */
  48179. readonly components: {
  48180. [id: string]: WebXRControllerComponent;
  48181. };
  48182. /**
  48183. * Disable the model's animation. Can be set at any time.
  48184. */
  48185. disableAnimation: boolean;
  48186. /**
  48187. * Observers registered here will be triggered when the model of this controller is done loading
  48188. */
  48189. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48190. /**
  48191. * The profile id of this motion controller
  48192. */
  48193. abstract profileId: string;
  48194. /**
  48195. * The root mesh of the model. It is null if the model was not yet initialized
  48196. */
  48197. rootMesh: Nullable<AbstractMesh>;
  48198. /**
  48199. * constructs a new abstract motion controller
  48200. * @param scene the scene to which the model of the controller will be added
  48201. * @param layout The profile layout to load
  48202. * @param gamepadObject The gamepad object correlating to this controller
  48203. * @param handedness handedness (left/right/none) of this controller
  48204. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48205. */
  48206. constructor(scene: Scene, layout: IMotionControllerLayout,
  48207. /**
  48208. * The gamepad object correlating to this controller
  48209. */
  48210. gamepadObject: IMinimalMotionControllerObject,
  48211. /**
  48212. * handedness (left/right/none) of this controller
  48213. */
  48214. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48215. /**
  48216. * Dispose this controller, the model mesh and all its components
  48217. */
  48218. dispose(): void;
  48219. /**
  48220. * Returns all components of specific type
  48221. * @param type the type to search for
  48222. * @return an array of components with this type
  48223. */
  48224. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48225. /**
  48226. * get a component based an its component id as defined in layout.components
  48227. * @param id the id of the component
  48228. * @returns the component correlates to the id or undefined if not found
  48229. */
  48230. getComponent(id: string): WebXRControllerComponent;
  48231. /**
  48232. * Get the list of components available in this motion controller
  48233. * @returns an array of strings correlating to available components
  48234. */
  48235. getComponentIds(): string[];
  48236. /**
  48237. * Get the first component of specific type
  48238. * @param type type of component to find
  48239. * @return a controller component or null if not found
  48240. */
  48241. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48242. /**
  48243. * Get the main (Select) component of this controller as defined in the layout
  48244. * @returns the main component of this controller
  48245. */
  48246. getMainComponent(): WebXRControllerComponent;
  48247. /**
  48248. * Loads the model correlating to this controller
  48249. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48250. * @returns A promise fulfilled with the result of the model loading
  48251. */
  48252. loadModel(): Promise<boolean>;
  48253. /**
  48254. * Update this model using the current XRFrame
  48255. * @param xrFrame the current xr frame to use and update the model
  48256. */
  48257. updateFromXRFrame(xrFrame: XRFrame): void;
  48258. /**
  48259. * Backwards compatibility due to a deeply-integrated typo
  48260. */
  48261. get handness(): XREye;
  48262. /**
  48263. * Pulse (vibrate) this controller
  48264. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48265. * Consecutive calls to this function will cancel the last pulse call
  48266. *
  48267. * @param value the strength of the pulse in 0.0...1.0 range
  48268. * @param duration Duration of the pulse in milliseconds
  48269. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48270. * @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
  48271. */
  48272. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48273. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48274. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48275. /**
  48276. * Moves the axis on the controller mesh based on its current state
  48277. * @param axis the index of the axis
  48278. * @param axisValue the value of the axis which determines the meshes new position
  48279. * @hidden
  48280. */
  48281. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48282. /**
  48283. * Update the model itself with the current frame data
  48284. * @param xrFrame the frame to use for updating the model mesh
  48285. */
  48286. protected updateModel(xrFrame: XRFrame): void;
  48287. /**
  48288. * Get the filename and path for this controller's model
  48289. * @returns a map of filename and path
  48290. */
  48291. protected abstract _getFilenameAndPath(): {
  48292. filename: string;
  48293. path: string;
  48294. };
  48295. /**
  48296. * This function is called before the mesh is loaded. It checks for loading constraints.
  48297. * For example, this function can check if the GLB loader is available
  48298. * If this function returns false, the generic controller will be loaded instead
  48299. * @returns Is the client ready to load the mesh
  48300. */
  48301. protected abstract _getModelLoadingConstraints(): boolean;
  48302. /**
  48303. * This function will be called after the model was successfully loaded and can be used
  48304. * for mesh transformations before it is available for the user
  48305. * @param meshes the loaded meshes
  48306. */
  48307. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48308. /**
  48309. * Set the root mesh for this controller. Important for the WebXR controller class
  48310. * @param meshes the loaded meshes
  48311. */
  48312. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48313. /**
  48314. * A function executed each frame that updates the mesh (if needed)
  48315. * @param xrFrame the current xrFrame
  48316. */
  48317. protected abstract _updateModel(xrFrame: XRFrame): void;
  48318. private _getGenericFilenameAndPath;
  48319. private _getGenericParentMesh;
  48320. }
  48321. }
  48322. declare module BABYLON {
  48323. /**
  48324. * A generic trigger-only motion controller for WebXR
  48325. */
  48326. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48327. /**
  48328. * Static version of the profile id of this controller
  48329. */
  48330. static ProfileId: string;
  48331. profileId: string;
  48332. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48333. protected _getFilenameAndPath(): {
  48334. filename: string;
  48335. path: string;
  48336. };
  48337. protected _getModelLoadingConstraints(): boolean;
  48338. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48339. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48340. protected _updateModel(): void;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Class containing static functions to help procedurally build meshes
  48346. */
  48347. export class SphereBuilder {
  48348. /**
  48349. * Creates a sphere mesh
  48350. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48351. * * 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`)
  48352. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48353. * * 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
  48354. * * 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)
  48355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48356. * * 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
  48357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48358. * @param name defines the name of the mesh
  48359. * @param options defines the options used to create the mesh
  48360. * @param scene defines the hosting scene
  48361. * @returns the sphere mesh
  48362. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48363. */
  48364. static CreateSphere(name: string, options: {
  48365. segments?: number;
  48366. diameter?: number;
  48367. diameterX?: number;
  48368. diameterY?: number;
  48369. diameterZ?: number;
  48370. arc?: number;
  48371. slice?: number;
  48372. sideOrientation?: number;
  48373. frontUVs?: Vector4;
  48374. backUVs?: Vector4;
  48375. updatable?: boolean;
  48376. }, scene?: Nullable<Scene>): Mesh;
  48377. }
  48378. }
  48379. declare module BABYLON {
  48380. /**
  48381. * A profiled motion controller has its profile loaded from an online repository.
  48382. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48383. */
  48384. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48385. private _repositoryUrl;
  48386. private _buttonMeshMapping;
  48387. private _touchDots;
  48388. /**
  48389. * The profile ID of this controller. Will be populated when the controller initializes.
  48390. */
  48391. profileId: string;
  48392. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48393. dispose(): void;
  48394. protected _getFilenameAndPath(): {
  48395. filename: string;
  48396. path: string;
  48397. };
  48398. protected _getModelLoadingConstraints(): boolean;
  48399. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48400. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48401. protected _updateModel(_xrFrame: XRFrame): void;
  48402. }
  48403. }
  48404. declare module BABYLON {
  48405. /**
  48406. * A construction function type to create a new controller based on an xrInput object
  48407. */
  48408. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48409. /**
  48410. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48411. *
  48412. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48413. * it should be replaced with auto-loaded controllers.
  48414. *
  48415. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48416. */
  48417. export class WebXRMotionControllerManager {
  48418. private static _AvailableControllers;
  48419. private static _Fallbacks;
  48420. private static _ProfileLoadingPromises;
  48421. private static _ProfilesList;
  48422. /**
  48423. * The base URL of the online controller repository. Can be changed at any time.
  48424. */
  48425. static BaseRepositoryUrl: string;
  48426. /**
  48427. * Which repository gets priority - local or online
  48428. */
  48429. static PrioritizeOnlineRepository: boolean;
  48430. /**
  48431. * Use the online repository, or use only locally-defined controllers
  48432. */
  48433. static UseOnlineRepository: boolean;
  48434. /**
  48435. * Clear the cache used for profile loading and reload when requested again
  48436. */
  48437. static ClearProfilesCache(): void;
  48438. /**
  48439. * Register the default fallbacks.
  48440. * This function is called automatically when this file is imported.
  48441. */
  48442. static DefaultFallbacks(): void;
  48443. /**
  48444. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48445. * @param profileId the profile to which a fallback needs to be found
  48446. * @return an array with corresponding fallback profiles
  48447. */
  48448. static FindFallbackWithProfileId(profileId: string): string[];
  48449. /**
  48450. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48451. * The order of search:
  48452. *
  48453. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48454. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48455. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48456. * 4) return the generic trigger controller if none were found
  48457. *
  48458. * @param xrInput the xrInput to which a new controller is initialized
  48459. * @param scene the scene to which the model will be added
  48460. * @param forceProfile force a certain profile for this controller
  48461. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48462. */
  48463. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48464. /**
  48465. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48466. *
  48467. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48468. *
  48469. * @param type the profile type to register
  48470. * @param constructFunction the function to be called when loading this profile
  48471. */
  48472. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48473. /**
  48474. * Register a fallback to a specific profile.
  48475. * @param profileId the profileId that will receive the fallbacks
  48476. * @param fallbacks A list of fallback profiles
  48477. */
  48478. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48479. /**
  48480. * Will update the list of profiles available in the repository
  48481. * @return a promise that resolves to a map of profiles available online
  48482. */
  48483. static UpdateProfilesList(): Promise<{
  48484. [profile: string]: string;
  48485. }>;
  48486. private static _LoadProfileFromRepository;
  48487. private static _LoadProfilesFromAvailableControllers;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * Configuration options for the WebXR controller creation
  48493. */
  48494. export interface IWebXRControllerOptions {
  48495. /**
  48496. * Should the controller mesh be animated when a user interacts with it
  48497. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48498. */
  48499. disableMotionControllerAnimation?: boolean;
  48500. /**
  48501. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48502. */
  48503. doNotLoadControllerMesh?: boolean;
  48504. /**
  48505. * Force a specific controller type for this controller.
  48506. * This can be used when creating your own profile or when testing different controllers
  48507. */
  48508. forceControllerProfile?: string;
  48509. /**
  48510. * Defines a rendering group ID for meshes that will be loaded.
  48511. * This is for the default controllers only.
  48512. */
  48513. renderingGroupId?: number;
  48514. }
  48515. /**
  48516. * Represents an XR controller
  48517. */
  48518. export class WebXRInputSource {
  48519. private _scene;
  48520. /** The underlying input source for the controller */
  48521. inputSource: XRInputSource;
  48522. private _options;
  48523. private _tmpVector;
  48524. private _uniqueId;
  48525. private _disposed;
  48526. /**
  48527. * 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
  48528. */
  48529. grip?: AbstractMesh;
  48530. /**
  48531. * If available, this is the gamepad object related to this controller.
  48532. * Using this object it is possible to get click events and trackpad changes of the
  48533. * webxr controller that is currently being used.
  48534. */
  48535. motionController?: WebXRAbstractMotionController;
  48536. /**
  48537. * Event that fires when the controller is removed/disposed.
  48538. * The object provided as event data is this controller, after associated assets were disposed.
  48539. * uniqueId is still available.
  48540. */
  48541. onDisposeObservable: Observable<WebXRInputSource>;
  48542. /**
  48543. * Will be triggered when the mesh associated with the motion controller is done loading.
  48544. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48545. * A shortened version of controller -> motion controller -> on mesh loaded.
  48546. */
  48547. onMeshLoadedObservable: Observable<AbstractMesh>;
  48548. /**
  48549. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48550. */
  48551. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48552. /**
  48553. * Pointer which can be used to select objects or attach a visible laser to
  48554. */
  48555. pointer: AbstractMesh;
  48556. /**
  48557. * Creates the input source object
  48558. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48559. * @param _scene the scene which the controller should be associated to
  48560. * @param inputSource the underlying input source for the controller
  48561. * @param _options options for this controller creation
  48562. */
  48563. constructor(_scene: Scene,
  48564. /** The underlying input source for the controller */
  48565. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48566. /**
  48567. * Get this controllers unique id
  48568. */
  48569. get uniqueId(): string;
  48570. /**
  48571. * Disposes of the object
  48572. */
  48573. dispose(): void;
  48574. /**
  48575. * Gets a world space ray coming from the pointer or grip
  48576. * @param result the resulting ray
  48577. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48578. */
  48579. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48580. /**
  48581. * Updates the controller pose based on the given XRFrame
  48582. * @param xrFrame xr frame to update the pose with
  48583. * @param referenceSpace reference space to use
  48584. */
  48585. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48586. }
  48587. }
  48588. declare module BABYLON {
  48589. /**
  48590. * The schema for initialization options of the XR Input class
  48591. */
  48592. export interface IWebXRInputOptions {
  48593. /**
  48594. * If set to true no model will be automatically loaded
  48595. */
  48596. doNotLoadControllerMeshes?: boolean;
  48597. /**
  48598. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48599. * If not found, the xr input profile data will be used.
  48600. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48601. */
  48602. forceInputProfile?: string;
  48603. /**
  48604. * Do not send a request to the controller repository to load the profile.
  48605. *
  48606. * Instead, use the controllers available in babylon itself.
  48607. */
  48608. disableOnlineControllerRepository?: boolean;
  48609. /**
  48610. * A custom URL for the controllers repository
  48611. */
  48612. customControllersRepositoryURL?: string;
  48613. /**
  48614. * Should the controller model's components not move according to the user input
  48615. */
  48616. disableControllerAnimation?: boolean;
  48617. /**
  48618. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48619. */
  48620. controllerOptions?: IWebXRControllerOptions;
  48621. }
  48622. /**
  48623. * XR input used to track XR inputs such as controllers/rays
  48624. */
  48625. export class WebXRInput implements IDisposable {
  48626. /**
  48627. * the xr session manager for this session
  48628. */
  48629. xrSessionManager: WebXRSessionManager;
  48630. /**
  48631. * the WebXR camera for this session. Mainly used for teleportation
  48632. */
  48633. xrCamera: WebXRCamera;
  48634. private readonly options;
  48635. /**
  48636. * XR controllers being tracked
  48637. */
  48638. controllers: Array<WebXRInputSource>;
  48639. private _frameObserver;
  48640. private _sessionEndedObserver;
  48641. private _sessionInitObserver;
  48642. /**
  48643. * Event when a controller has been connected/added
  48644. */
  48645. onControllerAddedObservable: Observable<WebXRInputSource>;
  48646. /**
  48647. * Event when a controller has been removed/disconnected
  48648. */
  48649. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48650. /**
  48651. * Initializes the WebXRInput
  48652. * @param xrSessionManager the xr session manager for this session
  48653. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48654. * @param options = initialization options for this xr input
  48655. */
  48656. constructor(
  48657. /**
  48658. * the xr session manager for this session
  48659. */
  48660. xrSessionManager: WebXRSessionManager,
  48661. /**
  48662. * the WebXR camera for this session. Mainly used for teleportation
  48663. */
  48664. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48665. private _onInputSourcesChange;
  48666. private _addAndRemoveControllers;
  48667. /**
  48668. * Disposes of the object
  48669. */
  48670. dispose(): void;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /**
  48675. * This is the base class for all WebXR features.
  48676. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48677. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48678. */
  48679. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48680. protected _xrSessionManager: WebXRSessionManager;
  48681. private _attached;
  48682. private _removeOnDetach;
  48683. /**
  48684. * Is this feature disposed?
  48685. */
  48686. isDisposed: boolean;
  48687. /**
  48688. * Should auto-attach be disabled?
  48689. */
  48690. disableAutoAttach: boolean;
  48691. /**
  48692. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48693. */
  48694. xrNativeFeatureName: string;
  48695. /**
  48696. * Construct a new (abstract) WebXR feature
  48697. * @param _xrSessionManager the xr session manager for this feature
  48698. */
  48699. constructor(_xrSessionManager: WebXRSessionManager);
  48700. /**
  48701. * Is this feature attached
  48702. */
  48703. get attached(): boolean;
  48704. /**
  48705. * attach this feature
  48706. *
  48707. * @param force should attachment be forced (even when already attached)
  48708. * @returns true if successful, false is failed or already attached
  48709. */
  48710. attach(force?: boolean): boolean;
  48711. /**
  48712. * detach this feature.
  48713. *
  48714. * @returns true if successful, false if failed or already detached
  48715. */
  48716. detach(): boolean;
  48717. /**
  48718. * Dispose this feature and all of the resources attached
  48719. */
  48720. dispose(): void;
  48721. /**
  48722. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48723. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48724. *
  48725. * @returns whether or not the feature is compatible in this environment
  48726. */
  48727. isCompatible(): boolean;
  48728. /**
  48729. * This is used to register callbacks that will automatically be removed when detach is called.
  48730. * @param observable the observable to which the observer will be attached
  48731. * @param callback the callback to register
  48732. */
  48733. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48734. /**
  48735. * Code in this function will be executed on each xrFrame received from the browser.
  48736. * This function will not execute after the feature is detached.
  48737. * @param _xrFrame the current frame
  48738. */
  48739. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48740. }
  48741. }
  48742. declare module BABYLON {
  48743. /**
  48744. * Renders a layer on top of an existing scene
  48745. */
  48746. export class UtilityLayerRenderer implements IDisposable {
  48747. /** the original scene that will be rendered on top of */
  48748. originalScene: Scene;
  48749. private _pointerCaptures;
  48750. private _lastPointerEvents;
  48751. private static _DefaultUtilityLayer;
  48752. private static _DefaultKeepDepthUtilityLayer;
  48753. private _sharedGizmoLight;
  48754. private _renderCamera;
  48755. /**
  48756. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48757. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48758. * @returns the camera that is used when rendering the utility layer
  48759. */
  48760. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48761. /**
  48762. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48763. * @param cam the camera that should be used when rendering the utility layer
  48764. */
  48765. setRenderCamera(cam: Nullable<Camera>): void;
  48766. /**
  48767. * @hidden
  48768. * Light which used by gizmos to get light shading
  48769. */
  48770. _getSharedGizmoLight(): HemisphericLight;
  48771. /**
  48772. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48773. */
  48774. pickUtilitySceneFirst: boolean;
  48775. /**
  48776. * 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)
  48777. */
  48778. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48779. /**
  48780. * 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)
  48781. */
  48782. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48783. /**
  48784. * The scene that is rendered on top of the original scene
  48785. */
  48786. utilityLayerScene: Scene;
  48787. /**
  48788. * If the utility layer should automatically be rendered on top of existing scene
  48789. */
  48790. shouldRender: boolean;
  48791. /**
  48792. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48793. */
  48794. onlyCheckPointerDownEvents: boolean;
  48795. /**
  48796. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48797. */
  48798. processAllEvents: boolean;
  48799. /**
  48800. * Observable raised when the pointer move from the utility layer scene to the main scene
  48801. */
  48802. onPointerOutObservable: Observable<number>;
  48803. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48804. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48805. private _afterRenderObserver;
  48806. private _sceneDisposeObserver;
  48807. private _originalPointerObserver;
  48808. /**
  48809. * Instantiates a UtilityLayerRenderer
  48810. * @param originalScene the original scene that will be rendered on top of
  48811. * @param handleEvents boolean indicating if the utility layer should handle events
  48812. */
  48813. constructor(
  48814. /** the original scene that will be rendered on top of */
  48815. originalScene: Scene, handleEvents?: boolean);
  48816. private _notifyObservers;
  48817. /**
  48818. * Renders the utility layers scene on top of the original scene
  48819. */
  48820. render(): void;
  48821. /**
  48822. * Disposes of the renderer
  48823. */
  48824. dispose(): void;
  48825. private _updateCamera;
  48826. }
  48827. }
  48828. declare module BABYLON {
  48829. /**
  48830. * Options interface for the pointer selection module
  48831. */
  48832. export interface IWebXRControllerPointerSelectionOptions {
  48833. /**
  48834. * if provided, this scene will be used to render meshes.
  48835. */
  48836. customUtilityLayerScene?: Scene;
  48837. /**
  48838. * 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)
  48839. * If not disabled, the last picked point will be used to execute a pointer up event
  48840. * If disabled, pointer up event will be triggered right after the pointer down event.
  48841. * Used in screen and gaze target ray mode only
  48842. */
  48843. disablePointerUpOnTouchOut: boolean;
  48844. /**
  48845. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48846. */
  48847. forceGazeMode: boolean;
  48848. /**
  48849. * 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
  48850. * to start a new countdown to the pointer down event.
  48851. * Defaults to 1.
  48852. */
  48853. gazeModePointerMovedFactor?: number;
  48854. /**
  48855. * Different button type to use instead of the main component
  48856. */
  48857. overrideButtonId?: string;
  48858. /**
  48859. * use this rendering group id for the meshes (optional)
  48860. */
  48861. renderingGroupId?: number;
  48862. /**
  48863. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48864. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48865. * 3000 means 3 seconds between pointing at something and selecting it
  48866. */
  48867. timeToSelect?: number;
  48868. /**
  48869. * Should meshes created here be added to a utility layer or the main scene
  48870. */
  48871. useUtilityLayer?: boolean;
  48872. /**
  48873. * Optional WebXR camera to be used for gaze selection
  48874. */
  48875. gazeCamera?: WebXRCamera;
  48876. /**
  48877. * the xr input to use with this pointer selection
  48878. */
  48879. xrInput: WebXRInput;
  48880. }
  48881. /**
  48882. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48883. */
  48884. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48885. private readonly _options;
  48886. private static _idCounter;
  48887. private _attachController;
  48888. private _controllers;
  48889. private _scene;
  48890. private _tmpVectorForPickCompare;
  48891. /**
  48892. * The module's name
  48893. */
  48894. static readonly Name: string;
  48895. /**
  48896. * The (Babylon) version of this module.
  48897. * This is an integer representing the implementation version.
  48898. * This number does not correspond to the WebXR specs version
  48899. */
  48900. static readonly Version: number;
  48901. /**
  48902. * Disable lighting on the laser pointer (so it will always be visible)
  48903. */
  48904. disablePointerLighting: boolean;
  48905. /**
  48906. * Disable lighting on the selection mesh (so it will always be visible)
  48907. */
  48908. disableSelectionMeshLighting: boolean;
  48909. /**
  48910. * Should the laser pointer be displayed
  48911. */
  48912. displayLaserPointer: boolean;
  48913. /**
  48914. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48915. */
  48916. displaySelectionMesh: boolean;
  48917. /**
  48918. * This color will be set to the laser pointer when selection is triggered
  48919. */
  48920. laserPointerPickedColor: Color3;
  48921. /**
  48922. * Default color of the laser pointer
  48923. */
  48924. laserPointerDefaultColor: Color3;
  48925. /**
  48926. * default color of the selection ring
  48927. */
  48928. selectionMeshDefaultColor: Color3;
  48929. /**
  48930. * This color will be applied to the selection ring when selection is triggered
  48931. */
  48932. selectionMeshPickedColor: Color3;
  48933. /**
  48934. * Optional filter to be used for ray selection. This predicate shares behavior with
  48935. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48936. */
  48937. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48938. /**
  48939. * constructs a new background remover module
  48940. * @param _xrSessionManager the session manager for this module
  48941. * @param _options read-only options to be used in this module
  48942. */
  48943. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48944. /**
  48945. * attach this feature
  48946. * Will usually be called by the features manager
  48947. *
  48948. * @returns true if successful.
  48949. */
  48950. attach(): boolean;
  48951. /**
  48952. * detach this feature.
  48953. * Will usually be called by the features manager
  48954. *
  48955. * @returns true if successful.
  48956. */
  48957. detach(): boolean;
  48958. /**
  48959. * Will get the mesh under a specific pointer.
  48960. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48961. * @param controllerId the controllerId to check
  48962. * @returns The mesh under pointer or null if no mesh is under the pointer
  48963. */
  48964. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48965. /**
  48966. * Get the xr controller that correlates to the pointer id in the pointer event
  48967. *
  48968. * @param id the pointer id to search for
  48969. * @returns the controller that correlates to this id or null if not found
  48970. */
  48971. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48972. protected _onXRFrame(_xrFrame: XRFrame): void;
  48973. private _attachGazeMode;
  48974. private _attachScreenRayMode;
  48975. private _attachTrackedPointerRayMode;
  48976. private _convertNormalToDirectionOfRay;
  48977. private _detachController;
  48978. private _generateNewMeshPair;
  48979. private _pickingMoved;
  48980. private _updatePointerDistance;
  48981. /** @hidden */
  48982. get lasterPointerDefaultColor(): Color3;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Button which can be used to enter a different mode of XR
  48988. */
  48989. export class WebXREnterExitUIButton {
  48990. /** button element */
  48991. element: HTMLElement;
  48992. /** XR initialization options for the button */
  48993. sessionMode: XRSessionMode;
  48994. /** Reference space type */
  48995. referenceSpaceType: XRReferenceSpaceType;
  48996. /**
  48997. * Creates a WebXREnterExitUIButton
  48998. * @param element button element
  48999. * @param sessionMode XR initialization session mode
  49000. * @param referenceSpaceType the type of reference space to be used
  49001. */
  49002. constructor(
  49003. /** button element */
  49004. element: HTMLElement,
  49005. /** XR initialization options for the button */
  49006. sessionMode: XRSessionMode,
  49007. /** Reference space type */
  49008. referenceSpaceType: XRReferenceSpaceType);
  49009. /**
  49010. * Extendable function which can be used to update the button's visuals when the state changes
  49011. * @param activeButton the current active button in the UI
  49012. */
  49013. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49014. }
  49015. /**
  49016. * Options to create the webXR UI
  49017. */
  49018. export class WebXREnterExitUIOptions {
  49019. /**
  49020. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49021. */
  49022. customButtons?: Array<WebXREnterExitUIButton>;
  49023. /**
  49024. * A reference space type to use when creating the default button.
  49025. * Default is local-floor
  49026. */
  49027. referenceSpaceType?: XRReferenceSpaceType;
  49028. /**
  49029. * Context to enter xr with
  49030. */
  49031. renderTarget?: Nullable<WebXRRenderTarget>;
  49032. /**
  49033. * A session mode to use when creating the default button.
  49034. * Default is immersive-vr
  49035. */
  49036. sessionMode?: XRSessionMode;
  49037. /**
  49038. * A list of optional features to init the session with
  49039. */
  49040. optionalFeatures?: string[];
  49041. /**
  49042. * A list of optional features to init the session with
  49043. */
  49044. requiredFeatures?: string[];
  49045. }
  49046. /**
  49047. * UI to allow the user to enter/exit XR mode
  49048. */
  49049. export class WebXREnterExitUI implements IDisposable {
  49050. private scene;
  49051. /** version of the options passed to this UI */
  49052. options: WebXREnterExitUIOptions;
  49053. private _activeButton;
  49054. private _buttons;
  49055. /**
  49056. * The HTML Div Element to which buttons are added.
  49057. */
  49058. readonly overlay: HTMLDivElement;
  49059. /**
  49060. * Fired every time the active button is changed.
  49061. *
  49062. * When xr is entered via a button that launches xr that button will be the callback parameter
  49063. *
  49064. * When exiting xr the callback parameter will be null)
  49065. */
  49066. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49067. /**
  49068. *
  49069. * @param scene babylon scene object to use
  49070. * @param options (read-only) version of the options passed to this UI
  49071. */
  49072. private constructor();
  49073. /**
  49074. * Creates UI to allow the user to enter/exit XR mode
  49075. * @param scene the scene to add the ui to
  49076. * @param helper the xr experience helper to enter/exit xr with
  49077. * @param options options to configure the UI
  49078. * @returns the created ui
  49079. */
  49080. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49081. /**
  49082. * Disposes of the XR UI component
  49083. */
  49084. dispose(): void;
  49085. private _updateButtons;
  49086. }
  49087. }
  49088. declare module BABYLON {
  49089. /**
  49090. * Class containing static functions to help procedurally build meshes
  49091. */
  49092. export class LinesBuilder {
  49093. /**
  49094. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49095. * * 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
  49096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49097. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49098. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49099. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49100. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49101. * * 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
  49102. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49105. * @param name defines the name of the new line system
  49106. * @param options defines the options used to create the line system
  49107. * @param scene defines the hosting scene
  49108. * @returns a new line system mesh
  49109. */
  49110. static CreateLineSystem(name: string, options: {
  49111. lines: Vector3[][];
  49112. updatable?: boolean;
  49113. instance?: Nullable<LinesMesh>;
  49114. colors?: Nullable<Color4[][]>;
  49115. useVertexAlpha?: boolean;
  49116. }, scene: Nullable<Scene>): LinesMesh;
  49117. /**
  49118. * Creates a line mesh
  49119. * 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
  49120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49121. * * The parameter `points` is an array successive Vector3
  49122. * * 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
  49123. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49125. * * When updating an instance, remember that only point positions can change, not the number of points
  49126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49128. * @param name defines the name of the new line system
  49129. * @param options defines the options used to create the line system
  49130. * @param scene defines the hosting scene
  49131. * @returns a new line mesh
  49132. */
  49133. static CreateLines(name: string, options: {
  49134. points: Vector3[];
  49135. updatable?: boolean;
  49136. instance?: Nullable<LinesMesh>;
  49137. colors?: Color4[];
  49138. useVertexAlpha?: boolean;
  49139. }, scene?: Nullable<Scene>): LinesMesh;
  49140. /**
  49141. * Creates a dashed line mesh
  49142. * * 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
  49143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49144. * * The parameter `points` is an array successive Vector3
  49145. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49146. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49147. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49148. * * 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
  49149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49150. * * When updating an instance, remember that only point positions can change, not the number of points
  49151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49152. * @param name defines the name of the mesh
  49153. * @param options defines the options used to create the mesh
  49154. * @param scene defines the hosting scene
  49155. * @returns the dashed line mesh
  49156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49157. */
  49158. static CreateDashedLines(name: string, options: {
  49159. points: Vector3[];
  49160. dashSize?: number;
  49161. gapSize?: number;
  49162. dashNb?: number;
  49163. updatable?: boolean;
  49164. instance?: LinesMesh;
  49165. useVertexAlpha?: boolean;
  49166. }, scene?: Nullable<Scene>): LinesMesh;
  49167. }
  49168. }
  49169. declare module BABYLON {
  49170. /**
  49171. * Construction options for a timer
  49172. */
  49173. export interface ITimerOptions<T> {
  49174. /**
  49175. * Time-to-end
  49176. */
  49177. timeout: number;
  49178. /**
  49179. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49180. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49181. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49182. */
  49183. contextObservable: Observable<T>;
  49184. /**
  49185. * Optional parameters when adding an observer to the observable
  49186. */
  49187. observableParameters?: {
  49188. mask?: number;
  49189. insertFirst?: boolean;
  49190. scope?: any;
  49191. };
  49192. /**
  49193. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49194. */
  49195. breakCondition?: (data?: ITimerData<T>) => boolean;
  49196. /**
  49197. * Will be triggered when the time condition has met
  49198. */
  49199. onEnded?: (data: ITimerData<any>) => void;
  49200. /**
  49201. * Will be triggered when the break condition has met (prematurely ended)
  49202. */
  49203. onAborted?: (data: ITimerData<any>) => void;
  49204. /**
  49205. * Optional function to execute on each tick (or count)
  49206. */
  49207. onTick?: (data: ITimerData<any>) => void;
  49208. }
  49209. /**
  49210. * An interface defining the data sent by the timer
  49211. */
  49212. export interface ITimerData<T> {
  49213. /**
  49214. * When did it start
  49215. */
  49216. startTime: number;
  49217. /**
  49218. * Time now
  49219. */
  49220. currentTime: number;
  49221. /**
  49222. * Time passed since started
  49223. */
  49224. deltaTime: number;
  49225. /**
  49226. * How much is completed, in [0.0...1.0].
  49227. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49228. */
  49229. completeRate: number;
  49230. /**
  49231. * What the registered observable sent in the last count
  49232. */
  49233. payload: T;
  49234. }
  49235. /**
  49236. * The current state of the timer
  49237. */
  49238. export enum TimerState {
  49239. /**
  49240. * Timer initialized, not yet started
  49241. */
  49242. INIT = 0,
  49243. /**
  49244. * Timer started and counting
  49245. */
  49246. STARTED = 1,
  49247. /**
  49248. * Timer ended (whether aborted or time reached)
  49249. */
  49250. ENDED = 2
  49251. }
  49252. /**
  49253. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49254. *
  49255. * @param options options with which to initialize this timer
  49256. */
  49257. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49258. /**
  49259. * An advanced implementation of a timer class
  49260. */
  49261. export class AdvancedTimer<T = any> implements IDisposable {
  49262. /**
  49263. * Will notify each time the timer calculates the remaining time
  49264. */
  49265. onEachCountObservable: Observable<ITimerData<T>>;
  49266. /**
  49267. * Will trigger when the timer was aborted due to the break condition
  49268. */
  49269. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49270. /**
  49271. * Will trigger when the timer ended successfully
  49272. */
  49273. onTimerEndedObservable: Observable<ITimerData<T>>;
  49274. /**
  49275. * Will trigger when the timer state has changed
  49276. */
  49277. onStateChangedObservable: Observable<TimerState>;
  49278. private _observer;
  49279. private _contextObservable;
  49280. private _observableParameters;
  49281. private _startTime;
  49282. private _timer;
  49283. private _state;
  49284. private _breakCondition;
  49285. private _timeToEnd;
  49286. private _breakOnNextTick;
  49287. /**
  49288. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49289. * @param options construction options for this advanced timer
  49290. */
  49291. constructor(options: ITimerOptions<T>);
  49292. /**
  49293. * set a breaking condition for this timer. Default is to never break during count
  49294. * @param predicate the new break condition. Returns true to break, false otherwise
  49295. */
  49296. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49297. /**
  49298. * Reset ALL associated observables in this advanced timer
  49299. */
  49300. clearObservables(): void;
  49301. /**
  49302. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49303. *
  49304. * @param timeToEnd how much time to measure until timer ended
  49305. */
  49306. start(timeToEnd?: number): void;
  49307. /**
  49308. * Will force a stop on the next tick.
  49309. */
  49310. stop(): void;
  49311. /**
  49312. * Dispose this timer, clearing all resources
  49313. */
  49314. dispose(): void;
  49315. private _setState;
  49316. private _tick;
  49317. private _stop;
  49318. }
  49319. }
  49320. declare module BABYLON {
  49321. /**
  49322. * The options container for the teleportation module
  49323. */
  49324. export interface IWebXRTeleportationOptions {
  49325. /**
  49326. * if provided, this scene will be used to render meshes.
  49327. */
  49328. customUtilityLayerScene?: Scene;
  49329. /**
  49330. * Values to configure the default target mesh
  49331. */
  49332. defaultTargetMeshOptions?: {
  49333. /**
  49334. * Fill color of the teleportation area
  49335. */
  49336. teleportationFillColor?: string;
  49337. /**
  49338. * Border color for the teleportation area
  49339. */
  49340. teleportationBorderColor?: string;
  49341. /**
  49342. * Disable the mesh's animation sequence
  49343. */
  49344. disableAnimation?: boolean;
  49345. /**
  49346. * Disable lighting on the material or the ring and arrow
  49347. */
  49348. disableLighting?: boolean;
  49349. /**
  49350. * Override the default material of the torus and arrow
  49351. */
  49352. torusArrowMaterial?: Material;
  49353. };
  49354. /**
  49355. * A list of meshes to use as floor meshes.
  49356. * Meshes can be added and removed after initializing the feature using the
  49357. * addFloorMesh and removeFloorMesh functions
  49358. * If empty, rotation will still work
  49359. */
  49360. floorMeshes?: AbstractMesh[];
  49361. /**
  49362. * use this rendering group id for the meshes (optional)
  49363. */
  49364. renderingGroupId?: number;
  49365. /**
  49366. * Should teleportation move only to snap points
  49367. */
  49368. snapPointsOnly?: boolean;
  49369. /**
  49370. * An array of points to which the teleportation will snap to.
  49371. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49372. */
  49373. snapPositions?: Vector3[];
  49374. /**
  49375. * How close should the teleportation ray be in order to snap to position.
  49376. * Default to 0.8 units (meters)
  49377. */
  49378. snapToPositionRadius?: number;
  49379. /**
  49380. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49381. * If you want to support rotation, make sure your mesh has a direction indicator.
  49382. *
  49383. * When left untouched, the default mesh will be initialized.
  49384. */
  49385. teleportationTargetMesh?: AbstractMesh;
  49386. /**
  49387. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49388. */
  49389. timeToTeleport?: number;
  49390. /**
  49391. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49392. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49393. */
  49394. useMainComponentOnly?: boolean;
  49395. /**
  49396. * Should meshes created here be added to a utility layer or the main scene
  49397. */
  49398. useUtilityLayer?: boolean;
  49399. /**
  49400. * Babylon XR Input class for controller
  49401. */
  49402. xrInput: WebXRInput;
  49403. /**
  49404. * Meshes that the teleportation ray cannot go through
  49405. */
  49406. pickBlockerMeshes?: AbstractMesh[];
  49407. }
  49408. /**
  49409. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49410. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49411. * the input of the attached controllers.
  49412. */
  49413. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49414. private _options;
  49415. private _controllers;
  49416. private _currentTeleportationControllerId;
  49417. private _floorMeshes;
  49418. private _quadraticBezierCurve;
  49419. private _selectionFeature;
  49420. private _snapToPositions;
  49421. private _snappedToPoint;
  49422. private _teleportationRingMaterial?;
  49423. private _tmpRay;
  49424. private _tmpVector;
  49425. private _tmpQuaternion;
  49426. /**
  49427. * The module's name
  49428. */
  49429. static readonly Name: string;
  49430. /**
  49431. * The (Babylon) version of this module.
  49432. * This is an integer representing the implementation version.
  49433. * This number does not correspond to the webxr specs version
  49434. */
  49435. static readonly Version: number;
  49436. /**
  49437. * Is movement backwards enabled
  49438. */
  49439. backwardsMovementEnabled: boolean;
  49440. /**
  49441. * Distance to travel when moving backwards
  49442. */
  49443. backwardsTeleportationDistance: number;
  49444. /**
  49445. * The distance from the user to the inspection point in the direction of the controller
  49446. * A higher number will allow the user to move further
  49447. * defaults to 5 (meters, in xr units)
  49448. */
  49449. parabolicCheckRadius: number;
  49450. /**
  49451. * Should the module support parabolic ray on top of direct ray
  49452. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49453. * Very helpful when moving between floors / different heights
  49454. */
  49455. parabolicRayEnabled: boolean;
  49456. /**
  49457. * How much rotation should be applied when rotating right and left
  49458. */
  49459. rotationAngle: number;
  49460. /**
  49461. * Is rotation enabled when moving forward?
  49462. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49463. */
  49464. rotationEnabled: boolean;
  49465. /**
  49466. * constructs a new anchor system
  49467. * @param _xrSessionManager an instance of WebXRSessionManager
  49468. * @param _options configuration object for this feature
  49469. */
  49470. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49471. /**
  49472. * Get the snapPointsOnly flag
  49473. */
  49474. get snapPointsOnly(): boolean;
  49475. /**
  49476. * Sets the snapPointsOnly flag
  49477. * @param snapToPoints should teleportation be exclusively to snap points
  49478. */
  49479. set snapPointsOnly(snapToPoints: boolean);
  49480. /**
  49481. * Add a new mesh to the floor meshes array
  49482. * @param mesh the mesh to use as floor mesh
  49483. */
  49484. addFloorMesh(mesh: AbstractMesh): void;
  49485. /**
  49486. * Add a new snap-to point to fix teleportation to this position
  49487. * @param newSnapPoint The new Snap-To point
  49488. */
  49489. addSnapPoint(newSnapPoint: Vector3): void;
  49490. attach(): boolean;
  49491. detach(): boolean;
  49492. dispose(): void;
  49493. /**
  49494. * Remove a mesh from the floor meshes array
  49495. * @param mesh the mesh to remove
  49496. */
  49497. removeFloorMesh(mesh: AbstractMesh): void;
  49498. /**
  49499. * Remove a mesh from the floor meshes array using its name
  49500. * @param name the mesh name to remove
  49501. */
  49502. removeFloorMeshByName(name: string): void;
  49503. /**
  49504. * 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
  49505. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49506. * @returns was the point found and removed or not
  49507. */
  49508. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49509. /**
  49510. * This function sets a selection feature that will be disabled when
  49511. * the forward ray is shown and will be reattached when hidden.
  49512. * This is used to remove the selection rays when moving.
  49513. * @param selectionFeature the feature to disable when forward movement is enabled
  49514. */
  49515. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49516. protected _onXRFrame(_xrFrame: XRFrame): void;
  49517. private _attachController;
  49518. private _createDefaultTargetMesh;
  49519. private _detachController;
  49520. private _findClosestSnapPointWithRadius;
  49521. private _setTargetMeshPosition;
  49522. private _setTargetMeshVisibility;
  49523. private _showParabolicPath;
  49524. private _teleportForward;
  49525. }
  49526. }
  49527. declare module BABYLON {
  49528. /**
  49529. * Options for the default xr helper
  49530. */
  49531. export class WebXRDefaultExperienceOptions {
  49532. /**
  49533. * Enable or disable default UI to enter XR
  49534. */
  49535. disableDefaultUI?: boolean;
  49536. /**
  49537. * Should teleportation not initialize. defaults to false.
  49538. */
  49539. disableTeleportation?: boolean;
  49540. /**
  49541. * Floor meshes that will be used for teleport
  49542. */
  49543. floorMeshes?: Array<AbstractMesh>;
  49544. /**
  49545. * If set to true, the first frame will not be used to reset position
  49546. * The first frame is mainly used when copying transformation from the old camera
  49547. * Mainly used in AR
  49548. */
  49549. ignoreNativeCameraTransformation?: boolean;
  49550. /**
  49551. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49552. */
  49553. inputOptions?: IWebXRInputOptions;
  49554. /**
  49555. * optional configuration for the output canvas
  49556. */
  49557. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49558. /**
  49559. * optional UI options. This can be used among other to change session mode and reference space type
  49560. */
  49561. uiOptions?: WebXREnterExitUIOptions;
  49562. /**
  49563. * When loading teleportation and pointer select, use stable versions instead of latest.
  49564. */
  49565. useStablePlugins?: boolean;
  49566. /**
  49567. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49568. */
  49569. renderingGroupId?: number;
  49570. /**
  49571. * A list of optional features to init the session with
  49572. * If set to true, all features we support will be added
  49573. */
  49574. optionalFeatures?: boolean | string[];
  49575. }
  49576. /**
  49577. * Default experience which provides a similar setup to the previous webVRExperience
  49578. */
  49579. export class WebXRDefaultExperience {
  49580. /**
  49581. * Base experience
  49582. */
  49583. baseExperience: WebXRExperienceHelper;
  49584. /**
  49585. * Enables ui for entering/exiting xr
  49586. */
  49587. enterExitUI: WebXREnterExitUI;
  49588. /**
  49589. * Input experience extension
  49590. */
  49591. input: WebXRInput;
  49592. /**
  49593. * Enables laser pointer and selection
  49594. */
  49595. pointerSelection: WebXRControllerPointerSelection;
  49596. /**
  49597. * Default target xr should render to
  49598. */
  49599. renderTarget: WebXRRenderTarget;
  49600. /**
  49601. * Enables teleportation
  49602. */
  49603. teleportation: WebXRMotionControllerTeleportation;
  49604. private constructor();
  49605. /**
  49606. * Creates the default xr experience
  49607. * @param scene scene
  49608. * @param options options for basic configuration
  49609. * @returns resulting WebXRDefaultExperience
  49610. */
  49611. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49612. /**
  49613. * DIsposes of the experience helper
  49614. */
  49615. dispose(): void;
  49616. }
  49617. }
  49618. declare module BABYLON {
  49619. /**
  49620. * Options to modify the vr teleportation behavior.
  49621. */
  49622. export interface VRTeleportationOptions {
  49623. /**
  49624. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49625. */
  49626. floorMeshName?: string;
  49627. /**
  49628. * A list of meshes to be used as the teleportation floor. (default: empty)
  49629. */
  49630. floorMeshes?: Mesh[];
  49631. /**
  49632. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49633. */
  49634. teleportationMode?: number;
  49635. /**
  49636. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49637. */
  49638. teleportationTime?: number;
  49639. /**
  49640. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49641. */
  49642. teleportationSpeed?: number;
  49643. /**
  49644. * The easing function used in the animation or null for Linear. (default CircleEase)
  49645. */
  49646. easingFunction?: EasingFunction;
  49647. }
  49648. /**
  49649. * Options to modify the vr experience helper's behavior.
  49650. */
  49651. export interface VRExperienceHelperOptions extends WebVROptions {
  49652. /**
  49653. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49654. */
  49655. createDeviceOrientationCamera?: boolean;
  49656. /**
  49657. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49658. */
  49659. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49660. /**
  49661. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49662. */
  49663. laserToggle?: boolean;
  49664. /**
  49665. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49666. */
  49667. floorMeshes?: Mesh[];
  49668. /**
  49669. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49670. */
  49671. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49672. /**
  49673. * Defines if WebXR should be used instead of WebVR (if available)
  49674. */
  49675. useXR?: boolean;
  49676. }
  49677. /**
  49678. * Event containing information after VR has been entered
  49679. */
  49680. export class OnAfterEnteringVRObservableEvent {
  49681. /**
  49682. * If entering vr was successful
  49683. */
  49684. success: boolean;
  49685. }
  49686. /**
  49687. * Helps to quickly add VR support to an existing scene.
  49688. * See https://doc.babylonjs.com/how_to/webvr_helper
  49689. */
  49690. export class VRExperienceHelper {
  49691. /** Options to modify the vr experience helper's behavior. */
  49692. webVROptions: VRExperienceHelperOptions;
  49693. private _scene;
  49694. private _position;
  49695. private _btnVR;
  49696. private _btnVRDisplayed;
  49697. private _webVRsupported;
  49698. private _webVRready;
  49699. private _webVRrequesting;
  49700. private _webVRpresenting;
  49701. private _hasEnteredVR;
  49702. private _fullscreenVRpresenting;
  49703. private _inputElement;
  49704. private _webVRCamera;
  49705. private _vrDeviceOrientationCamera;
  49706. private _deviceOrientationCamera;
  49707. private _existingCamera;
  49708. private _onKeyDown;
  49709. private _onVrDisplayPresentChange;
  49710. private _onVRDisplayChanged;
  49711. private _onVRRequestPresentStart;
  49712. private _onVRRequestPresentComplete;
  49713. /**
  49714. * 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)
  49715. */
  49716. enableGazeEvenWhenNoPointerLock: boolean;
  49717. /**
  49718. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49719. */
  49720. exitVROnDoubleTap: boolean;
  49721. /**
  49722. * Observable raised right before entering VR.
  49723. */
  49724. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49725. /**
  49726. * Observable raised when entering VR has completed.
  49727. */
  49728. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49729. /**
  49730. * Observable raised when exiting VR.
  49731. */
  49732. onExitingVRObservable: Observable<VRExperienceHelper>;
  49733. /**
  49734. * Observable raised when controller mesh is loaded.
  49735. */
  49736. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49737. /** Return this.onEnteringVRObservable
  49738. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49739. */
  49740. get onEnteringVR(): Observable<VRExperienceHelper>;
  49741. /** Return this.onExitingVRObservable
  49742. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49743. */
  49744. get onExitingVR(): Observable<VRExperienceHelper>;
  49745. /** Return this.onControllerMeshLoadedObservable
  49746. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49747. */
  49748. get onControllerMeshLoaded(): Observable<WebVRController>;
  49749. private _rayLength;
  49750. private _useCustomVRButton;
  49751. private _teleportationRequested;
  49752. private _teleportActive;
  49753. private _floorMeshName;
  49754. private _floorMeshesCollection;
  49755. private _teleportationMode;
  49756. private _teleportationTime;
  49757. private _teleportationSpeed;
  49758. private _teleportationEasing;
  49759. private _rotationAllowed;
  49760. private _teleportBackwardsVector;
  49761. private _teleportationTarget;
  49762. private _isDefaultTeleportationTarget;
  49763. private _postProcessMove;
  49764. private _teleportationFillColor;
  49765. private _teleportationBorderColor;
  49766. private _rotationAngle;
  49767. private _haloCenter;
  49768. private _cameraGazer;
  49769. private _padSensibilityUp;
  49770. private _padSensibilityDown;
  49771. private _leftController;
  49772. private _rightController;
  49773. private _gazeColor;
  49774. private _laserColor;
  49775. private _pickedLaserColor;
  49776. private _pickedGazeColor;
  49777. /**
  49778. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49779. */
  49780. onNewMeshSelected: Observable<AbstractMesh>;
  49781. /**
  49782. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49783. * This observable will provide the mesh and the controller used to select the mesh
  49784. */
  49785. onMeshSelectedWithController: Observable<{
  49786. mesh: AbstractMesh;
  49787. controller: WebVRController;
  49788. }>;
  49789. /**
  49790. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49791. */
  49792. onNewMeshPicked: Observable<PickingInfo>;
  49793. private _circleEase;
  49794. /**
  49795. * Observable raised before camera teleportation
  49796. */
  49797. onBeforeCameraTeleport: Observable<Vector3>;
  49798. /**
  49799. * Observable raised after camera teleportation
  49800. */
  49801. onAfterCameraTeleport: Observable<Vector3>;
  49802. /**
  49803. * Observable raised when current selected mesh gets unselected
  49804. */
  49805. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49806. private _raySelectionPredicate;
  49807. /**
  49808. * To be optionaly changed by user to define custom ray selection
  49809. */
  49810. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49811. /**
  49812. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49813. */
  49814. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49815. /**
  49816. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49817. */
  49818. teleportationEnabled: boolean;
  49819. private _defaultHeight;
  49820. private _teleportationInitialized;
  49821. private _interactionsEnabled;
  49822. private _interactionsRequested;
  49823. private _displayGaze;
  49824. private _displayLaserPointer;
  49825. /**
  49826. * The mesh used to display where the user is going to teleport.
  49827. */
  49828. get teleportationTarget(): Mesh;
  49829. /**
  49830. * Sets the mesh to be used to display where the user is going to teleport.
  49831. */
  49832. set teleportationTarget(value: Mesh);
  49833. /**
  49834. * 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
  49835. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49836. * See https://doc.babylonjs.com/resources/baking_transformations
  49837. */
  49838. get gazeTrackerMesh(): Mesh;
  49839. set gazeTrackerMesh(value: Mesh);
  49840. /**
  49841. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49842. */
  49843. updateGazeTrackerScale: boolean;
  49844. /**
  49845. * If the gaze trackers color should be updated when selecting meshes
  49846. */
  49847. updateGazeTrackerColor: boolean;
  49848. /**
  49849. * If the controller laser color should be updated when selecting meshes
  49850. */
  49851. updateControllerLaserColor: boolean;
  49852. /**
  49853. * The gaze tracking mesh corresponding to the left controller
  49854. */
  49855. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49856. /**
  49857. * The gaze tracking mesh corresponding to the right controller
  49858. */
  49859. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49860. /**
  49861. * If the ray of the gaze should be displayed.
  49862. */
  49863. get displayGaze(): boolean;
  49864. /**
  49865. * Sets if the ray of the gaze should be displayed.
  49866. */
  49867. set displayGaze(value: boolean);
  49868. /**
  49869. * If the ray of the LaserPointer should be displayed.
  49870. */
  49871. get displayLaserPointer(): boolean;
  49872. /**
  49873. * Sets if the ray of the LaserPointer should be displayed.
  49874. */
  49875. set displayLaserPointer(value: boolean);
  49876. /**
  49877. * The deviceOrientationCamera used as the camera when not in VR.
  49878. */
  49879. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49880. /**
  49881. * Based on the current WebVR support, returns the current VR camera used.
  49882. */
  49883. get currentVRCamera(): Nullable<Camera>;
  49884. /**
  49885. * The webVRCamera which is used when in VR.
  49886. */
  49887. get webVRCamera(): WebVRFreeCamera;
  49888. /**
  49889. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49890. */
  49891. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49892. /**
  49893. * The html button that is used to trigger entering into VR.
  49894. */
  49895. get vrButton(): Nullable<HTMLButtonElement>;
  49896. private get _teleportationRequestInitiated();
  49897. /**
  49898. * Defines whether or not Pointer lock should be requested when switching to
  49899. * full screen.
  49900. */
  49901. requestPointerLockOnFullScreen: boolean;
  49902. /**
  49903. * If asking to force XR, this will be populated with the default xr experience
  49904. */
  49905. xr: WebXRDefaultExperience;
  49906. /**
  49907. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49908. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49909. */
  49910. xrTestDone: boolean;
  49911. /**
  49912. * Instantiates a VRExperienceHelper.
  49913. * Helps to quickly add VR support to an existing scene.
  49914. * @param scene The scene the VRExperienceHelper belongs to.
  49915. * @param webVROptions Options to modify the vr experience helper's behavior.
  49916. */
  49917. constructor(scene: Scene,
  49918. /** Options to modify the vr experience helper's behavior. */
  49919. webVROptions?: VRExperienceHelperOptions);
  49920. private completeVRInit;
  49921. private _onDefaultMeshLoaded;
  49922. private _onResize;
  49923. private _onFullscreenChange;
  49924. /**
  49925. * Gets a value indicating if we are currently in VR mode.
  49926. */
  49927. get isInVRMode(): boolean;
  49928. private onVrDisplayPresentChange;
  49929. private onVRDisplayChanged;
  49930. private moveButtonToBottomRight;
  49931. private displayVRButton;
  49932. private updateButtonVisibility;
  49933. private _cachedAngularSensibility;
  49934. /**
  49935. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49936. * Otherwise, will use the fullscreen API.
  49937. */
  49938. enterVR(): void;
  49939. /**
  49940. * Attempt to exit VR, or fullscreen.
  49941. */
  49942. exitVR(): void;
  49943. /**
  49944. * The position of the vr experience helper.
  49945. */
  49946. get position(): Vector3;
  49947. /**
  49948. * Sets the position of the vr experience helper.
  49949. */
  49950. set position(value: Vector3);
  49951. /**
  49952. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49953. */
  49954. enableInteractions(): void;
  49955. private get _noControllerIsActive();
  49956. private beforeRender;
  49957. private _isTeleportationFloor;
  49958. /**
  49959. * Adds a floor mesh to be used for teleportation.
  49960. * @param floorMesh the mesh to be used for teleportation.
  49961. */
  49962. addFloorMesh(floorMesh: Mesh): void;
  49963. /**
  49964. * Removes a floor mesh from being used for teleportation.
  49965. * @param floorMesh the mesh to be removed.
  49966. */
  49967. removeFloorMesh(floorMesh: Mesh): void;
  49968. /**
  49969. * Enables interactions and teleportation using the VR controllers and gaze.
  49970. * @param vrTeleportationOptions options to modify teleportation behavior.
  49971. */
  49972. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49973. private _onNewGamepadConnected;
  49974. private _tryEnableInteractionOnController;
  49975. private _onNewGamepadDisconnected;
  49976. private _enableInteractionOnController;
  49977. private _checkTeleportWithRay;
  49978. private _checkRotate;
  49979. private _checkTeleportBackwards;
  49980. private _enableTeleportationOnController;
  49981. private _createTeleportationCircles;
  49982. private _displayTeleportationTarget;
  49983. private _hideTeleportationTarget;
  49984. private _rotateCamera;
  49985. private _moveTeleportationSelectorTo;
  49986. private _workingVector;
  49987. private _workingQuaternion;
  49988. private _workingMatrix;
  49989. /**
  49990. * Time Constant Teleportation Mode
  49991. */
  49992. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49993. /**
  49994. * Speed Constant Teleportation Mode
  49995. */
  49996. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49997. /**
  49998. * Teleports the users feet to the desired location
  49999. * @param location The location where the user's feet should be placed
  50000. */
  50001. teleportCamera(location: Vector3): void;
  50002. private _convertNormalToDirectionOfRay;
  50003. private _castRayAndSelectObject;
  50004. private _notifySelectedMeshUnselected;
  50005. /**
  50006. * Permanently set new colors for the laser pointer
  50007. * @param color the new laser color
  50008. * @param pickedColor the new laser color when picked mesh detected
  50009. */
  50010. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50011. /**
  50012. * Set lighting enabled / disabled on the laser pointer of both controllers
  50013. * @param enabled should the lighting be enabled on the laser pointer
  50014. */
  50015. setLaserLightingState(enabled?: boolean): void;
  50016. /**
  50017. * Permanently set new colors for the gaze pointer
  50018. * @param color the new gaze color
  50019. * @param pickedColor the new gaze color when picked mesh detected
  50020. */
  50021. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50022. /**
  50023. * Sets the color of the laser ray from the vr controllers.
  50024. * @param color new color for the ray.
  50025. */
  50026. changeLaserColor(color: Color3): void;
  50027. /**
  50028. * Sets the color of the ray from the vr headsets gaze.
  50029. * @param color new color for the ray.
  50030. */
  50031. changeGazeColor(color: Color3): void;
  50032. /**
  50033. * Exits VR and disposes of the vr experience helper
  50034. */
  50035. dispose(): void;
  50036. /**
  50037. * Gets the name of the VRExperienceHelper class
  50038. * @returns "VRExperienceHelper"
  50039. */
  50040. getClassName(): string;
  50041. }
  50042. }
  50043. declare module BABYLON {
  50044. /**
  50045. * Contains an array of blocks representing the octree
  50046. */
  50047. export interface IOctreeContainer<T> {
  50048. /**
  50049. * Blocks within the octree
  50050. */
  50051. blocks: Array<OctreeBlock<T>>;
  50052. }
  50053. /**
  50054. * Class used to store a cell in an octree
  50055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50056. */
  50057. export class OctreeBlock<T> {
  50058. /**
  50059. * Gets the content of the current block
  50060. */
  50061. entries: T[];
  50062. /**
  50063. * Gets the list of block children
  50064. */
  50065. blocks: Array<OctreeBlock<T>>;
  50066. private _depth;
  50067. private _maxDepth;
  50068. private _capacity;
  50069. private _minPoint;
  50070. private _maxPoint;
  50071. private _boundingVectors;
  50072. private _creationFunc;
  50073. /**
  50074. * Creates a new block
  50075. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50076. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50077. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50078. * @param depth defines the current depth of this block in the octree
  50079. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50080. * @param creationFunc defines a callback to call when an element is added to the block
  50081. */
  50082. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50083. /**
  50084. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50085. */
  50086. get capacity(): number;
  50087. /**
  50088. * Gets the minimum vector (in world space) of the block's bounding box
  50089. */
  50090. get minPoint(): Vector3;
  50091. /**
  50092. * Gets the maximum vector (in world space) of the block's bounding box
  50093. */
  50094. get maxPoint(): Vector3;
  50095. /**
  50096. * Add a new element to this block
  50097. * @param entry defines the element to add
  50098. */
  50099. addEntry(entry: T): void;
  50100. /**
  50101. * Remove an element from this block
  50102. * @param entry defines the element to remove
  50103. */
  50104. removeEntry(entry: T): void;
  50105. /**
  50106. * Add an array of elements to this block
  50107. * @param entries defines the array of elements to add
  50108. */
  50109. addEntries(entries: T[]): void;
  50110. /**
  50111. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50112. * @param frustumPlanes defines the frustum planes to test
  50113. * @param selection defines the array to store current content if selection is positive
  50114. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50115. */
  50116. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50117. /**
  50118. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50119. * @param sphereCenter defines the bounding sphere center
  50120. * @param sphereRadius defines the bounding sphere radius
  50121. * @param selection defines the array to store current content if selection is positive
  50122. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50123. */
  50124. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50125. /**
  50126. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50127. * @param ray defines the ray to test with
  50128. * @param selection defines the array to store current content if selection is positive
  50129. */
  50130. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50131. /**
  50132. * Subdivide the content into child blocks (this block will then be empty)
  50133. */
  50134. createInnerBlocks(): void;
  50135. /**
  50136. * @hidden
  50137. */
  50138. 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;
  50139. }
  50140. }
  50141. declare module BABYLON {
  50142. /**
  50143. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50144. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50145. */
  50146. export class Octree<T> {
  50147. /** 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.) */
  50148. maxDepth: number;
  50149. /**
  50150. * Blocks within the octree containing objects
  50151. */
  50152. blocks: Array<OctreeBlock<T>>;
  50153. /**
  50154. * Content stored in the octree
  50155. */
  50156. dynamicContent: T[];
  50157. private _maxBlockCapacity;
  50158. private _selectionContent;
  50159. private _creationFunc;
  50160. /**
  50161. * Creates a octree
  50162. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50163. * @param creationFunc function to be used to instatiate the octree
  50164. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50165. * @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.)
  50166. */
  50167. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50168. /** 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.) */
  50169. maxDepth?: number);
  50170. /**
  50171. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50172. * @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);
  50173. * @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);
  50174. * @param entries meshes to be added to the octree blocks
  50175. */
  50176. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50177. /**
  50178. * Adds a mesh to the octree
  50179. * @param entry Mesh to add to the octree
  50180. */
  50181. addMesh(entry: T): void;
  50182. /**
  50183. * Remove an element from the octree
  50184. * @param entry defines the element to remove
  50185. */
  50186. removeMesh(entry: T): void;
  50187. /**
  50188. * Selects an array of meshes within the frustum
  50189. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50190. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50191. * @returns array of meshes within the frustum
  50192. */
  50193. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50194. /**
  50195. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50196. * @param sphereCenter defines the bounding sphere center
  50197. * @param sphereRadius defines the bounding sphere radius
  50198. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50199. * @returns an array of objects that intersect the sphere
  50200. */
  50201. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50202. /**
  50203. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50204. * @param ray defines the ray to test with
  50205. * @returns array of intersected objects
  50206. */
  50207. intersectsRay(ray: Ray): SmartArray<T>;
  50208. /**
  50209. * Adds a mesh into the octree block if it intersects the block
  50210. */
  50211. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50212. /**
  50213. * Adds a submesh into the octree block if it intersects the block
  50214. */
  50215. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50216. }
  50217. }
  50218. declare module BABYLON {
  50219. interface Scene {
  50220. /**
  50221. * @hidden
  50222. * Backing Filed
  50223. */
  50224. _selectionOctree: Octree<AbstractMesh>;
  50225. /**
  50226. * Gets the octree used to boost mesh selection (picking)
  50227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50228. */
  50229. selectionOctree: Octree<AbstractMesh>;
  50230. /**
  50231. * Creates or updates the octree used to boost selection (picking)
  50232. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50233. * @param maxCapacity defines the maximum capacity per leaf
  50234. * @param maxDepth defines the maximum depth of the octree
  50235. * @returns an octree of AbstractMesh
  50236. */
  50237. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50238. }
  50239. interface AbstractMesh {
  50240. /**
  50241. * @hidden
  50242. * Backing Field
  50243. */
  50244. _submeshesOctree: Octree<SubMesh>;
  50245. /**
  50246. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50247. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50248. * @param maxCapacity defines the maximum size of each block (64 by default)
  50249. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50250. * @returns the new octree
  50251. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50253. */
  50254. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50255. }
  50256. /**
  50257. * Defines the octree scene component responsible to manage any octrees
  50258. * in a given scene.
  50259. */
  50260. export class OctreeSceneComponent {
  50261. /**
  50262. * The component name help to identify the component in the list of scene components.
  50263. */
  50264. readonly name: string;
  50265. /**
  50266. * The scene the component belongs to.
  50267. */
  50268. scene: Scene;
  50269. /**
  50270. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50271. */
  50272. readonly checksIsEnabled: boolean;
  50273. /**
  50274. * Creates a new instance of the component for the given scene
  50275. * @param scene Defines the scene to register the component in
  50276. */
  50277. constructor(scene: Scene);
  50278. /**
  50279. * Registers the component in a given scene
  50280. */
  50281. register(): void;
  50282. /**
  50283. * Return the list of active meshes
  50284. * @returns the list of active meshes
  50285. */
  50286. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50287. /**
  50288. * Return the list of active sub meshes
  50289. * @param mesh The mesh to get the candidates sub meshes from
  50290. * @returns the list of active sub meshes
  50291. */
  50292. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50293. private _tempRay;
  50294. /**
  50295. * Return the list of sub meshes intersecting with a given local ray
  50296. * @param mesh defines the mesh to find the submesh for
  50297. * @param localRay defines the ray in local space
  50298. * @returns the list of intersecting sub meshes
  50299. */
  50300. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50301. /**
  50302. * Return the list of sub meshes colliding with a collider
  50303. * @param mesh defines the mesh to find the submesh for
  50304. * @param collider defines the collider to evaluate the collision against
  50305. * @returns the list of colliding sub meshes
  50306. */
  50307. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50308. /**
  50309. * Rebuilds the elements related to this component in case of
  50310. * context lost for instance.
  50311. */
  50312. rebuild(): void;
  50313. /**
  50314. * Disposes the component and the associated ressources.
  50315. */
  50316. dispose(): void;
  50317. }
  50318. }
  50319. declare module BABYLON {
  50320. /**
  50321. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50322. */
  50323. export class Gizmo implements IDisposable {
  50324. /** The utility layer the gizmo will be added to */
  50325. gizmoLayer: UtilityLayerRenderer;
  50326. /**
  50327. * The root mesh of the gizmo
  50328. */
  50329. _rootMesh: Mesh;
  50330. private _attachedMesh;
  50331. private _attachedNode;
  50332. /**
  50333. * Ratio for the scale of the gizmo (Default: 1)
  50334. */
  50335. protected _scaleRatio: number;
  50336. /**
  50337. * Ratio for the scale of the gizmo (Default: 1)
  50338. */
  50339. set scaleRatio(value: number);
  50340. get scaleRatio(): number;
  50341. /**
  50342. * If a custom mesh has been set (Default: false)
  50343. */
  50344. protected _customMeshSet: boolean;
  50345. /**
  50346. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50347. * * When set, interactions will be enabled
  50348. */
  50349. get attachedMesh(): Nullable<AbstractMesh>;
  50350. set attachedMesh(value: Nullable<AbstractMesh>);
  50351. /**
  50352. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50353. * * When set, interactions will be enabled
  50354. */
  50355. get attachedNode(): Nullable<Node>;
  50356. set attachedNode(value: Nullable<Node>);
  50357. /**
  50358. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50359. * @param mesh The mesh to replace the default mesh of the gizmo
  50360. */
  50361. setCustomMesh(mesh: Mesh): void;
  50362. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50363. /**
  50364. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50365. */
  50366. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50367. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50368. /**
  50369. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50370. */
  50371. updateGizmoPositionToMatchAttachedMesh: boolean;
  50372. /**
  50373. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50374. */
  50375. updateScale: boolean;
  50376. protected _interactionsEnabled: boolean;
  50377. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50378. private _beforeRenderObserver;
  50379. private _tempQuaternion;
  50380. private _tempVector;
  50381. private _tempVector2;
  50382. private _tempMatrix1;
  50383. private _tempMatrix2;
  50384. private _rightHandtoLeftHandMatrix;
  50385. /**
  50386. * Creates a gizmo
  50387. * @param gizmoLayer The utility layer the gizmo will be added to
  50388. */
  50389. constructor(
  50390. /** The utility layer the gizmo will be added to */
  50391. gizmoLayer?: UtilityLayerRenderer);
  50392. /**
  50393. * Updates the gizmo to match the attached mesh's position/rotation
  50394. */
  50395. protected _update(): void;
  50396. /**
  50397. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50398. * @param value Node, TransformNode or mesh
  50399. */
  50400. protected _matrixChanged(): void;
  50401. /**
  50402. * Disposes of the gizmo
  50403. */
  50404. dispose(): void;
  50405. }
  50406. }
  50407. declare module BABYLON {
  50408. /**
  50409. * Single plane drag gizmo
  50410. */
  50411. export class PlaneDragGizmo extends Gizmo {
  50412. /**
  50413. * Drag behavior responsible for the gizmos dragging interactions
  50414. */
  50415. dragBehavior: PointerDragBehavior;
  50416. private _pointerObserver;
  50417. /**
  50418. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50419. */
  50420. snapDistance: number;
  50421. /**
  50422. * Event that fires each time the gizmo snaps to a new location.
  50423. * * snapDistance is the the change in distance
  50424. */
  50425. onSnapObservable: Observable<{
  50426. snapDistance: number;
  50427. }>;
  50428. private _plane;
  50429. private _coloredMaterial;
  50430. private _hoverMaterial;
  50431. private _isEnabled;
  50432. private _parent;
  50433. /** @hidden */
  50434. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50435. /** @hidden */
  50436. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50437. /**
  50438. * Creates a PlaneDragGizmo
  50439. * @param gizmoLayer The utility layer the gizmo will be added to
  50440. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50441. * @param color The color of the gizmo
  50442. */
  50443. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50444. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50445. /**
  50446. * If the gizmo is enabled
  50447. */
  50448. set isEnabled(value: boolean);
  50449. get isEnabled(): boolean;
  50450. /**
  50451. * Disposes of the gizmo
  50452. */
  50453. dispose(): void;
  50454. }
  50455. }
  50456. declare module BABYLON {
  50457. /**
  50458. * Gizmo that enables dragging a mesh along 3 axis
  50459. */
  50460. export class PositionGizmo extends Gizmo {
  50461. /**
  50462. * Internal gizmo used for interactions on the x axis
  50463. */
  50464. xGizmo: AxisDragGizmo;
  50465. /**
  50466. * Internal gizmo used for interactions on the y axis
  50467. */
  50468. yGizmo: AxisDragGizmo;
  50469. /**
  50470. * Internal gizmo used for interactions on the z axis
  50471. */
  50472. zGizmo: AxisDragGizmo;
  50473. /**
  50474. * Internal gizmo used for interactions on the yz plane
  50475. */
  50476. xPlaneGizmo: PlaneDragGizmo;
  50477. /**
  50478. * Internal gizmo used for interactions on the xz plane
  50479. */
  50480. yPlaneGizmo: PlaneDragGizmo;
  50481. /**
  50482. * Internal gizmo used for interactions on the xy plane
  50483. */
  50484. zPlaneGizmo: PlaneDragGizmo;
  50485. /**
  50486. * private variables
  50487. */
  50488. private _meshAttached;
  50489. private _nodeAttached;
  50490. private _snapDistance;
  50491. /** Fires an event when any of it's sub gizmos are dragged */
  50492. onDragStartObservable: Observable<unknown>;
  50493. /** Fires an event when any of it's sub gizmos are released from dragging */
  50494. onDragEndObservable: Observable<unknown>;
  50495. /**
  50496. * If set to true, planar drag is enabled
  50497. */
  50498. private _planarGizmoEnabled;
  50499. get attachedMesh(): Nullable<AbstractMesh>;
  50500. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50501. get attachedNode(): Nullable<Node>;
  50502. set attachedNode(node: Nullable<Node>);
  50503. /**
  50504. * Creates a PositionGizmo
  50505. * @param gizmoLayer The utility layer the gizmo will be added to
  50506. @param thickness display gizmo axis thickness
  50507. */
  50508. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50509. /**
  50510. * If the planar drag gizmo is enabled
  50511. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50512. */
  50513. set planarGizmoEnabled(value: boolean);
  50514. get planarGizmoEnabled(): boolean;
  50515. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50516. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50517. /**
  50518. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50519. */
  50520. set snapDistance(value: number);
  50521. get snapDistance(): number;
  50522. /**
  50523. * Ratio for the scale of the gizmo (Default: 1)
  50524. */
  50525. set scaleRatio(value: number);
  50526. get scaleRatio(): number;
  50527. /**
  50528. * Disposes of the gizmo
  50529. */
  50530. dispose(): void;
  50531. /**
  50532. * CustomMeshes are not supported by this gizmo
  50533. * @param mesh The mesh to replace the default mesh of the gizmo
  50534. */
  50535. setCustomMesh(mesh: Mesh): void;
  50536. }
  50537. }
  50538. declare module BABYLON {
  50539. /**
  50540. * Single axis drag gizmo
  50541. */
  50542. export class AxisDragGizmo extends Gizmo {
  50543. /**
  50544. * Drag behavior responsible for the gizmos dragging interactions
  50545. */
  50546. dragBehavior: PointerDragBehavior;
  50547. private _pointerObserver;
  50548. /**
  50549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50550. */
  50551. snapDistance: number;
  50552. /**
  50553. * Event that fires each time the gizmo snaps to a new location.
  50554. * * snapDistance is the the change in distance
  50555. */
  50556. onSnapObservable: Observable<{
  50557. snapDistance: number;
  50558. }>;
  50559. private _isEnabled;
  50560. private _parent;
  50561. private _arrow;
  50562. private _coloredMaterial;
  50563. private _hoverMaterial;
  50564. /** @hidden */
  50565. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50566. /** @hidden */
  50567. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50568. /**
  50569. * Creates an AxisDragGizmo
  50570. * @param gizmoLayer The utility layer the gizmo will be added to
  50571. * @param dragAxis The axis which the gizmo will be able to drag on
  50572. * @param color The color of the gizmo
  50573. * @param thickness display gizmo axis thickness
  50574. */
  50575. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50576. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50577. /**
  50578. * If the gizmo is enabled
  50579. */
  50580. set isEnabled(value: boolean);
  50581. get isEnabled(): boolean;
  50582. /**
  50583. * Disposes of the gizmo
  50584. */
  50585. dispose(): void;
  50586. }
  50587. }
  50588. declare module BABYLON.Debug {
  50589. /**
  50590. * The Axes viewer will show 3 axes in a specific point in space
  50591. */
  50592. export class AxesViewer {
  50593. private _xAxis;
  50594. private _yAxis;
  50595. private _zAxis;
  50596. private _scaleLinesFactor;
  50597. private _instanced;
  50598. /**
  50599. * Gets the hosting scene
  50600. */
  50601. scene: Nullable<Scene>;
  50602. /**
  50603. * Gets or sets a number used to scale line length
  50604. */
  50605. scaleLines: number;
  50606. /** Gets the node hierarchy used to render x-axis */
  50607. get xAxis(): TransformNode;
  50608. /** Gets the node hierarchy used to render y-axis */
  50609. get yAxis(): TransformNode;
  50610. /** Gets the node hierarchy used to render z-axis */
  50611. get zAxis(): TransformNode;
  50612. /**
  50613. * Creates a new AxesViewer
  50614. * @param scene defines the hosting scene
  50615. * @param scaleLines defines a number used to scale line length (1 by default)
  50616. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50617. * @param xAxis defines the node hierarchy used to render the x-axis
  50618. * @param yAxis defines the node hierarchy used to render the y-axis
  50619. * @param zAxis defines the node hierarchy used to render the z-axis
  50620. */
  50621. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50622. /**
  50623. * Force the viewer to update
  50624. * @param position defines the position of the viewer
  50625. * @param xaxis defines the x axis of the viewer
  50626. * @param yaxis defines the y axis of the viewer
  50627. * @param zaxis defines the z axis of the viewer
  50628. */
  50629. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50630. /**
  50631. * Creates an instance of this axes viewer.
  50632. * @returns a new axes viewer with instanced meshes
  50633. */
  50634. createInstance(): AxesViewer;
  50635. /** Releases resources */
  50636. dispose(): void;
  50637. private static _SetRenderingGroupId;
  50638. }
  50639. }
  50640. declare module BABYLON.Debug {
  50641. /**
  50642. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50643. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50644. */
  50645. export class BoneAxesViewer extends AxesViewer {
  50646. /**
  50647. * Gets or sets the target mesh where to display the axes viewer
  50648. */
  50649. mesh: Nullable<Mesh>;
  50650. /**
  50651. * Gets or sets the target bone where to display the axes viewer
  50652. */
  50653. bone: Nullable<Bone>;
  50654. /** Gets current position */
  50655. pos: Vector3;
  50656. /** Gets direction of X axis */
  50657. xaxis: Vector3;
  50658. /** Gets direction of Y axis */
  50659. yaxis: Vector3;
  50660. /** Gets direction of Z axis */
  50661. zaxis: Vector3;
  50662. /**
  50663. * Creates a new BoneAxesViewer
  50664. * @param scene defines the hosting scene
  50665. * @param bone defines the target bone
  50666. * @param mesh defines the target mesh
  50667. * @param scaleLines defines a scaling factor for line length (1 by default)
  50668. */
  50669. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50670. /**
  50671. * Force the viewer to update
  50672. */
  50673. update(): void;
  50674. /** Releases resources */
  50675. dispose(): void;
  50676. }
  50677. }
  50678. declare module BABYLON {
  50679. /**
  50680. * Interface used to define scene explorer extensibility option
  50681. */
  50682. export interface IExplorerExtensibilityOption {
  50683. /**
  50684. * Define the option label
  50685. */
  50686. label: string;
  50687. /**
  50688. * Defines the action to execute on click
  50689. */
  50690. action: (entity: any) => void;
  50691. }
  50692. /**
  50693. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50694. */
  50695. export interface IExplorerExtensibilityGroup {
  50696. /**
  50697. * Defines a predicate to test if a given type mut be extended
  50698. */
  50699. predicate: (entity: any) => boolean;
  50700. /**
  50701. * Gets the list of options added to a type
  50702. */
  50703. entries: IExplorerExtensibilityOption[];
  50704. }
  50705. /**
  50706. * Interface used to define the options to use to create the Inspector
  50707. */
  50708. export interface IInspectorOptions {
  50709. /**
  50710. * Display in overlay mode (default: false)
  50711. */
  50712. overlay?: boolean;
  50713. /**
  50714. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50715. */
  50716. globalRoot?: HTMLElement;
  50717. /**
  50718. * Display the Scene explorer
  50719. */
  50720. showExplorer?: boolean;
  50721. /**
  50722. * Display the property inspector
  50723. */
  50724. showInspector?: boolean;
  50725. /**
  50726. * Display in embed mode (both panes on the right)
  50727. */
  50728. embedMode?: boolean;
  50729. /**
  50730. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50731. */
  50732. handleResize?: boolean;
  50733. /**
  50734. * Allow the panes to popup (default: true)
  50735. */
  50736. enablePopup?: boolean;
  50737. /**
  50738. * Allow the panes to be closed by users (default: true)
  50739. */
  50740. enableClose?: boolean;
  50741. /**
  50742. * Optional list of extensibility entries
  50743. */
  50744. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50745. /**
  50746. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50747. */
  50748. inspectorURL?: string;
  50749. /**
  50750. * Optional initial tab (default to DebugLayerTab.Properties)
  50751. */
  50752. initialTab?: DebugLayerTab;
  50753. }
  50754. interface Scene {
  50755. /**
  50756. * @hidden
  50757. * Backing field
  50758. */
  50759. _debugLayer: DebugLayer;
  50760. /**
  50761. * Gets the debug layer (aka Inspector) associated with the scene
  50762. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50763. */
  50764. debugLayer: DebugLayer;
  50765. }
  50766. /**
  50767. * Enum of inspector action tab
  50768. */
  50769. export enum DebugLayerTab {
  50770. /**
  50771. * Properties tag (default)
  50772. */
  50773. Properties = 0,
  50774. /**
  50775. * Debug tab
  50776. */
  50777. Debug = 1,
  50778. /**
  50779. * Statistics tab
  50780. */
  50781. Statistics = 2,
  50782. /**
  50783. * Tools tab
  50784. */
  50785. Tools = 3,
  50786. /**
  50787. * Settings tab
  50788. */
  50789. Settings = 4
  50790. }
  50791. /**
  50792. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50793. * what is happening in your scene
  50794. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50795. */
  50796. export class DebugLayer {
  50797. /**
  50798. * Define the url to get the inspector script from.
  50799. * By default it uses the babylonjs CDN.
  50800. * @ignoreNaming
  50801. */
  50802. static InspectorURL: string;
  50803. private _scene;
  50804. private BJSINSPECTOR;
  50805. private _onPropertyChangedObservable?;
  50806. /**
  50807. * Observable triggered when a property is changed through the inspector.
  50808. */
  50809. get onPropertyChangedObservable(): any;
  50810. /**
  50811. * Instantiates a new debug layer.
  50812. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50813. * what is happening in your scene
  50814. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50815. * @param scene Defines the scene to inspect
  50816. */
  50817. constructor(scene: Scene);
  50818. /** Creates the inspector window. */
  50819. private _createInspector;
  50820. /**
  50821. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50822. * @param entity defines the entity to select
  50823. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50824. */
  50825. select(entity: any, lineContainerTitles?: string | string[]): void;
  50826. /** Get the inspector from bundle or global */
  50827. private _getGlobalInspector;
  50828. /**
  50829. * Get if the inspector is visible or not.
  50830. * @returns true if visible otherwise, false
  50831. */
  50832. isVisible(): boolean;
  50833. /**
  50834. * Hide the inspector and close its window.
  50835. */
  50836. hide(): void;
  50837. /**
  50838. * Update the scene in the inspector
  50839. */
  50840. setAsActiveScene(): void;
  50841. /**
  50842. * Launch the debugLayer.
  50843. * @param config Define the configuration of the inspector
  50844. * @return a promise fulfilled when the debug layer is visible
  50845. */
  50846. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50847. }
  50848. }
  50849. declare module BABYLON {
  50850. /**
  50851. * Class containing static functions to help procedurally build meshes
  50852. */
  50853. export class BoxBuilder {
  50854. /**
  50855. * Creates a box mesh
  50856. * * The parameter `size` sets the size (float) of each box side (default 1)
  50857. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50858. * * 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)
  50859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50861. * * 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
  50862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50863. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50864. * @param name defines the name of the mesh
  50865. * @param options defines the options used to create the mesh
  50866. * @param scene defines the hosting scene
  50867. * @returns the box mesh
  50868. */
  50869. static CreateBox(name: string, options: {
  50870. size?: number;
  50871. width?: number;
  50872. height?: number;
  50873. depth?: number;
  50874. faceUV?: Vector4[];
  50875. faceColors?: Color4[];
  50876. sideOrientation?: number;
  50877. frontUVs?: Vector4;
  50878. backUVs?: Vector4;
  50879. wrap?: boolean;
  50880. topBaseAt?: number;
  50881. bottomBaseAt?: number;
  50882. updatable?: boolean;
  50883. }, scene?: Nullable<Scene>): Mesh;
  50884. }
  50885. }
  50886. declare module BABYLON.Debug {
  50887. /**
  50888. * Used to show the physics impostor around the specific mesh
  50889. */
  50890. export class PhysicsViewer {
  50891. /** @hidden */
  50892. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50893. /** @hidden */
  50894. protected _meshes: Array<Nullable<AbstractMesh>>;
  50895. /** @hidden */
  50896. protected _scene: Nullable<Scene>;
  50897. /** @hidden */
  50898. protected _numMeshes: number;
  50899. /** @hidden */
  50900. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50901. private _renderFunction;
  50902. private _utilityLayer;
  50903. private _debugBoxMesh;
  50904. private _debugSphereMesh;
  50905. private _debugCylinderMesh;
  50906. private _debugMaterial;
  50907. private _debugMeshMeshes;
  50908. /**
  50909. * Creates a new PhysicsViewer
  50910. * @param scene defines the hosting scene
  50911. */
  50912. constructor(scene: Scene);
  50913. /** @hidden */
  50914. protected _updateDebugMeshes(): void;
  50915. /**
  50916. * Renders a specified physic impostor
  50917. * @param impostor defines the impostor to render
  50918. * @param targetMesh defines the mesh represented by the impostor
  50919. * @returns the new debug mesh used to render the impostor
  50920. */
  50921. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50922. /**
  50923. * Hides a specified physic impostor
  50924. * @param impostor defines the impostor to hide
  50925. */
  50926. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50927. private _getDebugMaterial;
  50928. private _getDebugBoxMesh;
  50929. private _getDebugSphereMesh;
  50930. private _getDebugCylinderMesh;
  50931. private _getDebugMeshMesh;
  50932. private _getDebugMesh;
  50933. /** Releases all resources */
  50934. dispose(): void;
  50935. }
  50936. }
  50937. declare module BABYLON {
  50938. /**
  50939. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50940. * in order to better appreciate the issue one might have.
  50941. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50942. */
  50943. export class RayHelper {
  50944. /**
  50945. * Defines the ray we are currently tryin to visualize.
  50946. */
  50947. ray: Nullable<Ray>;
  50948. private _renderPoints;
  50949. private _renderLine;
  50950. private _renderFunction;
  50951. private _scene;
  50952. private _onAfterRenderObserver;
  50953. private _onAfterStepObserver;
  50954. private _attachedToMesh;
  50955. private _meshSpaceDirection;
  50956. private _meshSpaceOrigin;
  50957. /**
  50958. * Helper function to create a colored helper in a scene in one line.
  50959. * @param ray Defines the ray we are currently tryin to visualize
  50960. * @param scene Defines the scene the ray is used in
  50961. * @param color Defines the color we want to see the ray in
  50962. * @returns The newly created ray helper.
  50963. */
  50964. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50965. /**
  50966. * Instantiate a new ray helper.
  50967. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50968. * in order to better appreciate the issue one might have.
  50969. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50970. * @param ray Defines the ray we are currently tryin to visualize
  50971. */
  50972. constructor(ray: Ray);
  50973. /**
  50974. * Shows the ray we are willing to debug.
  50975. * @param scene Defines the scene the ray needs to be rendered in
  50976. * @param color Defines the color the ray needs to be rendered in
  50977. */
  50978. show(scene: Scene, color?: Color3): void;
  50979. /**
  50980. * Hides the ray we are debugging.
  50981. */
  50982. hide(): void;
  50983. private _render;
  50984. /**
  50985. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50986. * @param mesh Defines the mesh we want the helper attached to
  50987. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50988. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50989. * @param length Defines the length of the ray
  50990. */
  50991. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50992. /**
  50993. * Detach the ray helper from the mesh it has previously been attached to.
  50994. */
  50995. detachFromMesh(): void;
  50996. private _updateToMesh;
  50997. /**
  50998. * Dispose the helper and release its associated resources.
  50999. */
  51000. dispose(): void;
  51001. }
  51002. }
  51003. declare module BABYLON {
  51004. /**
  51005. * Defines the options associated with the creation of a SkeletonViewer.
  51006. */
  51007. export interface ISkeletonViewerOptions {
  51008. /** Should the system pause animations before building the Viewer? */
  51009. pauseAnimations: boolean;
  51010. /** Should the system return the skeleton to rest before building? */
  51011. returnToRest: boolean;
  51012. /** public Display Mode of the Viewer */
  51013. displayMode: number;
  51014. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51015. displayOptions: ISkeletonViewerDisplayOptions;
  51016. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51017. computeBonesUsingShaders: boolean;
  51018. /** Flag ignore non weighted bones */
  51019. useAllBones: boolean;
  51020. }
  51021. /**
  51022. * Defines how to display the various bone meshes for the viewer.
  51023. */
  51024. export interface ISkeletonViewerDisplayOptions {
  51025. /** How far down to start tapering the bone spurs */
  51026. midStep?: number;
  51027. /** How big is the midStep? */
  51028. midStepFactor?: number;
  51029. /** Base for the Sphere Size */
  51030. sphereBaseSize?: number;
  51031. /** The ratio of the sphere to the longest bone in units */
  51032. sphereScaleUnit?: number;
  51033. /** Ratio for the Sphere Size */
  51034. sphereFactor?: number;
  51035. }
  51036. /**
  51037. * Defines the constructor options for the BoneWeight Shader.
  51038. */
  51039. export interface IBoneWeightShaderOptions {
  51040. /** Skeleton to Map */
  51041. skeleton: Skeleton;
  51042. /** Colors for Uninfluenced bones */
  51043. colorBase?: Color3;
  51044. /** Colors for 0.0-0.25 Weight bones */
  51045. colorZero?: Color3;
  51046. /** Color for 0.25-0.5 Weight Influence */
  51047. colorQuarter?: Color3;
  51048. /** Color for 0.5-0.75 Weight Influence */
  51049. colorHalf?: Color3;
  51050. /** Color for 0.75-1 Weight Influence */
  51051. colorFull?: Color3;
  51052. /** Color for Zero Weight Influence */
  51053. targetBoneIndex?: number;
  51054. }
  51055. /**
  51056. * Simple structure of the gradient steps for the Color Map.
  51057. */
  51058. export interface ISkeletonMapShaderColorMapKnot {
  51059. /** Color of the Knot */
  51060. color: Color3;
  51061. /** Location of the Knot */
  51062. location: number;
  51063. }
  51064. /**
  51065. * Defines the constructor options for the SkeletonMap Shader.
  51066. */
  51067. export interface ISkeletonMapShaderOptions {
  51068. /** Skeleton to Map */
  51069. skeleton: Skeleton;
  51070. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51071. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51072. }
  51073. }
  51074. declare module BABYLON {
  51075. /**
  51076. * Class containing static functions to help procedurally build meshes
  51077. */
  51078. export class RibbonBuilder {
  51079. /**
  51080. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51081. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51082. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51083. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51084. * * 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
  51085. * * 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
  51086. * * 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
  51087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51088. * * 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
  51089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51090. * * 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
  51091. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51092. * * 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
  51093. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51095. * @param name defines the name of the mesh
  51096. * @param options defines the options used to create the mesh
  51097. * @param scene defines the hosting scene
  51098. * @returns the ribbon mesh
  51099. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51100. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51101. */
  51102. static CreateRibbon(name: string, options: {
  51103. pathArray: Vector3[][];
  51104. closeArray?: boolean;
  51105. closePath?: boolean;
  51106. offset?: number;
  51107. updatable?: boolean;
  51108. sideOrientation?: number;
  51109. frontUVs?: Vector4;
  51110. backUVs?: Vector4;
  51111. instance?: Mesh;
  51112. invertUV?: boolean;
  51113. uvs?: Vector2[];
  51114. colors?: Color4[];
  51115. }, scene?: Nullable<Scene>): Mesh;
  51116. }
  51117. }
  51118. declare module BABYLON {
  51119. /**
  51120. * Class containing static functions to help procedurally build meshes
  51121. */
  51122. export class ShapeBuilder {
  51123. /**
  51124. * 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.
  51125. * * 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.
  51126. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51127. * * 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.
  51128. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51129. * * 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
  51130. * * 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
  51131. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51133. * * 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
  51134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51136. * @param name defines the name of the mesh
  51137. * @param options defines the options used to create the mesh
  51138. * @param scene defines the hosting scene
  51139. * @returns the extruded shape mesh
  51140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51142. */
  51143. static ExtrudeShape(name: string, options: {
  51144. shape: Vector3[];
  51145. path: Vector3[];
  51146. scale?: number;
  51147. rotation?: number;
  51148. cap?: number;
  51149. updatable?: boolean;
  51150. sideOrientation?: number;
  51151. frontUVs?: Vector4;
  51152. backUVs?: Vector4;
  51153. instance?: Mesh;
  51154. invertUV?: boolean;
  51155. }, scene?: Nullable<Scene>): Mesh;
  51156. /**
  51157. * Creates an custom extruded shape mesh.
  51158. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51159. * * 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.
  51160. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51161. * * 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
  51162. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51163. * * 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
  51164. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51165. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51166. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51167. * * 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
  51168. * * 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
  51169. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51171. * * 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
  51172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51174. * @param name defines the name of the mesh
  51175. * @param options defines the options used to create the mesh
  51176. * @param scene defines the hosting scene
  51177. * @returns the custom extruded shape mesh
  51178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51181. */
  51182. static ExtrudeShapeCustom(name: string, options: {
  51183. shape: Vector3[];
  51184. path: Vector3[];
  51185. scaleFunction?: any;
  51186. rotationFunction?: any;
  51187. ribbonCloseArray?: boolean;
  51188. ribbonClosePath?: boolean;
  51189. cap?: number;
  51190. updatable?: boolean;
  51191. sideOrientation?: number;
  51192. frontUVs?: Vector4;
  51193. backUVs?: Vector4;
  51194. instance?: Mesh;
  51195. invertUV?: boolean;
  51196. }, scene?: Nullable<Scene>): Mesh;
  51197. private static _ExtrudeShapeGeneric;
  51198. }
  51199. }
  51200. declare module BABYLON.Debug {
  51201. /**
  51202. * Class used to render a debug view of a given skeleton
  51203. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51204. */
  51205. export class SkeletonViewer {
  51206. /** defines the skeleton to render */
  51207. skeleton: Skeleton;
  51208. /** defines the mesh attached to the skeleton */
  51209. mesh: AbstractMesh;
  51210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51211. autoUpdateBonesMatrices: boolean;
  51212. /** defines the rendering group id to use with the viewer */
  51213. renderingGroupId: number;
  51214. /** is the options for the viewer */
  51215. options: Partial<ISkeletonViewerOptions>;
  51216. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51217. static readonly DISPLAY_LINES: number;
  51218. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51219. static readonly DISPLAY_SPHERES: number;
  51220. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51221. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51222. /** public static method to create a BoneWeight Shader
  51223. * @param options The constructor options
  51224. * @param scene The scene that the shader is scoped to
  51225. * @returns The created ShaderMaterial
  51226. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51227. */
  51228. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51229. /** public static method to create a BoneWeight Shader
  51230. * @param options The constructor options
  51231. * @param scene The scene that the shader is scoped to
  51232. * @returns The created ShaderMaterial
  51233. */
  51234. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51235. /** private static method to create a BoneWeight Shader
  51236. * @param size The size of the buffer to create (usually the bone count)
  51237. * @param colorMap The gradient data to generate
  51238. * @param scene The scene that the shader is scoped to
  51239. * @returns an Array of floats from the color gradient values
  51240. */
  51241. private static _CreateBoneMapColorBuffer;
  51242. /** If SkeletonViewer scene scope. */
  51243. private _scene;
  51244. /** Gets or sets the color used to render the skeleton */
  51245. color: Color3;
  51246. /** Array of the points of the skeleton fo the line view. */
  51247. private _debugLines;
  51248. /** The SkeletonViewers Mesh. */
  51249. private _debugMesh;
  51250. /** If SkeletonViewer is enabled. */
  51251. private _isEnabled;
  51252. /** If SkeletonViewer is ready. */
  51253. private _ready;
  51254. /** SkeletonViewer render observable. */
  51255. private _obs;
  51256. /** The Utility Layer to render the gizmos in. */
  51257. private _utilityLayer;
  51258. private _boneIndices;
  51259. /** Gets the Scene. */
  51260. get scene(): Scene;
  51261. /** Gets the utilityLayer. */
  51262. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51263. /** Checks Ready Status. */
  51264. get isReady(): Boolean;
  51265. /** Sets Ready Status. */
  51266. set ready(value: boolean);
  51267. /** Gets the debugMesh */
  51268. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51269. /** Sets the debugMesh */
  51270. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51271. /** Gets the material */
  51272. get material(): StandardMaterial;
  51273. /** Sets the material */
  51274. set material(value: StandardMaterial);
  51275. /** Gets the material */
  51276. get displayMode(): number;
  51277. /** Sets the material */
  51278. set displayMode(value: number);
  51279. /**
  51280. * Creates a new SkeletonViewer
  51281. * @param skeleton defines the skeleton to render
  51282. * @param mesh defines the mesh attached to the skeleton
  51283. * @param scene defines the hosting scene
  51284. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51285. * @param renderingGroupId defines the rendering group id to use with the viewer
  51286. * @param options All of the extra constructor options for the SkeletonViewer
  51287. */
  51288. constructor(
  51289. /** defines the skeleton to render */
  51290. skeleton: Skeleton,
  51291. /** defines the mesh attached to the skeleton */
  51292. mesh: AbstractMesh,
  51293. /** The Scene scope*/
  51294. scene: Scene,
  51295. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51296. autoUpdateBonesMatrices?: boolean,
  51297. /** defines the rendering group id to use with the viewer */
  51298. renderingGroupId?: number,
  51299. /** is the options for the viewer */
  51300. options?: Partial<ISkeletonViewerOptions>);
  51301. /** The Dynamic bindings for the update functions */
  51302. private _bindObs;
  51303. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51304. update(): void;
  51305. /** Gets or sets a boolean indicating if the viewer is enabled */
  51306. set isEnabled(value: boolean);
  51307. get isEnabled(): boolean;
  51308. private _getBonePosition;
  51309. private _getLinesForBonesWithLength;
  51310. private _getLinesForBonesNoLength;
  51311. /** function to revert the mesh and scene back to the initial state. */
  51312. private _revert;
  51313. /** function to build and bind sphere joint points and spur bone representations. */
  51314. private _buildSpheresAndSpurs;
  51315. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51316. private _displayLinesUpdate;
  51317. /** Changes the displayMode of the skeleton viewer
  51318. * @param mode The displayMode numerical value
  51319. */
  51320. changeDisplayMode(mode: number): void;
  51321. /** Changes the displayMode of the skeleton viewer
  51322. * @param option String of the option name
  51323. * @param value The numerical option value
  51324. */
  51325. changeDisplayOptions(option: string, value: number): void;
  51326. /** Release associated resources */
  51327. dispose(): void;
  51328. }
  51329. }
  51330. declare module BABYLON {
  51331. /**
  51332. * Enum for Device Types
  51333. */
  51334. export enum DeviceType {
  51335. /** Generic */
  51336. Generic = 0,
  51337. /** Keyboard */
  51338. Keyboard = 1,
  51339. /** Mouse */
  51340. Mouse = 2,
  51341. /** Touch Pointers */
  51342. Touch = 3,
  51343. /** PS4 Dual Shock */
  51344. DualShock = 4,
  51345. /** Xbox */
  51346. Xbox = 5,
  51347. /** Switch Controller */
  51348. Switch = 6
  51349. }
  51350. /**
  51351. * Enum for All Pointers (Touch/Mouse)
  51352. */
  51353. export enum PointerInput {
  51354. /** Horizontal Axis */
  51355. Horizontal = 0,
  51356. /** Vertical Axis */
  51357. Vertical = 1,
  51358. /** Left Click or Touch */
  51359. LeftClick = 2,
  51360. /** Middle Click */
  51361. MiddleClick = 3,
  51362. /** Right Click */
  51363. RightClick = 4,
  51364. /** Browser Back */
  51365. BrowserBack = 5,
  51366. /** Browser Forward */
  51367. BrowserForward = 6
  51368. }
  51369. /**
  51370. * Enum for Dual Shock Gamepad
  51371. */
  51372. export enum DualShockInput {
  51373. /** Cross */
  51374. Cross = 0,
  51375. /** Circle */
  51376. Circle = 1,
  51377. /** Square */
  51378. Square = 2,
  51379. /** Triangle */
  51380. Triangle = 3,
  51381. /** L1 */
  51382. L1 = 4,
  51383. /** R1 */
  51384. R1 = 5,
  51385. /** L2 */
  51386. L2 = 6,
  51387. /** R2 */
  51388. R2 = 7,
  51389. /** Share */
  51390. Share = 8,
  51391. /** Options */
  51392. Options = 9,
  51393. /** L3 */
  51394. L3 = 10,
  51395. /** R3 */
  51396. R3 = 11,
  51397. /** DPadUp */
  51398. DPadUp = 12,
  51399. /** DPadDown */
  51400. DPadDown = 13,
  51401. /** DPadLeft */
  51402. DPadLeft = 14,
  51403. /** DRight */
  51404. DPadRight = 15,
  51405. /** Home */
  51406. Home = 16,
  51407. /** TouchPad */
  51408. TouchPad = 17,
  51409. /** LStickXAxis */
  51410. LStickXAxis = 18,
  51411. /** LStickYAxis */
  51412. LStickYAxis = 19,
  51413. /** RStickXAxis */
  51414. RStickXAxis = 20,
  51415. /** RStickYAxis */
  51416. RStickYAxis = 21
  51417. }
  51418. /**
  51419. * Enum for Xbox Gamepad
  51420. */
  51421. export enum XboxInput {
  51422. /** A */
  51423. A = 0,
  51424. /** B */
  51425. B = 1,
  51426. /** X */
  51427. X = 2,
  51428. /** Y */
  51429. Y = 3,
  51430. /** LB */
  51431. LB = 4,
  51432. /** RB */
  51433. RB = 5,
  51434. /** LT */
  51435. LT = 6,
  51436. /** RT */
  51437. RT = 7,
  51438. /** Back */
  51439. Back = 8,
  51440. /** Start */
  51441. Start = 9,
  51442. /** LS */
  51443. LS = 10,
  51444. /** RS */
  51445. RS = 11,
  51446. /** DPadUp */
  51447. DPadUp = 12,
  51448. /** DPadDown */
  51449. DPadDown = 13,
  51450. /** DPadLeft */
  51451. DPadLeft = 14,
  51452. /** DRight */
  51453. DPadRight = 15,
  51454. /** Home */
  51455. Home = 16,
  51456. /** LStickXAxis */
  51457. LStickXAxis = 17,
  51458. /** LStickYAxis */
  51459. LStickYAxis = 18,
  51460. /** RStickXAxis */
  51461. RStickXAxis = 19,
  51462. /** RStickYAxis */
  51463. RStickYAxis = 20
  51464. }
  51465. /**
  51466. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51467. */
  51468. export enum SwitchInput {
  51469. /** B */
  51470. B = 0,
  51471. /** A */
  51472. A = 1,
  51473. /** Y */
  51474. Y = 2,
  51475. /** X */
  51476. X = 3,
  51477. /** L */
  51478. L = 4,
  51479. /** R */
  51480. R = 5,
  51481. /** ZL */
  51482. ZL = 6,
  51483. /** ZR */
  51484. ZR = 7,
  51485. /** Minus */
  51486. Minus = 8,
  51487. /** Plus */
  51488. Plus = 9,
  51489. /** LS */
  51490. LS = 10,
  51491. /** RS */
  51492. RS = 11,
  51493. /** DPadUp */
  51494. DPadUp = 12,
  51495. /** DPadDown */
  51496. DPadDown = 13,
  51497. /** DPadLeft */
  51498. DPadLeft = 14,
  51499. /** DRight */
  51500. DPadRight = 15,
  51501. /** Home */
  51502. Home = 16,
  51503. /** Capture */
  51504. Capture = 17,
  51505. /** LStickXAxis */
  51506. LStickXAxis = 18,
  51507. /** LStickYAxis */
  51508. LStickYAxis = 19,
  51509. /** RStickXAxis */
  51510. RStickXAxis = 20,
  51511. /** RStickYAxis */
  51512. RStickYAxis = 21
  51513. }
  51514. }
  51515. declare module BABYLON {
  51516. /**
  51517. * This class will take all inputs from Keyboard, Pointer, and
  51518. * any Gamepads and provide a polling system that all devices
  51519. * will use. This class assumes that there will only be one
  51520. * pointer device and one keyboard.
  51521. */
  51522. export class DeviceInputSystem implements IDisposable {
  51523. /**
  51524. * Callback to be triggered when a device is connected
  51525. */
  51526. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51527. /**
  51528. * Callback to be triggered when a device is disconnected
  51529. */
  51530. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51531. /**
  51532. * Callback to be triggered when event driven input is updated
  51533. */
  51534. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51535. private _inputs;
  51536. private _gamepads;
  51537. private _keyboardActive;
  51538. private _pointerActive;
  51539. private _elementToAttachTo;
  51540. private _keyboardDownEvent;
  51541. private _keyboardUpEvent;
  51542. private _pointerMoveEvent;
  51543. private _pointerDownEvent;
  51544. private _pointerUpEvent;
  51545. private _gamepadConnectedEvent;
  51546. private _gamepadDisconnectedEvent;
  51547. private static _MAX_KEYCODES;
  51548. private static _MAX_POINTER_INPUTS;
  51549. private constructor();
  51550. /**
  51551. * Creates a new DeviceInputSystem instance
  51552. * @param engine Engine to pull input element from
  51553. * @returns The new instance
  51554. */
  51555. static Create(engine: Engine): DeviceInputSystem;
  51556. /**
  51557. * Checks for current device input value, given an id and input index
  51558. * @param deviceName Id of connected device
  51559. * @param inputIndex Index of device input
  51560. * @returns Current value of input
  51561. */
  51562. /**
  51563. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51564. * @param deviceType Enum specifiying device type
  51565. * @param deviceSlot "Slot" or index that device is referenced in
  51566. * @param inputIndex Id of input to be checked
  51567. * @returns Current value of input
  51568. */
  51569. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51570. /**
  51571. * Dispose of all the eventlisteners
  51572. */
  51573. dispose(): void;
  51574. /**
  51575. * Add device and inputs to device array
  51576. * @param deviceType Enum specifiying device type
  51577. * @param deviceSlot "Slot" or index that device is referenced in
  51578. * @param numberOfInputs Number of input entries to create for given device
  51579. */
  51580. private _registerDevice;
  51581. /**
  51582. * Given a specific device name, remove that device from the device map
  51583. * @param deviceType Enum specifiying device type
  51584. * @param deviceSlot "Slot" or index that device is referenced in
  51585. */
  51586. private _unregisterDevice;
  51587. /**
  51588. * Handle all actions that come from keyboard interaction
  51589. */
  51590. private _handleKeyActions;
  51591. /**
  51592. * Handle all actions that come from pointer interaction
  51593. */
  51594. private _handlePointerActions;
  51595. /**
  51596. * Handle all actions that come from gamepad interaction
  51597. */
  51598. private _handleGamepadActions;
  51599. /**
  51600. * Update all non-event based devices with each frame
  51601. * @param deviceType Enum specifiying device type
  51602. * @param deviceSlot "Slot" or index that device is referenced in
  51603. * @param inputIndex Id of input to be checked
  51604. */
  51605. private _updateDevice;
  51606. /**
  51607. * Gets DeviceType from the device name
  51608. * @param deviceName Name of Device from DeviceInputSystem
  51609. * @returns DeviceType enum value
  51610. */
  51611. private _getGamepadDeviceType;
  51612. }
  51613. }
  51614. declare module BABYLON {
  51615. /**
  51616. * Type to handle enforcement of inputs
  51617. */
  51618. 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;
  51619. }
  51620. declare module BABYLON {
  51621. /**
  51622. * Class that handles all input for a specific device
  51623. */
  51624. export class DeviceSource<T extends DeviceType> {
  51625. /** Type of device */
  51626. readonly deviceType: DeviceType;
  51627. /** "Slot" or index that device is referenced in */
  51628. readonly deviceSlot: number;
  51629. /**
  51630. * Observable to handle device input changes per device
  51631. */
  51632. readonly onInputChangedObservable: Observable<{
  51633. inputIndex: DeviceInput<T>;
  51634. previousState: Nullable<number>;
  51635. currentState: Nullable<number>;
  51636. }>;
  51637. private readonly _deviceInputSystem;
  51638. /**
  51639. * Default Constructor
  51640. * @param deviceInputSystem Reference to DeviceInputSystem
  51641. * @param deviceType Type of device
  51642. * @param deviceSlot "Slot" or index that device is referenced in
  51643. */
  51644. constructor(deviceInputSystem: DeviceInputSystem,
  51645. /** Type of device */
  51646. deviceType: DeviceType,
  51647. /** "Slot" or index that device is referenced in */
  51648. deviceSlot?: number);
  51649. /**
  51650. * Get input for specific input
  51651. * @param inputIndex index of specific input on device
  51652. * @returns Input value from DeviceInputSystem
  51653. */
  51654. getInput(inputIndex: DeviceInput<T>): number;
  51655. }
  51656. /**
  51657. * Class to keep track of devices
  51658. */
  51659. export class DeviceSourceManager implements IDisposable {
  51660. /**
  51661. * Observable to be triggered when before a device is connected
  51662. */
  51663. readonly onBeforeDeviceConnectedObservable: Observable<{
  51664. deviceType: DeviceType;
  51665. deviceSlot: number;
  51666. }>;
  51667. /**
  51668. * Observable to be triggered when before a device is disconnected
  51669. */
  51670. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51671. deviceType: DeviceType;
  51672. deviceSlot: number;
  51673. }>;
  51674. /**
  51675. * Observable to be triggered when after a device is connected
  51676. */
  51677. readonly onAfterDeviceConnectedObservable: Observable<{
  51678. deviceType: DeviceType;
  51679. deviceSlot: number;
  51680. }>;
  51681. /**
  51682. * Observable to be triggered when after a device is disconnected
  51683. */
  51684. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51685. deviceType: DeviceType;
  51686. deviceSlot: number;
  51687. }>;
  51688. private readonly _devices;
  51689. private readonly _firstDevice;
  51690. private readonly _deviceInputSystem;
  51691. /**
  51692. * Default Constructor
  51693. * @param engine engine to pull input element from
  51694. */
  51695. constructor(engine: Engine);
  51696. /**
  51697. * Gets a DeviceSource, given a type and slot
  51698. * @param deviceType Enum specifying device type
  51699. * @param deviceSlot "Slot" or index that device is referenced in
  51700. * @returns DeviceSource object
  51701. */
  51702. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51703. /**
  51704. * Gets an array of DeviceSource objects for a given device type
  51705. * @param deviceType Enum specifying device type
  51706. * @returns Array of DeviceSource objects
  51707. */
  51708. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51709. /**
  51710. * Dispose of DeviceInputSystem and other parts
  51711. */
  51712. dispose(): void;
  51713. /**
  51714. * Function to add device name to device list
  51715. * @param deviceType Enum specifying device type
  51716. * @param deviceSlot "Slot" or index that device is referenced in
  51717. */
  51718. private _addDevice;
  51719. /**
  51720. * Function to remove device name to device list
  51721. * @param deviceType Enum specifying device type
  51722. * @param deviceSlot "Slot" or index that device is referenced in
  51723. */
  51724. private _removeDevice;
  51725. /**
  51726. * Updates array storing first connected device of each type
  51727. * @param type Type of Device
  51728. */
  51729. private _updateFirstDevices;
  51730. }
  51731. }
  51732. declare module BABYLON {
  51733. /**
  51734. * Options to create the null engine
  51735. */
  51736. export class NullEngineOptions {
  51737. /**
  51738. * Render width (Default: 512)
  51739. */
  51740. renderWidth: number;
  51741. /**
  51742. * Render height (Default: 256)
  51743. */
  51744. renderHeight: number;
  51745. /**
  51746. * Texture size (Default: 512)
  51747. */
  51748. textureSize: number;
  51749. /**
  51750. * If delta time between frames should be constant
  51751. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51752. */
  51753. deterministicLockstep: boolean;
  51754. /**
  51755. * Maximum about of steps between frames (Default: 4)
  51756. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51757. */
  51758. lockstepMaxSteps: number;
  51759. /**
  51760. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51761. */
  51762. useHighPrecisionMatrix?: boolean;
  51763. }
  51764. /**
  51765. * The null engine class provides support for headless version of babylon.js.
  51766. * This can be used in server side scenario or for testing purposes
  51767. */
  51768. export class NullEngine extends Engine {
  51769. private _options;
  51770. /**
  51771. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51772. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51773. * @returns true if engine is in deterministic lock step mode
  51774. */
  51775. isDeterministicLockStep(): boolean;
  51776. /**
  51777. * Gets the max steps when engine is running in deterministic lock step
  51778. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51779. * @returns the max steps
  51780. */
  51781. getLockstepMaxSteps(): number;
  51782. /**
  51783. * Gets the current hardware scaling level.
  51784. * By default the hardware scaling level is computed from the window device ratio.
  51785. * 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.
  51786. * @returns a number indicating the current hardware scaling level
  51787. */
  51788. getHardwareScalingLevel(): number;
  51789. constructor(options?: NullEngineOptions);
  51790. /**
  51791. * Creates a vertex buffer
  51792. * @param vertices the data for the vertex buffer
  51793. * @returns the new WebGL static buffer
  51794. */
  51795. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51796. /**
  51797. * Creates a new index buffer
  51798. * @param indices defines the content of the index buffer
  51799. * @param updatable defines if the index buffer must be updatable
  51800. * @returns a new webGL buffer
  51801. */
  51802. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51803. /**
  51804. * Clear the current render buffer or the current render target (if any is set up)
  51805. * @param color defines the color to use
  51806. * @param backBuffer defines if the back buffer must be cleared
  51807. * @param depth defines if the depth buffer must be cleared
  51808. * @param stencil defines if the stencil buffer must be cleared
  51809. */
  51810. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51811. /**
  51812. * Gets the current render width
  51813. * @param useScreen defines if screen size must be used (or the current render target if any)
  51814. * @returns a number defining the current render width
  51815. */
  51816. getRenderWidth(useScreen?: boolean): number;
  51817. /**
  51818. * Gets the current render height
  51819. * @param useScreen defines if screen size must be used (or the current render target if any)
  51820. * @returns a number defining the current render height
  51821. */
  51822. getRenderHeight(useScreen?: boolean): number;
  51823. /**
  51824. * Set the WebGL's viewport
  51825. * @param viewport defines the viewport element to be used
  51826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51828. */
  51829. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51830. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51831. /**
  51832. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51833. * @param pipelineContext defines the pipeline context to use
  51834. * @param uniformsNames defines the list of uniform names
  51835. * @returns an array of webGL uniform locations
  51836. */
  51837. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51838. /**
  51839. * Gets the lsit of active attributes for a given webGL program
  51840. * @param pipelineContext defines the pipeline context to use
  51841. * @param attributesNames defines the list of attribute names to get
  51842. * @returns an array of indices indicating the offset of each attribute
  51843. */
  51844. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51845. /**
  51846. * Binds an effect to the webGL context
  51847. * @param effect defines the effect to bind
  51848. */
  51849. bindSamplers(effect: Effect): void;
  51850. /**
  51851. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51852. * @param effect defines the effect to activate
  51853. */
  51854. enableEffect(effect: Effect): void;
  51855. /**
  51856. * Set various states to the webGL context
  51857. * @param culling defines backface culling state
  51858. * @param zOffset defines the value to apply to zOffset (0 by default)
  51859. * @param force defines if states must be applied even if cache is up to date
  51860. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51861. */
  51862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51863. /**
  51864. * Set the value of an uniform to an array of int32
  51865. * @param uniform defines the webGL uniform location where to store the value
  51866. * @param array defines the array of int32 to store
  51867. */
  51868. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51869. /**
  51870. * Set the value of an uniform to an array of int32 (stored as vec2)
  51871. * @param uniform defines the webGL uniform location where to store the value
  51872. * @param array defines the array of int32 to store
  51873. */
  51874. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51875. /**
  51876. * Set the value of an uniform to an array of int32 (stored as vec3)
  51877. * @param uniform defines the webGL uniform location where to store the value
  51878. * @param array defines the array of int32 to store
  51879. */
  51880. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51881. /**
  51882. * Set the value of an uniform to an array of int32 (stored as vec4)
  51883. * @param uniform defines the webGL uniform location where to store the value
  51884. * @param array defines the array of int32 to store
  51885. */
  51886. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51887. /**
  51888. * Set the value of an uniform to an array of float32
  51889. * @param uniform defines the webGL uniform location where to store the value
  51890. * @param array defines the array of float32 to store
  51891. */
  51892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51893. /**
  51894. * Set the value of an uniform to an array of float32 (stored as vec2)
  51895. * @param uniform defines the webGL uniform location where to store the value
  51896. * @param array defines the array of float32 to store
  51897. */
  51898. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51899. /**
  51900. * Set the value of an uniform to an array of float32 (stored as vec3)
  51901. * @param uniform defines the webGL uniform location where to store the value
  51902. * @param array defines the array of float32 to store
  51903. */
  51904. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51905. /**
  51906. * Set the value of an uniform to an array of float32 (stored as vec4)
  51907. * @param uniform defines the webGL uniform location where to store the value
  51908. * @param array defines the array of float32 to store
  51909. */
  51910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51911. /**
  51912. * Set the value of an uniform to an array of number
  51913. * @param uniform defines the webGL uniform location where to store the value
  51914. * @param array defines the array of number to store
  51915. */
  51916. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51917. /**
  51918. * Set the value of an uniform to an array of number (stored as vec2)
  51919. * @param uniform defines the webGL uniform location where to store the value
  51920. * @param array defines the array of number to store
  51921. */
  51922. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51923. /**
  51924. * Set the value of an uniform to an array of number (stored as vec3)
  51925. * @param uniform defines the webGL uniform location where to store the value
  51926. * @param array defines the array of number to store
  51927. */
  51928. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51929. /**
  51930. * Set the value of an uniform to an array of number (stored as vec4)
  51931. * @param uniform defines the webGL uniform location where to store the value
  51932. * @param array defines the array of number to store
  51933. */
  51934. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51935. /**
  51936. * Set the value of an uniform to an array of float32 (stored as matrices)
  51937. * @param uniform defines the webGL uniform location where to store the value
  51938. * @param matrices defines the array of float32 to store
  51939. */
  51940. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51941. /**
  51942. * Set the value of an uniform to a matrix (3x3)
  51943. * @param uniform defines the webGL uniform location where to store the value
  51944. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51945. */
  51946. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51947. /**
  51948. * Set the value of an uniform to a matrix (2x2)
  51949. * @param uniform defines the webGL uniform location where to store the value
  51950. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51951. */
  51952. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51953. /**
  51954. * Set the value of an uniform to a number (float)
  51955. * @param uniform defines the webGL uniform location where to store the value
  51956. * @param value defines the float number to store
  51957. */
  51958. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51959. /**
  51960. * Set the value of an uniform to a vec2
  51961. * @param uniform defines the webGL uniform location where to store the value
  51962. * @param x defines the 1st component of the value
  51963. * @param y defines the 2nd component of the value
  51964. */
  51965. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51966. /**
  51967. * Set the value of an uniform to a vec3
  51968. * @param uniform defines the webGL uniform location where to store the value
  51969. * @param x defines the 1st component of the value
  51970. * @param y defines the 2nd component of the value
  51971. * @param z defines the 3rd component of the value
  51972. */
  51973. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51974. /**
  51975. * Set the value of an uniform to a boolean
  51976. * @param uniform defines the webGL uniform location where to store the value
  51977. * @param bool defines the boolean to store
  51978. */
  51979. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51980. /**
  51981. * Set the value of an uniform to a vec4
  51982. * @param uniform defines the webGL uniform location where to store the value
  51983. * @param x defines the 1st component of the value
  51984. * @param y defines the 2nd component of the value
  51985. * @param z defines the 3rd component of the value
  51986. * @param w defines the 4th component of the value
  51987. */
  51988. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51989. /**
  51990. * Sets the current alpha mode
  51991. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51992. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51993. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51994. */
  51995. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51996. /**
  51997. * Bind webGl buffers directly to the webGL context
  51998. * @param vertexBuffers defines the vertex buffer to bind
  51999. * @param indexBuffer defines the index buffer to bind
  52000. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52001. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52002. * @param effect defines the effect associated with the vertex buffer
  52003. */
  52004. bindBuffers(vertexBuffers: {
  52005. [key: string]: VertexBuffer;
  52006. }, indexBuffer: DataBuffer, effect: Effect): void;
  52007. /**
  52008. * Force the entire cache to be cleared
  52009. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52010. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52011. */
  52012. wipeCaches(bruteForce?: boolean): void;
  52013. /**
  52014. * Send a draw order
  52015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52016. * @param indexStart defines the starting index
  52017. * @param indexCount defines the number of index to draw
  52018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52019. */
  52020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52021. /**
  52022. * Draw a list of indexed primitives
  52023. * @param fillMode defines the primitive to use
  52024. * @param indexStart defines the starting index
  52025. * @param indexCount defines the number of index to draw
  52026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52027. */
  52028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52029. /**
  52030. * Draw a list of unindexed primitives
  52031. * @param fillMode defines the primitive to use
  52032. * @param verticesStart defines the index of first vertex to draw
  52033. * @param verticesCount defines the count of vertices to draw
  52034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52035. */
  52036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52037. /** @hidden */
  52038. _createTexture(): WebGLTexture;
  52039. /** @hidden */
  52040. _releaseTexture(texture: InternalTexture): void;
  52041. /**
  52042. * Usually called from Texture.ts.
  52043. * Passed information to create a WebGLTexture
  52044. * @param urlArg defines a value which contains one of the following:
  52045. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52046. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52047. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52048. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52049. * @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)
  52050. * @param scene needed for loading to the correct scene
  52051. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52052. * @param onLoad optional callback to be called upon successful completion
  52053. * @param onError optional callback to be called upon failure
  52054. * @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
  52055. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52056. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52057. * @param forcedExtension defines the extension to use to pick the right loader
  52058. * @param mimeType defines an optional mime type
  52059. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52060. */
  52061. 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;
  52062. /**
  52063. * Creates a new render target texture
  52064. * @param size defines the size of the texture
  52065. * @param options defines the options used to create the texture
  52066. * @returns a new render target texture stored in an InternalTexture
  52067. */
  52068. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52069. /**
  52070. * Update the sampling mode of a given texture
  52071. * @param samplingMode defines the required sampling mode
  52072. * @param texture defines the texture to update
  52073. */
  52074. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52075. /**
  52076. * Binds the frame buffer to the specified texture.
  52077. * @param texture The texture to render to or null for the default canvas
  52078. * @param faceIndex The face of the texture to render to in case of cube texture
  52079. * @param requiredWidth The width of the target to render to
  52080. * @param requiredHeight The height of the target to render to
  52081. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52082. * @param lodLevel defines le lod level to bind to the frame buffer
  52083. */
  52084. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52085. /**
  52086. * Unbind the current render target texture from the webGL context
  52087. * @param texture defines the render target texture to unbind
  52088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52090. */
  52091. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52092. /**
  52093. * Creates a dynamic vertex buffer
  52094. * @param vertices the data for the dynamic vertex buffer
  52095. * @returns the new WebGL dynamic buffer
  52096. */
  52097. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52098. /**
  52099. * Update the content of a dynamic texture
  52100. * @param texture defines the texture to update
  52101. * @param canvas defines the canvas containing the source
  52102. * @param invertY defines if data must be stored with Y axis inverted
  52103. * @param premulAlpha defines if alpha is stored as premultiplied
  52104. * @param format defines the format of the data
  52105. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52106. */
  52107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52108. /**
  52109. * Gets a boolean indicating if all created effects are ready
  52110. * @returns true if all effects are ready
  52111. */
  52112. areAllEffectsReady(): boolean;
  52113. /**
  52114. * @hidden
  52115. * Get the current error code of the webGL context
  52116. * @returns the error code
  52117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52118. */
  52119. getError(): number;
  52120. /** @hidden */
  52121. _getUnpackAlignement(): number;
  52122. /** @hidden */
  52123. _unpackFlipY(value: boolean): void;
  52124. /**
  52125. * Update a dynamic index buffer
  52126. * @param indexBuffer defines the target index buffer
  52127. * @param indices defines the data to update
  52128. * @param offset defines the offset in the target index buffer where update should start
  52129. */
  52130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52131. /**
  52132. * Updates a dynamic vertex buffer.
  52133. * @param vertexBuffer the vertex buffer to update
  52134. * @param vertices the data used to update the vertex buffer
  52135. * @param byteOffset the byte offset of the data (optional)
  52136. * @param byteLength the byte length of the data (optional)
  52137. */
  52138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52139. /** @hidden */
  52140. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52141. /** @hidden */
  52142. _bindTexture(channel: number, texture: InternalTexture): void;
  52143. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52144. /**
  52145. * 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
  52146. */
  52147. releaseEffects(): void;
  52148. displayLoadingUI(): void;
  52149. hideLoadingUI(): void;
  52150. /** @hidden */
  52151. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52152. /** @hidden */
  52153. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52154. /** @hidden */
  52155. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52156. /** @hidden */
  52157. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52158. }
  52159. }
  52160. declare module BABYLON {
  52161. /**
  52162. * @hidden
  52163. **/
  52164. export class _TimeToken {
  52165. _startTimeQuery: Nullable<WebGLQuery>;
  52166. _endTimeQuery: Nullable<WebGLQuery>;
  52167. _timeElapsedQuery: Nullable<WebGLQuery>;
  52168. _timeElapsedQueryEnded: boolean;
  52169. }
  52170. }
  52171. declare module BABYLON {
  52172. /** @hidden */
  52173. export class _OcclusionDataStorage {
  52174. /** @hidden */
  52175. occlusionInternalRetryCounter: number;
  52176. /** @hidden */
  52177. isOcclusionQueryInProgress: boolean;
  52178. /** @hidden */
  52179. isOccluded: boolean;
  52180. /** @hidden */
  52181. occlusionRetryCount: number;
  52182. /** @hidden */
  52183. occlusionType: number;
  52184. /** @hidden */
  52185. occlusionQueryAlgorithmType: number;
  52186. }
  52187. interface Engine {
  52188. /**
  52189. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52190. * @return the new query
  52191. */
  52192. createQuery(): WebGLQuery;
  52193. /**
  52194. * Delete and release a webGL query
  52195. * @param query defines the query to delete
  52196. * @return the current engine
  52197. */
  52198. deleteQuery(query: WebGLQuery): Engine;
  52199. /**
  52200. * Check if a given query has resolved and got its value
  52201. * @param query defines the query to check
  52202. * @returns true if the query got its value
  52203. */
  52204. isQueryResultAvailable(query: WebGLQuery): boolean;
  52205. /**
  52206. * Gets the value of a given query
  52207. * @param query defines the query to check
  52208. * @returns the value of the query
  52209. */
  52210. getQueryResult(query: WebGLQuery): number;
  52211. /**
  52212. * Initiates an occlusion query
  52213. * @param algorithmType defines the algorithm to use
  52214. * @param query defines the query to use
  52215. * @returns the current engine
  52216. * @see https://doc.babylonjs.com/features/occlusionquery
  52217. */
  52218. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52219. /**
  52220. * Ends an occlusion query
  52221. * @see https://doc.babylonjs.com/features/occlusionquery
  52222. * @param algorithmType defines the algorithm to use
  52223. * @returns the current engine
  52224. */
  52225. endOcclusionQuery(algorithmType: number): Engine;
  52226. /**
  52227. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52228. * Please note that only one query can be issued at a time
  52229. * @returns a time token used to track the time span
  52230. */
  52231. startTimeQuery(): Nullable<_TimeToken>;
  52232. /**
  52233. * Ends a time query
  52234. * @param token defines the token used to measure the time span
  52235. * @returns the time spent (in ns)
  52236. */
  52237. endTimeQuery(token: _TimeToken): int;
  52238. /** @hidden */
  52239. _currentNonTimestampToken: Nullable<_TimeToken>;
  52240. /** @hidden */
  52241. _createTimeQuery(): WebGLQuery;
  52242. /** @hidden */
  52243. _deleteTimeQuery(query: WebGLQuery): void;
  52244. /** @hidden */
  52245. _getGlAlgorithmType(algorithmType: number): number;
  52246. /** @hidden */
  52247. _getTimeQueryResult(query: WebGLQuery): any;
  52248. /** @hidden */
  52249. _getTimeQueryAvailability(query: WebGLQuery): any;
  52250. }
  52251. interface AbstractMesh {
  52252. /**
  52253. * Backing filed
  52254. * @hidden
  52255. */
  52256. __occlusionDataStorage: _OcclusionDataStorage;
  52257. /**
  52258. * Access property
  52259. * @hidden
  52260. */
  52261. _occlusionDataStorage: _OcclusionDataStorage;
  52262. /**
  52263. * 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.
  52264. * The default value is -1 which means don't break the query and wait till the result
  52265. * @see https://doc.babylonjs.com/features/occlusionquery
  52266. */
  52267. occlusionRetryCount: number;
  52268. /**
  52269. * 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:
  52270. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52271. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52272. * * 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.
  52273. * @see https://doc.babylonjs.com/features/occlusionquery
  52274. */
  52275. occlusionType: number;
  52276. /**
  52277. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52278. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52279. * * 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.
  52280. * @see https://doc.babylonjs.com/features/occlusionquery
  52281. */
  52282. occlusionQueryAlgorithmType: number;
  52283. /**
  52284. * 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
  52285. * @see https://doc.babylonjs.com/features/occlusionquery
  52286. */
  52287. isOccluded: boolean;
  52288. /**
  52289. * Flag to check the progress status of the query
  52290. * @see https://doc.babylonjs.com/features/occlusionquery
  52291. */
  52292. isOcclusionQueryInProgress: boolean;
  52293. }
  52294. }
  52295. declare module BABYLON {
  52296. /** @hidden */
  52297. export var _forceTransformFeedbackToBundle: boolean;
  52298. interface Engine {
  52299. /**
  52300. * Creates a webGL transform feedback object
  52301. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52302. * @returns the webGL transform feedback object
  52303. */
  52304. createTransformFeedback(): WebGLTransformFeedback;
  52305. /**
  52306. * Delete a webGL transform feedback object
  52307. * @param value defines the webGL transform feedback object to delete
  52308. */
  52309. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52310. /**
  52311. * Bind a webGL transform feedback object to the webgl context
  52312. * @param value defines the webGL transform feedback object to bind
  52313. */
  52314. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52315. /**
  52316. * Begins a transform feedback operation
  52317. * @param usePoints defines if points or triangles must be used
  52318. */
  52319. beginTransformFeedback(usePoints: boolean): void;
  52320. /**
  52321. * Ends a transform feedback operation
  52322. */
  52323. endTransformFeedback(): void;
  52324. /**
  52325. * Specify the varyings to use with transform feedback
  52326. * @param program defines the associated webGL program
  52327. * @param value defines the list of strings representing the varying names
  52328. */
  52329. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52330. /**
  52331. * Bind a webGL buffer for a transform feedback operation
  52332. * @param value defines the webGL buffer to bind
  52333. */
  52334. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52335. }
  52336. }
  52337. declare module BABYLON {
  52338. /**
  52339. * Class used to define an additional view for the engine
  52340. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52341. */
  52342. export class EngineView {
  52343. /** Defines the canvas where to render the view */
  52344. target: HTMLCanvasElement;
  52345. /** Defines an optional camera used to render the view (will use active camera else) */
  52346. camera?: Camera;
  52347. }
  52348. interface Engine {
  52349. /**
  52350. * Gets or sets the HTML element to use for attaching events
  52351. */
  52352. inputElement: Nullable<HTMLElement>;
  52353. /**
  52354. * Gets the current engine view
  52355. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52356. */
  52357. activeView: Nullable<EngineView>;
  52358. /** Gets or sets the list of views */
  52359. views: EngineView[];
  52360. /**
  52361. * Register a new child canvas
  52362. * @param canvas defines the canvas to register
  52363. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52364. * @returns the associated view
  52365. */
  52366. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52367. /**
  52368. * Remove a registered child canvas
  52369. * @param canvas defines the canvas to remove
  52370. * @returns the current engine
  52371. */
  52372. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52373. }
  52374. }
  52375. declare module BABYLON {
  52376. interface Engine {
  52377. /** @hidden */
  52378. _excludedCompressedTextures: string[];
  52379. /** @hidden */
  52380. _textureFormatInUse: string;
  52381. /**
  52382. * Gets the list of texture formats supported
  52383. */
  52384. readonly texturesSupported: Array<string>;
  52385. /**
  52386. * Gets the texture format in use
  52387. */
  52388. readonly textureFormatInUse: Nullable<string>;
  52389. /**
  52390. * Set the compressed texture extensions or file names to skip.
  52391. *
  52392. * @param skippedFiles defines the list of those texture files you want to skip
  52393. * Example: [".dds", ".env", "myfile.png"]
  52394. */
  52395. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52396. /**
  52397. * Set the compressed texture format to use, based on the formats you have, and the formats
  52398. * supported by the hardware / browser.
  52399. *
  52400. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52401. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52402. * to API arguments needed to compressed textures. This puts the burden on the container
  52403. * generator to house the arcane code for determining these for current & future formats.
  52404. *
  52405. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52406. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52407. *
  52408. * Note: The result of this call is not taken into account when a texture is base64.
  52409. *
  52410. * @param formatsAvailable defines the list of those format families you have created
  52411. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52412. *
  52413. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52414. * @returns The extension selected.
  52415. */
  52416. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52417. }
  52418. }
  52419. declare module BABYLON {
  52420. /**
  52421. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52422. */
  52423. export interface CubeMapInfo {
  52424. /**
  52425. * The pixel array for the front face.
  52426. * This is stored in format, left to right, up to down format.
  52427. */
  52428. front: Nullable<ArrayBufferView>;
  52429. /**
  52430. * The pixel array for the back face.
  52431. * This is stored in format, left to right, up to down format.
  52432. */
  52433. back: Nullable<ArrayBufferView>;
  52434. /**
  52435. * The pixel array for the left face.
  52436. * This is stored in format, left to right, up to down format.
  52437. */
  52438. left: Nullable<ArrayBufferView>;
  52439. /**
  52440. * The pixel array for the right face.
  52441. * This is stored in format, left to right, up to down format.
  52442. */
  52443. right: Nullable<ArrayBufferView>;
  52444. /**
  52445. * The pixel array for the up face.
  52446. * This is stored in format, left to right, up to down format.
  52447. */
  52448. up: Nullable<ArrayBufferView>;
  52449. /**
  52450. * The pixel array for the down face.
  52451. * This is stored in format, left to right, up to down format.
  52452. */
  52453. down: Nullable<ArrayBufferView>;
  52454. /**
  52455. * The size of the cubemap stored.
  52456. *
  52457. * Each faces will be size * size pixels.
  52458. */
  52459. size: number;
  52460. /**
  52461. * The format of the texture.
  52462. *
  52463. * RGBA, RGB.
  52464. */
  52465. format: number;
  52466. /**
  52467. * The type of the texture data.
  52468. *
  52469. * UNSIGNED_INT, FLOAT.
  52470. */
  52471. type: number;
  52472. /**
  52473. * Specifies whether the texture is in gamma space.
  52474. */
  52475. gammaSpace: boolean;
  52476. }
  52477. /**
  52478. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52479. */
  52480. export class PanoramaToCubeMapTools {
  52481. private static FACE_LEFT;
  52482. private static FACE_RIGHT;
  52483. private static FACE_FRONT;
  52484. private static FACE_BACK;
  52485. private static FACE_DOWN;
  52486. private static FACE_UP;
  52487. /**
  52488. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52489. *
  52490. * @param float32Array The source data.
  52491. * @param inputWidth The width of the input panorama.
  52492. * @param inputHeight The height of the input panorama.
  52493. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52494. * @return The cubemap data
  52495. */
  52496. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52497. private static CreateCubemapTexture;
  52498. private static CalcProjectionSpherical;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * Helper class dealing with the extraction of spherical polynomial dataArray
  52504. * from a cube map.
  52505. */
  52506. export class CubeMapToSphericalPolynomialTools {
  52507. private static FileFaces;
  52508. /**
  52509. * Converts a texture to the according Spherical Polynomial data.
  52510. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52511. *
  52512. * @param texture The texture to extract the information from.
  52513. * @return The Spherical Polynomial data.
  52514. */
  52515. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52516. /**
  52517. * Converts a cubemap to the according Spherical Polynomial data.
  52518. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52519. *
  52520. * @param cubeInfo The Cube map to extract the information from.
  52521. * @return The Spherical Polynomial data.
  52522. */
  52523. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52524. }
  52525. }
  52526. declare module BABYLON {
  52527. interface BaseTexture {
  52528. /**
  52529. * Get the polynomial representation of the texture data.
  52530. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52531. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52532. */
  52533. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52534. }
  52535. }
  52536. declare module BABYLON {
  52537. /** @hidden */
  52538. export var rgbdEncodePixelShader: {
  52539. name: string;
  52540. shader: string;
  52541. };
  52542. }
  52543. declare module BABYLON {
  52544. /** @hidden */
  52545. export var rgbdDecodePixelShader: {
  52546. name: string;
  52547. shader: string;
  52548. };
  52549. }
  52550. declare module BABYLON {
  52551. /**
  52552. * Raw texture data and descriptor sufficient for WebGL texture upload
  52553. */
  52554. export interface EnvironmentTextureInfo {
  52555. /**
  52556. * Version of the environment map
  52557. */
  52558. version: number;
  52559. /**
  52560. * Width of image
  52561. */
  52562. width: number;
  52563. /**
  52564. * Irradiance information stored in the file.
  52565. */
  52566. irradiance: any;
  52567. /**
  52568. * Specular information stored in the file.
  52569. */
  52570. specular: any;
  52571. }
  52572. /**
  52573. * Defines One Image in the file. It requires only the position in the file
  52574. * as well as the length.
  52575. */
  52576. interface BufferImageData {
  52577. /**
  52578. * Length of the image data.
  52579. */
  52580. length: number;
  52581. /**
  52582. * Position of the data from the null terminator delimiting the end of the JSON.
  52583. */
  52584. position: number;
  52585. }
  52586. /**
  52587. * Defines the specular data enclosed in the file.
  52588. * This corresponds to the version 1 of the data.
  52589. */
  52590. export interface EnvironmentTextureSpecularInfoV1 {
  52591. /**
  52592. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52593. */
  52594. specularDataPosition?: number;
  52595. /**
  52596. * This contains all the images data needed to reconstruct the cubemap.
  52597. */
  52598. mipmaps: Array<BufferImageData>;
  52599. /**
  52600. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52601. */
  52602. lodGenerationScale: number;
  52603. }
  52604. /**
  52605. * Sets of helpers addressing the serialization and deserialization of environment texture
  52606. * stored in a BabylonJS env file.
  52607. * Those files are usually stored as .env files.
  52608. */
  52609. export class EnvironmentTextureTools {
  52610. /**
  52611. * Magic number identifying the env file.
  52612. */
  52613. private static _MagicBytes;
  52614. /**
  52615. * Gets the environment info from an env file.
  52616. * @param data The array buffer containing the .env bytes.
  52617. * @returns the environment file info (the json header) if successfully parsed.
  52618. */
  52619. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52620. /**
  52621. * Creates an environment texture from a loaded cube texture.
  52622. * @param texture defines the cube texture to convert in env file
  52623. * @return a promise containing the environment data if succesfull.
  52624. */
  52625. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52626. /**
  52627. * Creates a JSON representation of the spherical data.
  52628. * @param texture defines the texture containing the polynomials
  52629. * @return the JSON representation of the spherical info
  52630. */
  52631. private static _CreateEnvTextureIrradiance;
  52632. /**
  52633. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52634. * @param data the image data
  52635. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52636. * @return the views described by info providing access to the underlying buffer
  52637. */
  52638. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52639. /**
  52640. * Uploads the texture info contained in the env file to the GPU.
  52641. * @param texture defines the internal texture to upload to
  52642. * @param data defines the data to load
  52643. * @param info defines the texture info retrieved through the GetEnvInfo method
  52644. * @returns a promise
  52645. */
  52646. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52647. private static _OnImageReadyAsync;
  52648. /**
  52649. * Uploads the levels of image data to the GPU.
  52650. * @param texture defines the internal texture to upload to
  52651. * @param imageData defines the array buffer views of image data [mipmap][face]
  52652. * @returns a promise
  52653. */
  52654. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52655. /**
  52656. * Uploads spherical polynomials information to the texture.
  52657. * @param texture defines the texture we are trying to upload the information to
  52658. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52659. */
  52660. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52661. /** @hidden */
  52662. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Class used to inline functions in shader code
  52668. */
  52669. export class ShaderCodeInliner {
  52670. private static readonly _RegexpFindFunctionNameAndType;
  52671. private _sourceCode;
  52672. private _functionDescr;
  52673. private _numMaxIterations;
  52674. /** Gets or sets the token used to mark the functions to inline */
  52675. inlineToken: string;
  52676. /** Gets or sets the debug mode */
  52677. debug: boolean;
  52678. /** Gets the code after the inlining process */
  52679. get code(): string;
  52680. /**
  52681. * Initializes the inliner
  52682. * @param sourceCode shader code source to inline
  52683. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52684. */
  52685. constructor(sourceCode: string, numMaxIterations?: number);
  52686. /**
  52687. * Start the processing of the shader code
  52688. */
  52689. processCode(): void;
  52690. private _collectFunctions;
  52691. private _processInlining;
  52692. private _extractBetweenMarkers;
  52693. private _skipWhitespaces;
  52694. private _removeComments;
  52695. private _replaceFunctionCallsByCode;
  52696. private _findBackward;
  52697. private _escapeRegExp;
  52698. private _replaceNames;
  52699. }
  52700. }
  52701. declare module BABYLON {
  52702. /**
  52703. * Container for accessors for natively-stored mesh data buffers.
  52704. */
  52705. class NativeDataBuffer extends DataBuffer {
  52706. /**
  52707. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52708. */
  52709. nativeIndexBuffer?: any;
  52710. /**
  52711. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52712. */
  52713. nativeVertexBuffer?: any;
  52714. }
  52715. /** @hidden */
  52716. class NativeTexture extends InternalTexture {
  52717. getInternalTexture(): InternalTexture;
  52718. getViewCount(): number;
  52719. }
  52720. /** @hidden */
  52721. export class NativeEngine extends Engine {
  52722. private readonly _native;
  52723. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52724. private readonly INVALID_HANDLE;
  52725. private _boundBuffersVertexArray;
  52726. getHardwareScalingLevel(): number;
  52727. constructor();
  52728. dispose(): void;
  52729. /**
  52730. * Can be used to override the current requestAnimationFrame requester.
  52731. * @hidden
  52732. */
  52733. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52734. /**
  52735. * Override default engine behavior.
  52736. * @param color
  52737. * @param backBuffer
  52738. * @param depth
  52739. * @param stencil
  52740. */
  52741. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52742. /**
  52743. * Gets host document
  52744. * @returns the host document object
  52745. */
  52746. getHostDocument(): Nullable<Document>;
  52747. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52748. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52749. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52750. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52751. [key: string]: VertexBuffer;
  52752. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52753. bindBuffers(vertexBuffers: {
  52754. [key: string]: VertexBuffer;
  52755. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52756. recordVertexArrayObject(vertexBuffers: {
  52757. [key: string]: VertexBuffer;
  52758. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52759. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52760. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52761. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52762. /**
  52763. * Draw a list of indexed primitives
  52764. * @param fillMode defines the primitive to use
  52765. * @param indexStart defines the starting index
  52766. * @param indexCount defines the number of index to draw
  52767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52768. */
  52769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52770. /**
  52771. * Draw a list of unindexed primitives
  52772. * @param fillMode defines the primitive to use
  52773. * @param verticesStart defines the index of first vertex to draw
  52774. * @param verticesCount defines the count of vertices to draw
  52775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52776. */
  52777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52778. createPipelineContext(): IPipelineContext;
  52779. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52780. /** @hidden */
  52781. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52782. /** @hidden */
  52783. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52784. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52785. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52786. protected _setProgram(program: WebGLProgram): void;
  52787. _releaseEffect(effect: Effect): void;
  52788. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52789. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52790. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52791. bindSamplers(effect: Effect): void;
  52792. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52793. getRenderWidth(useScreen?: boolean): number;
  52794. getRenderHeight(useScreen?: boolean): number;
  52795. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52796. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52797. /**
  52798. * Set the z offset to apply to current rendering
  52799. * @param value defines the offset to apply
  52800. */
  52801. setZOffset(value: number): void;
  52802. /**
  52803. * Gets the current value of the zOffset
  52804. * @returns the current zOffset state
  52805. */
  52806. getZOffset(): number;
  52807. /**
  52808. * Enable or disable depth buffering
  52809. * @param enable defines the state to set
  52810. */
  52811. setDepthBuffer(enable: boolean): void;
  52812. /**
  52813. * Gets a boolean indicating if depth writing is enabled
  52814. * @returns the current depth writing state
  52815. */
  52816. getDepthWrite(): boolean;
  52817. /**
  52818. * Enable or disable depth writing
  52819. * @param enable defines the state to set
  52820. */
  52821. setDepthWrite(enable: boolean): void;
  52822. /**
  52823. * Enable or disable color writing
  52824. * @param enable defines the state to set
  52825. */
  52826. setColorWrite(enable: boolean): void;
  52827. /**
  52828. * Gets a boolean indicating if color writing is enabled
  52829. * @returns the current color writing state
  52830. */
  52831. getColorWrite(): boolean;
  52832. /**
  52833. * Sets alpha constants used by some alpha blending modes
  52834. * @param r defines the red component
  52835. * @param g defines the green component
  52836. * @param b defines the blue component
  52837. * @param a defines the alpha component
  52838. */
  52839. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52840. /**
  52841. * Sets the current alpha mode
  52842. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52843. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52844. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52845. */
  52846. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52847. /**
  52848. * Gets the current alpha mode
  52849. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52850. * @returns the current alpha mode
  52851. */
  52852. getAlphaMode(): number;
  52853. setInt(uniform: WebGLUniformLocation, int: number): void;
  52854. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52855. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52856. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52857. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52858. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52859. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52860. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52861. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52862. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52863. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52864. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52865. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52866. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52867. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52868. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52869. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52870. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52871. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52872. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52873. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52874. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52875. wipeCaches(bruteForce?: boolean): void;
  52876. _createTexture(): WebGLTexture;
  52877. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52878. /**
  52879. * Usually called from Texture.ts.
  52880. * Passed information to create a WebGLTexture
  52881. * @param url defines a value which contains one of the following:
  52882. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52883. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52884. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52886. * @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)
  52887. * @param scene needed for loading to the correct scene
  52888. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52889. * @param onLoad optional callback to be called upon successful completion
  52890. * @param onError optional callback to be called upon failure
  52891. * @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
  52892. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52893. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52894. * @param forcedExtension defines the extension to use to pick the right loader
  52895. * @param mimeType defines an optional mime type
  52896. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52897. */
  52898. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  52899. /**
  52900. * Creates a cube texture
  52901. * @param rootUrl defines the url where the files to load is located
  52902. * @param scene defines the current scene
  52903. * @param files defines the list of files to load (1 per face)
  52904. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52905. * @param onLoad defines an optional callback raised when the texture is loaded
  52906. * @param onError defines an optional callback raised if there is an issue to load the texture
  52907. * @param format defines the format of the data
  52908. * @param forcedExtension defines the extension to use to pick the right loader
  52909. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52910. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52911. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52912. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52913. * @returns the cube texture as an InternalTexture
  52914. */
  52915. 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;
  52916. private _getSamplingFilter;
  52917. private static _GetNativeTextureFormat;
  52918. createRenderTargetTexture(size: number | {
  52919. width: number;
  52920. height: number;
  52921. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52922. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52923. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52924. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52925. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52926. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52927. /**
  52928. * Updates a dynamic vertex buffer.
  52929. * @param vertexBuffer the vertex buffer to update
  52930. * @param data the data used to update the vertex buffer
  52931. * @param byteOffset the byte offset of the data (optional)
  52932. * @param byteLength the byte length of the data (optional)
  52933. */
  52934. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52935. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52936. private _updateAnisotropicLevel;
  52937. private _getAddressMode;
  52938. /** @hidden */
  52939. _bindTexture(channel: number, texture: InternalTexture): void;
  52940. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52941. releaseEffects(): void;
  52942. /** @hidden */
  52943. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52944. /** @hidden */
  52945. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52946. /** @hidden */
  52947. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52948. /** @hidden */
  52949. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52950. }
  52951. }
  52952. declare module BABYLON {
  52953. /**
  52954. * Gather the list of clipboard event types as constants.
  52955. */
  52956. export class ClipboardEventTypes {
  52957. /**
  52958. * The clipboard event is fired when a copy command is active (pressed).
  52959. */
  52960. static readonly COPY: number;
  52961. /**
  52962. * The clipboard event is fired when a cut command is active (pressed).
  52963. */
  52964. static readonly CUT: number;
  52965. /**
  52966. * The clipboard event is fired when a paste command is active (pressed).
  52967. */
  52968. static readonly PASTE: number;
  52969. }
  52970. /**
  52971. * This class is used to store clipboard related info for the onClipboardObservable event.
  52972. */
  52973. export class ClipboardInfo {
  52974. /**
  52975. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52976. */
  52977. type: number;
  52978. /**
  52979. * Defines the related dom event
  52980. */
  52981. event: ClipboardEvent;
  52982. /**
  52983. *Creates an instance of ClipboardInfo.
  52984. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52985. * @param event Defines the related dom event
  52986. */
  52987. constructor(
  52988. /**
  52989. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52990. */
  52991. type: number,
  52992. /**
  52993. * Defines the related dom event
  52994. */
  52995. event: ClipboardEvent);
  52996. /**
  52997. * Get the clipboard event's type from the keycode.
  52998. * @param keyCode Defines the keyCode for the current keyboard event.
  52999. * @return {number}
  53000. */
  53001. static GetTypeFromCharacter(keyCode: number): number;
  53002. }
  53003. }
  53004. declare module BABYLON {
  53005. /**
  53006. * Google Daydream controller
  53007. */
  53008. export class DaydreamController extends WebVRController {
  53009. /**
  53010. * Base Url for the controller model.
  53011. */
  53012. static MODEL_BASE_URL: string;
  53013. /**
  53014. * File name for the controller model.
  53015. */
  53016. static MODEL_FILENAME: string;
  53017. /**
  53018. * Gamepad Id prefix used to identify Daydream Controller.
  53019. */
  53020. static readonly GAMEPAD_ID_PREFIX: string;
  53021. /**
  53022. * Creates a new DaydreamController from a gamepad
  53023. * @param vrGamepad the gamepad that the controller should be created from
  53024. */
  53025. constructor(vrGamepad: any);
  53026. /**
  53027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53028. * @param scene scene in which to add meshes
  53029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53030. */
  53031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53032. /**
  53033. * Called once for each button that changed state since the last frame
  53034. * @param buttonIdx Which button index changed
  53035. * @param state New state of the button
  53036. * @param changes Which properties on the state changed since last frame
  53037. */
  53038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53039. }
  53040. }
  53041. declare module BABYLON {
  53042. /**
  53043. * Gear VR Controller
  53044. */
  53045. export class GearVRController extends WebVRController {
  53046. /**
  53047. * Base Url for the controller model.
  53048. */
  53049. static MODEL_BASE_URL: string;
  53050. /**
  53051. * File name for the controller model.
  53052. */
  53053. static MODEL_FILENAME: string;
  53054. /**
  53055. * Gamepad Id prefix used to identify this controller.
  53056. */
  53057. static readonly GAMEPAD_ID_PREFIX: string;
  53058. private readonly _buttonIndexToObservableNameMap;
  53059. /**
  53060. * Creates a new GearVRController from a gamepad
  53061. * @param vrGamepad the gamepad that the controller should be created from
  53062. */
  53063. constructor(vrGamepad: any);
  53064. /**
  53065. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53066. * @param scene scene in which to add meshes
  53067. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53068. */
  53069. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53070. /**
  53071. * Called once for each button that changed state since the last frame
  53072. * @param buttonIdx Which button index changed
  53073. * @param state New state of the button
  53074. * @param changes Which properties on the state changed since last frame
  53075. */
  53076. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /**
  53081. * Generic Controller
  53082. */
  53083. export class GenericController extends WebVRController {
  53084. /**
  53085. * Base Url for the controller model.
  53086. */
  53087. static readonly MODEL_BASE_URL: string;
  53088. /**
  53089. * File name for the controller model.
  53090. */
  53091. static readonly MODEL_FILENAME: string;
  53092. /**
  53093. * Creates a new GenericController from a gamepad
  53094. * @param vrGamepad the gamepad that the controller should be created from
  53095. */
  53096. constructor(vrGamepad: any);
  53097. /**
  53098. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53099. * @param scene scene in which to add meshes
  53100. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53101. */
  53102. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53103. /**
  53104. * Called once for each button that changed state since the last frame
  53105. * @param buttonIdx Which button index changed
  53106. * @param state New state of the button
  53107. * @param changes Which properties on the state changed since last frame
  53108. */
  53109. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53110. }
  53111. }
  53112. declare module BABYLON {
  53113. /**
  53114. * Oculus Touch Controller
  53115. */
  53116. export class OculusTouchController extends WebVRController {
  53117. /**
  53118. * Base Url for the controller model.
  53119. */
  53120. static MODEL_BASE_URL: string;
  53121. /**
  53122. * File name for the left controller model.
  53123. */
  53124. static MODEL_LEFT_FILENAME: string;
  53125. /**
  53126. * File name for the right controller model.
  53127. */
  53128. static MODEL_RIGHT_FILENAME: string;
  53129. /**
  53130. * Base Url for the Quest controller model.
  53131. */
  53132. static QUEST_MODEL_BASE_URL: string;
  53133. /**
  53134. * @hidden
  53135. * If the controllers are running on a device that needs the updated Quest controller models
  53136. */
  53137. static _IsQuest: boolean;
  53138. /**
  53139. * Fired when the secondary trigger on this controller is modified
  53140. */
  53141. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53142. /**
  53143. * Fired when the thumb rest on this controller is modified
  53144. */
  53145. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53146. /**
  53147. * Creates a new OculusTouchController from a gamepad
  53148. * @param vrGamepad the gamepad that the controller should be created from
  53149. */
  53150. constructor(vrGamepad: any);
  53151. /**
  53152. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53153. * @param scene scene in which to add meshes
  53154. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53155. */
  53156. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53157. /**
  53158. * Fired when the A button on this controller is modified
  53159. */
  53160. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53161. /**
  53162. * Fired when the B button on this controller is modified
  53163. */
  53164. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53165. /**
  53166. * Fired when the X button on this controller is modified
  53167. */
  53168. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53169. /**
  53170. * Fired when the Y button on this controller is modified
  53171. */
  53172. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53173. /**
  53174. * Called once for each button that changed state since the last frame
  53175. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53176. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53177. * 2) secondary trigger (same)
  53178. * 3) A (right) X (left), touch, pressed = value
  53179. * 4) B / Y
  53180. * 5) thumb rest
  53181. * @param buttonIdx Which button index changed
  53182. * @param state New state of the button
  53183. * @param changes Which properties on the state changed since last frame
  53184. */
  53185. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53186. }
  53187. }
  53188. declare module BABYLON {
  53189. /**
  53190. * Vive Controller
  53191. */
  53192. export class ViveController extends WebVRController {
  53193. /**
  53194. * Base Url for the controller model.
  53195. */
  53196. static MODEL_BASE_URL: string;
  53197. /**
  53198. * File name for the controller model.
  53199. */
  53200. static MODEL_FILENAME: string;
  53201. /**
  53202. * Creates a new ViveController from a gamepad
  53203. * @param vrGamepad the gamepad that the controller should be created from
  53204. */
  53205. constructor(vrGamepad: any);
  53206. /**
  53207. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53208. * @param scene scene in which to add meshes
  53209. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53210. */
  53211. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53212. /**
  53213. * Fired when the left button on this controller is modified
  53214. */
  53215. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53216. /**
  53217. * Fired when the right button on this controller is modified
  53218. */
  53219. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53220. /**
  53221. * Fired when the menu button on this controller is modified
  53222. */
  53223. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53224. /**
  53225. * Called once for each button that changed state since the last frame
  53226. * Vive mapping:
  53227. * 0: touchpad
  53228. * 1: trigger
  53229. * 2: left AND right buttons
  53230. * 3: menu button
  53231. * @param buttonIdx Which button index changed
  53232. * @param state New state of the button
  53233. * @param changes Which properties on the state changed since last frame
  53234. */
  53235. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53236. }
  53237. }
  53238. declare module BABYLON {
  53239. /**
  53240. * Defines the WindowsMotionController object that the state of the windows motion controller
  53241. */
  53242. export class WindowsMotionController extends WebVRController {
  53243. /**
  53244. * The base url used to load the left and right controller models
  53245. */
  53246. static MODEL_BASE_URL: string;
  53247. /**
  53248. * The name of the left controller model file
  53249. */
  53250. static MODEL_LEFT_FILENAME: string;
  53251. /**
  53252. * The name of the right controller model file
  53253. */
  53254. static MODEL_RIGHT_FILENAME: string;
  53255. /**
  53256. * The controller name prefix for this controller type
  53257. */
  53258. static readonly GAMEPAD_ID_PREFIX: string;
  53259. /**
  53260. * The controller id pattern for this controller type
  53261. */
  53262. private static readonly GAMEPAD_ID_PATTERN;
  53263. private _loadedMeshInfo;
  53264. protected readonly _mapping: {
  53265. buttons: string[];
  53266. buttonMeshNames: {
  53267. trigger: string;
  53268. menu: string;
  53269. grip: string;
  53270. thumbstick: string;
  53271. trackpad: string;
  53272. };
  53273. buttonObservableNames: {
  53274. trigger: string;
  53275. menu: string;
  53276. grip: string;
  53277. thumbstick: string;
  53278. trackpad: string;
  53279. };
  53280. axisMeshNames: string[];
  53281. pointingPoseMeshName: string;
  53282. };
  53283. /**
  53284. * Fired when the trackpad on this controller is clicked
  53285. */
  53286. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53287. /**
  53288. * Fired when the trackpad on this controller is modified
  53289. */
  53290. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53291. /**
  53292. * The current x and y values of this controller's trackpad
  53293. */
  53294. trackpad: StickValues;
  53295. /**
  53296. * Creates a new WindowsMotionController from a gamepad
  53297. * @param vrGamepad the gamepad that the controller should be created from
  53298. */
  53299. constructor(vrGamepad: any);
  53300. /**
  53301. * Fired when the trigger on this controller is modified
  53302. */
  53303. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53304. /**
  53305. * Fired when the menu button on this controller is modified
  53306. */
  53307. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53308. /**
  53309. * Fired when the grip button on this controller is modified
  53310. */
  53311. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53312. /**
  53313. * Fired when the thumbstick button on this controller is modified
  53314. */
  53315. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53316. /**
  53317. * Fired when the touchpad button on this controller is modified
  53318. */
  53319. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53320. /**
  53321. * Fired when the touchpad values on this controller are modified
  53322. */
  53323. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53324. protected _updateTrackpad(): void;
  53325. /**
  53326. * Called once per frame by the engine.
  53327. */
  53328. update(): void;
  53329. /**
  53330. * Called once for each button that changed state since the last frame
  53331. * @param buttonIdx Which button index changed
  53332. * @param state New state of the button
  53333. * @param changes Which properties on the state changed since last frame
  53334. */
  53335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53336. /**
  53337. * Moves the buttons on the controller mesh based on their current state
  53338. * @param buttonName the name of the button to move
  53339. * @param buttonValue the value of the button which determines the buttons new position
  53340. */
  53341. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53342. /**
  53343. * Moves the axis on the controller mesh based on its current state
  53344. * @param axis the index of the axis
  53345. * @param axisValue the value of the axis which determines the meshes new position
  53346. * @hidden
  53347. */
  53348. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53349. /**
  53350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53351. * @param scene scene in which to add meshes
  53352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53353. */
  53354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53355. /**
  53356. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53357. * can be transformed by button presses and axes values, based on this._mapping.
  53358. *
  53359. * @param scene scene in which the meshes exist
  53360. * @param meshes list of meshes that make up the controller model to process
  53361. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53362. */
  53363. private processModel;
  53364. private createMeshInfo;
  53365. /**
  53366. * Gets the ray of the controller in the direction the controller is pointing
  53367. * @param length the length the resulting ray should be
  53368. * @returns a ray in the direction the controller is pointing
  53369. */
  53370. getForwardRay(length?: number): Ray;
  53371. /**
  53372. * Disposes of the controller
  53373. */
  53374. dispose(): void;
  53375. }
  53376. /**
  53377. * This class represents a new windows motion controller in XR.
  53378. */
  53379. export class XRWindowsMotionController extends WindowsMotionController {
  53380. /**
  53381. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53382. */
  53383. protected readonly _mapping: {
  53384. buttons: string[];
  53385. buttonMeshNames: {
  53386. trigger: string;
  53387. menu: string;
  53388. grip: string;
  53389. thumbstick: string;
  53390. trackpad: string;
  53391. };
  53392. buttonObservableNames: {
  53393. trigger: string;
  53394. menu: string;
  53395. grip: string;
  53396. thumbstick: string;
  53397. trackpad: string;
  53398. };
  53399. axisMeshNames: string[];
  53400. pointingPoseMeshName: string;
  53401. };
  53402. /**
  53403. * Construct a new XR-Based windows motion controller
  53404. *
  53405. * @param gamepadInfo the gamepad object from the browser
  53406. */
  53407. constructor(gamepadInfo: any);
  53408. /**
  53409. * holds the thumbstick values (X,Y)
  53410. */
  53411. thumbstickValues: StickValues;
  53412. /**
  53413. * Fired when the thumbstick on this controller is clicked
  53414. */
  53415. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53416. /**
  53417. * Fired when the thumbstick on this controller is modified
  53418. */
  53419. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53420. /**
  53421. * Fired when the touchpad button on this controller is modified
  53422. */
  53423. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53424. /**
  53425. * Fired when the touchpad values on this controller are modified
  53426. */
  53427. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53428. /**
  53429. * Fired when the thumbstick button on this controller is modified
  53430. * here to prevent breaking changes
  53431. */
  53432. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53433. /**
  53434. * updating the thumbstick(!) and not the trackpad.
  53435. * This is named this way due to the difference between WebVR and XR and to avoid
  53436. * changing the parent class.
  53437. */
  53438. protected _updateTrackpad(): void;
  53439. /**
  53440. * Disposes the class with joy
  53441. */
  53442. dispose(): void;
  53443. }
  53444. }
  53445. declare module BABYLON {
  53446. /**
  53447. * Class containing static functions to help procedurally build meshes
  53448. */
  53449. export class PolyhedronBuilder {
  53450. /**
  53451. * Creates a polyhedron mesh
  53452. * * 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
  53453. * * The parameter `size` (positive float, default 1) sets the polygon size
  53454. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53455. * * 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`
  53456. * * 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
  53457. * * 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)`)
  53458. * * 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
  53459. * * 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
  53460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53461. * * 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
  53462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53463. * @param name defines the name of the mesh
  53464. * @param options defines the options used to create the mesh
  53465. * @param scene defines the hosting scene
  53466. * @returns the polyhedron mesh
  53467. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53468. */
  53469. static CreatePolyhedron(name: string, options: {
  53470. type?: number;
  53471. size?: number;
  53472. sizeX?: number;
  53473. sizeY?: number;
  53474. sizeZ?: number;
  53475. custom?: any;
  53476. faceUV?: Vector4[];
  53477. faceColors?: Color4[];
  53478. flat?: boolean;
  53479. updatable?: boolean;
  53480. sideOrientation?: number;
  53481. frontUVs?: Vector4;
  53482. backUVs?: Vector4;
  53483. }, scene?: Nullable<Scene>): Mesh;
  53484. }
  53485. }
  53486. declare module BABYLON {
  53487. /**
  53488. * Gizmo that enables scaling a mesh along 3 axis
  53489. */
  53490. export class ScaleGizmo extends Gizmo {
  53491. /**
  53492. * Internal gizmo used for interactions on the x axis
  53493. */
  53494. xGizmo: AxisScaleGizmo;
  53495. /**
  53496. * Internal gizmo used for interactions on the y axis
  53497. */
  53498. yGizmo: AxisScaleGizmo;
  53499. /**
  53500. * Internal gizmo used for interactions on the z axis
  53501. */
  53502. zGizmo: AxisScaleGizmo;
  53503. /**
  53504. * Internal gizmo used to scale all axis equally
  53505. */
  53506. uniformScaleGizmo: AxisScaleGizmo;
  53507. private _meshAttached;
  53508. private _nodeAttached;
  53509. private _snapDistance;
  53510. private _uniformScalingMesh;
  53511. private _octahedron;
  53512. private _sensitivity;
  53513. /** Fires an event when any of it's sub gizmos are dragged */
  53514. onDragStartObservable: Observable<unknown>;
  53515. /** Fires an event when any of it's sub gizmos are released from dragging */
  53516. onDragEndObservable: Observable<unknown>;
  53517. get attachedMesh(): Nullable<AbstractMesh>;
  53518. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53519. get attachedNode(): Nullable<Node>;
  53520. set attachedNode(node: Nullable<Node>);
  53521. /**
  53522. * Creates a ScaleGizmo
  53523. * @param gizmoLayer The utility layer the gizmo will be added to
  53524. * @param thickness display gizmo axis thickness
  53525. */
  53526. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53527. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53528. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53529. /**
  53530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53531. */
  53532. set snapDistance(value: number);
  53533. get snapDistance(): number;
  53534. /**
  53535. * Ratio for the scale of the gizmo (Default: 1)
  53536. */
  53537. set scaleRatio(value: number);
  53538. get scaleRatio(): number;
  53539. /**
  53540. * Sensitivity factor for dragging (Default: 1)
  53541. */
  53542. set sensitivity(value: number);
  53543. get sensitivity(): number;
  53544. /**
  53545. * Disposes of the gizmo
  53546. */
  53547. dispose(): void;
  53548. }
  53549. }
  53550. declare module BABYLON {
  53551. /**
  53552. * Single axis scale gizmo
  53553. */
  53554. export class AxisScaleGizmo extends Gizmo {
  53555. /**
  53556. * Drag behavior responsible for the gizmos dragging interactions
  53557. */
  53558. dragBehavior: PointerDragBehavior;
  53559. private _pointerObserver;
  53560. /**
  53561. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53562. */
  53563. snapDistance: number;
  53564. /**
  53565. * Event that fires each time the gizmo snaps to a new location.
  53566. * * snapDistance is the the change in distance
  53567. */
  53568. onSnapObservable: Observable<{
  53569. snapDistance: number;
  53570. }>;
  53571. /**
  53572. * If the scaling operation should be done on all axis (default: false)
  53573. */
  53574. uniformScaling: boolean;
  53575. /**
  53576. * Custom sensitivity value for the drag strength
  53577. */
  53578. sensitivity: number;
  53579. private _isEnabled;
  53580. private _parent;
  53581. private _arrow;
  53582. private _coloredMaterial;
  53583. private _hoverMaterial;
  53584. /**
  53585. * Creates an AxisScaleGizmo
  53586. * @param gizmoLayer The utility layer the gizmo will be added to
  53587. * @param dragAxis The axis which the gizmo will be able to scale on
  53588. * @param color The color of the gizmo
  53589. * @param thickness display gizmo axis thickness
  53590. */
  53591. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53592. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53593. /**
  53594. * If the gizmo is enabled
  53595. */
  53596. set isEnabled(value: boolean);
  53597. get isEnabled(): boolean;
  53598. /**
  53599. * Disposes of the gizmo
  53600. */
  53601. dispose(): void;
  53602. /**
  53603. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53604. * @param mesh The mesh to replace the default mesh of the gizmo
  53605. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53606. */
  53607. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53608. }
  53609. }
  53610. declare module BABYLON {
  53611. /**
  53612. * Bounding box gizmo
  53613. */
  53614. export class BoundingBoxGizmo extends Gizmo {
  53615. private _lineBoundingBox;
  53616. private _rotateSpheresParent;
  53617. private _scaleBoxesParent;
  53618. private _boundingDimensions;
  53619. private _renderObserver;
  53620. private _pointerObserver;
  53621. private _scaleDragSpeed;
  53622. private _tmpQuaternion;
  53623. private _tmpVector;
  53624. private _tmpRotationMatrix;
  53625. /**
  53626. * 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)
  53627. */
  53628. ignoreChildren: boolean;
  53629. /**
  53630. * 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)
  53631. */
  53632. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53633. /**
  53634. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53635. */
  53636. rotationSphereSize: number;
  53637. /**
  53638. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53639. */
  53640. scaleBoxSize: number;
  53641. /**
  53642. * 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)
  53643. */
  53644. fixedDragMeshScreenSize: boolean;
  53645. /**
  53646. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53647. */
  53648. fixedDragMeshScreenSizeDistanceFactor: number;
  53649. /**
  53650. * Fired when a rotation sphere or scale box is dragged
  53651. */
  53652. onDragStartObservable: Observable<{}>;
  53653. /**
  53654. * Fired when a scale box is dragged
  53655. */
  53656. onScaleBoxDragObservable: Observable<{}>;
  53657. /**
  53658. * Fired when a scale box drag is ended
  53659. */
  53660. onScaleBoxDragEndObservable: Observable<{}>;
  53661. /**
  53662. * Fired when a rotation sphere is dragged
  53663. */
  53664. onRotationSphereDragObservable: Observable<{}>;
  53665. /**
  53666. * Fired when a rotation sphere drag is ended
  53667. */
  53668. onRotationSphereDragEndObservable: Observable<{}>;
  53669. /**
  53670. * 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)
  53671. */
  53672. scalePivot: Nullable<Vector3>;
  53673. /**
  53674. * Mesh used as a pivot to rotate the attached node
  53675. */
  53676. private _anchorMesh;
  53677. private _existingMeshScale;
  53678. private _dragMesh;
  53679. private pointerDragBehavior;
  53680. private coloredMaterial;
  53681. private hoverColoredMaterial;
  53682. /**
  53683. * Sets the color of the bounding box gizmo
  53684. * @param color the color to set
  53685. */
  53686. setColor(color: Color3): void;
  53687. /**
  53688. * Creates an BoundingBoxGizmo
  53689. * @param gizmoLayer The utility layer the gizmo will be added to
  53690. * @param color The color of the gizmo
  53691. */
  53692. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53693. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53694. private _selectNode;
  53695. /**
  53696. * Updates the bounding box information for the Gizmo
  53697. */
  53698. updateBoundingBox(): void;
  53699. private _updateRotationSpheres;
  53700. private _updateScaleBoxes;
  53701. /**
  53702. * Enables rotation on the specified axis and disables rotation on the others
  53703. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53704. */
  53705. setEnabledRotationAxis(axis: string): void;
  53706. /**
  53707. * Enables/disables scaling
  53708. * @param enable if scaling should be enabled
  53709. * @param homogeneousScaling defines if scaling should only be homogeneous
  53710. */
  53711. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53712. private _updateDummy;
  53713. /**
  53714. * Enables a pointer drag behavior on the bounding box of the gizmo
  53715. */
  53716. enableDragBehavior(): void;
  53717. /**
  53718. * Disposes of the gizmo
  53719. */
  53720. dispose(): void;
  53721. /**
  53722. * 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)
  53723. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53724. * @returns the bounding box mesh with the passed in mesh as a child
  53725. */
  53726. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53727. /**
  53728. * CustomMeshes are not supported by this gizmo
  53729. * @param mesh The mesh to replace the default mesh of the gizmo
  53730. */
  53731. setCustomMesh(mesh: Mesh): void;
  53732. }
  53733. }
  53734. declare module BABYLON {
  53735. /**
  53736. * Single plane rotation gizmo
  53737. */
  53738. export class PlaneRotationGizmo extends Gizmo {
  53739. /**
  53740. * Drag behavior responsible for the gizmos dragging interactions
  53741. */
  53742. dragBehavior: PointerDragBehavior;
  53743. private _pointerObserver;
  53744. /**
  53745. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53746. */
  53747. snapDistance: number;
  53748. /**
  53749. * Event that fires each time the gizmo snaps to a new location.
  53750. * * snapDistance is the the change in distance
  53751. */
  53752. onSnapObservable: Observable<{
  53753. snapDistance: number;
  53754. }>;
  53755. private _isEnabled;
  53756. private _parent;
  53757. /**
  53758. * Creates a PlaneRotationGizmo
  53759. * @param gizmoLayer The utility layer the gizmo will be added to
  53760. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53761. * @param color The color of the gizmo
  53762. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53763. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53764. * @param thickness display gizmo axis thickness
  53765. */
  53766. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53767. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53768. /**
  53769. * If the gizmo is enabled
  53770. */
  53771. set isEnabled(value: boolean);
  53772. get isEnabled(): boolean;
  53773. /**
  53774. * Disposes of the gizmo
  53775. */
  53776. dispose(): void;
  53777. }
  53778. }
  53779. declare module BABYLON {
  53780. /**
  53781. * Gizmo that enables rotating a mesh along 3 axis
  53782. */
  53783. export class RotationGizmo extends Gizmo {
  53784. /**
  53785. * Internal gizmo used for interactions on the x axis
  53786. */
  53787. xGizmo: PlaneRotationGizmo;
  53788. /**
  53789. * Internal gizmo used for interactions on the y axis
  53790. */
  53791. yGizmo: PlaneRotationGizmo;
  53792. /**
  53793. * Internal gizmo used for interactions on the z axis
  53794. */
  53795. zGizmo: PlaneRotationGizmo;
  53796. /** Fires an event when any of it's sub gizmos are dragged */
  53797. onDragStartObservable: Observable<unknown>;
  53798. /** Fires an event when any of it's sub gizmos are released from dragging */
  53799. onDragEndObservable: Observable<unknown>;
  53800. private _meshAttached;
  53801. private _nodeAttached;
  53802. get attachedMesh(): Nullable<AbstractMesh>;
  53803. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53804. get attachedNode(): Nullable<Node>;
  53805. set attachedNode(node: Nullable<Node>);
  53806. /**
  53807. * Creates a RotationGizmo
  53808. * @param gizmoLayer The utility layer the gizmo will be added to
  53809. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53810. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53811. * @param thickness display gizmo axis thickness
  53812. */
  53813. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53814. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53815. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53816. /**
  53817. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53818. */
  53819. set snapDistance(value: number);
  53820. get snapDistance(): number;
  53821. /**
  53822. * Ratio for the scale of the gizmo (Default: 1)
  53823. */
  53824. set scaleRatio(value: number);
  53825. get scaleRatio(): number;
  53826. /**
  53827. * Disposes of the gizmo
  53828. */
  53829. dispose(): void;
  53830. /**
  53831. * CustomMeshes are not supported by this gizmo
  53832. * @param mesh The mesh to replace the default mesh of the gizmo
  53833. */
  53834. setCustomMesh(mesh: Mesh): void;
  53835. }
  53836. }
  53837. declare module BABYLON {
  53838. /**
  53839. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53840. */
  53841. export class GizmoManager implements IDisposable {
  53842. private scene;
  53843. /**
  53844. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53845. */
  53846. gizmos: {
  53847. positionGizmo: Nullable<PositionGizmo>;
  53848. rotationGizmo: Nullable<RotationGizmo>;
  53849. scaleGizmo: Nullable<ScaleGizmo>;
  53850. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53851. };
  53852. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53853. clearGizmoOnEmptyPointerEvent: boolean;
  53854. /** Fires an event when the manager is attached to a mesh */
  53855. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53856. /** Fires an event when the manager is attached to a node */
  53857. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53858. private _gizmosEnabled;
  53859. private _pointerObserver;
  53860. private _attachedMesh;
  53861. private _attachedNode;
  53862. private _boundingBoxColor;
  53863. private _defaultUtilityLayer;
  53864. private _defaultKeepDepthUtilityLayer;
  53865. private _thickness;
  53866. /**
  53867. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53868. */
  53869. boundingBoxDragBehavior: SixDofDragBehavior;
  53870. /**
  53871. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53872. */
  53873. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53874. /**
  53875. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53876. */
  53877. attachableNodes: Nullable<Array<Node>>;
  53878. /**
  53879. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53880. */
  53881. usePointerToAttachGizmos: boolean;
  53882. /**
  53883. * Utility layer that the bounding box gizmo belongs to
  53884. */
  53885. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53886. /**
  53887. * Utility layer that all gizmos besides bounding box belong to
  53888. */
  53889. get utilityLayer(): UtilityLayerRenderer;
  53890. /**
  53891. * Instatiates a gizmo manager
  53892. * @param scene the scene to overlay the gizmos on top of
  53893. * @param thickness display gizmo axis thickness
  53894. */
  53895. constructor(scene: Scene, thickness?: number);
  53896. /**
  53897. * Attaches a set of gizmos to the specified mesh
  53898. * @param mesh The mesh the gizmo's should be attached to
  53899. */
  53900. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53901. /**
  53902. * Attaches a set of gizmos to the specified node
  53903. * @param node The node the gizmo's should be attached to
  53904. */
  53905. attachToNode(node: Nullable<Node>): void;
  53906. /**
  53907. * If the position gizmo is enabled
  53908. */
  53909. set positionGizmoEnabled(value: boolean);
  53910. get positionGizmoEnabled(): boolean;
  53911. /**
  53912. * If the rotation gizmo is enabled
  53913. */
  53914. set rotationGizmoEnabled(value: boolean);
  53915. get rotationGizmoEnabled(): boolean;
  53916. /**
  53917. * If the scale gizmo is enabled
  53918. */
  53919. set scaleGizmoEnabled(value: boolean);
  53920. get scaleGizmoEnabled(): boolean;
  53921. /**
  53922. * If the boundingBox gizmo is enabled
  53923. */
  53924. set boundingBoxGizmoEnabled(value: boolean);
  53925. get boundingBoxGizmoEnabled(): boolean;
  53926. /**
  53927. * Disposes of the gizmo manager
  53928. */
  53929. dispose(): void;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /**
  53934. * A directional light is defined by a direction (what a surprise!).
  53935. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53936. * 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.
  53937. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53938. */
  53939. export class DirectionalLight extends ShadowLight {
  53940. private _shadowFrustumSize;
  53941. /**
  53942. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53943. */
  53944. get shadowFrustumSize(): number;
  53945. /**
  53946. * Specifies a fix frustum size for the shadow generation.
  53947. */
  53948. set shadowFrustumSize(value: number);
  53949. private _shadowOrthoScale;
  53950. /**
  53951. * Gets the shadow projection scale against the optimal computed one.
  53952. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53953. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53954. */
  53955. get shadowOrthoScale(): number;
  53956. /**
  53957. * Sets the shadow projection scale against the optimal computed one.
  53958. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53959. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53960. */
  53961. set shadowOrthoScale(value: number);
  53962. /**
  53963. * Automatically compute the projection matrix to best fit (including all the casters)
  53964. * on each frame.
  53965. */
  53966. autoUpdateExtends: boolean;
  53967. /**
  53968. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53969. * on each frame. autoUpdateExtends must be set to true for this to work
  53970. */
  53971. autoCalcShadowZBounds: boolean;
  53972. private _orthoLeft;
  53973. private _orthoRight;
  53974. private _orthoTop;
  53975. private _orthoBottom;
  53976. /**
  53977. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53978. * The directional light is emitted from everywhere in the given direction.
  53979. * It can cast shadows.
  53980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53981. * @param name The friendly name of the light
  53982. * @param direction The direction of the light
  53983. * @param scene The scene the light belongs to
  53984. */
  53985. constructor(name: string, direction: Vector3, scene: Scene);
  53986. /**
  53987. * Returns the string "DirectionalLight".
  53988. * @return The class name
  53989. */
  53990. getClassName(): string;
  53991. /**
  53992. * Returns the integer 1.
  53993. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53994. */
  53995. getTypeID(): number;
  53996. /**
  53997. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53998. * Returns the DirectionalLight Shadow projection matrix.
  53999. */
  54000. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54001. /**
  54002. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54003. * Returns the DirectionalLight Shadow projection matrix.
  54004. */
  54005. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54006. /**
  54007. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54008. * Returns the DirectionalLight Shadow projection matrix.
  54009. */
  54010. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54011. protected _buildUniformLayout(): void;
  54012. /**
  54013. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54014. * @param effect The effect to update
  54015. * @param lightIndex The index of the light in the effect to update
  54016. * @returns The directional light
  54017. */
  54018. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54019. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54020. /**
  54021. * Gets the minZ used for shadow according to both the scene and the light.
  54022. *
  54023. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54024. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54025. * @param activeCamera The camera we are returning the min for
  54026. * @returns the depth min z
  54027. */
  54028. getDepthMinZ(activeCamera: Camera): number;
  54029. /**
  54030. * Gets the maxZ used for shadow according to both the scene and the light.
  54031. *
  54032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54034. * @param activeCamera The camera we are returning the max for
  54035. * @returns the depth max z
  54036. */
  54037. getDepthMaxZ(activeCamera: Camera): number;
  54038. /**
  54039. * Prepares the list of defines specific to the light type.
  54040. * @param defines the list of defines
  54041. * @param lightIndex defines the index of the light for the effect
  54042. */
  54043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54044. }
  54045. }
  54046. declare module BABYLON {
  54047. /**
  54048. * Class containing static functions to help procedurally build meshes
  54049. */
  54050. export class HemisphereBuilder {
  54051. /**
  54052. * Creates a hemisphere mesh
  54053. * @param name defines the name of the mesh
  54054. * @param options defines the options used to create the mesh
  54055. * @param scene defines the hosting scene
  54056. * @returns the hemisphere mesh
  54057. */
  54058. static CreateHemisphere(name: string, options: {
  54059. segments?: number;
  54060. diameter?: number;
  54061. sideOrientation?: number;
  54062. }, scene: any): Mesh;
  54063. }
  54064. }
  54065. declare module BABYLON {
  54066. /**
  54067. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54068. * These values define a cone of light starting from the position, emitting toward the direction.
  54069. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54070. * and the exponent defines the speed of the decay of the light with distance (reach).
  54071. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54072. */
  54073. export class SpotLight extends ShadowLight {
  54074. private _angle;
  54075. private _innerAngle;
  54076. private _cosHalfAngle;
  54077. private _lightAngleScale;
  54078. private _lightAngleOffset;
  54079. /**
  54080. * Gets the cone angle of the spot light in Radians.
  54081. */
  54082. get angle(): number;
  54083. /**
  54084. * Sets the cone angle of the spot light in Radians.
  54085. */
  54086. set angle(value: number);
  54087. /**
  54088. * Only used in gltf falloff mode, this defines the angle where
  54089. * the directional falloff will start before cutting at angle which could be seen
  54090. * as outer angle.
  54091. */
  54092. get innerAngle(): number;
  54093. /**
  54094. * Only used in gltf falloff mode, this defines the angle where
  54095. * the directional falloff will start before cutting at angle which could be seen
  54096. * as outer angle.
  54097. */
  54098. set innerAngle(value: number);
  54099. private _shadowAngleScale;
  54100. /**
  54101. * Allows scaling the angle of the light for shadow generation only.
  54102. */
  54103. get shadowAngleScale(): number;
  54104. /**
  54105. * Allows scaling the angle of the light for shadow generation only.
  54106. */
  54107. set shadowAngleScale(value: number);
  54108. /**
  54109. * The light decay speed with the distance from the emission spot.
  54110. */
  54111. exponent: number;
  54112. private _projectionTextureMatrix;
  54113. /**
  54114. * Allows reading the projecton texture
  54115. */
  54116. get projectionTextureMatrix(): Matrix;
  54117. protected _projectionTextureLightNear: number;
  54118. /**
  54119. * Gets the near clip of the Spotlight for texture projection.
  54120. */
  54121. get projectionTextureLightNear(): number;
  54122. /**
  54123. * Sets the near clip of the Spotlight for texture projection.
  54124. */
  54125. set projectionTextureLightNear(value: number);
  54126. protected _projectionTextureLightFar: number;
  54127. /**
  54128. * Gets the far clip of the Spotlight for texture projection.
  54129. */
  54130. get projectionTextureLightFar(): number;
  54131. /**
  54132. * Sets the far clip of the Spotlight for texture projection.
  54133. */
  54134. set projectionTextureLightFar(value: number);
  54135. protected _projectionTextureUpDirection: Vector3;
  54136. /**
  54137. * Gets the Up vector of the Spotlight for texture projection.
  54138. */
  54139. get projectionTextureUpDirection(): Vector3;
  54140. /**
  54141. * Sets the Up vector of the Spotlight for texture projection.
  54142. */
  54143. set projectionTextureUpDirection(value: Vector3);
  54144. private _projectionTexture;
  54145. /**
  54146. * Gets the projection texture of the light.
  54147. */
  54148. get projectionTexture(): Nullable<BaseTexture>;
  54149. /**
  54150. * Sets the projection texture of the light.
  54151. */
  54152. set projectionTexture(value: Nullable<BaseTexture>);
  54153. private _projectionTextureViewLightDirty;
  54154. private _projectionTextureProjectionLightDirty;
  54155. private _projectionTextureDirty;
  54156. private _projectionTextureViewTargetVector;
  54157. private _projectionTextureViewLightMatrix;
  54158. private _projectionTextureProjectionLightMatrix;
  54159. private _projectionTextureScalingMatrix;
  54160. /**
  54161. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54162. * It can cast shadows.
  54163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54164. * @param name The light friendly name
  54165. * @param position The position of the spot light in the scene
  54166. * @param direction The direction of the light in the scene
  54167. * @param angle The cone angle of the light in Radians
  54168. * @param exponent The light decay speed with the distance from the emission spot
  54169. * @param scene The scene the lights belongs to
  54170. */
  54171. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54172. /**
  54173. * Returns the string "SpotLight".
  54174. * @returns the class name
  54175. */
  54176. getClassName(): string;
  54177. /**
  54178. * Returns the integer 2.
  54179. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54180. */
  54181. getTypeID(): number;
  54182. /**
  54183. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54184. */
  54185. protected _setDirection(value: Vector3): void;
  54186. /**
  54187. * Overrides the position setter to recompute the projection texture view light Matrix.
  54188. */
  54189. protected _setPosition(value: Vector3): void;
  54190. /**
  54191. * 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.
  54192. * Returns the SpotLight.
  54193. */
  54194. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54195. protected _computeProjectionTextureViewLightMatrix(): void;
  54196. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54197. /**
  54198. * Main function for light texture projection matrix computing.
  54199. */
  54200. protected _computeProjectionTextureMatrix(): void;
  54201. protected _buildUniformLayout(): void;
  54202. private _computeAngleValues;
  54203. /**
  54204. * Sets the passed Effect "effect" with the Light textures.
  54205. * @param effect The effect to update
  54206. * @param lightIndex The index of the light in the effect to update
  54207. * @returns The light
  54208. */
  54209. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54210. /**
  54211. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54212. * @param effect The effect to update
  54213. * @param lightIndex The index of the light in the effect to update
  54214. * @returns The spot light
  54215. */
  54216. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54217. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54218. /**
  54219. * Disposes the light and the associated resources.
  54220. */
  54221. dispose(): void;
  54222. /**
  54223. * Prepares the list of defines specific to the light type.
  54224. * @param defines the list of defines
  54225. * @param lightIndex defines the index of the light for the effect
  54226. */
  54227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54228. }
  54229. }
  54230. declare module BABYLON {
  54231. /**
  54232. * Gizmo that enables viewing a light
  54233. */
  54234. export class LightGizmo extends Gizmo {
  54235. private _lightMesh;
  54236. private _material;
  54237. private _cachedPosition;
  54238. private _cachedForward;
  54239. private _attachedMeshParent;
  54240. private _pointerObserver;
  54241. /**
  54242. * Event that fires each time the gizmo is clicked
  54243. */
  54244. onClickedObservable: Observable<Light>;
  54245. /**
  54246. * Creates a LightGizmo
  54247. * @param gizmoLayer The utility layer the gizmo will be added to
  54248. */
  54249. constructor(gizmoLayer?: UtilityLayerRenderer);
  54250. private _light;
  54251. /**
  54252. * The light that the gizmo is attached to
  54253. */
  54254. set light(light: Nullable<Light>);
  54255. get light(): Nullable<Light>;
  54256. /**
  54257. * Gets the material used to render the light gizmo
  54258. */
  54259. get material(): StandardMaterial;
  54260. /**
  54261. * @hidden
  54262. * Updates the gizmo to match the attached mesh's position/rotation
  54263. */
  54264. protected _update(): void;
  54265. private static _Scale;
  54266. /**
  54267. * Creates the lines for a light mesh
  54268. */
  54269. private static _CreateLightLines;
  54270. /**
  54271. * Disposes of the light gizmo
  54272. */
  54273. dispose(): void;
  54274. private static _CreateHemisphericLightMesh;
  54275. private static _CreatePointLightMesh;
  54276. private static _CreateSpotLightMesh;
  54277. private static _CreateDirectionalLightMesh;
  54278. }
  54279. }
  54280. declare module BABYLON {
  54281. /**
  54282. * Gizmo that enables viewing a camera
  54283. */
  54284. export class CameraGizmo extends Gizmo {
  54285. private _cameraMesh;
  54286. private _cameraLinesMesh;
  54287. private _material;
  54288. private _pointerObserver;
  54289. /**
  54290. * Event that fires each time the gizmo is clicked
  54291. */
  54292. onClickedObservable: Observable<Camera>;
  54293. /**
  54294. * Creates a CameraGizmo
  54295. * @param gizmoLayer The utility layer the gizmo will be added to
  54296. */
  54297. constructor(gizmoLayer?: UtilityLayerRenderer);
  54298. private _camera;
  54299. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54300. get displayFrustum(): boolean;
  54301. set displayFrustum(value: boolean);
  54302. /**
  54303. * The camera that the gizmo is attached to
  54304. */
  54305. set camera(camera: Nullable<Camera>);
  54306. get camera(): Nullable<Camera>;
  54307. /**
  54308. * Gets the material used to render the camera gizmo
  54309. */
  54310. get material(): StandardMaterial;
  54311. /**
  54312. * @hidden
  54313. * Updates the gizmo to match the attached mesh's position/rotation
  54314. */
  54315. protected _update(): void;
  54316. private static _Scale;
  54317. private _invProjection;
  54318. /**
  54319. * Disposes of the camera gizmo
  54320. */
  54321. dispose(): void;
  54322. private static _CreateCameraMesh;
  54323. private static _CreateCameraFrustum;
  54324. }
  54325. }
  54326. declare module BABYLON {
  54327. /** @hidden */
  54328. export var backgroundFragmentDeclaration: {
  54329. name: string;
  54330. shader: string;
  54331. };
  54332. }
  54333. declare module BABYLON {
  54334. /** @hidden */
  54335. export var backgroundUboDeclaration: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module BABYLON {
  54341. /** @hidden */
  54342. export var backgroundPixelShader: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module BABYLON {
  54348. /** @hidden */
  54349. export var backgroundVertexDeclaration: {
  54350. name: string;
  54351. shader: string;
  54352. };
  54353. }
  54354. declare module BABYLON {
  54355. /** @hidden */
  54356. export var backgroundVertexShader: {
  54357. name: string;
  54358. shader: string;
  54359. };
  54360. }
  54361. declare module BABYLON {
  54362. /**
  54363. * Background material used to create an efficient environement around your scene.
  54364. */
  54365. export class BackgroundMaterial extends PushMaterial {
  54366. /**
  54367. * Standard reflectance value at parallel view angle.
  54368. */
  54369. static StandardReflectance0: number;
  54370. /**
  54371. * Standard reflectance value at grazing angle.
  54372. */
  54373. static StandardReflectance90: number;
  54374. protected _primaryColor: Color3;
  54375. /**
  54376. * Key light Color (multiply against the environement texture)
  54377. */
  54378. primaryColor: Color3;
  54379. protected __perceptualColor: Nullable<Color3>;
  54380. /**
  54381. * Experimental Internal Use Only.
  54382. *
  54383. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54384. * This acts as a helper to set the primary color to a more "human friendly" value.
  54385. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54386. * output color as close as possible from the chosen value.
  54387. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54388. * part of lighting setup.)
  54389. */
  54390. get _perceptualColor(): Nullable<Color3>;
  54391. set _perceptualColor(value: Nullable<Color3>);
  54392. protected _primaryColorShadowLevel: float;
  54393. /**
  54394. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54395. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54396. */
  54397. get primaryColorShadowLevel(): float;
  54398. set primaryColorShadowLevel(value: float);
  54399. protected _primaryColorHighlightLevel: float;
  54400. /**
  54401. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54402. * The primary color is used at the level chosen to define what the white area would look.
  54403. */
  54404. get primaryColorHighlightLevel(): float;
  54405. set primaryColorHighlightLevel(value: float);
  54406. protected _reflectionTexture: Nullable<BaseTexture>;
  54407. /**
  54408. * Reflection Texture used in the material.
  54409. * Should be author in a specific way for the best result (refer to the documentation).
  54410. */
  54411. reflectionTexture: Nullable<BaseTexture>;
  54412. protected _reflectionBlur: float;
  54413. /**
  54414. * Reflection Texture level of blur.
  54415. *
  54416. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54417. * texture twice.
  54418. */
  54419. reflectionBlur: float;
  54420. protected _diffuseTexture: Nullable<BaseTexture>;
  54421. /**
  54422. * Diffuse Texture used in the material.
  54423. * Should be author in a specific way for the best result (refer to the documentation).
  54424. */
  54425. diffuseTexture: Nullable<BaseTexture>;
  54426. protected _shadowLights: Nullable<IShadowLight[]>;
  54427. /**
  54428. * Specify the list of lights casting shadow on the material.
  54429. * All scene shadow lights will be included if null.
  54430. */
  54431. shadowLights: Nullable<IShadowLight[]>;
  54432. protected _shadowLevel: float;
  54433. /**
  54434. * Helps adjusting the shadow to a softer level if required.
  54435. * 0 means black shadows and 1 means no shadows.
  54436. */
  54437. shadowLevel: float;
  54438. protected _sceneCenter: Vector3;
  54439. /**
  54440. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54441. * It is usually zero but might be interesting to modify according to your setup.
  54442. */
  54443. sceneCenter: Vector3;
  54444. protected _opacityFresnel: boolean;
  54445. /**
  54446. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54447. * This helps ensuring a nice transition when the camera goes under the ground.
  54448. */
  54449. opacityFresnel: boolean;
  54450. protected _reflectionFresnel: boolean;
  54451. /**
  54452. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54453. * This helps adding a mirror texture on the ground.
  54454. */
  54455. reflectionFresnel: boolean;
  54456. protected _reflectionFalloffDistance: number;
  54457. /**
  54458. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54459. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54460. */
  54461. reflectionFalloffDistance: number;
  54462. protected _reflectionAmount: number;
  54463. /**
  54464. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54465. */
  54466. reflectionAmount: number;
  54467. protected _reflectionReflectance0: number;
  54468. /**
  54469. * This specifies the weight of the reflection at grazing angle.
  54470. */
  54471. reflectionReflectance0: number;
  54472. protected _reflectionReflectance90: number;
  54473. /**
  54474. * This specifies the weight of the reflection at a perpendicular point of view.
  54475. */
  54476. reflectionReflectance90: number;
  54477. /**
  54478. * Sets the reflection reflectance fresnel values according to the default standard
  54479. * empirically know to work well :-)
  54480. */
  54481. set reflectionStandardFresnelWeight(value: number);
  54482. protected _useRGBColor: boolean;
  54483. /**
  54484. * Helps to directly use the maps channels instead of their level.
  54485. */
  54486. useRGBColor: boolean;
  54487. protected _enableNoise: boolean;
  54488. /**
  54489. * This helps reducing the banding effect that could occur on the background.
  54490. */
  54491. enableNoise: boolean;
  54492. /**
  54493. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54494. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54495. * Recommended to be keep at 1.0 except for special cases.
  54496. */
  54497. get fovMultiplier(): number;
  54498. set fovMultiplier(value: number);
  54499. private _fovMultiplier;
  54500. /**
  54501. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54502. */
  54503. useEquirectangularFOV: boolean;
  54504. private _maxSimultaneousLights;
  54505. /**
  54506. * Number of Simultaneous lights allowed on the material.
  54507. */
  54508. maxSimultaneousLights: int;
  54509. private _shadowOnly;
  54510. /**
  54511. * Make the material only render shadows
  54512. */
  54513. shadowOnly: boolean;
  54514. /**
  54515. * Default configuration related to image processing available in the Background Material.
  54516. */
  54517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54518. /**
  54519. * Keep track of the image processing observer to allow dispose and replace.
  54520. */
  54521. private _imageProcessingObserver;
  54522. /**
  54523. * Attaches a new image processing configuration to the PBR Material.
  54524. * @param configuration (if null the scene configuration will be use)
  54525. */
  54526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54527. /**
  54528. * Gets the image processing configuration used either in this material.
  54529. */
  54530. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54531. /**
  54532. * Sets the Default image processing configuration used either in the this material.
  54533. *
  54534. * If sets to null, the scene one is in use.
  54535. */
  54536. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54537. /**
  54538. * Gets wether the color curves effect is enabled.
  54539. */
  54540. get cameraColorCurvesEnabled(): boolean;
  54541. /**
  54542. * Sets wether the color curves effect is enabled.
  54543. */
  54544. set cameraColorCurvesEnabled(value: boolean);
  54545. /**
  54546. * Gets wether the color grading effect is enabled.
  54547. */
  54548. get cameraColorGradingEnabled(): boolean;
  54549. /**
  54550. * Gets wether the color grading effect is enabled.
  54551. */
  54552. set cameraColorGradingEnabled(value: boolean);
  54553. /**
  54554. * Gets wether tonemapping is enabled or not.
  54555. */
  54556. get cameraToneMappingEnabled(): boolean;
  54557. /**
  54558. * Sets wether tonemapping is enabled or not
  54559. */
  54560. set cameraToneMappingEnabled(value: boolean);
  54561. /**
  54562. * The camera exposure used on this material.
  54563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54564. * This corresponds to a photographic exposure.
  54565. */
  54566. get cameraExposure(): float;
  54567. /**
  54568. * The camera exposure used on this material.
  54569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54570. * This corresponds to a photographic exposure.
  54571. */
  54572. set cameraExposure(value: float);
  54573. /**
  54574. * Gets The camera contrast used on this material.
  54575. */
  54576. get cameraContrast(): float;
  54577. /**
  54578. * Sets The camera contrast used on this material.
  54579. */
  54580. set cameraContrast(value: float);
  54581. /**
  54582. * Gets the Color Grading 2D Lookup Texture.
  54583. */
  54584. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54585. /**
  54586. * Sets the Color Grading 2D Lookup Texture.
  54587. */
  54588. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54589. /**
  54590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54592. * 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;
  54593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54594. */
  54595. get cameraColorCurves(): Nullable<ColorCurves>;
  54596. /**
  54597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54599. * 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;
  54600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54601. */
  54602. set cameraColorCurves(value: Nullable<ColorCurves>);
  54603. /**
  54604. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54605. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54606. */
  54607. switchToBGR: boolean;
  54608. private _renderTargets;
  54609. private _reflectionControls;
  54610. private _white;
  54611. private _primaryShadowColor;
  54612. private _primaryHighlightColor;
  54613. /**
  54614. * Instantiates a Background Material in the given scene
  54615. * @param name The friendly name of the material
  54616. * @param scene The scene to add the material to
  54617. */
  54618. constructor(name: string, scene: Scene);
  54619. /**
  54620. * Gets a boolean indicating that current material needs to register RTT
  54621. */
  54622. get hasRenderTargetTextures(): boolean;
  54623. /**
  54624. * The entire material has been created in order to prevent overdraw.
  54625. * @returns false
  54626. */
  54627. needAlphaTesting(): boolean;
  54628. /**
  54629. * The entire material has been created in order to prevent overdraw.
  54630. * @returns true if blending is enable
  54631. */
  54632. needAlphaBlending(): boolean;
  54633. /**
  54634. * Checks wether the material is ready to be rendered for a given mesh.
  54635. * @param mesh The mesh to render
  54636. * @param subMesh The submesh to check against
  54637. * @param useInstances Specify wether or not the material is used with instances
  54638. * @returns true if all the dependencies are ready (Textures, Effects...)
  54639. */
  54640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54641. /**
  54642. * Compute the primary color according to the chosen perceptual color.
  54643. */
  54644. private _computePrimaryColorFromPerceptualColor;
  54645. /**
  54646. * Compute the highlights and shadow colors according to their chosen levels.
  54647. */
  54648. private _computePrimaryColors;
  54649. /**
  54650. * Build the uniform buffer used in the material.
  54651. */
  54652. buildUniformLayout(): void;
  54653. /**
  54654. * Unbind the material.
  54655. */
  54656. unbind(): void;
  54657. /**
  54658. * Bind only the world matrix to the material.
  54659. * @param world The world matrix to bind.
  54660. */
  54661. bindOnlyWorldMatrix(world: Matrix): void;
  54662. /**
  54663. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54664. * @param world The world matrix to bind.
  54665. * @param subMesh The submesh to bind for.
  54666. */
  54667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54668. /**
  54669. * Checks to see if a texture is used in the material.
  54670. * @param texture - Base texture to use.
  54671. * @returns - Boolean specifying if a texture is used in the material.
  54672. */
  54673. hasTexture(texture: BaseTexture): boolean;
  54674. /**
  54675. * Dispose the material.
  54676. * @param forceDisposeEffect Force disposal of the associated effect.
  54677. * @param forceDisposeTextures Force disposal of the associated textures.
  54678. */
  54679. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54680. /**
  54681. * Clones the material.
  54682. * @param name The cloned name.
  54683. * @returns The cloned material.
  54684. */
  54685. clone(name: string): BackgroundMaterial;
  54686. /**
  54687. * Serializes the current material to its JSON representation.
  54688. * @returns The JSON representation.
  54689. */
  54690. serialize(): any;
  54691. /**
  54692. * Gets the class name of the material
  54693. * @returns "BackgroundMaterial"
  54694. */
  54695. getClassName(): string;
  54696. /**
  54697. * Parse a JSON input to create back a background material.
  54698. * @param source The JSON data to parse
  54699. * @param scene The scene to create the parsed material in
  54700. * @param rootUrl The root url of the assets the material depends upon
  54701. * @returns the instantiated BackgroundMaterial.
  54702. */
  54703. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54704. }
  54705. }
  54706. declare module BABYLON {
  54707. /**
  54708. * Represents the different options available during the creation of
  54709. * a Environment helper.
  54710. *
  54711. * This can control the default ground, skybox and image processing setup of your scene.
  54712. */
  54713. export interface IEnvironmentHelperOptions {
  54714. /**
  54715. * Specifies whether or not to create a ground.
  54716. * True by default.
  54717. */
  54718. createGround: boolean;
  54719. /**
  54720. * Specifies the ground size.
  54721. * 15 by default.
  54722. */
  54723. groundSize: number;
  54724. /**
  54725. * The texture used on the ground for the main color.
  54726. * Comes from the BabylonJS CDN by default.
  54727. *
  54728. * Remarks: Can be either a texture or a url.
  54729. */
  54730. groundTexture: string | BaseTexture;
  54731. /**
  54732. * The color mixed in the ground texture by default.
  54733. * BabylonJS clearColor by default.
  54734. */
  54735. groundColor: Color3;
  54736. /**
  54737. * Specifies the ground opacity.
  54738. * 1 by default.
  54739. */
  54740. groundOpacity: number;
  54741. /**
  54742. * Enables the ground to receive shadows.
  54743. * True by default.
  54744. */
  54745. enableGroundShadow: boolean;
  54746. /**
  54747. * Helps preventing the shadow to be fully black on the ground.
  54748. * 0.5 by default.
  54749. */
  54750. groundShadowLevel: number;
  54751. /**
  54752. * Creates a mirror texture attach to the ground.
  54753. * false by default.
  54754. */
  54755. enableGroundMirror: boolean;
  54756. /**
  54757. * Specifies the ground mirror size ratio.
  54758. * 0.3 by default as the default kernel is 64.
  54759. */
  54760. groundMirrorSizeRatio: number;
  54761. /**
  54762. * Specifies the ground mirror blur kernel size.
  54763. * 64 by default.
  54764. */
  54765. groundMirrorBlurKernel: number;
  54766. /**
  54767. * Specifies the ground mirror visibility amount.
  54768. * 1 by default
  54769. */
  54770. groundMirrorAmount: number;
  54771. /**
  54772. * Specifies the ground mirror reflectance weight.
  54773. * This uses the standard weight of the background material to setup the fresnel effect
  54774. * of the mirror.
  54775. * 1 by default.
  54776. */
  54777. groundMirrorFresnelWeight: number;
  54778. /**
  54779. * Specifies the ground mirror Falloff distance.
  54780. * This can helps reducing the size of the reflection.
  54781. * 0 by Default.
  54782. */
  54783. groundMirrorFallOffDistance: number;
  54784. /**
  54785. * Specifies the ground mirror texture type.
  54786. * Unsigned Int by Default.
  54787. */
  54788. groundMirrorTextureType: number;
  54789. /**
  54790. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54791. * the shown objects.
  54792. */
  54793. groundYBias: number;
  54794. /**
  54795. * Specifies whether or not to create a skybox.
  54796. * True by default.
  54797. */
  54798. createSkybox: boolean;
  54799. /**
  54800. * Specifies the skybox size.
  54801. * 20 by default.
  54802. */
  54803. skyboxSize: number;
  54804. /**
  54805. * The texture used on the skybox for the main color.
  54806. * Comes from the BabylonJS CDN by default.
  54807. *
  54808. * Remarks: Can be either a texture or a url.
  54809. */
  54810. skyboxTexture: string | BaseTexture;
  54811. /**
  54812. * The color mixed in the skybox texture by default.
  54813. * BabylonJS clearColor by default.
  54814. */
  54815. skyboxColor: Color3;
  54816. /**
  54817. * The background rotation around the Y axis of the scene.
  54818. * This helps aligning the key lights of your scene with the background.
  54819. * 0 by default.
  54820. */
  54821. backgroundYRotation: number;
  54822. /**
  54823. * Compute automatically the size of the elements to best fit with the scene.
  54824. */
  54825. sizeAuto: boolean;
  54826. /**
  54827. * Default position of the rootMesh if autoSize is not true.
  54828. */
  54829. rootPosition: Vector3;
  54830. /**
  54831. * Sets up the image processing in the scene.
  54832. * true by default.
  54833. */
  54834. setupImageProcessing: boolean;
  54835. /**
  54836. * The texture used as your environment texture in the scene.
  54837. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54838. *
  54839. * Remarks: Can be either a texture or a url.
  54840. */
  54841. environmentTexture: string | BaseTexture;
  54842. /**
  54843. * The value of the exposure to apply to the scene.
  54844. * 0.6 by default if setupImageProcessing is true.
  54845. */
  54846. cameraExposure: number;
  54847. /**
  54848. * The value of the contrast to apply to the scene.
  54849. * 1.6 by default if setupImageProcessing is true.
  54850. */
  54851. cameraContrast: number;
  54852. /**
  54853. * Specifies whether or not tonemapping should be enabled in the scene.
  54854. * true by default if setupImageProcessing is true.
  54855. */
  54856. toneMappingEnabled: boolean;
  54857. }
  54858. /**
  54859. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54860. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54861. * It also helps with the default setup of your imageProcessing configuration.
  54862. */
  54863. export class EnvironmentHelper {
  54864. /**
  54865. * Default ground texture URL.
  54866. */
  54867. private static _groundTextureCDNUrl;
  54868. /**
  54869. * Default skybox texture URL.
  54870. */
  54871. private static _skyboxTextureCDNUrl;
  54872. /**
  54873. * Default environment texture URL.
  54874. */
  54875. private static _environmentTextureCDNUrl;
  54876. /**
  54877. * Creates the default options for the helper.
  54878. */
  54879. private static _getDefaultOptions;
  54880. private _rootMesh;
  54881. /**
  54882. * Gets the root mesh created by the helper.
  54883. */
  54884. get rootMesh(): Mesh;
  54885. private _skybox;
  54886. /**
  54887. * Gets the skybox created by the helper.
  54888. */
  54889. get skybox(): Nullable<Mesh>;
  54890. private _skyboxTexture;
  54891. /**
  54892. * Gets the skybox texture created by the helper.
  54893. */
  54894. get skyboxTexture(): Nullable<BaseTexture>;
  54895. private _skyboxMaterial;
  54896. /**
  54897. * Gets the skybox material created by the helper.
  54898. */
  54899. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54900. private _ground;
  54901. /**
  54902. * Gets the ground mesh created by the helper.
  54903. */
  54904. get ground(): Nullable<Mesh>;
  54905. private _groundTexture;
  54906. /**
  54907. * Gets the ground texture created by the helper.
  54908. */
  54909. get groundTexture(): Nullable<BaseTexture>;
  54910. private _groundMirror;
  54911. /**
  54912. * Gets the ground mirror created by the helper.
  54913. */
  54914. get groundMirror(): Nullable<MirrorTexture>;
  54915. /**
  54916. * Gets the ground mirror render list to helps pushing the meshes
  54917. * you wish in the ground reflection.
  54918. */
  54919. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54920. private _groundMaterial;
  54921. /**
  54922. * Gets the ground material created by the helper.
  54923. */
  54924. get groundMaterial(): Nullable<BackgroundMaterial>;
  54925. /**
  54926. * Stores the creation options.
  54927. */
  54928. private readonly _scene;
  54929. private _options;
  54930. /**
  54931. * This observable will be notified with any error during the creation of the environment,
  54932. * mainly texture creation errors.
  54933. */
  54934. onErrorObservable: Observable<{
  54935. message?: string;
  54936. exception?: any;
  54937. }>;
  54938. /**
  54939. * constructor
  54940. * @param options Defines the options we want to customize the helper
  54941. * @param scene The scene to add the material to
  54942. */
  54943. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54944. /**
  54945. * Updates the background according to the new options
  54946. * @param options
  54947. */
  54948. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54949. /**
  54950. * Sets the primary color of all the available elements.
  54951. * @param color the main color to affect to the ground and the background
  54952. */
  54953. setMainColor(color: Color3): void;
  54954. /**
  54955. * Setup the image processing according to the specified options.
  54956. */
  54957. private _setupImageProcessing;
  54958. /**
  54959. * Setup the environment texture according to the specified options.
  54960. */
  54961. private _setupEnvironmentTexture;
  54962. /**
  54963. * Setup the background according to the specified options.
  54964. */
  54965. private _setupBackground;
  54966. /**
  54967. * Get the scene sizes according to the setup.
  54968. */
  54969. private _getSceneSize;
  54970. /**
  54971. * Setup the ground according to the specified options.
  54972. */
  54973. private _setupGround;
  54974. /**
  54975. * Setup the ground material according to the specified options.
  54976. */
  54977. private _setupGroundMaterial;
  54978. /**
  54979. * Setup the ground diffuse texture according to the specified options.
  54980. */
  54981. private _setupGroundDiffuseTexture;
  54982. /**
  54983. * Setup the ground mirror texture according to the specified options.
  54984. */
  54985. private _setupGroundMirrorTexture;
  54986. /**
  54987. * Setup the ground to receive the mirror texture.
  54988. */
  54989. private _setupMirrorInGroundMaterial;
  54990. /**
  54991. * Setup the skybox according to the specified options.
  54992. */
  54993. private _setupSkybox;
  54994. /**
  54995. * Setup the skybox material according to the specified options.
  54996. */
  54997. private _setupSkyboxMaterial;
  54998. /**
  54999. * Setup the skybox reflection texture according to the specified options.
  55000. */
  55001. private _setupSkyboxReflectionTexture;
  55002. private _errorHandler;
  55003. /**
  55004. * Dispose all the elements created by the Helper.
  55005. */
  55006. dispose(): void;
  55007. }
  55008. }
  55009. declare module BABYLON {
  55010. /**
  55011. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55012. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55013. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55014. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55015. */
  55016. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55017. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55018. /**
  55019. * Define the source as a Monoscopic panoramic 360/180.
  55020. */
  55021. static readonly MODE_MONOSCOPIC: number;
  55022. /**
  55023. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55024. */
  55025. static readonly MODE_TOPBOTTOM: number;
  55026. /**
  55027. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55028. */
  55029. static readonly MODE_SIDEBYSIDE: number;
  55030. private _halfDome;
  55031. protected _useDirectMapping: boolean;
  55032. /**
  55033. * The texture being displayed on the sphere
  55034. */
  55035. protected _texture: T;
  55036. /**
  55037. * Gets the texture being displayed on the sphere
  55038. */
  55039. get texture(): T;
  55040. /**
  55041. * Sets the texture being displayed on the sphere
  55042. */
  55043. set texture(newTexture: T);
  55044. /**
  55045. * The skybox material
  55046. */
  55047. protected _material: BackgroundMaterial;
  55048. /**
  55049. * The surface used for the dome
  55050. */
  55051. protected _mesh: Mesh;
  55052. /**
  55053. * Gets the mesh used for the dome.
  55054. */
  55055. get mesh(): Mesh;
  55056. /**
  55057. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55058. */
  55059. private _halfDomeMask;
  55060. /**
  55061. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55062. * Also see the options.resolution property.
  55063. */
  55064. get fovMultiplier(): number;
  55065. set fovMultiplier(value: number);
  55066. protected _textureMode: number;
  55067. /**
  55068. * Gets or set the current texture mode for the texture. It can be:
  55069. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55070. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55071. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55072. */
  55073. get textureMode(): number;
  55074. /**
  55075. * Sets the current texture mode for the texture. It can be:
  55076. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55077. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55078. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55079. */
  55080. set textureMode(value: number);
  55081. /**
  55082. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55083. */
  55084. get halfDome(): boolean;
  55085. /**
  55086. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55087. */
  55088. set halfDome(enabled: boolean);
  55089. /**
  55090. * Oberserver used in Stereoscopic VR Mode.
  55091. */
  55092. private _onBeforeCameraRenderObserver;
  55093. /**
  55094. * Observable raised when an error occured while loading the 360 image
  55095. */
  55096. onLoadErrorObservable: Observable<string>;
  55097. /**
  55098. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55099. * @param name Element's name, child elements will append suffixes for their own names.
  55100. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55101. * @param options An object containing optional or exposed sub element properties
  55102. */
  55103. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55104. resolution?: number;
  55105. clickToPlay?: boolean;
  55106. autoPlay?: boolean;
  55107. loop?: boolean;
  55108. size?: number;
  55109. poster?: string;
  55110. faceForward?: boolean;
  55111. useDirectMapping?: boolean;
  55112. halfDomeMode?: boolean;
  55113. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55114. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55115. protected _changeTextureMode(value: number): void;
  55116. /**
  55117. * Releases resources associated with this node.
  55118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55120. */
  55121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55122. }
  55123. }
  55124. declare module BABYLON {
  55125. /**
  55126. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55127. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55128. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55129. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55130. */
  55131. export class PhotoDome extends TextureDome<Texture> {
  55132. /**
  55133. * Define the image as a Monoscopic panoramic 360 image.
  55134. */
  55135. static readonly MODE_MONOSCOPIC: number;
  55136. /**
  55137. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55138. */
  55139. static readonly MODE_TOPBOTTOM: number;
  55140. /**
  55141. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55142. */
  55143. static readonly MODE_SIDEBYSIDE: number;
  55144. /**
  55145. * Gets or sets the texture being displayed on the sphere
  55146. */
  55147. get photoTexture(): Texture;
  55148. /**
  55149. * sets the texture being displayed on the sphere
  55150. */
  55151. set photoTexture(value: Texture);
  55152. /**
  55153. * Gets the current video mode for the video. It can be:
  55154. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55155. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55156. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55157. */
  55158. get imageMode(): number;
  55159. /**
  55160. * Sets the current video mode for the video. It can be:
  55161. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55162. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55163. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55164. */
  55165. set imageMode(value: number);
  55166. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55167. }
  55168. }
  55169. declare module BABYLON {
  55170. /**
  55171. * Class used to host RGBD texture specific utilities
  55172. */
  55173. export class RGBDTextureTools {
  55174. /**
  55175. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55176. * @param texture the texture to expand.
  55177. */
  55178. static ExpandRGBDTexture(texture: Texture): void;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * Class used to host texture specific utilities
  55184. */
  55185. export class BRDFTextureTools {
  55186. /**
  55187. * Prevents texture cache collision
  55188. */
  55189. private static _instanceNumber;
  55190. /**
  55191. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55192. * @param scene defines the hosting scene
  55193. * @returns the environment BRDF texture
  55194. */
  55195. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55196. private static _environmentBRDFBase64Texture;
  55197. }
  55198. }
  55199. declare module BABYLON {
  55200. /**
  55201. * @hidden
  55202. */
  55203. export interface IMaterialClearCoatDefines {
  55204. CLEARCOAT: boolean;
  55205. CLEARCOAT_DEFAULTIOR: boolean;
  55206. CLEARCOAT_TEXTURE: boolean;
  55207. CLEARCOAT_TEXTUREDIRECTUV: number;
  55208. CLEARCOAT_BUMP: boolean;
  55209. CLEARCOAT_BUMPDIRECTUV: number;
  55210. CLEARCOAT_TINT: boolean;
  55211. CLEARCOAT_TINT_TEXTURE: boolean;
  55212. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55213. /** @hidden */
  55214. _areTexturesDirty: boolean;
  55215. }
  55216. /**
  55217. * Define the code related to the clear coat parameters of the pbr material.
  55218. */
  55219. export class PBRClearCoatConfiguration {
  55220. /**
  55221. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55222. * The default fits with a polyurethane material.
  55223. */
  55224. private static readonly _DefaultIndexOfRefraction;
  55225. private _isEnabled;
  55226. /**
  55227. * Defines if the clear coat is enabled in the material.
  55228. */
  55229. isEnabled: boolean;
  55230. /**
  55231. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55232. */
  55233. intensity: number;
  55234. /**
  55235. * Defines the clear coat layer roughness.
  55236. */
  55237. roughness: number;
  55238. private _indexOfRefraction;
  55239. /**
  55240. * Defines the index of refraction of the clear coat.
  55241. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55242. * The default fits with a polyurethane material.
  55243. * Changing the default value is more performance intensive.
  55244. */
  55245. indexOfRefraction: number;
  55246. private _texture;
  55247. /**
  55248. * Stores the clear coat values in a texture.
  55249. */
  55250. texture: Nullable<BaseTexture>;
  55251. private _bumpTexture;
  55252. /**
  55253. * Define the clear coat specific bump texture.
  55254. */
  55255. bumpTexture: Nullable<BaseTexture>;
  55256. private _isTintEnabled;
  55257. /**
  55258. * Defines if the clear coat tint is enabled in the material.
  55259. */
  55260. isTintEnabled: boolean;
  55261. /**
  55262. * Defines the clear coat tint of the material.
  55263. * This is only use if tint is enabled
  55264. */
  55265. tintColor: Color3;
  55266. /**
  55267. * Defines the distance at which the tint color should be found in the
  55268. * clear coat media.
  55269. * This is only use if tint is enabled
  55270. */
  55271. tintColorAtDistance: number;
  55272. /**
  55273. * Defines the clear coat layer thickness.
  55274. * This is only use if tint is enabled
  55275. */
  55276. tintThickness: number;
  55277. private _tintTexture;
  55278. /**
  55279. * Stores the clear tint values in a texture.
  55280. * rgb is tint
  55281. * a is a thickness factor
  55282. */
  55283. tintTexture: Nullable<BaseTexture>;
  55284. /** @hidden */
  55285. private _internalMarkAllSubMeshesAsTexturesDirty;
  55286. /** @hidden */
  55287. _markAllSubMeshesAsTexturesDirty(): void;
  55288. /**
  55289. * Instantiate a new istance of clear coat configuration.
  55290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55291. */
  55292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55293. /**
  55294. * Gets wehter the submesh is ready to be used or not.
  55295. * @param defines the list of "defines" to update.
  55296. * @param scene defines the scene the material belongs to.
  55297. * @param engine defines the engine the material belongs to.
  55298. * @param disableBumpMap defines wether the material disables bump or not.
  55299. * @returns - boolean indicating that the submesh is ready or not.
  55300. */
  55301. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55302. /**
  55303. * Checks to see if a texture is used in the material.
  55304. * @param defines the list of "defines" to update.
  55305. * @param scene defines the scene to the material belongs to.
  55306. */
  55307. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55308. /**
  55309. * Binds the material data.
  55310. * @param uniformBuffer defines the Uniform buffer to fill in.
  55311. * @param scene defines the scene the material belongs to.
  55312. * @param engine defines the engine the material belongs to.
  55313. * @param disableBumpMap defines wether the material disables bump or not.
  55314. * @param isFrozen defines wether the material is frozen or not.
  55315. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55316. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55317. */
  55318. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55319. /**
  55320. * Checks to see if a texture is used in the material.
  55321. * @param texture - Base texture to use.
  55322. * @returns - Boolean specifying if a texture is used in the material.
  55323. */
  55324. hasTexture(texture: BaseTexture): boolean;
  55325. /**
  55326. * Returns an array of the actively used textures.
  55327. * @param activeTextures Array of BaseTextures
  55328. */
  55329. getActiveTextures(activeTextures: BaseTexture[]): void;
  55330. /**
  55331. * Returns the animatable textures.
  55332. * @param animatables Array of animatable textures.
  55333. */
  55334. getAnimatables(animatables: IAnimatable[]): void;
  55335. /**
  55336. * Disposes the resources of the material.
  55337. * @param forceDisposeTextures - Forces the disposal of all textures.
  55338. */
  55339. dispose(forceDisposeTextures?: boolean): void;
  55340. /**
  55341. * Get the current class name of the texture useful for serialization or dynamic coding.
  55342. * @returns "PBRClearCoatConfiguration"
  55343. */
  55344. getClassName(): string;
  55345. /**
  55346. * Add fallbacks to the effect fallbacks list.
  55347. * @param defines defines the Base texture to use.
  55348. * @param fallbacks defines the current fallback list.
  55349. * @param currentRank defines the current fallback rank.
  55350. * @returns the new fallback rank.
  55351. */
  55352. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55353. /**
  55354. * Add the required uniforms to the current list.
  55355. * @param uniforms defines the current uniform list.
  55356. */
  55357. static AddUniforms(uniforms: string[]): void;
  55358. /**
  55359. * Add the required samplers to the current list.
  55360. * @param samplers defines the current sampler list.
  55361. */
  55362. static AddSamplers(samplers: string[]): void;
  55363. /**
  55364. * Add the required uniforms to the current buffer.
  55365. * @param uniformBuffer defines the current uniform buffer.
  55366. */
  55367. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55368. /**
  55369. * Makes a duplicate of the current configuration into another one.
  55370. * @param clearCoatConfiguration define the config where to copy the info
  55371. */
  55372. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55373. /**
  55374. * Serializes this clear coat configuration.
  55375. * @returns - An object with the serialized config.
  55376. */
  55377. serialize(): any;
  55378. /**
  55379. * Parses a anisotropy Configuration from a serialized object.
  55380. * @param source - Serialized object.
  55381. * @param scene Defines the scene we are parsing for
  55382. * @param rootUrl Defines the rootUrl to load from
  55383. */
  55384. parse(source: any, scene: Scene, rootUrl: string): void;
  55385. }
  55386. }
  55387. declare module BABYLON {
  55388. /**
  55389. * @hidden
  55390. */
  55391. export interface IMaterialAnisotropicDefines {
  55392. ANISOTROPIC: boolean;
  55393. ANISOTROPIC_TEXTURE: boolean;
  55394. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55395. MAINUV1: boolean;
  55396. _areTexturesDirty: boolean;
  55397. _needUVs: boolean;
  55398. }
  55399. /**
  55400. * Define the code related to the anisotropic parameters of the pbr material.
  55401. */
  55402. export class PBRAnisotropicConfiguration {
  55403. private _isEnabled;
  55404. /**
  55405. * Defines if the anisotropy is enabled in the material.
  55406. */
  55407. isEnabled: boolean;
  55408. /**
  55409. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55410. */
  55411. intensity: number;
  55412. /**
  55413. * Defines if the effect is along the tangents, bitangents or in between.
  55414. * By default, the effect is "strectching" the highlights along the tangents.
  55415. */
  55416. direction: Vector2;
  55417. private _texture;
  55418. /**
  55419. * Stores the anisotropy values in a texture.
  55420. * rg is direction (like normal from -1 to 1)
  55421. * b is a intensity
  55422. */
  55423. texture: Nullable<BaseTexture>;
  55424. /** @hidden */
  55425. private _internalMarkAllSubMeshesAsTexturesDirty;
  55426. /** @hidden */
  55427. _markAllSubMeshesAsTexturesDirty(): void;
  55428. /**
  55429. * Instantiate a new istance of anisotropy configuration.
  55430. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55431. */
  55432. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55433. /**
  55434. * Specifies that the submesh is ready to be used.
  55435. * @param defines the list of "defines" to update.
  55436. * @param scene defines the scene the material belongs to.
  55437. * @returns - boolean indicating that the submesh is ready or not.
  55438. */
  55439. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55440. /**
  55441. * Checks to see if a texture is used in the material.
  55442. * @param defines the list of "defines" to update.
  55443. * @param mesh the mesh we are preparing the defines for.
  55444. * @param scene defines the scene the material belongs to.
  55445. */
  55446. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55447. /**
  55448. * Binds the material data.
  55449. * @param uniformBuffer defines the Uniform buffer to fill in.
  55450. * @param scene defines the scene the material belongs to.
  55451. * @param isFrozen defines wether the material is frozen or not.
  55452. */
  55453. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55454. /**
  55455. * Checks to see if a texture is used in the material.
  55456. * @param texture - Base texture to use.
  55457. * @returns - Boolean specifying if a texture is used in the material.
  55458. */
  55459. hasTexture(texture: BaseTexture): boolean;
  55460. /**
  55461. * Returns an array of the actively used textures.
  55462. * @param activeTextures Array of BaseTextures
  55463. */
  55464. getActiveTextures(activeTextures: BaseTexture[]): void;
  55465. /**
  55466. * Returns the animatable textures.
  55467. * @param animatables Array of animatable textures.
  55468. */
  55469. getAnimatables(animatables: IAnimatable[]): void;
  55470. /**
  55471. * Disposes the resources of the material.
  55472. * @param forceDisposeTextures - Forces the disposal of all textures.
  55473. */
  55474. dispose(forceDisposeTextures?: boolean): void;
  55475. /**
  55476. * Get the current class name of the texture useful for serialization or dynamic coding.
  55477. * @returns "PBRAnisotropicConfiguration"
  55478. */
  55479. getClassName(): string;
  55480. /**
  55481. * Add fallbacks to the effect fallbacks list.
  55482. * @param defines defines the Base texture to use.
  55483. * @param fallbacks defines the current fallback list.
  55484. * @param currentRank defines the current fallback rank.
  55485. * @returns the new fallback rank.
  55486. */
  55487. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55488. /**
  55489. * Add the required uniforms to the current list.
  55490. * @param uniforms defines the current uniform list.
  55491. */
  55492. static AddUniforms(uniforms: string[]): void;
  55493. /**
  55494. * Add the required uniforms to the current buffer.
  55495. * @param uniformBuffer defines the current uniform buffer.
  55496. */
  55497. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55498. /**
  55499. * Add the required samplers to the current list.
  55500. * @param samplers defines the current sampler list.
  55501. */
  55502. static AddSamplers(samplers: string[]): void;
  55503. /**
  55504. * Makes a duplicate of the current configuration into another one.
  55505. * @param anisotropicConfiguration define the config where to copy the info
  55506. */
  55507. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55508. /**
  55509. * Serializes this anisotropy configuration.
  55510. * @returns - An object with the serialized config.
  55511. */
  55512. serialize(): any;
  55513. /**
  55514. * Parses a anisotropy Configuration from a serialized object.
  55515. * @param source - Serialized object.
  55516. * @param scene Defines the scene we are parsing for
  55517. * @param rootUrl Defines the rootUrl to load from
  55518. */
  55519. parse(source: any, scene: Scene, rootUrl: string): void;
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /**
  55524. * @hidden
  55525. */
  55526. export interface IMaterialBRDFDefines {
  55527. BRDF_V_HEIGHT_CORRELATED: boolean;
  55528. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55529. SPHERICAL_HARMONICS: boolean;
  55530. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55531. /** @hidden */
  55532. _areMiscDirty: boolean;
  55533. }
  55534. /**
  55535. * Define the code related to the BRDF parameters of the pbr material.
  55536. */
  55537. export class PBRBRDFConfiguration {
  55538. /**
  55539. * Default value used for the energy conservation.
  55540. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55541. */
  55542. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55543. /**
  55544. * Default value used for the Smith Visibility Height Correlated mode.
  55545. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55546. */
  55547. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55548. /**
  55549. * Default value used for the IBL diffuse part.
  55550. * This can help switching back to the polynomials mode globally which is a tiny bit
  55551. * less GPU intensive at the drawback of a lower quality.
  55552. */
  55553. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55554. /**
  55555. * Default value used for activating energy conservation for the specular workflow.
  55556. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55557. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55558. */
  55559. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55560. private _useEnergyConservation;
  55561. /**
  55562. * Defines if the material uses energy conservation.
  55563. */
  55564. useEnergyConservation: boolean;
  55565. private _useSmithVisibilityHeightCorrelated;
  55566. /**
  55567. * LEGACY Mode set to false
  55568. * Defines if the material uses height smith correlated visibility term.
  55569. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55570. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55571. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55572. * Not relying on height correlated will also disable energy conservation.
  55573. */
  55574. useSmithVisibilityHeightCorrelated: boolean;
  55575. private _useSphericalHarmonics;
  55576. /**
  55577. * LEGACY Mode set to false
  55578. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55579. * diffuse part of the IBL.
  55580. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55581. * to the ground truth.
  55582. */
  55583. useSphericalHarmonics: boolean;
  55584. private _useSpecularGlossinessInputEnergyConservation;
  55585. /**
  55586. * Defines if the material uses energy conservation, when the specular workflow is active.
  55587. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55588. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55589. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55590. */
  55591. useSpecularGlossinessInputEnergyConservation: boolean;
  55592. /** @hidden */
  55593. private _internalMarkAllSubMeshesAsMiscDirty;
  55594. /** @hidden */
  55595. _markAllSubMeshesAsMiscDirty(): void;
  55596. /**
  55597. * Instantiate a new istance of clear coat configuration.
  55598. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55599. */
  55600. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55601. /**
  55602. * Checks to see if a texture is used in the material.
  55603. * @param defines the list of "defines" to update.
  55604. */
  55605. prepareDefines(defines: IMaterialBRDFDefines): void;
  55606. /**
  55607. * Get the current class name of the texture useful for serialization or dynamic coding.
  55608. * @returns "PBRClearCoatConfiguration"
  55609. */
  55610. getClassName(): string;
  55611. /**
  55612. * Makes a duplicate of the current configuration into another one.
  55613. * @param brdfConfiguration define the config where to copy the info
  55614. */
  55615. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55616. /**
  55617. * Serializes this BRDF configuration.
  55618. * @returns - An object with the serialized config.
  55619. */
  55620. serialize(): any;
  55621. /**
  55622. * Parses a anisotropy Configuration from a serialized object.
  55623. * @param source - Serialized object.
  55624. * @param scene Defines the scene we are parsing for
  55625. * @param rootUrl Defines the rootUrl to load from
  55626. */
  55627. parse(source: any, scene: Scene, rootUrl: string): void;
  55628. }
  55629. }
  55630. declare module BABYLON {
  55631. /**
  55632. * @hidden
  55633. */
  55634. export interface IMaterialSheenDefines {
  55635. SHEEN: boolean;
  55636. SHEEN_TEXTURE: boolean;
  55637. SHEEN_TEXTUREDIRECTUV: number;
  55638. SHEEN_LINKWITHALBEDO: boolean;
  55639. SHEEN_ROUGHNESS: boolean;
  55640. SHEEN_ALBEDOSCALING: boolean;
  55641. /** @hidden */
  55642. _areTexturesDirty: boolean;
  55643. }
  55644. /**
  55645. * Define the code related to the Sheen parameters of the pbr material.
  55646. */
  55647. export class PBRSheenConfiguration {
  55648. private _isEnabled;
  55649. /**
  55650. * Defines if the material uses sheen.
  55651. */
  55652. isEnabled: boolean;
  55653. private _linkSheenWithAlbedo;
  55654. /**
  55655. * Defines if the sheen is linked to the sheen color.
  55656. */
  55657. linkSheenWithAlbedo: boolean;
  55658. /**
  55659. * Defines the sheen intensity.
  55660. */
  55661. intensity: number;
  55662. /**
  55663. * Defines the sheen color.
  55664. */
  55665. color: Color3;
  55666. private _texture;
  55667. /**
  55668. * Stores the sheen tint values in a texture.
  55669. * rgb is tint
  55670. * a is a intensity or roughness if roughness has been defined
  55671. */
  55672. texture: Nullable<BaseTexture>;
  55673. private _roughness;
  55674. /**
  55675. * Defines the sheen roughness.
  55676. * It is not taken into account if linkSheenWithAlbedo is true.
  55677. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55678. */
  55679. roughness: Nullable<number>;
  55680. private _albedoScaling;
  55681. /**
  55682. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55683. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55684. * making it easier to setup and tweak the effect
  55685. */
  55686. albedoScaling: boolean;
  55687. /** @hidden */
  55688. private _internalMarkAllSubMeshesAsTexturesDirty;
  55689. /** @hidden */
  55690. _markAllSubMeshesAsTexturesDirty(): void;
  55691. /**
  55692. * Instantiate a new istance of clear coat configuration.
  55693. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55694. */
  55695. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55696. /**
  55697. * Specifies that the submesh is ready to be used.
  55698. * @param defines the list of "defines" to update.
  55699. * @param scene defines the scene the material belongs to.
  55700. * @returns - boolean indicating that the submesh is ready or not.
  55701. */
  55702. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55703. /**
  55704. * Checks to see if a texture is used in the material.
  55705. * @param defines the list of "defines" to update.
  55706. * @param scene defines the scene the material belongs to.
  55707. */
  55708. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55709. /**
  55710. * Binds the material data.
  55711. * @param uniformBuffer defines the Uniform buffer to fill in.
  55712. * @param scene defines the scene the material belongs to.
  55713. * @param isFrozen defines wether the material is frozen or not.
  55714. */
  55715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55716. /**
  55717. * Checks to see if a texture is used in the material.
  55718. * @param texture - Base texture to use.
  55719. * @returns - Boolean specifying if a texture is used in the material.
  55720. */
  55721. hasTexture(texture: BaseTexture): boolean;
  55722. /**
  55723. * Returns an array of the actively used textures.
  55724. * @param activeTextures Array of BaseTextures
  55725. */
  55726. getActiveTextures(activeTextures: BaseTexture[]): void;
  55727. /**
  55728. * Returns the animatable textures.
  55729. * @param animatables Array of animatable textures.
  55730. */
  55731. getAnimatables(animatables: IAnimatable[]): void;
  55732. /**
  55733. * Disposes the resources of the material.
  55734. * @param forceDisposeTextures - Forces the disposal of all textures.
  55735. */
  55736. dispose(forceDisposeTextures?: boolean): void;
  55737. /**
  55738. * Get the current class name of the texture useful for serialization or dynamic coding.
  55739. * @returns "PBRSheenConfiguration"
  55740. */
  55741. getClassName(): string;
  55742. /**
  55743. * Add fallbacks to the effect fallbacks list.
  55744. * @param defines defines the Base texture to use.
  55745. * @param fallbacks defines the current fallback list.
  55746. * @param currentRank defines the current fallback rank.
  55747. * @returns the new fallback rank.
  55748. */
  55749. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55750. /**
  55751. * Add the required uniforms to the current list.
  55752. * @param uniforms defines the current uniform list.
  55753. */
  55754. static AddUniforms(uniforms: string[]): void;
  55755. /**
  55756. * Add the required uniforms to the current buffer.
  55757. * @param uniformBuffer defines the current uniform buffer.
  55758. */
  55759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55760. /**
  55761. * Add the required samplers to the current list.
  55762. * @param samplers defines the current sampler list.
  55763. */
  55764. static AddSamplers(samplers: string[]): void;
  55765. /**
  55766. * Makes a duplicate of the current configuration into another one.
  55767. * @param sheenConfiguration define the config where to copy the info
  55768. */
  55769. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55770. /**
  55771. * Serializes this BRDF configuration.
  55772. * @returns - An object with the serialized config.
  55773. */
  55774. serialize(): any;
  55775. /**
  55776. * Parses a anisotropy Configuration from a serialized object.
  55777. * @param source - Serialized object.
  55778. * @param scene Defines the scene we are parsing for
  55779. * @param rootUrl Defines the rootUrl to load from
  55780. */
  55781. parse(source: any, scene: Scene, rootUrl: string): void;
  55782. }
  55783. }
  55784. declare module BABYLON {
  55785. /**
  55786. * @hidden
  55787. */
  55788. export interface IMaterialSubSurfaceDefines {
  55789. SUBSURFACE: boolean;
  55790. SS_REFRACTION: boolean;
  55791. SS_TRANSLUCENCY: boolean;
  55792. SS_SCATTERING: boolean;
  55793. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55794. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55795. SS_REFRACTIONMAP_3D: boolean;
  55796. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55797. SS_LODINREFRACTIONALPHA: boolean;
  55798. SS_GAMMAREFRACTION: boolean;
  55799. SS_RGBDREFRACTION: boolean;
  55800. SS_LINEARSPECULARREFRACTION: boolean;
  55801. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55802. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55803. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55804. /** @hidden */
  55805. _areTexturesDirty: boolean;
  55806. }
  55807. /**
  55808. * Define the code related to the sub surface parameters of the pbr material.
  55809. */
  55810. export class PBRSubSurfaceConfiguration {
  55811. private _isRefractionEnabled;
  55812. /**
  55813. * Defines if the refraction is enabled in the material.
  55814. */
  55815. isRefractionEnabled: boolean;
  55816. private _isTranslucencyEnabled;
  55817. /**
  55818. * Defines if the translucency is enabled in the material.
  55819. */
  55820. isTranslucencyEnabled: boolean;
  55821. private _isScatteringEnabled;
  55822. /**
  55823. * Defines if the sub surface scattering is enabled in the material.
  55824. */
  55825. isScatteringEnabled: boolean;
  55826. private _scatteringDiffusionProfileIndex;
  55827. /**
  55828. * Diffusion profile for subsurface scattering.
  55829. * Useful for better scattering in the skins or foliages.
  55830. */
  55831. get scatteringDiffusionProfile(): Nullable<Color3>;
  55832. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55833. /**
  55834. * Defines the refraction intensity of the material.
  55835. * The refraction when enabled replaces the Diffuse part of the material.
  55836. * The intensity helps transitionning between diffuse and refraction.
  55837. */
  55838. refractionIntensity: number;
  55839. /**
  55840. * Defines the translucency intensity of the material.
  55841. * When translucency has been enabled, this defines how much of the "translucency"
  55842. * is addded to the diffuse part of the material.
  55843. */
  55844. translucencyIntensity: number;
  55845. /**
  55846. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55847. */
  55848. useAlbedoToTintRefraction: boolean;
  55849. private _thicknessTexture;
  55850. /**
  55851. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55852. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55853. * 0 would mean minimumThickness
  55854. * 1 would mean maximumThickness
  55855. * The other channels might be use as a mask to vary the different effects intensity.
  55856. */
  55857. thicknessTexture: Nullable<BaseTexture>;
  55858. private _refractionTexture;
  55859. /**
  55860. * Defines the texture to use for refraction.
  55861. */
  55862. refractionTexture: Nullable<BaseTexture>;
  55863. private _indexOfRefraction;
  55864. /**
  55865. * Index of refraction of the material base layer.
  55866. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55867. *
  55868. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55869. *
  55870. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55871. */
  55872. indexOfRefraction: number;
  55873. private _volumeIndexOfRefraction;
  55874. /**
  55875. * Index of refraction of the material's volume.
  55876. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55877. *
  55878. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55879. * the volume will use the same IOR as the surface.
  55880. */
  55881. get volumeIndexOfRefraction(): number;
  55882. set volumeIndexOfRefraction(value: number);
  55883. private _invertRefractionY;
  55884. /**
  55885. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55886. */
  55887. invertRefractionY: boolean;
  55888. private _linkRefractionWithTransparency;
  55889. /**
  55890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55891. * Materials half opaque for instance using refraction could benefit from this control.
  55892. */
  55893. linkRefractionWithTransparency: boolean;
  55894. /**
  55895. * Defines the minimum thickness stored in the thickness map.
  55896. * If no thickness map is defined, this value will be used to simulate thickness.
  55897. */
  55898. minimumThickness: number;
  55899. /**
  55900. * Defines the maximum thickness stored in the thickness map.
  55901. */
  55902. maximumThickness: number;
  55903. /**
  55904. * Defines the volume tint of the material.
  55905. * This is used for both translucency and scattering.
  55906. */
  55907. tintColor: Color3;
  55908. /**
  55909. * Defines the distance at which the tint color should be found in the media.
  55910. * This is used for refraction only.
  55911. */
  55912. tintColorAtDistance: number;
  55913. /**
  55914. * Defines how far each channel transmit through the media.
  55915. * It is defined as a color to simplify it selection.
  55916. */
  55917. diffusionDistance: Color3;
  55918. private _useMaskFromThicknessTexture;
  55919. /**
  55920. * Stores the intensity of the different subsurface effects in the thickness texture.
  55921. * * the green channel is the translucency intensity.
  55922. * * the blue channel is the scattering intensity.
  55923. * * the alpha channel is the refraction intensity.
  55924. */
  55925. useMaskFromThicknessTexture: boolean;
  55926. private _scene;
  55927. /** @hidden */
  55928. private _internalMarkAllSubMeshesAsTexturesDirty;
  55929. private _internalMarkScenePrePassDirty;
  55930. /** @hidden */
  55931. _markAllSubMeshesAsTexturesDirty(): void;
  55932. /** @hidden */
  55933. _markScenePrePassDirty(): void;
  55934. /**
  55935. * Instantiate a new istance of sub surface configuration.
  55936. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55937. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55938. * @param scene The scene
  55939. */
  55940. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55941. /**
  55942. * Gets wehter the submesh is ready to be used or not.
  55943. * @param defines the list of "defines" to update.
  55944. * @param scene defines the scene the material belongs to.
  55945. * @returns - boolean indicating that the submesh is ready or not.
  55946. */
  55947. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55948. /**
  55949. * Checks to see if a texture is used in the material.
  55950. * @param defines the list of "defines" to update.
  55951. * @param scene defines the scene to the material belongs to.
  55952. */
  55953. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55954. /**
  55955. * Binds the material data.
  55956. * @param uniformBuffer defines the Uniform buffer to fill in.
  55957. * @param scene defines the scene the material belongs to.
  55958. * @param engine defines the engine the material belongs to.
  55959. * @param isFrozen defines whether the material is frozen or not.
  55960. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55961. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55962. */
  55963. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55964. /**
  55965. * Unbinds the material from the mesh.
  55966. * @param activeEffect defines the effect that should be unbound from.
  55967. * @returns true if unbound, otherwise false
  55968. */
  55969. unbind(activeEffect: Effect): boolean;
  55970. /**
  55971. * Returns the texture used for refraction or null if none is used.
  55972. * @param scene defines the scene the material belongs to.
  55973. * @returns - Refraction texture if present. If no refraction texture and refraction
  55974. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55975. */
  55976. private _getRefractionTexture;
  55977. /**
  55978. * Returns true if alpha blending should be disabled.
  55979. */
  55980. get disableAlphaBlending(): boolean;
  55981. /**
  55982. * Fills the list of render target textures.
  55983. * @param renderTargets the list of render targets to update
  55984. */
  55985. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55986. /**
  55987. * Checks to see if a texture is used in the material.
  55988. * @param texture - Base texture to use.
  55989. * @returns - Boolean specifying if a texture is used in the material.
  55990. */
  55991. hasTexture(texture: BaseTexture): boolean;
  55992. /**
  55993. * Gets a boolean indicating that current material needs to register RTT
  55994. * @returns true if this uses a render target otherwise false.
  55995. */
  55996. hasRenderTargetTextures(): boolean;
  55997. /**
  55998. * Returns an array of the actively used textures.
  55999. * @param activeTextures Array of BaseTextures
  56000. */
  56001. getActiveTextures(activeTextures: BaseTexture[]): void;
  56002. /**
  56003. * Returns the animatable textures.
  56004. * @param animatables Array of animatable textures.
  56005. */
  56006. getAnimatables(animatables: IAnimatable[]): void;
  56007. /**
  56008. * Disposes the resources of the material.
  56009. * @param forceDisposeTextures - Forces the disposal of all textures.
  56010. */
  56011. dispose(forceDisposeTextures?: boolean): void;
  56012. /**
  56013. * Get the current class name of the texture useful for serialization or dynamic coding.
  56014. * @returns "PBRSubSurfaceConfiguration"
  56015. */
  56016. getClassName(): string;
  56017. /**
  56018. * Add fallbacks to the effect fallbacks list.
  56019. * @param defines defines the Base texture to use.
  56020. * @param fallbacks defines the current fallback list.
  56021. * @param currentRank defines the current fallback rank.
  56022. * @returns the new fallback rank.
  56023. */
  56024. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56025. /**
  56026. * Add the required uniforms to the current list.
  56027. * @param uniforms defines the current uniform list.
  56028. */
  56029. static AddUniforms(uniforms: string[]): void;
  56030. /**
  56031. * Add the required samplers to the current list.
  56032. * @param samplers defines the current sampler list.
  56033. */
  56034. static AddSamplers(samplers: string[]): void;
  56035. /**
  56036. * Add the required uniforms to the current buffer.
  56037. * @param uniformBuffer defines the current uniform buffer.
  56038. */
  56039. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56040. /**
  56041. * Makes a duplicate of the current configuration into another one.
  56042. * @param configuration define the config where to copy the info
  56043. */
  56044. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56045. /**
  56046. * Serializes this Sub Surface configuration.
  56047. * @returns - An object with the serialized config.
  56048. */
  56049. serialize(): any;
  56050. /**
  56051. * Parses a anisotropy Configuration from a serialized object.
  56052. * @param source - Serialized object.
  56053. * @param scene Defines the scene we are parsing for
  56054. * @param rootUrl Defines the rootUrl to load from
  56055. */
  56056. parse(source: any, scene: Scene, rootUrl: string): void;
  56057. }
  56058. }
  56059. declare module BABYLON {
  56060. /** @hidden */
  56061. export var pbrFragmentDeclaration: {
  56062. name: string;
  56063. shader: string;
  56064. };
  56065. }
  56066. declare module BABYLON {
  56067. /** @hidden */
  56068. export var pbrUboDeclaration: {
  56069. name: string;
  56070. shader: string;
  56071. };
  56072. }
  56073. declare module BABYLON {
  56074. /** @hidden */
  56075. export var pbrFragmentExtraDeclaration: {
  56076. name: string;
  56077. shader: string;
  56078. };
  56079. }
  56080. declare module BABYLON {
  56081. /** @hidden */
  56082. export var pbrFragmentSamplersDeclaration: {
  56083. name: string;
  56084. shader: string;
  56085. };
  56086. }
  56087. declare module BABYLON {
  56088. /** @hidden */
  56089. export var importanceSampling: {
  56090. name: string;
  56091. shader: string;
  56092. };
  56093. }
  56094. declare module BABYLON {
  56095. /** @hidden */
  56096. export var pbrHelperFunctions: {
  56097. name: string;
  56098. shader: string;
  56099. };
  56100. }
  56101. declare module BABYLON {
  56102. /** @hidden */
  56103. export var harmonicsFunctions: {
  56104. name: string;
  56105. shader: string;
  56106. };
  56107. }
  56108. declare module BABYLON {
  56109. /** @hidden */
  56110. export var pbrDirectLightingSetupFunctions: {
  56111. name: string;
  56112. shader: string;
  56113. };
  56114. }
  56115. declare module BABYLON {
  56116. /** @hidden */
  56117. export var pbrDirectLightingFalloffFunctions: {
  56118. name: string;
  56119. shader: string;
  56120. };
  56121. }
  56122. declare module BABYLON {
  56123. /** @hidden */
  56124. export var pbrBRDFFunctions: {
  56125. name: string;
  56126. shader: string;
  56127. };
  56128. }
  56129. declare module BABYLON {
  56130. /** @hidden */
  56131. export var hdrFilteringFunctions: {
  56132. name: string;
  56133. shader: string;
  56134. };
  56135. }
  56136. declare module BABYLON {
  56137. /** @hidden */
  56138. export var pbrDirectLightingFunctions: {
  56139. name: string;
  56140. shader: string;
  56141. };
  56142. }
  56143. declare module BABYLON {
  56144. /** @hidden */
  56145. export var pbrIBLFunctions: {
  56146. name: string;
  56147. shader: string;
  56148. };
  56149. }
  56150. declare module BABYLON {
  56151. /** @hidden */
  56152. export var pbrBlockAlbedoOpacity: {
  56153. name: string;
  56154. shader: string;
  56155. };
  56156. }
  56157. declare module BABYLON {
  56158. /** @hidden */
  56159. export var pbrBlockReflectivity: {
  56160. name: string;
  56161. shader: string;
  56162. };
  56163. }
  56164. declare module BABYLON {
  56165. /** @hidden */
  56166. export var pbrBlockAmbientOcclusion: {
  56167. name: string;
  56168. shader: string;
  56169. };
  56170. }
  56171. declare module BABYLON {
  56172. /** @hidden */
  56173. export var pbrBlockAlphaFresnel: {
  56174. name: string;
  56175. shader: string;
  56176. };
  56177. }
  56178. declare module BABYLON {
  56179. /** @hidden */
  56180. export var pbrBlockAnisotropic: {
  56181. name: string;
  56182. shader: string;
  56183. };
  56184. }
  56185. declare module BABYLON {
  56186. /** @hidden */
  56187. export var pbrBlockReflection: {
  56188. name: string;
  56189. shader: string;
  56190. };
  56191. }
  56192. declare module BABYLON {
  56193. /** @hidden */
  56194. export var pbrBlockSheen: {
  56195. name: string;
  56196. shader: string;
  56197. };
  56198. }
  56199. declare module BABYLON {
  56200. /** @hidden */
  56201. export var pbrBlockClearcoat: {
  56202. name: string;
  56203. shader: string;
  56204. };
  56205. }
  56206. declare module BABYLON {
  56207. /** @hidden */
  56208. export var pbrBlockSubSurface: {
  56209. name: string;
  56210. shader: string;
  56211. };
  56212. }
  56213. declare module BABYLON {
  56214. /** @hidden */
  56215. export var pbrBlockNormalGeometric: {
  56216. name: string;
  56217. shader: string;
  56218. };
  56219. }
  56220. declare module BABYLON {
  56221. /** @hidden */
  56222. export var pbrBlockNormalFinal: {
  56223. name: string;
  56224. shader: string;
  56225. };
  56226. }
  56227. declare module BABYLON {
  56228. /** @hidden */
  56229. export var pbrBlockLightmapInit: {
  56230. name: string;
  56231. shader: string;
  56232. };
  56233. }
  56234. declare module BABYLON {
  56235. /** @hidden */
  56236. export var pbrBlockGeometryInfo: {
  56237. name: string;
  56238. shader: string;
  56239. };
  56240. }
  56241. declare module BABYLON {
  56242. /** @hidden */
  56243. export var pbrBlockReflectance0: {
  56244. name: string;
  56245. shader: string;
  56246. };
  56247. }
  56248. declare module BABYLON {
  56249. /** @hidden */
  56250. export var pbrBlockReflectance: {
  56251. name: string;
  56252. shader: string;
  56253. };
  56254. }
  56255. declare module BABYLON {
  56256. /** @hidden */
  56257. export var pbrBlockDirectLighting: {
  56258. name: string;
  56259. shader: string;
  56260. };
  56261. }
  56262. declare module BABYLON {
  56263. /** @hidden */
  56264. export var pbrBlockFinalLitComponents: {
  56265. name: string;
  56266. shader: string;
  56267. };
  56268. }
  56269. declare module BABYLON {
  56270. /** @hidden */
  56271. export var pbrBlockFinalUnlitComponents: {
  56272. name: string;
  56273. shader: string;
  56274. };
  56275. }
  56276. declare module BABYLON {
  56277. /** @hidden */
  56278. export var pbrBlockFinalColorComposition: {
  56279. name: string;
  56280. shader: string;
  56281. };
  56282. }
  56283. declare module BABYLON {
  56284. /** @hidden */
  56285. export var pbrBlockImageProcessing: {
  56286. name: string;
  56287. shader: string;
  56288. };
  56289. }
  56290. declare module BABYLON {
  56291. /** @hidden */
  56292. export var pbrDebug: {
  56293. name: string;
  56294. shader: string;
  56295. };
  56296. }
  56297. declare module BABYLON {
  56298. /** @hidden */
  56299. export var pbrPixelShader: {
  56300. name: string;
  56301. shader: string;
  56302. };
  56303. }
  56304. declare module BABYLON {
  56305. /** @hidden */
  56306. export var pbrVertexDeclaration: {
  56307. name: string;
  56308. shader: string;
  56309. };
  56310. }
  56311. declare module BABYLON {
  56312. /** @hidden */
  56313. export var pbrVertexShader: {
  56314. name: string;
  56315. shader: string;
  56316. };
  56317. }
  56318. declare module BABYLON {
  56319. /**
  56320. * Manages the defines for the PBR Material.
  56321. * @hidden
  56322. */
  56323. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56324. PBR: boolean;
  56325. NUM_SAMPLES: string;
  56326. REALTIME_FILTERING: boolean;
  56327. MAINUV1: boolean;
  56328. MAINUV2: boolean;
  56329. UV1: boolean;
  56330. UV2: boolean;
  56331. ALBEDO: boolean;
  56332. GAMMAALBEDO: boolean;
  56333. ALBEDODIRECTUV: number;
  56334. VERTEXCOLOR: boolean;
  56335. DETAIL: boolean;
  56336. DETAILDIRECTUV: number;
  56337. DETAIL_NORMALBLENDMETHOD: number;
  56338. AMBIENT: boolean;
  56339. AMBIENTDIRECTUV: number;
  56340. AMBIENTINGRAYSCALE: boolean;
  56341. OPACITY: boolean;
  56342. VERTEXALPHA: boolean;
  56343. OPACITYDIRECTUV: number;
  56344. OPACITYRGB: boolean;
  56345. ALPHATEST: boolean;
  56346. DEPTHPREPASS: boolean;
  56347. ALPHABLEND: boolean;
  56348. ALPHAFROMALBEDO: boolean;
  56349. ALPHATESTVALUE: string;
  56350. SPECULAROVERALPHA: boolean;
  56351. RADIANCEOVERALPHA: boolean;
  56352. ALPHAFRESNEL: boolean;
  56353. LINEARALPHAFRESNEL: boolean;
  56354. PREMULTIPLYALPHA: boolean;
  56355. EMISSIVE: boolean;
  56356. EMISSIVEDIRECTUV: number;
  56357. REFLECTIVITY: boolean;
  56358. REFLECTIVITYDIRECTUV: number;
  56359. SPECULARTERM: boolean;
  56360. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56361. MICROSURFACEAUTOMATIC: boolean;
  56362. LODBASEDMICROSFURACE: boolean;
  56363. MICROSURFACEMAP: boolean;
  56364. MICROSURFACEMAPDIRECTUV: number;
  56365. METALLICWORKFLOW: boolean;
  56366. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56367. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56368. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56369. AOSTOREINMETALMAPRED: boolean;
  56370. METALLIC_REFLECTANCE: boolean;
  56371. METALLIC_REFLECTANCEDIRECTUV: number;
  56372. ENVIRONMENTBRDF: boolean;
  56373. ENVIRONMENTBRDF_RGBD: boolean;
  56374. NORMAL: boolean;
  56375. TANGENT: boolean;
  56376. BUMP: boolean;
  56377. BUMPDIRECTUV: number;
  56378. OBJECTSPACE_NORMALMAP: boolean;
  56379. PARALLAX: boolean;
  56380. PARALLAXOCCLUSION: boolean;
  56381. NORMALXYSCALE: boolean;
  56382. LIGHTMAP: boolean;
  56383. LIGHTMAPDIRECTUV: number;
  56384. USELIGHTMAPASSHADOWMAP: boolean;
  56385. GAMMALIGHTMAP: boolean;
  56386. RGBDLIGHTMAP: boolean;
  56387. REFLECTION: boolean;
  56388. REFLECTIONMAP_3D: boolean;
  56389. REFLECTIONMAP_SPHERICAL: boolean;
  56390. REFLECTIONMAP_PLANAR: boolean;
  56391. REFLECTIONMAP_CUBIC: boolean;
  56392. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56393. REFLECTIONMAP_PROJECTION: boolean;
  56394. REFLECTIONMAP_SKYBOX: boolean;
  56395. REFLECTIONMAP_EXPLICIT: boolean;
  56396. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56397. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56398. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56399. INVERTCUBICMAP: boolean;
  56400. USESPHERICALFROMREFLECTIONMAP: boolean;
  56401. USEIRRADIANCEMAP: boolean;
  56402. SPHERICAL_HARMONICS: boolean;
  56403. USESPHERICALINVERTEX: boolean;
  56404. REFLECTIONMAP_OPPOSITEZ: boolean;
  56405. LODINREFLECTIONALPHA: boolean;
  56406. GAMMAREFLECTION: boolean;
  56407. RGBDREFLECTION: boolean;
  56408. LINEARSPECULARREFLECTION: boolean;
  56409. RADIANCEOCCLUSION: boolean;
  56410. HORIZONOCCLUSION: boolean;
  56411. INSTANCES: boolean;
  56412. THIN_INSTANCES: boolean;
  56413. PREPASS: boolean;
  56414. SCENE_MRT_COUNT: number;
  56415. NUM_BONE_INFLUENCERS: number;
  56416. BonesPerMesh: number;
  56417. BONETEXTURE: boolean;
  56418. NONUNIFORMSCALING: boolean;
  56419. MORPHTARGETS: boolean;
  56420. MORPHTARGETS_NORMAL: boolean;
  56421. MORPHTARGETS_TANGENT: boolean;
  56422. MORPHTARGETS_UV: boolean;
  56423. NUM_MORPH_INFLUENCERS: number;
  56424. IMAGEPROCESSING: boolean;
  56425. VIGNETTE: boolean;
  56426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56427. VIGNETTEBLENDMODEOPAQUE: boolean;
  56428. TONEMAPPING: boolean;
  56429. TONEMAPPING_ACES: boolean;
  56430. CONTRAST: boolean;
  56431. COLORCURVES: boolean;
  56432. COLORGRADING: boolean;
  56433. COLORGRADING3D: boolean;
  56434. SAMPLER3DGREENDEPTH: boolean;
  56435. SAMPLER3DBGRMAP: boolean;
  56436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56437. EXPOSURE: boolean;
  56438. MULTIVIEW: boolean;
  56439. USEPHYSICALLIGHTFALLOFF: boolean;
  56440. USEGLTFLIGHTFALLOFF: boolean;
  56441. TWOSIDEDLIGHTING: boolean;
  56442. SHADOWFLOAT: boolean;
  56443. CLIPPLANE: boolean;
  56444. CLIPPLANE2: boolean;
  56445. CLIPPLANE3: boolean;
  56446. CLIPPLANE4: boolean;
  56447. CLIPPLANE5: boolean;
  56448. CLIPPLANE6: boolean;
  56449. POINTSIZE: boolean;
  56450. FOG: boolean;
  56451. LOGARITHMICDEPTH: boolean;
  56452. FORCENORMALFORWARD: boolean;
  56453. SPECULARAA: boolean;
  56454. CLEARCOAT: boolean;
  56455. CLEARCOAT_DEFAULTIOR: boolean;
  56456. CLEARCOAT_TEXTURE: boolean;
  56457. CLEARCOAT_TEXTUREDIRECTUV: number;
  56458. CLEARCOAT_BUMP: boolean;
  56459. CLEARCOAT_BUMPDIRECTUV: number;
  56460. CLEARCOAT_TINT: boolean;
  56461. CLEARCOAT_TINT_TEXTURE: boolean;
  56462. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56463. ANISOTROPIC: boolean;
  56464. ANISOTROPIC_TEXTURE: boolean;
  56465. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56466. BRDF_V_HEIGHT_CORRELATED: boolean;
  56467. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56468. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56469. SHEEN: boolean;
  56470. SHEEN_TEXTURE: boolean;
  56471. SHEEN_TEXTUREDIRECTUV: number;
  56472. SHEEN_LINKWITHALBEDO: boolean;
  56473. SHEEN_ROUGHNESS: boolean;
  56474. SHEEN_ALBEDOSCALING: boolean;
  56475. SUBSURFACE: boolean;
  56476. SS_REFRACTION: boolean;
  56477. SS_TRANSLUCENCY: boolean;
  56478. SS_SCATTERING: boolean;
  56479. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56480. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56481. SS_REFRACTIONMAP_3D: boolean;
  56482. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56483. SS_LODINREFRACTIONALPHA: boolean;
  56484. SS_GAMMAREFRACTION: boolean;
  56485. SS_RGBDREFRACTION: boolean;
  56486. SS_LINEARSPECULARREFRACTION: boolean;
  56487. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56488. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56489. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56490. UNLIT: boolean;
  56491. DEBUGMODE: number;
  56492. /**
  56493. * Initializes the PBR Material defines.
  56494. */
  56495. constructor();
  56496. /**
  56497. * Resets the PBR Material defines.
  56498. */
  56499. reset(): void;
  56500. }
  56501. /**
  56502. * The Physically based material base class of BJS.
  56503. *
  56504. * This offers the main features of a standard PBR material.
  56505. * For more information, please refer to the documentation :
  56506. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56507. */
  56508. export abstract class PBRBaseMaterial extends PushMaterial {
  56509. /**
  56510. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56511. */
  56512. static readonly PBRMATERIAL_OPAQUE: number;
  56513. /**
  56514. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56515. */
  56516. static readonly PBRMATERIAL_ALPHATEST: number;
  56517. /**
  56518. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56519. */
  56520. static readonly PBRMATERIAL_ALPHABLEND: number;
  56521. /**
  56522. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56523. * They are also discarded below the alpha cutoff threshold to improve performances.
  56524. */
  56525. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56526. /**
  56527. * Defines the default value of how much AO map is occluding the analytical lights
  56528. * (point spot...).
  56529. */
  56530. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56531. /**
  56532. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56533. */
  56534. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56535. /**
  56536. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56537. * to enhance interoperability with other engines.
  56538. */
  56539. static readonly LIGHTFALLOFF_GLTF: number;
  56540. /**
  56541. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56542. * to enhance interoperability with other materials.
  56543. */
  56544. static readonly LIGHTFALLOFF_STANDARD: number;
  56545. /**
  56546. * Intensity of the direct lights e.g. the four lights available in your scene.
  56547. * This impacts both the direct diffuse and specular highlights.
  56548. */
  56549. protected _directIntensity: number;
  56550. /**
  56551. * Intensity of the emissive part of the material.
  56552. * This helps controlling the emissive effect without modifying the emissive color.
  56553. */
  56554. protected _emissiveIntensity: number;
  56555. /**
  56556. * Intensity of the environment e.g. how much the environment will light the object
  56557. * either through harmonics for rough material or through the refelction for shiny ones.
  56558. */
  56559. protected _environmentIntensity: number;
  56560. /**
  56561. * This is a special control allowing the reduction of the specular highlights coming from the
  56562. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56563. */
  56564. protected _specularIntensity: number;
  56565. /**
  56566. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56567. */
  56568. private _lightingInfos;
  56569. /**
  56570. * Debug Control allowing disabling the bump map on this material.
  56571. */
  56572. protected _disableBumpMap: boolean;
  56573. /**
  56574. * AKA Diffuse Texture in standard nomenclature.
  56575. */
  56576. protected _albedoTexture: Nullable<BaseTexture>;
  56577. /**
  56578. * AKA Occlusion Texture in other nomenclature.
  56579. */
  56580. protected _ambientTexture: Nullable<BaseTexture>;
  56581. /**
  56582. * AKA Occlusion Texture Intensity in other nomenclature.
  56583. */
  56584. protected _ambientTextureStrength: number;
  56585. /**
  56586. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56587. * 1 means it completely occludes it
  56588. * 0 mean it has no impact
  56589. */
  56590. protected _ambientTextureImpactOnAnalyticalLights: number;
  56591. /**
  56592. * Stores the alpha values in a texture.
  56593. */
  56594. protected _opacityTexture: Nullable<BaseTexture>;
  56595. /**
  56596. * Stores the reflection values in a texture.
  56597. */
  56598. protected _reflectionTexture: Nullable<BaseTexture>;
  56599. /**
  56600. * Stores the emissive values in a texture.
  56601. */
  56602. protected _emissiveTexture: Nullable<BaseTexture>;
  56603. /**
  56604. * AKA Specular texture in other nomenclature.
  56605. */
  56606. protected _reflectivityTexture: Nullable<BaseTexture>;
  56607. /**
  56608. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56609. */
  56610. protected _metallicTexture: Nullable<BaseTexture>;
  56611. /**
  56612. * Specifies the metallic scalar of the metallic/roughness workflow.
  56613. * Can also be used to scale the metalness values of the metallic texture.
  56614. */
  56615. protected _metallic: Nullable<number>;
  56616. /**
  56617. * Specifies the roughness scalar of the metallic/roughness workflow.
  56618. * Can also be used to scale the roughness values of the metallic texture.
  56619. */
  56620. protected _roughness: Nullable<number>;
  56621. /**
  56622. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56623. * By default the indexOfrefraction is used to compute F0;
  56624. *
  56625. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56626. *
  56627. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56628. * F90 = metallicReflectanceColor;
  56629. */
  56630. protected _metallicF0Factor: number;
  56631. /**
  56632. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56633. * By default the F90 is always 1;
  56634. *
  56635. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56636. *
  56637. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56638. * F90 = metallicReflectanceColor;
  56639. */
  56640. protected _metallicReflectanceColor: Color3;
  56641. /**
  56642. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56643. * This is multiply against the scalar values defined in the material.
  56644. */
  56645. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56646. /**
  56647. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56648. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56649. */
  56650. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56651. /**
  56652. * Stores surface normal data used to displace a mesh in a texture.
  56653. */
  56654. protected _bumpTexture: Nullable<BaseTexture>;
  56655. /**
  56656. * Stores the pre-calculated light information of a mesh in a texture.
  56657. */
  56658. protected _lightmapTexture: Nullable<BaseTexture>;
  56659. /**
  56660. * The color of a material in ambient lighting.
  56661. */
  56662. protected _ambientColor: Color3;
  56663. /**
  56664. * AKA Diffuse Color in other nomenclature.
  56665. */
  56666. protected _albedoColor: Color3;
  56667. /**
  56668. * AKA Specular Color in other nomenclature.
  56669. */
  56670. protected _reflectivityColor: Color3;
  56671. /**
  56672. * The color applied when light is reflected from a material.
  56673. */
  56674. protected _reflectionColor: Color3;
  56675. /**
  56676. * The color applied when light is emitted from a material.
  56677. */
  56678. protected _emissiveColor: Color3;
  56679. /**
  56680. * AKA Glossiness in other nomenclature.
  56681. */
  56682. protected _microSurface: number;
  56683. /**
  56684. * Specifies that the material will use the light map as a show map.
  56685. */
  56686. protected _useLightmapAsShadowmap: boolean;
  56687. /**
  56688. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56689. * makes the reflect vector face the model (under horizon).
  56690. */
  56691. protected _useHorizonOcclusion: boolean;
  56692. /**
  56693. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56694. * too much the area relying on ambient texture to define their ambient occlusion.
  56695. */
  56696. protected _useRadianceOcclusion: boolean;
  56697. /**
  56698. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56699. */
  56700. protected _useAlphaFromAlbedoTexture: boolean;
  56701. /**
  56702. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56703. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56704. */
  56705. protected _useSpecularOverAlpha: boolean;
  56706. /**
  56707. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56708. */
  56709. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56710. /**
  56711. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56712. */
  56713. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56714. /**
  56715. * Specifies if the metallic texture contains the roughness information in its green channel.
  56716. */
  56717. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56718. /**
  56719. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56720. */
  56721. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56722. /**
  56723. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56724. */
  56725. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56726. /**
  56727. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56728. */
  56729. protected _useAmbientInGrayScale: boolean;
  56730. /**
  56731. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56732. * The material will try to infer what glossiness each pixel should be.
  56733. */
  56734. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56735. /**
  56736. * Defines the falloff type used in this material.
  56737. * It by default is Physical.
  56738. */
  56739. protected _lightFalloff: number;
  56740. /**
  56741. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56742. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56743. */
  56744. protected _useRadianceOverAlpha: boolean;
  56745. /**
  56746. * Allows using an object space normal map (instead of tangent space).
  56747. */
  56748. protected _useObjectSpaceNormalMap: boolean;
  56749. /**
  56750. * Allows using the bump map in parallax mode.
  56751. */
  56752. protected _useParallax: boolean;
  56753. /**
  56754. * Allows using the bump map in parallax occlusion mode.
  56755. */
  56756. protected _useParallaxOcclusion: boolean;
  56757. /**
  56758. * Controls the scale bias of the parallax mode.
  56759. */
  56760. protected _parallaxScaleBias: number;
  56761. /**
  56762. * If sets to true, disables all the lights affecting the material.
  56763. */
  56764. protected _disableLighting: boolean;
  56765. /**
  56766. * Number of Simultaneous lights allowed on the material.
  56767. */
  56768. protected _maxSimultaneousLights: number;
  56769. /**
  56770. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56771. */
  56772. protected _invertNormalMapX: boolean;
  56773. /**
  56774. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56775. */
  56776. protected _invertNormalMapY: boolean;
  56777. /**
  56778. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56779. */
  56780. protected _twoSidedLighting: boolean;
  56781. /**
  56782. * Defines the alpha limits in alpha test mode.
  56783. */
  56784. protected _alphaCutOff: number;
  56785. /**
  56786. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56787. */
  56788. protected _forceAlphaTest: boolean;
  56789. /**
  56790. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56791. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56792. */
  56793. protected _useAlphaFresnel: boolean;
  56794. /**
  56795. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56796. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56797. */
  56798. protected _useLinearAlphaFresnel: boolean;
  56799. /**
  56800. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56801. * from cos thetav and roughness:
  56802. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56803. */
  56804. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56805. /**
  56806. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56807. */
  56808. protected _forceIrradianceInFragment: boolean;
  56809. private _realTimeFiltering;
  56810. /**
  56811. * Enables realtime filtering on the texture.
  56812. */
  56813. get realTimeFiltering(): boolean;
  56814. set realTimeFiltering(b: boolean);
  56815. private _realTimeFilteringQuality;
  56816. /**
  56817. * Quality switch for realtime filtering
  56818. */
  56819. get realTimeFilteringQuality(): number;
  56820. set realTimeFilteringQuality(n: number);
  56821. /**
  56822. * Can this material render to several textures at once
  56823. */
  56824. get canRenderToMRT(): boolean;
  56825. /**
  56826. * Force normal to face away from face.
  56827. */
  56828. protected _forceNormalForward: boolean;
  56829. /**
  56830. * Enables specular anti aliasing in the PBR shader.
  56831. * It will both interacts on the Geometry for analytical and IBL lighting.
  56832. * It also prefilter the roughness map based on the bump values.
  56833. */
  56834. protected _enableSpecularAntiAliasing: boolean;
  56835. /**
  56836. * Default configuration related to image processing available in the PBR Material.
  56837. */
  56838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56839. /**
  56840. * Keep track of the image processing observer to allow dispose and replace.
  56841. */
  56842. private _imageProcessingObserver;
  56843. /**
  56844. * Attaches a new image processing configuration to the PBR Material.
  56845. * @param configuration
  56846. */
  56847. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56848. /**
  56849. * Stores the available render targets.
  56850. */
  56851. private _renderTargets;
  56852. /**
  56853. * Sets the global ambient color for the material used in lighting calculations.
  56854. */
  56855. private _globalAmbientColor;
  56856. /**
  56857. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56858. */
  56859. private _useLogarithmicDepth;
  56860. /**
  56861. * If set to true, no lighting calculations will be applied.
  56862. */
  56863. private _unlit;
  56864. private _debugMode;
  56865. /**
  56866. * @hidden
  56867. * This is reserved for the inspector.
  56868. * Defines the material debug mode.
  56869. * It helps seeing only some components of the material while troubleshooting.
  56870. */
  56871. debugMode: number;
  56872. /**
  56873. * @hidden
  56874. * This is reserved for the inspector.
  56875. * Specify from where on screen the debug mode should start.
  56876. * The value goes from -1 (full screen) to 1 (not visible)
  56877. * It helps with side by side comparison against the final render
  56878. * This defaults to -1
  56879. */
  56880. private debugLimit;
  56881. /**
  56882. * @hidden
  56883. * This is reserved for the inspector.
  56884. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56885. * You can use the factor to better multiply the final value.
  56886. */
  56887. private debugFactor;
  56888. /**
  56889. * Defines the clear coat layer parameters for the material.
  56890. */
  56891. readonly clearCoat: PBRClearCoatConfiguration;
  56892. /**
  56893. * Defines the anisotropic parameters for the material.
  56894. */
  56895. readonly anisotropy: PBRAnisotropicConfiguration;
  56896. /**
  56897. * Defines the BRDF parameters for the material.
  56898. */
  56899. readonly brdf: PBRBRDFConfiguration;
  56900. /**
  56901. * Defines the Sheen parameters for the material.
  56902. */
  56903. readonly sheen: PBRSheenConfiguration;
  56904. /**
  56905. * Defines the SubSurface parameters for the material.
  56906. */
  56907. readonly subSurface: PBRSubSurfaceConfiguration;
  56908. /**
  56909. * Defines the detail map parameters for the material.
  56910. */
  56911. readonly detailMap: DetailMapConfiguration;
  56912. protected _rebuildInParallel: boolean;
  56913. /**
  56914. * Instantiates a new PBRMaterial instance.
  56915. *
  56916. * @param name The material name
  56917. * @param scene The scene the material will be use in.
  56918. */
  56919. constructor(name: string, scene: Scene);
  56920. /**
  56921. * Gets a boolean indicating that current material needs to register RTT
  56922. */
  56923. get hasRenderTargetTextures(): boolean;
  56924. /**
  56925. * Gets the name of the material class.
  56926. */
  56927. getClassName(): string;
  56928. /**
  56929. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56930. */
  56931. get useLogarithmicDepth(): boolean;
  56932. /**
  56933. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56934. */
  56935. set useLogarithmicDepth(value: boolean);
  56936. /**
  56937. * Returns true if alpha blending should be disabled.
  56938. */
  56939. protected get _disableAlphaBlending(): boolean;
  56940. /**
  56941. * Specifies whether or not this material should be rendered in alpha blend mode.
  56942. */
  56943. needAlphaBlending(): boolean;
  56944. /**
  56945. * Specifies whether or not this material should be rendered in alpha test mode.
  56946. */
  56947. needAlphaTesting(): boolean;
  56948. /**
  56949. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56950. */
  56951. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56952. /**
  56953. * Gets the texture used for the alpha test.
  56954. */
  56955. getAlphaTestTexture(): Nullable<BaseTexture>;
  56956. /**
  56957. * Specifies that the submesh is ready to be used.
  56958. * @param mesh - BJS mesh.
  56959. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56960. * @param useInstances - Specifies that instances should be used.
  56961. * @returns - boolean indicating that the submesh is ready or not.
  56962. */
  56963. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56964. /**
  56965. * Specifies if the material uses metallic roughness workflow.
  56966. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56967. */
  56968. isMetallicWorkflow(): boolean;
  56969. private _prepareEffect;
  56970. private _prepareDefines;
  56971. /**
  56972. * Force shader compilation
  56973. */
  56974. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56975. /**
  56976. * Initializes the uniform buffer layout for the shader.
  56977. */
  56978. buildUniformLayout(): void;
  56979. /**
  56980. * Unbinds the material from the mesh
  56981. */
  56982. unbind(): void;
  56983. /**
  56984. * Binds the submesh data.
  56985. * @param world - The world matrix.
  56986. * @param mesh - The BJS mesh.
  56987. * @param subMesh - A submesh of the BJS mesh.
  56988. */
  56989. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56990. /**
  56991. * Returns the animatable textures.
  56992. * @returns - Array of animatable textures.
  56993. */
  56994. getAnimatables(): IAnimatable[];
  56995. /**
  56996. * Returns the texture used for reflections.
  56997. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56998. */
  56999. private _getReflectionTexture;
  57000. /**
  57001. * Returns an array of the actively used textures.
  57002. * @returns - Array of BaseTextures
  57003. */
  57004. getActiveTextures(): BaseTexture[];
  57005. /**
  57006. * Checks to see if a texture is used in the material.
  57007. * @param texture - Base texture to use.
  57008. * @returns - Boolean specifying if a texture is used in the material.
  57009. */
  57010. hasTexture(texture: BaseTexture): boolean;
  57011. /**
  57012. * Sets the required values to the prepass renderer.
  57013. * @param prePassRenderer defines the prepass renderer to setup
  57014. */
  57015. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57016. /**
  57017. * Disposes the resources of the material.
  57018. * @param forceDisposeEffect - Forces the disposal of effects.
  57019. * @param forceDisposeTextures - Forces the disposal of all textures.
  57020. */
  57021. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57022. }
  57023. }
  57024. declare module BABYLON {
  57025. /**
  57026. * The Physically based material of BJS.
  57027. *
  57028. * This offers the main features of a standard PBR material.
  57029. * For more information, please refer to the documentation :
  57030. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57031. */
  57032. export class PBRMaterial extends PBRBaseMaterial {
  57033. /**
  57034. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57035. */
  57036. static readonly PBRMATERIAL_OPAQUE: number;
  57037. /**
  57038. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57039. */
  57040. static readonly PBRMATERIAL_ALPHATEST: number;
  57041. /**
  57042. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57043. */
  57044. static readonly PBRMATERIAL_ALPHABLEND: number;
  57045. /**
  57046. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57047. * They are also discarded below the alpha cutoff threshold to improve performances.
  57048. */
  57049. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57050. /**
  57051. * Defines the default value of how much AO map is occluding the analytical lights
  57052. * (point spot...).
  57053. */
  57054. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57055. /**
  57056. * Intensity of the direct lights e.g. the four lights available in your scene.
  57057. * This impacts both the direct diffuse and specular highlights.
  57058. */
  57059. directIntensity: number;
  57060. /**
  57061. * Intensity of the emissive part of the material.
  57062. * This helps controlling the emissive effect without modifying the emissive color.
  57063. */
  57064. emissiveIntensity: number;
  57065. /**
  57066. * Intensity of the environment e.g. how much the environment will light the object
  57067. * either through harmonics for rough material or through the refelction for shiny ones.
  57068. */
  57069. environmentIntensity: number;
  57070. /**
  57071. * This is a special control allowing the reduction of the specular highlights coming from the
  57072. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57073. */
  57074. specularIntensity: number;
  57075. /**
  57076. * Debug Control allowing disabling the bump map on this material.
  57077. */
  57078. disableBumpMap: boolean;
  57079. /**
  57080. * AKA Diffuse Texture in standard nomenclature.
  57081. */
  57082. albedoTexture: BaseTexture;
  57083. /**
  57084. * AKA Occlusion Texture in other nomenclature.
  57085. */
  57086. ambientTexture: BaseTexture;
  57087. /**
  57088. * AKA Occlusion Texture Intensity in other nomenclature.
  57089. */
  57090. ambientTextureStrength: number;
  57091. /**
  57092. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57093. * 1 means it completely occludes it
  57094. * 0 mean it has no impact
  57095. */
  57096. ambientTextureImpactOnAnalyticalLights: number;
  57097. /**
  57098. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57099. */
  57100. opacityTexture: BaseTexture;
  57101. /**
  57102. * Stores the reflection values in a texture.
  57103. */
  57104. reflectionTexture: Nullable<BaseTexture>;
  57105. /**
  57106. * Stores the emissive values in a texture.
  57107. */
  57108. emissiveTexture: BaseTexture;
  57109. /**
  57110. * AKA Specular texture in other nomenclature.
  57111. */
  57112. reflectivityTexture: BaseTexture;
  57113. /**
  57114. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57115. */
  57116. metallicTexture: BaseTexture;
  57117. /**
  57118. * Specifies the metallic scalar of the metallic/roughness workflow.
  57119. * Can also be used to scale the metalness values of the metallic texture.
  57120. */
  57121. metallic: Nullable<number>;
  57122. /**
  57123. * Specifies the roughness scalar of the metallic/roughness workflow.
  57124. * Can also be used to scale the roughness values of the metallic texture.
  57125. */
  57126. roughness: Nullable<number>;
  57127. /**
  57128. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57129. * By default the indexOfrefraction is used to compute F0;
  57130. *
  57131. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57132. *
  57133. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57134. * F90 = metallicReflectanceColor;
  57135. */
  57136. metallicF0Factor: number;
  57137. /**
  57138. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57139. * By default the F90 is always 1;
  57140. *
  57141. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57142. *
  57143. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57144. * F90 = metallicReflectanceColor;
  57145. */
  57146. metallicReflectanceColor: Color3;
  57147. /**
  57148. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57149. * This is multiply against the scalar values defined in the material.
  57150. */
  57151. metallicReflectanceTexture: Nullable<BaseTexture>;
  57152. /**
  57153. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57154. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57155. */
  57156. microSurfaceTexture: BaseTexture;
  57157. /**
  57158. * Stores surface normal data used to displace a mesh in a texture.
  57159. */
  57160. bumpTexture: BaseTexture;
  57161. /**
  57162. * Stores the pre-calculated light information of a mesh in a texture.
  57163. */
  57164. lightmapTexture: BaseTexture;
  57165. /**
  57166. * Stores the refracted light information in a texture.
  57167. */
  57168. get refractionTexture(): Nullable<BaseTexture>;
  57169. set refractionTexture(value: Nullable<BaseTexture>);
  57170. /**
  57171. * The color of a material in ambient lighting.
  57172. */
  57173. ambientColor: Color3;
  57174. /**
  57175. * AKA Diffuse Color in other nomenclature.
  57176. */
  57177. albedoColor: Color3;
  57178. /**
  57179. * AKA Specular Color in other nomenclature.
  57180. */
  57181. reflectivityColor: Color3;
  57182. /**
  57183. * The color reflected from the material.
  57184. */
  57185. reflectionColor: Color3;
  57186. /**
  57187. * The color emitted from the material.
  57188. */
  57189. emissiveColor: Color3;
  57190. /**
  57191. * AKA Glossiness in other nomenclature.
  57192. */
  57193. microSurface: number;
  57194. /**
  57195. * Index of refraction of the material base layer.
  57196. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57197. *
  57198. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57199. *
  57200. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57201. */
  57202. get indexOfRefraction(): number;
  57203. set indexOfRefraction(value: number);
  57204. /**
  57205. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57206. */
  57207. get invertRefractionY(): boolean;
  57208. set invertRefractionY(value: boolean);
  57209. /**
  57210. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57211. * Materials half opaque for instance using refraction could benefit from this control.
  57212. */
  57213. get linkRefractionWithTransparency(): boolean;
  57214. set linkRefractionWithTransparency(value: boolean);
  57215. /**
  57216. * If true, the light map contains occlusion information instead of lighting info.
  57217. */
  57218. useLightmapAsShadowmap: boolean;
  57219. /**
  57220. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57221. */
  57222. useAlphaFromAlbedoTexture: boolean;
  57223. /**
  57224. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57225. */
  57226. forceAlphaTest: boolean;
  57227. /**
  57228. * Defines the alpha limits in alpha test mode.
  57229. */
  57230. alphaCutOff: number;
  57231. /**
  57232. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57233. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57234. */
  57235. useSpecularOverAlpha: boolean;
  57236. /**
  57237. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57238. */
  57239. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57240. /**
  57241. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57242. */
  57243. useRoughnessFromMetallicTextureAlpha: boolean;
  57244. /**
  57245. * Specifies if the metallic texture contains the roughness information in its green channel.
  57246. */
  57247. useRoughnessFromMetallicTextureGreen: boolean;
  57248. /**
  57249. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57250. */
  57251. useMetallnessFromMetallicTextureBlue: boolean;
  57252. /**
  57253. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57254. */
  57255. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57256. /**
  57257. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57258. */
  57259. useAmbientInGrayScale: boolean;
  57260. /**
  57261. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57262. * The material will try to infer what glossiness each pixel should be.
  57263. */
  57264. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57265. /**
  57266. * BJS is using an harcoded light falloff based on a manually sets up range.
  57267. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57268. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57269. */
  57270. get usePhysicalLightFalloff(): boolean;
  57271. /**
  57272. * BJS is using an harcoded light falloff based on a manually sets up range.
  57273. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57274. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57275. */
  57276. set usePhysicalLightFalloff(value: boolean);
  57277. /**
  57278. * In order to support the falloff compatibility with gltf, a special mode has been added
  57279. * to reproduce the gltf light falloff.
  57280. */
  57281. get useGLTFLightFalloff(): boolean;
  57282. /**
  57283. * In order to support the falloff compatibility with gltf, a special mode has been added
  57284. * to reproduce the gltf light falloff.
  57285. */
  57286. set useGLTFLightFalloff(value: boolean);
  57287. /**
  57288. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57289. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57290. */
  57291. useRadianceOverAlpha: boolean;
  57292. /**
  57293. * Allows using an object space normal map (instead of tangent space).
  57294. */
  57295. useObjectSpaceNormalMap: boolean;
  57296. /**
  57297. * Allows using the bump map in parallax mode.
  57298. */
  57299. useParallax: boolean;
  57300. /**
  57301. * Allows using the bump map in parallax occlusion mode.
  57302. */
  57303. useParallaxOcclusion: boolean;
  57304. /**
  57305. * Controls the scale bias of the parallax mode.
  57306. */
  57307. parallaxScaleBias: number;
  57308. /**
  57309. * If sets to true, disables all the lights affecting the material.
  57310. */
  57311. disableLighting: boolean;
  57312. /**
  57313. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57314. */
  57315. forceIrradianceInFragment: boolean;
  57316. /**
  57317. * Number of Simultaneous lights allowed on the material.
  57318. */
  57319. maxSimultaneousLights: number;
  57320. /**
  57321. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57322. */
  57323. invertNormalMapX: boolean;
  57324. /**
  57325. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57326. */
  57327. invertNormalMapY: boolean;
  57328. /**
  57329. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57330. */
  57331. twoSidedLighting: boolean;
  57332. /**
  57333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57335. */
  57336. useAlphaFresnel: boolean;
  57337. /**
  57338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57340. */
  57341. useLinearAlphaFresnel: boolean;
  57342. /**
  57343. * Let user defines the brdf lookup texture used for IBL.
  57344. * A default 8bit version is embedded but you could point at :
  57345. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57346. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57347. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57348. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57349. */
  57350. environmentBRDFTexture: Nullable<BaseTexture>;
  57351. /**
  57352. * Force normal to face away from face.
  57353. */
  57354. forceNormalForward: boolean;
  57355. /**
  57356. * Enables specular anti aliasing in the PBR shader.
  57357. * It will both interacts on the Geometry for analytical and IBL lighting.
  57358. * It also prefilter the roughness map based on the bump values.
  57359. */
  57360. enableSpecularAntiAliasing: boolean;
  57361. /**
  57362. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57363. * makes the reflect vector face the model (under horizon).
  57364. */
  57365. useHorizonOcclusion: boolean;
  57366. /**
  57367. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57368. * too much the area relying on ambient texture to define their ambient occlusion.
  57369. */
  57370. useRadianceOcclusion: boolean;
  57371. /**
  57372. * If set to true, no lighting calculations will be applied.
  57373. */
  57374. unlit: boolean;
  57375. /**
  57376. * Gets the image processing configuration used either in this material.
  57377. */
  57378. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57379. /**
  57380. * Sets the Default image processing configuration used either in the this material.
  57381. *
  57382. * If sets to null, the scene one is in use.
  57383. */
  57384. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57385. /**
  57386. * Gets wether the color curves effect is enabled.
  57387. */
  57388. get cameraColorCurvesEnabled(): boolean;
  57389. /**
  57390. * Sets wether the color curves effect is enabled.
  57391. */
  57392. set cameraColorCurvesEnabled(value: boolean);
  57393. /**
  57394. * Gets wether the color grading effect is enabled.
  57395. */
  57396. get cameraColorGradingEnabled(): boolean;
  57397. /**
  57398. * Gets wether the color grading effect is enabled.
  57399. */
  57400. set cameraColorGradingEnabled(value: boolean);
  57401. /**
  57402. * Gets wether tonemapping is enabled or not.
  57403. */
  57404. get cameraToneMappingEnabled(): boolean;
  57405. /**
  57406. * Sets wether tonemapping is enabled or not
  57407. */
  57408. set cameraToneMappingEnabled(value: boolean);
  57409. /**
  57410. * The camera exposure used on this material.
  57411. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57412. * This corresponds to a photographic exposure.
  57413. */
  57414. get cameraExposure(): number;
  57415. /**
  57416. * The camera exposure used on this material.
  57417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57418. * This corresponds to a photographic exposure.
  57419. */
  57420. set cameraExposure(value: number);
  57421. /**
  57422. * Gets The camera contrast used on this material.
  57423. */
  57424. get cameraContrast(): number;
  57425. /**
  57426. * Sets The camera contrast used on this material.
  57427. */
  57428. set cameraContrast(value: number);
  57429. /**
  57430. * Gets the Color Grading 2D Lookup Texture.
  57431. */
  57432. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57433. /**
  57434. * Sets the Color Grading 2D Lookup Texture.
  57435. */
  57436. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57437. /**
  57438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57440. * 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;
  57441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57442. */
  57443. get cameraColorCurves(): Nullable<ColorCurves>;
  57444. /**
  57445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57447. * 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;
  57448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57449. */
  57450. set cameraColorCurves(value: Nullable<ColorCurves>);
  57451. /**
  57452. * Instantiates a new PBRMaterial instance.
  57453. *
  57454. * @param name The material name
  57455. * @param scene The scene the material will be use in.
  57456. */
  57457. constructor(name: string, scene: Scene);
  57458. /**
  57459. * Returns the name of this material class.
  57460. */
  57461. getClassName(): string;
  57462. /**
  57463. * Makes a duplicate of the current material.
  57464. * @param name - name to use for the new material.
  57465. */
  57466. clone(name: string): PBRMaterial;
  57467. /**
  57468. * Serializes this PBR Material.
  57469. * @returns - An object with the serialized material.
  57470. */
  57471. serialize(): any;
  57472. /**
  57473. * Parses a PBR Material from a serialized object.
  57474. * @param source - Serialized object.
  57475. * @param scene - BJS scene instance.
  57476. * @param rootUrl - url for the scene object
  57477. * @returns - PBRMaterial
  57478. */
  57479. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * Direct draw surface info
  57485. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57486. */
  57487. export interface DDSInfo {
  57488. /**
  57489. * Width of the texture
  57490. */
  57491. width: number;
  57492. /**
  57493. * Width of the texture
  57494. */
  57495. height: number;
  57496. /**
  57497. * Number of Mipmaps for the texture
  57498. * @see https://en.wikipedia.org/wiki/Mipmap
  57499. */
  57500. mipmapCount: number;
  57501. /**
  57502. * If the textures format is a known fourCC format
  57503. * @see https://www.fourcc.org/
  57504. */
  57505. isFourCC: boolean;
  57506. /**
  57507. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57508. */
  57509. isRGB: boolean;
  57510. /**
  57511. * If the texture is a lumincance format
  57512. */
  57513. isLuminance: boolean;
  57514. /**
  57515. * If this is a cube texture
  57516. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57517. */
  57518. isCube: boolean;
  57519. /**
  57520. * If the texture is a compressed format eg. FOURCC_DXT1
  57521. */
  57522. isCompressed: boolean;
  57523. /**
  57524. * The dxgiFormat of the texture
  57525. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57526. */
  57527. dxgiFormat: number;
  57528. /**
  57529. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57530. */
  57531. textureType: number;
  57532. /**
  57533. * Sphericle polynomial created for the dds texture
  57534. */
  57535. sphericalPolynomial?: SphericalPolynomial;
  57536. }
  57537. /**
  57538. * Class used to provide DDS decompression tools
  57539. */
  57540. export class DDSTools {
  57541. /**
  57542. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57543. */
  57544. static StoreLODInAlphaChannel: boolean;
  57545. /**
  57546. * Gets DDS information from an array buffer
  57547. * @param data defines the array buffer view to read data from
  57548. * @returns the DDS information
  57549. */
  57550. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57551. private static _FloatView;
  57552. private static _Int32View;
  57553. private static _ToHalfFloat;
  57554. private static _FromHalfFloat;
  57555. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57556. private static _GetHalfFloatRGBAArrayBuffer;
  57557. private static _GetFloatRGBAArrayBuffer;
  57558. private static _GetFloatAsUIntRGBAArrayBuffer;
  57559. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57560. private static _GetRGBAArrayBuffer;
  57561. private static _ExtractLongWordOrder;
  57562. private static _GetRGBArrayBuffer;
  57563. private static _GetLuminanceArrayBuffer;
  57564. /**
  57565. * Uploads DDS Levels to a Babylon Texture
  57566. * @hidden
  57567. */
  57568. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57569. }
  57570. interface ThinEngine {
  57571. /**
  57572. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57573. * @param rootUrl defines the url where the file to load is located
  57574. * @param scene defines the current scene
  57575. * @param lodScale defines scale to apply to the mip map selection
  57576. * @param lodOffset defines offset to apply to the mip map selection
  57577. * @param onLoad defines an optional callback raised when the texture is loaded
  57578. * @param onError defines an optional callback raised if there is an issue to load the texture
  57579. * @param format defines the format of the data
  57580. * @param forcedExtension defines the extension to use to pick the right loader
  57581. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57582. * @returns the cube texture as an InternalTexture
  57583. */
  57584. 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;
  57585. }
  57586. }
  57587. declare module BABYLON {
  57588. /**
  57589. * Implementation of the DDS Texture Loader.
  57590. * @hidden
  57591. */
  57592. export class _DDSTextureLoader implements IInternalTextureLoader {
  57593. /**
  57594. * Defines wether the loader supports cascade loading the different faces.
  57595. */
  57596. readonly supportCascades: boolean;
  57597. /**
  57598. * This returns if the loader support the current file information.
  57599. * @param extension defines the file extension of the file being loaded
  57600. * @returns true if the loader can load the specified file
  57601. */
  57602. canLoad(extension: string): boolean;
  57603. /**
  57604. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57605. * @param data contains the texture data
  57606. * @param texture defines the BabylonJS internal texture
  57607. * @param createPolynomials will be true if polynomials have been requested
  57608. * @param onLoad defines the callback to trigger once the texture is ready
  57609. * @param onError defines the callback to trigger in case of error
  57610. */
  57611. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57612. /**
  57613. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57614. * @param data contains the texture data
  57615. * @param texture defines the BabylonJS internal texture
  57616. * @param callback defines the method to call once ready to upload
  57617. */
  57618. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57619. }
  57620. }
  57621. declare module BABYLON {
  57622. /**
  57623. * Implementation of the ENV Texture Loader.
  57624. * @hidden
  57625. */
  57626. export class _ENVTextureLoader implements IInternalTextureLoader {
  57627. /**
  57628. * Defines wether the loader supports cascade loading the different faces.
  57629. */
  57630. readonly supportCascades: boolean;
  57631. /**
  57632. * This returns if the loader support the current file information.
  57633. * @param extension defines the file extension of the file being loaded
  57634. * @returns true if the loader can load the specified file
  57635. */
  57636. canLoad(extension: string): boolean;
  57637. /**
  57638. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57639. * @param data contains the texture data
  57640. * @param texture defines the BabylonJS internal texture
  57641. * @param createPolynomials will be true if polynomials have been requested
  57642. * @param onLoad defines the callback to trigger once the texture is ready
  57643. * @param onError defines the callback to trigger in case of error
  57644. */
  57645. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57646. /**
  57647. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57648. * @param data contains the texture data
  57649. * @param texture defines the BabylonJS internal texture
  57650. * @param callback defines the method to call once ready to upload
  57651. */
  57652. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57653. }
  57654. }
  57655. declare module BABYLON {
  57656. /**
  57657. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57658. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57659. */
  57660. export class KhronosTextureContainer {
  57661. /** contents of the KTX container file */
  57662. data: ArrayBufferView;
  57663. private static HEADER_LEN;
  57664. private static COMPRESSED_2D;
  57665. private static COMPRESSED_3D;
  57666. private static TEX_2D;
  57667. private static TEX_3D;
  57668. /**
  57669. * Gets the openGL type
  57670. */
  57671. glType: number;
  57672. /**
  57673. * Gets the openGL type size
  57674. */
  57675. glTypeSize: number;
  57676. /**
  57677. * Gets the openGL format
  57678. */
  57679. glFormat: number;
  57680. /**
  57681. * Gets the openGL internal format
  57682. */
  57683. glInternalFormat: number;
  57684. /**
  57685. * Gets the base internal format
  57686. */
  57687. glBaseInternalFormat: number;
  57688. /**
  57689. * Gets image width in pixel
  57690. */
  57691. pixelWidth: number;
  57692. /**
  57693. * Gets image height in pixel
  57694. */
  57695. pixelHeight: number;
  57696. /**
  57697. * Gets image depth in pixels
  57698. */
  57699. pixelDepth: number;
  57700. /**
  57701. * Gets the number of array elements
  57702. */
  57703. numberOfArrayElements: number;
  57704. /**
  57705. * Gets the number of faces
  57706. */
  57707. numberOfFaces: number;
  57708. /**
  57709. * Gets the number of mipmap levels
  57710. */
  57711. numberOfMipmapLevels: number;
  57712. /**
  57713. * Gets the bytes of key value data
  57714. */
  57715. bytesOfKeyValueData: number;
  57716. /**
  57717. * Gets the load type
  57718. */
  57719. loadType: number;
  57720. /**
  57721. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57722. */
  57723. isInvalid: boolean;
  57724. /**
  57725. * Creates a new KhronosTextureContainer
  57726. * @param data contents of the KTX container file
  57727. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57728. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57729. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57730. */
  57731. constructor(
  57732. /** contents of the KTX container file */
  57733. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57734. /**
  57735. * Uploads KTX content to a Babylon Texture.
  57736. * It is assumed that the texture has already been created & is currently bound
  57737. * @hidden
  57738. */
  57739. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57740. private _upload2DCompressedLevels;
  57741. /**
  57742. * Checks if the given data starts with a KTX file identifier.
  57743. * @param data the data to check
  57744. * @returns true if the data is a KTX file or false otherwise
  57745. */
  57746. static IsValid(data: ArrayBufferView): boolean;
  57747. }
  57748. }
  57749. declare module BABYLON {
  57750. /**
  57751. * Helper class to push actions to a pool of workers.
  57752. */
  57753. export class WorkerPool implements IDisposable {
  57754. private _workerInfos;
  57755. private _pendingActions;
  57756. /**
  57757. * Constructor
  57758. * @param workers Array of workers to use for actions
  57759. */
  57760. constructor(workers: Array<Worker>);
  57761. /**
  57762. * Terminates all workers and clears any pending actions.
  57763. */
  57764. dispose(): void;
  57765. /**
  57766. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57767. * pended until a worker has completed its action.
  57768. * @param action The action to perform. Call onComplete when the action is complete.
  57769. */
  57770. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57771. private _execute;
  57772. }
  57773. }
  57774. declare module BABYLON {
  57775. /**
  57776. * Class for loading KTX2 files
  57777. * @hidden
  57778. */
  57779. export class KhronosTextureContainer2 {
  57780. private static _WorkerPoolPromise?;
  57781. private static _Initialized;
  57782. private static _Ktx2Decoder;
  57783. /**
  57784. * URL to use when loading the KTX2 decoder module
  57785. */
  57786. static JSModuleURL: string;
  57787. /**
  57788. * Default number of workers used to handle data decoding
  57789. */
  57790. static DefaultNumWorkers: number;
  57791. private static GetDefaultNumWorkers;
  57792. private _engine;
  57793. private static _CreateWorkerPool;
  57794. /**
  57795. * Constructor
  57796. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57797. */
  57798. constructor(engine: ThinEngine, numWorkers?: number);
  57799. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57800. /**
  57801. * Stop all async operations and release resources.
  57802. */
  57803. dispose(): void;
  57804. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57805. /**
  57806. * Checks if the given data starts with a KTX2 file identifier.
  57807. * @param data the data to check
  57808. * @returns true if the data is a KTX2 file or false otherwise
  57809. */
  57810. static IsValid(data: ArrayBufferView): boolean;
  57811. }
  57812. export function workerFunc(): void;
  57813. }
  57814. declare module BABYLON {
  57815. /**
  57816. * Implementation of the KTX Texture Loader.
  57817. * @hidden
  57818. */
  57819. export class _KTXTextureLoader implements IInternalTextureLoader {
  57820. /**
  57821. * Defines wether the loader supports cascade loading the different faces.
  57822. */
  57823. readonly supportCascades: boolean;
  57824. /**
  57825. * This returns if the loader support the current file information.
  57826. * @param extension defines the file extension of the file being loaded
  57827. * @param mimeType defines the optional mime type of the file being loaded
  57828. * @returns true if the loader can load the specified file
  57829. */
  57830. canLoad(extension: string, mimeType?: string): boolean;
  57831. /**
  57832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57833. * @param data contains the texture data
  57834. * @param texture defines the BabylonJS internal texture
  57835. * @param createPolynomials will be true if polynomials have been requested
  57836. * @param onLoad defines the callback to trigger once the texture is ready
  57837. * @param onError defines the callback to trigger in case of error
  57838. */
  57839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57840. /**
  57841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57842. * @param data contains the texture data
  57843. * @param texture defines the BabylonJS internal texture
  57844. * @param callback defines the method to call once ready to upload
  57845. */
  57846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57847. }
  57848. }
  57849. declare module BABYLON {
  57850. /** @hidden */
  57851. export var _forceSceneHelpersToBundle: boolean;
  57852. interface Scene {
  57853. /**
  57854. * Creates a default light for the scene.
  57855. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57856. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57857. */
  57858. createDefaultLight(replace?: boolean): void;
  57859. /**
  57860. * Creates a default camera for the scene.
  57861. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57862. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57863. * @param replace has default false, when true replaces the active camera in the scene
  57864. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57865. */
  57866. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57867. /**
  57868. * Creates a default camera and a default light.
  57869. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57870. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57871. * @param replace has the default false, when true replaces the active camera/light in the scene
  57872. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57873. */
  57874. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57875. /**
  57876. * Creates a new sky box
  57877. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57878. * @param environmentTexture defines the texture to use as environment texture
  57879. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57880. * @param scale defines the overall scale of the skybox
  57881. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57882. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57883. * @returns a new mesh holding the sky box
  57884. */
  57885. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57886. /**
  57887. * Creates a new environment
  57888. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57889. * @param options defines the options you can use to configure the environment
  57890. * @returns the new EnvironmentHelper
  57891. */
  57892. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57893. /**
  57894. * Creates a new VREXperienceHelper
  57895. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57896. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57897. * @returns a new VREXperienceHelper
  57898. */
  57899. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57900. /**
  57901. * Creates a new WebXRDefaultExperience
  57902. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57903. * @param options experience options
  57904. * @returns a promise for a new WebXRDefaultExperience
  57905. */
  57906. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57907. }
  57908. }
  57909. declare module BABYLON {
  57910. /**
  57911. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57912. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57913. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57914. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57915. */
  57916. export class VideoDome extends TextureDome<VideoTexture> {
  57917. /**
  57918. * Define the video source as a Monoscopic panoramic 360 video.
  57919. */
  57920. static readonly MODE_MONOSCOPIC: number;
  57921. /**
  57922. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57923. */
  57924. static readonly MODE_TOPBOTTOM: number;
  57925. /**
  57926. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57927. */
  57928. static readonly MODE_SIDEBYSIDE: number;
  57929. /**
  57930. * Get the video texture associated with this video dome
  57931. */
  57932. get videoTexture(): VideoTexture;
  57933. /**
  57934. * Get the video mode of this dome
  57935. */
  57936. get videoMode(): number;
  57937. /**
  57938. * Set the video mode of this dome.
  57939. * @see textureMode
  57940. */
  57941. set videoMode(value: number);
  57942. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57943. }
  57944. }
  57945. declare module BABYLON {
  57946. /**
  57947. * This class can be used to get instrumentation data from a Babylon engine
  57948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57949. */
  57950. export class EngineInstrumentation implements IDisposable {
  57951. /**
  57952. * Define the instrumented engine.
  57953. */
  57954. engine: Engine;
  57955. private _captureGPUFrameTime;
  57956. private _gpuFrameTimeToken;
  57957. private _gpuFrameTime;
  57958. private _captureShaderCompilationTime;
  57959. private _shaderCompilationTime;
  57960. private _onBeginFrameObserver;
  57961. private _onEndFrameObserver;
  57962. private _onBeforeShaderCompilationObserver;
  57963. private _onAfterShaderCompilationObserver;
  57964. /**
  57965. * Gets the perf counter used for GPU frame time
  57966. */
  57967. get gpuFrameTimeCounter(): PerfCounter;
  57968. /**
  57969. * Gets the GPU frame time capture status
  57970. */
  57971. get captureGPUFrameTime(): boolean;
  57972. /**
  57973. * Enable or disable the GPU frame time capture
  57974. */
  57975. set captureGPUFrameTime(value: boolean);
  57976. /**
  57977. * Gets the perf counter used for shader compilation time
  57978. */
  57979. get shaderCompilationTimeCounter(): PerfCounter;
  57980. /**
  57981. * Gets the shader compilation time capture status
  57982. */
  57983. get captureShaderCompilationTime(): boolean;
  57984. /**
  57985. * Enable or disable the shader compilation time capture
  57986. */
  57987. set captureShaderCompilationTime(value: boolean);
  57988. /**
  57989. * Instantiates a new engine instrumentation.
  57990. * This class can be used to get instrumentation data from a Babylon engine
  57991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57992. * @param engine Defines the engine to instrument
  57993. */
  57994. constructor(
  57995. /**
  57996. * Define the instrumented engine.
  57997. */
  57998. engine: Engine);
  57999. /**
  58000. * Dispose and release associated resources.
  58001. */
  58002. dispose(): void;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /**
  58007. * This class can be used to get instrumentation data from a Babylon engine
  58008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58009. */
  58010. export class SceneInstrumentation implements IDisposable {
  58011. /**
  58012. * Defines the scene to instrument
  58013. */
  58014. scene: Scene;
  58015. private _captureActiveMeshesEvaluationTime;
  58016. private _activeMeshesEvaluationTime;
  58017. private _captureRenderTargetsRenderTime;
  58018. private _renderTargetsRenderTime;
  58019. private _captureFrameTime;
  58020. private _frameTime;
  58021. private _captureRenderTime;
  58022. private _renderTime;
  58023. private _captureInterFrameTime;
  58024. private _interFrameTime;
  58025. private _captureParticlesRenderTime;
  58026. private _particlesRenderTime;
  58027. private _captureSpritesRenderTime;
  58028. private _spritesRenderTime;
  58029. private _capturePhysicsTime;
  58030. private _physicsTime;
  58031. private _captureAnimationsTime;
  58032. private _animationsTime;
  58033. private _captureCameraRenderTime;
  58034. private _cameraRenderTime;
  58035. private _onBeforeActiveMeshesEvaluationObserver;
  58036. private _onAfterActiveMeshesEvaluationObserver;
  58037. private _onBeforeRenderTargetsRenderObserver;
  58038. private _onAfterRenderTargetsRenderObserver;
  58039. private _onAfterRenderObserver;
  58040. private _onBeforeDrawPhaseObserver;
  58041. private _onAfterDrawPhaseObserver;
  58042. private _onBeforeAnimationsObserver;
  58043. private _onBeforeParticlesRenderingObserver;
  58044. private _onAfterParticlesRenderingObserver;
  58045. private _onBeforeSpritesRenderingObserver;
  58046. private _onAfterSpritesRenderingObserver;
  58047. private _onBeforePhysicsObserver;
  58048. private _onAfterPhysicsObserver;
  58049. private _onAfterAnimationsObserver;
  58050. private _onBeforeCameraRenderObserver;
  58051. private _onAfterCameraRenderObserver;
  58052. /**
  58053. * Gets the perf counter used for active meshes evaluation time
  58054. */
  58055. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58056. /**
  58057. * Gets the active meshes evaluation time capture status
  58058. */
  58059. get captureActiveMeshesEvaluationTime(): boolean;
  58060. /**
  58061. * Enable or disable the active meshes evaluation time capture
  58062. */
  58063. set captureActiveMeshesEvaluationTime(value: boolean);
  58064. /**
  58065. * Gets the perf counter used for render targets render time
  58066. */
  58067. get renderTargetsRenderTimeCounter(): PerfCounter;
  58068. /**
  58069. * Gets the render targets render time capture status
  58070. */
  58071. get captureRenderTargetsRenderTime(): boolean;
  58072. /**
  58073. * Enable or disable the render targets render time capture
  58074. */
  58075. set captureRenderTargetsRenderTime(value: boolean);
  58076. /**
  58077. * Gets the perf counter used for particles render time
  58078. */
  58079. get particlesRenderTimeCounter(): PerfCounter;
  58080. /**
  58081. * Gets the particles render time capture status
  58082. */
  58083. get captureParticlesRenderTime(): boolean;
  58084. /**
  58085. * Enable or disable the particles render time capture
  58086. */
  58087. set captureParticlesRenderTime(value: boolean);
  58088. /**
  58089. * Gets the perf counter used for sprites render time
  58090. */
  58091. get spritesRenderTimeCounter(): PerfCounter;
  58092. /**
  58093. * Gets the sprites render time capture status
  58094. */
  58095. get captureSpritesRenderTime(): boolean;
  58096. /**
  58097. * Enable or disable the sprites render time capture
  58098. */
  58099. set captureSpritesRenderTime(value: boolean);
  58100. /**
  58101. * Gets the perf counter used for physics time
  58102. */
  58103. get physicsTimeCounter(): PerfCounter;
  58104. /**
  58105. * Gets the physics time capture status
  58106. */
  58107. get capturePhysicsTime(): boolean;
  58108. /**
  58109. * Enable or disable the physics time capture
  58110. */
  58111. set capturePhysicsTime(value: boolean);
  58112. /**
  58113. * Gets the perf counter used for animations time
  58114. */
  58115. get animationsTimeCounter(): PerfCounter;
  58116. /**
  58117. * Gets the animations time capture status
  58118. */
  58119. get captureAnimationsTime(): boolean;
  58120. /**
  58121. * Enable or disable the animations time capture
  58122. */
  58123. set captureAnimationsTime(value: boolean);
  58124. /**
  58125. * Gets the perf counter used for frame time capture
  58126. */
  58127. get frameTimeCounter(): PerfCounter;
  58128. /**
  58129. * Gets the frame time capture status
  58130. */
  58131. get captureFrameTime(): boolean;
  58132. /**
  58133. * Enable or disable the frame time capture
  58134. */
  58135. set captureFrameTime(value: boolean);
  58136. /**
  58137. * Gets the perf counter used for inter-frames time capture
  58138. */
  58139. get interFrameTimeCounter(): PerfCounter;
  58140. /**
  58141. * Gets the inter-frames time capture status
  58142. */
  58143. get captureInterFrameTime(): boolean;
  58144. /**
  58145. * Enable or disable the inter-frames time capture
  58146. */
  58147. set captureInterFrameTime(value: boolean);
  58148. /**
  58149. * Gets the perf counter used for render time capture
  58150. */
  58151. get renderTimeCounter(): PerfCounter;
  58152. /**
  58153. * Gets the render time capture status
  58154. */
  58155. get captureRenderTime(): boolean;
  58156. /**
  58157. * Enable or disable the render time capture
  58158. */
  58159. set captureRenderTime(value: boolean);
  58160. /**
  58161. * Gets the perf counter used for camera render time capture
  58162. */
  58163. get cameraRenderTimeCounter(): PerfCounter;
  58164. /**
  58165. * Gets the camera render time capture status
  58166. */
  58167. get captureCameraRenderTime(): boolean;
  58168. /**
  58169. * Enable or disable the camera render time capture
  58170. */
  58171. set captureCameraRenderTime(value: boolean);
  58172. /**
  58173. * Gets the perf counter used for draw calls
  58174. */
  58175. get drawCallsCounter(): PerfCounter;
  58176. /**
  58177. * Instantiates a new scene instrumentation.
  58178. * This class can be used to get instrumentation data from a Babylon engine
  58179. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58180. * @param scene Defines the scene to instrument
  58181. */
  58182. constructor(
  58183. /**
  58184. * Defines the scene to instrument
  58185. */
  58186. scene: Scene);
  58187. /**
  58188. * Dispose and release associated resources.
  58189. */
  58190. dispose(): void;
  58191. }
  58192. }
  58193. declare module BABYLON {
  58194. /** @hidden */
  58195. export var glowMapGenerationPixelShader: {
  58196. name: string;
  58197. shader: string;
  58198. };
  58199. }
  58200. declare module BABYLON {
  58201. /** @hidden */
  58202. export var glowMapGenerationVertexShader: {
  58203. name: string;
  58204. shader: string;
  58205. };
  58206. }
  58207. declare module BABYLON {
  58208. /**
  58209. * Effect layer options. This helps customizing the behaviour
  58210. * of the effect layer.
  58211. */
  58212. export interface IEffectLayerOptions {
  58213. /**
  58214. * Multiplication factor apply to the canvas size to compute the render target size
  58215. * used to generated the objects (the smaller the faster).
  58216. */
  58217. mainTextureRatio: number;
  58218. /**
  58219. * Enforces a fixed size texture to ensure effect stability across devices.
  58220. */
  58221. mainTextureFixedSize?: number;
  58222. /**
  58223. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58224. */
  58225. alphaBlendingMode: number;
  58226. /**
  58227. * The camera attached to the layer.
  58228. */
  58229. camera: Nullable<Camera>;
  58230. /**
  58231. * The rendering group to draw the layer in.
  58232. */
  58233. renderingGroupId: number;
  58234. }
  58235. /**
  58236. * The effect layer Helps adding post process effect blended with the main pass.
  58237. *
  58238. * This can be for instance use to generate glow or higlight effects on the scene.
  58239. *
  58240. * The effect layer class can not be used directly and is intented to inherited from to be
  58241. * customized per effects.
  58242. */
  58243. export abstract class EffectLayer {
  58244. private _vertexBuffers;
  58245. private _indexBuffer;
  58246. private _cachedDefines;
  58247. private _effectLayerMapGenerationEffect;
  58248. private _effectLayerOptions;
  58249. private _mergeEffect;
  58250. protected _scene: Scene;
  58251. protected _engine: Engine;
  58252. protected _maxSize: number;
  58253. protected _mainTextureDesiredSize: ISize;
  58254. protected _mainTexture: RenderTargetTexture;
  58255. protected _shouldRender: boolean;
  58256. protected _postProcesses: PostProcess[];
  58257. protected _textures: BaseTexture[];
  58258. protected _emissiveTextureAndColor: {
  58259. texture: Nullable<BaseTexture>;
  58260. color: Color4;
  58261. };
  58262. /**
  58263. * The name of the layer
  58264. */
  58265. name: string;
  58266. /**
  58267. * The clear color of the texture used to generate the glow map.
  58268. */
  58269. neutralColor: Color4;
  58270. /**
  58271. * Specifies whether the highlight layer is enabled or not.
  58272. */
  58273. isEnabled: boolean;
  58274. /**
  58275. * Gets the camera attached to the layer.
  58276. */
  58277. get camera(): Nullable<Camera>;
  58278. /**
  58279. * Gets the rendering group id the layer should render in.
  58280. */
  58281. get renderingGroupId(): number;
  58282. set renderingGroupId(renderingGroupId: number);
  58283. /**
  58284. * An event triggered when the effect layer has been disposed.
  58285. */
  58286. onDisposeObservable: Observable<EffectLayer>;
  58287. /**
  58288. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58289. */
  58290. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58291. /**
  58292. * An event triggered when the generated texture is being merged in the scene.
  58293. */
  58294. onBeforeComposeObservable: Observable<EffectLayer>;
  58295. /**
  58296. * An event triggered when the mesh is rendered into the effect render target.
  58297. */
  58298. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58299. /**
  58300. * An event triggered after the mesh has been rendered into the effect render target.
  58301. */
  58302. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58303. /**
  58304. * An event triggered when the generated texture has been merged in the scene.
  58305. */
  58306. onAfterComposeObservable: Observable<EffectLayer>;
  58307. /**
  58308. * An event triggered when the efffect layer changes its size.
  58309. */
  58310. onSizeChangedObservable: Observable<EffectLayer>;
  58311. /** @hidden */
  58312. static _SceneComponentInitialization: (scene: Scene) => void;
  58313. /**
  58314. * Instantiates a new effect Layer and references it in the scene.
  58315. * @param name The name of the layer
  58316. * @param scene The scene to use the layer in
  58317. */
  58318. constructor(
  58319. /** The Friendly of the effect in the scene */
  58320. name: string, scene: Scene);
  58321. /**
  58322. * Get the effect name of the layer.
  58323. * @return The effect name
  58324. */
  58325. abstract getEffectName(): string;
  58326. /**
  58327. * Checks for the readiness of the element composing the layer.
  58328. * @param subMesh the mesh to check for
  58329. * @param useInstances specify whether or not to use instances to render the mesh
  58330. * @return true if ready otherwise, false
  58331. */
  58332. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58333. /**
  58334. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58335. * @returns true if the effect requires stencil during the main canvas render pass.
  58336. */
  58337. abstract needStencil(): boolean;
  58338. /**
  58339. * Create the merge effect. This is the shader use to blit the information back
  58340. * to the main canvas at the end of the scene rendering.
  58341. * @returns The effect containing the shader used to merge the effect on the main canvas
  58342. */
  58343. protected abstract _createMergeEffect(): Effect;
  58344. /**
  58345. * Creates the render target textures and post processes used in the effect layer.
  58346. */
  58347. protected abstract _createTextureAndPostProcesses(): void;
  58348. /**
  58349. * Implementation specific of rendering the generating effect on the main canvas.
  58350. * @param effect The effect used to render through
  58351. */
  58352. protected abstract _internalRender(effect: Effect): void;
  58353. /**
  58354. * Sets the required values for both the emissive texture and and the main color.
  58355. */
  58356. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58357. /**
  58358. * Free any resources and references associated to a mesh.
  58359. * Internal use
  58360. * @param mesh The mesh to free.
  58361. */
  58362. abstract _disposeMesh(mesh: Mesh): void;
  58363. /**
  58364. * Serializes this layer (Glow or Highlight for example)
  58365. * @returns a serialized layer object
  58366. */
  58367. abstract serialize?(): any;
  58368. /**
  58369. * Initializes the effect layer with the required options.
  58370. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58371. */
  58372. protected _init(options: Partial<IEffectLayerOptions>): void;
  58373. /**
  58374. * Generates the index buffer of the full screen quad blending to the main canvas.
  58375. */
  58376. private _generateIndexBuffer;
  58377. /**
  58378. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58379. */
  58380. private _generateVertexBuffer;
  58381. /**
  58382. * Sets the main texture desired size which is the closest power of two
  58383. * of the engine canvas size.
  58384. */
  58385. private _setMainTextureSize;
  58386. /**
  58387. * Creates the main texture for the effect layer.
  58388. */
  58389. protected _createMainTexture(): void;
  58390. /**
  58391. * Adds specific effects defines.
  58392. * @param defines The defines to add specifics to.
  58393. */
  58394. protected _addCustomEffectDefines(defines: string[]): void;
  58395. /**
  58396. * Checks for the readiness of the element composing the layer.
  58397. * @param subMesh the mesh to check for
  58398. * @param useInstances specify whether or not to use instances to render the mesh
  58399. * @param emissiveTexture the associated emissive texture used to generate the glow
  58400. * @return true if ready otherwise, false
  58401. */
  58402. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58403. /**
  58404. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58405. */
  58406. render(): void;
  58407. /**
  58408. * Determine if a given mesh will be used in the current effect.
  58409. * @param mesh mesh to test
  58410. * @returns true if the mesh will be used
  58411. */
  58412. hasMesh(mesh: AbstractMesh): boolean;
  58413. /**
  58414. * Returns true if the layer contains information to display, otherwise false.
  58415. * @returns true if the glow layer should be rendered
  58416. */
  58417. shouldRender(): boolean;
  58418. /**
  58419. * Returns true if the mesh should render, otherwise false.
  58420. * @param mesh The mesh to render
  58421. * @returns true if it should render otherwise false
  58422. */
  58423. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58424. /**
  58425. * Returns true if the mesh can be rendered, otherwise false.
  58426. * @param mesh The mesh to render
  58427. * @param material The material used on the mesh
  58428. * @returns true if it can be rendered otherwise false
  58429. */
  58430. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58431. /**
  58432. * Returns true if the mesh should render, otherwise false.
  58433. * @param mesh The mesh to render
  58434. * @returns true if it should render otherwise false
  58435. */
  58436. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58437. /**
  58438. * Renders the submesh passed in parameter to the generation map.
  58439. */
  58440. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58441. /**
  58442. * Defines whether the current material of the mesh should be use to render the effect.
  58443. * @param mesh defines the current mesh to render
  58444. */
  58445. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58446. /**
  58447. * Rebuild the required buffers.
  58448. * @hidden Internal use only.
  58449. */
  58450. _rebuild(): void;
  58451. /**
  58452. * Dispose only the render target textures and post process.
  58453. */
  58454. private _disposeTextureAndPostProcesses;
  58455. /**
  58456. * Dispose the highlight layer and free resources.
  58457. */
  58458. dispose(): void;
  58459. /**
  58460. * Gets the class name of the effect layer
  58461. * @returns the string with the class name of the effect layer
  58462. */
  58463. getClassName(): string;
  58464. /**
  58465. * Creates an effect layer from parsed effect layer data
  58466. * @param parsedEffectLayer defines effect layer data
  58467. * @param scene defines the current scene
  58468. * @param rootUrl defines the root URL containing the effect layer information
  58469. * @returns a parsed effect Layer
  58470. */
  58471. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58472. }
  58473. }
  58474. declare module BABYLON {
  58475. interface AbstractScene {
  58476. /**
  58477. * The list of effect layers (highlights/glow) added to the scene
  58478. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58479. * @see https://doc.babylonjs.com/how_to/glow_layer
  58480. */
  58481. effectLayers: Array<EffectLayer>;
  58482. /**
  58483. * Removes the given effect layer from this scene.
  58484. * @param toRemove defines the effect layer to remove
  58485. * @returns the index of the removed effect layer
  58486. */
  58487. removeEffectLayer(toRemove: EffectLayer): number;
  58488. /**
  58489. * Adds the given effect layer to this scene
  58490. * @param newEffectLayer defines the effect layer to add
  58491. */
  58492. addEffectLayer(newEffectLayer: EffectLayer): void;
  58493. }
  58494. /**
  58495. * Defines the layer scene component responsible to manage any effect layers
  58496. * in a given scene.
  58497. */
  58498. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58499. /**
  58500. * The component name helpfull to identify the component in the list of scene components.
  58501. */
  58502. readonly name: string;
  58503. /**
  58504. * The scene the component belongs to.
  58505. */
  58506. scene: Scene;
  58507. private _engine;
  58508. private _renderEffects;
  58509. private _needStencil;
  58510. private _previousStencilState;
  58511. /**
  58512. * Creates a new instance of the component for the given scene
  58513. * @param scene Defines the scene to register the component in
  58514. */
  58515. constructor(scene: Scene);
  58516. /**
  58517. * Registers the component in a given scene
  58518. */
  58519. register(): void;
  58520. /**
  58521. * Rebuilds the elements related to this component in case of
  58522. * context lost for instance.
  58523. */
  58524. rebuild(): void;
  58525. /**
  58526. * Serializes the component data to the specified json object
  58527. * @param serializationObject The object to serialize to
  58528. */
  58529. serialize(serializationObject: any): void;
  58530. /**
  58531. * Adds all the elements from the container to the scene
  58532. * @param container the container holding the elements
  58533. */
  58534. addFromContainer(container: AbstractScene): void;
  58535. /**
  58536. * Removes all the elements in the container from the scene
  58537. * @param container contains the elements to remove
  58538. * @param dispose if the removed element should be disposed (default: false)
  58539. */
  58540. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58541. /**
  58542. * Disposes the component and the associated ressources.
  58543. */
  58544. dispose(): void;
  58545. private _isReadyForMesh;
  58546. private _renderMainTexture;
  58547. private _setStencil;
  58548. private _setStencilBack;
  58549. private _draw;
  58550. private _drawCamera;
  58551. private _drawRenderingGroup;
  58552. }
  58553. }
  58554. declare module BABYLON {
  58555. /** @hidden */
  58556. export var glowMapMergePixelShader: {
  58557. name: string;
  58558. shader: string;
  58559. };
  58560. }
  58561. declare module BABYLON {
  58562. /** @hidden */
  58563. export var glowMapMergeVertexShader: {
  58564. name: string;
  58565. shader: string;
  58566. };
  58567. }
  58568. declare module BABYLON {
  58569. interface AbstractScene {
  58570. /**
  58571. * Return a the first highlight layer of the scene with a given name.
  58572. * @param name The name of the highlight layer to look for.
  58573. * @return The highlight layer if found otherwise null.
  58574. */
  58575. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58576. }
  58577. /**
  58578. * Glow layer options. This helps customizing the behaviour
  58579. * of the glow layer.
  58580. */
  58581. export interface IGlowLayerOptions {
  58582. /**
  58583. * Multiplication factor apply to the canvas size to compute the render target size
  58584. * used to generated the glowing objects (the smaller the faster).
  58585. */
  58586. mainTextureRatio: number;
  58587. /**
  58588. * Enforces a fixed size texture to ensure resize independant blur.
  58589. */
  58590. mainTextureFixedSize?: number;
  58591. /**
  58592. * How big is the kernel of the blur texture.
  58593. */
  58594. blurKernelSize: number;
  58595. /**
  58596. * The camera attached to the layer.
  58597. */
  58598. camera: Nullable<Camera>;
  58599. /**
  58600. * Enable MSAA by chosing the number of samples.
  58601. */
  58602. mainTextureSamples?: number;
  58603. /**
  58604. * The rendering group to draw the layer in.
  58605. */
  58606. renderingGroupId: number;
  58607. }
  58608. /**
  58609. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58610. *
  58611. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58612. *
  58613. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58614. */
  58615. export class GlowLayer extends EffectLayer {
  58616. /**
  58617. * Effect Name of the layer.
  58618. */
  58619. static readonly EffectName: string;
  58620. /**
  58621. * The default blur kernel size used for the glow.
  58622. */
  58623. static DefaultBlurKernelSize: number;
  58624. /**
  58625. * The default texture size ratio used for the glow.
  58626. */
  58627. static DefaultTextureRatio: number;
  58628. /**
  58629. * Sets the kernel size of the blur.
  58630. */
  58631. set blurKernelSize(value: number);
  58632. /**
  58633. * Gets the kernel size of the blur.
  58634. */
  58635. get blurKernelSize(): number;
  58636. /**
  58637. * Sets the glow intensity.
  58638. */
  58639. set intensity(value: number);
  58640. /**
  58641. * Gets the glow intensity.
  58642. */
  58643. get intensity(): number;
  58644. private _options;
  58645. private _intensity;
  58646. private _horizontalBlurPostprocess1;
  58647. private _verticalBlurPostprocess1;
  58648. private _horizontalBlurPostprocess2;
  58649. private _verticalBlurPostprocess2;
  58650. private _blurTexture1;
  58651. private _blurTexture2;
  58652. private _postProcesses1;
  58653. private _postProcesses2;
  58654. private _includedOnlyMeshes;
  58655. private _excludedMeshes;
  58656. private _meshesUsingTheirOwnMaterials;
  58657. /**
  58658. * Callback used to let the user override the color selection on a per mesh basis
  58659. */
  58660. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58661. /**
  58662. * Callback used to let the user override the texture selection on a per mesh basis
  58663. */
  58664. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58665. /**
  58666. * Instantiates a new glow Layer and references it to the scene.
  58667. * @param name The name of the layer
  58668. * @param scene The scene to use the layer in
  58669. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58670. */
  58671. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58672. /**
  58673. * Get the effect name of the layer.
  58674. * @return The effect name
  58675. */
  58676. getEffectName(): string;
  58677. /**
  58678. * Create the merge effect. This is the shader use to blit the information back
  58679. * to the main canvas at the end of the scene rendering.
  58680. */
  58681. protected _createMergeEffect(): Effect;
  58682. /**
  58683. * Creates the render target textures and post processes used in the glow layer.
  58684. */
  58685. protected _createTextureAndPostProcesses(): void;
  58686. /**
  58687. * Checks for the readiness of the element composing the layer.
  58688. * @param subMesh the mesh to check for
  58689. * @param useInstances specify wether or not to use instances to render the mesh
  58690. * @param emissiveTexture the associated emissive texture used to generate the glow
  58691. * @return true if ready otherwise, false
  58692. */
  58693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58694. /**
  58695. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58696. */
  58697. needStencil(): boolean;
  58698. /**
  58699. * Returns true if the mesh can be rendered, otherwise false.
  58700. * @param mesh The mesh to render
  58701. * @param material The material used on the mesh
  58702. * @returns true if it can be rendered otherwise false
  58703. */
  58704. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58705. /**
  58706. * Implementation specific of rendering the generating effect on the main canvas.
  58707. * @param effect The effect used to render through
  58708. */
  58709. protected _internalRender(effect: Effect): void;
  58710. /**
  58711. * Sets the required values for both the emissive texture and and the main color.
  58712. */
  58713. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58714. /**
  58715. * Returns true if the mesh should render, otherwise false.
  58716. * @param mesh The mesh to render
  58717. * @returns true if it should render otherwise false
  58718. */
  58719. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58720. /**
  58721. * Adds specific effects defines.
  58722. * @param defines The defines to add specifics to.
  58723. */
  58724. protected _addCustomEffectDefines(defines: string[]): void;
  58725. /**
  58726. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58727. * @param mesh The mesh to exclude from the glow layer
  58728. */
  58729. addExcludedMesh(mesh: Mesh): void;
  58730. /**
  58731. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58732. * @param mesh The mesh to remove
  58733. */
  58734. removeExcludedMesh(mesh: Mesh): void;
  58735. /**
  58736. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58737. * @param mesh The mesh to include in the glow layer
  58738. */
  58739. addIncludedOnlyMesh(mesh: Mesh): void;
  58740. /**
  58741. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58742. * @param mesh The mesh to remove
  58743. */
  58744. removeIncludedOnlyMesh(mesh: Mesh): void;
  58745. /**
  58746. * Determine if a given mesh will be used in the glow layer
  58747. * @param mesh The mesh to test
  58748. * @returns true if the mesh will be highlighted by the current glow layer
  58749. */
  58750. hasMesh(mesh: AbstractMesh): boolean;
  58751. /**
  58752. * Defines whether the current material of the mesh should be use to render the effect.
  58753. * @param mesh defines the current mesh to render
  58754. */
  58755. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58756. /**
  58757. * Add a mesh to be rendered through its own material and not with emissive only.
  58758. * @param mesh The mesh for which we need to use its material
  58759. */
  58760. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58761. /**
  58762. * Remove a mesh from being rendered through its own material and not with emissive only.
  58763. * @param mesh The mesh for which we need to not use its material
  58764. */
  58765. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58766. /**
  58767. * Free any resources and references associated to a mesh.
  58768. * Internal use
  58769. * @param mesh The mesh to free.
  58770. * @hidden
  58771. */
  58772. _disposeMesh(mesh: Mesh): void;
  58773. /**
  58774. * Gets the class name of the effect layer
  58775. * @returns the string with the class name of the effect layer
  58776. */
  58777. getClassName(): string;
  58778. /**
  58779. * Serializes this glow layer
  58780. * @returns a serialized glow layer object
  58781. */
  58782. serialize(): any;
  58783. /**
  58784. * Creates a Glow Layer from parsed glow layer data
  58785. * @param parsedGlowLayer defines glow layer data
  58786. * @param scene defines the current scene
  58787. * @param rootUrl defines the root URL containing the glow layer information
  58788. * @returns a parsed Glow Layer
  58789. */
  58790. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58791. }
  58792. }
  58793. declare module BABYLON {
  58794. /** @hidden */
  58795. export var glowBlurPostProcessPixelShader: {
  58796. name: string;
  58797. shader: string;
  58798. };
  58799. }
  58800. declare module BABYLON {
  58801. interface AbstractScene {
  58802. /**
  58803. * Return a the first highlight layer of the scene with a given name.
  58804. * @param name The name of the highlight layer to look for.
  58805. * @return The highlight layer if found otherwise null.
  58806. */
  58807. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58808. }
  58809. /**
  58810. * Highlight layer options. This helps customizing the behaviour
  58811. * of the highlight layer.
  58812. */
  58813. export interface IHighlightLayerOptions {
  58814. /**
  58815. * Multiplication factor apply to the canvas size to compute the render target size
  58816. * used to generated the glowing objects (the smaller the faster).
  58817. */
  58818. mainTextureRatio: number;
  58819. /**
  58820. * Enforces a fixed size texture to ensure resize independant blur.
  58821. */
  58822. mainTextureFixedSize?: number;
  58823. /**
  58824. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58825. * of the picture to blur (the smaller the faster).
  58826. */
  58827. blurTextureSizeRatio: number;
  58828. /**
  58829. * How big in texel of the blur texture is the vertical blur.
  58830. */
  58831. blurVerticalSize: number;
  58832. /**
  58833. * How big in texel of the blur texture is the horizontal blur.
  58834. */
  58835. blurHorizontalSize: number;
  58836. /**
  58837. * Alpha blending mode used to apply the blur. Default is combine.
  58838. */
  58839. alphaBlendingMode: number;
  58840. /**
  58841. * The camera attached to the layer.
  58842. */
  58843. camera: Nullable<Camera>;
  58844. /**
  58845. * Should we display highlight as a solid stroke?
  58846. */
  58847. isStroke?: boolean;
  58848. /**
  58849. * The rendering group to draw the layer in.
  58850. */
  58851. renderingGroupId: number;
  58852. }
  58853. /**
  58854. * The highlight layer Helps adding a glow effect around a mesh.
  58855. *
  58856. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58857. * glowy meshes to your scene.
  58858. *
  58859. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58860. */
  58861. export class HighlightLayer extends EffectLayer {
  58862. name: string;
  58863. /**
  58864. * Effect Name of the highlight layer.
  58865. */
  58866. static readonly EffectName: string;
  58867. /**
  58868. * The neutral color used during the preparation of the glow effect.
  58869. * This is black by default as the blend operation is a blend operation.
  58870. */
  58871. static NeutralColor: Color4;
  58872. /**
  58873. * Stencil value used for glowing meshes.
  58874. */
  58875. static GlowingMeshStencilReference: number;
  58876. /**
  58877. * Stencil value used for the other meshes in the scene.
  58878. */
  58879. static NormalMeshStencilReference: number;
  58880. /**
  58881. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58882. */
  58883. innerGlow: boolean;
  58884. /**
  58885. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58886. */
  58887. outerGlow: boolean;
  58888. /**
  58889. * Specifies the horizontal size of the blur.
  58890. */
  58891. set blurHorizontalSize(value: number);
  58892. /**
  58893. * Specifies the vertical size of the blur.
  58894. */
  58895. set blurVerticalSize(value: number);
  58896. /**
  58897. * Gets the horizontal size of the blur.
  58898. */
  58899. get blurHorizontalSize(): number;
  58900. /**
  58901. * Gets the vertical size of the blur.
  58902. */
  58903. get blurVerticalSize(): number;
  58904. /**
  58905. * An event triggered when the highlight layer is being blurred.
  58906. */
  58907. onBeforeBlurObservable: Observable<HighlightLayer>;
  58908. /**
  58909. * An event triggered when the highlight layer has been blurred.
  58910. */
  58911. onAfterBlurObservable: Observable<HighlightLayer>;
  58912. private _instanceGlowingMeshStencilReference;
  58913. private _options;
  58914. private _downSamplePostprocess;
  58915. private _horizontalBlurPostprocess;
  58916. private _verticalBlurPostprocess;
  58917. private _blurTexture;
  58918. private _meshes;
  58919. private _excludedMeshes;
  58920. /**
  58921. * Instantiates a new highlight Layer and references it to the scene..
  58922. * @param name The name of the layer
  58923. * @param scene The scene to use the layer in
  58924. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58925. */
  58926. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58927. /**
  58928. * Get the effect name of the layer.
  58929. * @return The effect name
  58930. */
  58931. getEffectName(): string;
  58932. /**
  58933. * Create the merge effect. This is the shader use to blit the information back
  58934. * to the main canvas at the end of the scene rendering.
  58935. */
  58936. protected _createMergeEffect(): Effect;
  58937. /**
  58938. * Creates the render target textures and post processes used in the highlight layer.
  58939. */
  58940. protected _createTextureAndPostProcesses(): void;
  58941. /**
  58942. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58943. */
  58944. needStencil(): boolean;
  58945. /**
  58946. * Checks for the readiness of the element composing the layer.
  58947. * @param subMesh the mesh to check for
  58948. * @param useInstances specify wether or not to use instances to render the mesh
  58949. * @param emissiveTexture the associated emissive texture used to generate the glow
  58950. * @return true if ready otherwise, false
  58951. */
  58952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58953. /**
  58954. * Implementation specific of rendering the generating effect on the main canvas.
  58955. * @param effect The effect used to render through
  58956. */
  58957. protected _internalRender(effect: Effect): void;
  58958. /**
  58959. * Returns true if the layer contains information to display, otherwise false.
  58960. */
  58961. shouldRender(): boolean;
  58962. /**
  58963. * Returns true if the mesh should render, otherwise false.
  58964. * @param mesh The mesh to render
  58965. * @returns true if it should render otherwise false
  58966. */
  58967. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58968. /**
  58969. * Returns true if the mesh can be rendered, otherwise false.
  58970. * @param mesh The mesh to render
  58971. * @param material The material used on the mesh
  58972. * @returns true if it can be rendered otherwise false
  58973. */
  58974. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58975. /**
  58976. * Adds specific effects defines.
  58977. * @param defines The defines to add specifics to.
  58978. */
  58979. protected _addCustomEffectDefines(defines: string[]): void;
  58980. /**
  58981. * Sets the required values for both the emissive texture and and the main color.
  58982. */
  58983. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58984. /**
  58985. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58986. * @param mesh The mesh to exclude from the highlight layer
  58987. */
  58988. addExcludedMesh(mesh: Mesh): void;
  58989. /**
  58990. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58991. * @param mesh The mesh to highlight
  58992. */
  58993. removeExcludedMesh(mesh: Mesh): void;
  58994. /**
  58995. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58996. * @param mesh mesh to test
  58997. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58998. */
  58999. hasMesh(mesh: AbstractMesh): boolean;
  59000. /**
  59001. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59002. * @param mesh The mesh to highlight
  59003. * @param color The color of the highlight
  59004. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59005. */
  59006. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59007. /**
  59008. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59009. * @param mesh The mesh to highlight
  59010. */
  59011. removeMesh(mesh: Mesh): void;
  59012. /**
  59013. * Remove all the meshes currently referenced in the highlight layer
  59014. */
  59015. removeAllMeshes(): void;
  59016. /**
  59017. * Force the stencil to the normal expected value for none glowing parts
  59018. */
  59019. private _defaultStencilReference;
  59020. /**
  59021. * Free any resources and references associated to a mesh.
  59022. * Internal use
  59023. * @param mesh The mesh to free.
  59024. * @hidden
  59025. */
  59026. _disposeMesh(mesh: Mesh): void;
  59027. /**
  59028. * Dispose the highlight layer and free resources.
  59029. */
  59030. dispose(): void;
  59031. /**
  59032. * Gets the class name of the effect layer
  59033. * @returns the string with the class name of the effect layer
  59034. */
  59035. getClassName(): string;
  59036. /**
  59037. * Serializes this Highlight layer
  59038. * @returns a serialized Highlight layer object
  59039. */
  59040. serialize(): any;
  59041. /**
  59042. * Creates a Highlight layer from parsed Highlight layer data
  59043. * @param parsedHightlightLayer defines the Highlight layer data
  59044. * @param scene defines the current scene
  59045. * @param rootUrl defines the root URL containing the Highlight layer information
  59046. * @returns a parsed Highlight layer
  59047. */
  59048. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59049. }
  59050. }
  59051. declare module BABYLON {
  59052. interface AbstractScene {
  59053. /**
  59054. * The list of layers (background and foreground) of the scene
  59055. */
  59056. layers: Array<Layer>;
  59057. }
  59058. /**
  59059. * Defines the layer scene component responsible to manage any layers
  59060. * in a given scene.
  59061. */
  59062. export class LayerSceneComponent implements ISceneComponent {
  59063. /**
  59064. * The component name helpfull to identify the component in the list of scene components.
  59065. */
  59066. readonly name: string;
  59067. /**
  59068. * The scene the component belongs to.
  59069. */
  59070. scene: Scene;
  59071. private _engine;
  59072. /**
  59073. * Creates a new instance of the component for the given scene
  59074. * @param scene Defines the scene to register the component in
  59075. */
  59076. constructor(scene: Scene);
  59077. /**
  59078. * Registers the component in a given scene
  59079. */
  59080. register(): void;
  59081. /**
  59082. * Rebuilds the elements related to this component in case of
  59083. * context lost for instance.
  59084. */
  59085. rebuild(): void;
  59086. /**
  59087. * Disposes the component and the associated ressources.
  59088. */
  59089. dispose(): void;
  59090. private _draw;
  59091. private _drawCameraPredicate;
  59092. private _drawCameraBackground;
  59093. private _drawCameraForeground;
  59094. private _drawRenderTargetPredicate;
  59095. private _drawRenderTargetBackground;
  59096. private _drawRenderTargetForeground;
  59097. /**
  59098. * Adds all the elements from the container to the scene
  59099. * @param container the container holding the elements
  59100. */
  59101. addFromContainer(container: AbstractScene): void;
  59102. /**
  59103. * Removes all the elements in the container from the scene
  59104. * @param container contains the elements to remove
  59105. * @param dispose if the removed element should be disposed (default: false)
  59106. */
  59107. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59108. }
  59109. }
  59110. declare module BABYLON {
  59111. /** @hidden */
  59112. export var layerPixelShader: {
  59113. name: string;
  59114. shader: string;
  59115. };
  59116. }
  59117. declare module BABYLON {
  59118. /** @hidden */
  59119. export var layerVertexShader: {
  59120. name: string;
  59121. shader: string;
  59122. };
  59123. }
  59124. declare module BABYLON {
  59125. /**
  59126. * This represents a full screen 2d layer.
  59127. * This can be useful to display a picture in the background of your scene for instance.
  59128. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59129. */
  59130. export class Layer {
  59131. /**
  59132. * Define the name of the layer.
  59133. */
  59134. name: string;
  59135. /**
  59136. * Define the texture the layer should display.
  59137. */
  59138. texture: Nullable<Texture>;
  59139. /**
  59140. * Is the layer in background or foreground.
  59141. */
  59142. isBackground: boolean;
  59143. /**
  59144. * Define the color of the layer (instead of texture).
  59145. */
  59146. color: Color4;
  59147. /**
  59148. * Define the scale of the layer in order to zoom in out of the texture.
  59149. */
  59150. scale: Vector2;
  59151. /**
  59152. * Define an offset for the layer in order to shift the texture.
  59153. */
  59154. offset: Vector2;
  59155. /**
  59156. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59157. */
  59158. alphaBlendingMode: number;
  59159. /**
  59160. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59161. * Alpha test will not mix with the background color in case of transparency.
  59162. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59163. */
  59164. alphaTest: boolean;
  59165. /**
  59166. * Define a mask to restrict the layer to only some of the scene cameras.
  59167. */
  59168. layerMask: number;
  59169. /**
  59170. * Define the list of render target the layer is visible into.
  59171. */
  59172. renderTargetTextures: RenderTargetTexture[];
  59173. /**
  59174. * Define if the layer is only used in renderTarget or if it also
  59175. * renders in the main frame buffer of the canvas.
  59176. */
  59177. renderOnlyInRenderTargetTextures: boolean;
  59178. private _scene;
  59179. private _vertexBuffers;
  59180. private _indexBuffer;
  59181. private _effect;
  59182. private _previousDefines;
  59183. /**
  59184. * An event triggered when the layer is disposed.
  59185. */
  59186. onDisposeObservable: Observable<Layer>;
  59187. private _onDisposeObserver;
  59188. /**
  59189. * Back compatibility with callback before the onDisposeObservable existed.
  59190. * The set callback will be triggered when the layer has been disposed.
  59191. */
  59192. set onDispose(callback: () => void);
  59193. /**
  59194. * An event triggered before rendering the scene
  59195. */
  59196. onBeforeRenderObservable: Observable<Layer>;
  59197. private _onBeforeRenderObserver;
  59198. /**
  59199. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59200. * The set callback will be triggered just before rendering the layer.
  59201. */
  59202. set onBeforeRender(callback: () => void);
  59203. /**
  59204. * An event triggered after rendering the scene
  59205. */
  59206. onAfterRenderObservable: Observable<Layer>;
  59207. private _onAfterRenderObserver;
  59208. /**
  59209. * Back compatibility with callback before the onAfterRenderObservable existed.
  59210. * The set callback will be triggered just after rendering the layer.
  59211. */
  59212. set onAfterRender(callback: () => void);
  59213. /**
  59214. * Instantiates a new layer.
  59215. * This represents a full screen 2d layer.
  59216. * This can be useful to display a picture in the background of your scene for instance.
  59217. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59218. * @param name Define the name of the layer in the scene
  59219. * @param imgUrl Define the url of the texture to display in the layer
  59220. * @param scene Define the scene the layer belongs to
  59221. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59222. * @param color Defines a color for the layer
  59223. */
  59224. constructor(
  59225. /**
  59226. * Define the name of the layer.
  59227. */
  59228. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59229. private _createIndexBuffer;
  59230. /** @hidden */
  59231. _rebuild(): void;
  59232. /**
  59233. * Renders the layer in the scene.
  59234. */
  59235. render(): void;
  59236. /**
  59237. * Disposes and releases the associated ressources.
  59238. */
  59239. dispose(): void;
  59240. }
  59241. }
  59242. declare module BABYLON {
  59243. /** @hidden */
  59244. export var lensFlarePixelShader: {
  59245. name: string;
  59246. shader: string;
  59247. };
  59248. }
  59249. declare module BABYLON {
  59250. /** @hidden */
  59251. export var lensFlareVertexShader: {
  59252. name: string;
  59253. shader: string;
  59254. };
  59255. }
  59256. declare module BABYLON {
  59257. /**
  59258. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59259. * It is usually composed of several `lensFlare`.
  59260. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59261. */
  59262. export class LensFlareSystem {
  59263. /**
  59264. * Define the name of the lens flare system
  59265. */
  59266. name: string;
  59267. /**
  59268. * List of lens flares used in this system.
  59269. */
  59270. lensFlares: LensFlare[];
  59271. /**
  59272. * Define a limit from the border the lens flare can be visible.
  59273. */
  59274. borderLimit: number;
  59275. /**
  59276. * Define a viewport border we do not want to see the lens flare in.
  59277. */
  59278. viewportBorder: number;
  59279. /**
  59280. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59281. */
  59282. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59283. /**
  59284. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59285. */
  59286. layerMask: number;
  59287. /**
  59288. * Define the id of the lens flare system in the scene.
  59289. * (equal to name by default)
  59290. */
  59291. id: string;
  59292. private _scene;
  59293. private _emitter;
  59294. private _vertexBuffers;
  59295. private _indexBuffer;
  59296. private _effect;
  59297. private _positionX;
  59298. private _positionY;
  59299. private _isEnabled;
  59300. /** @hidden */
  59301. static _SceneComponentInitialization: (scene: Scene) => void;
  59302. /**
  59303. * Instantiates a lens flare system.
  59304. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59305. * It is usually composed of several `lensFlare`.
  59306. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59307. * @param name Define the name of the lens flare system in the scene
  59308. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59309. * @param scene Define the scene the lens flare system belongs to
  59310. */
  59311. constructor(
  59312. /**
  59313. * Define the name of the lens flare system
  59314. */
  59315. name: string, emitter: any, scene: Scene);
  59316. /**
  59317. * Define if the lens flare system is enabled.
  59318. */
  59319. get isEnabled(): boolean;
  59320. set isEnabled(value: boolean);
  59321. /**
  59322. * Get the scene the effects belongs to.
  59323. * @returns the scene holding the lens flare system
  59324. */
  59325. getScene(): Scene;
  59326. /**
  59327. * Get the emitter of the lens flare system.
  59328. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59329. * @returns the emitter of the lens flare system
  59330. */
  59331. getEmitter(): any;
  59332. /**
  59333. * Set the emitter of the lens flare system.
  59334. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59335. * @param newEmitter Define the new emitter of the system
  59336. */
  59337. setEmitter(newEmitter: any): void;
  59338. /**
  59339. * Get the lens flare system emitter position.
  59340. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59341. * @returns the position
  59342. */
  59343. getEmitterPosition(): Vector3;
  59344. /**
  59345. * @hidden
  59346. */
  59347. computeEffectivePosition(globalViewport: Viewport): boolean;
  59348. /** @hidden */
  59349. _isVisible(): boolean;
  59350. /**
  59351. * @hidden
  59352. */
  59353. render(): boolean;
  59354. /**
  59355. * Dispose and release the lens flare with its associated resources.
  59356. */
  59357. dispose(): void;
  59358. /**
  59359. * Parse a lens flare system from a JSON repressentation
  59360. * @param parsedLensFlareSystem Define the JSON to parse
  59361. * @param scene Define the scene the parsed system should be instantiated in
  59362. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59363. * @returns the parsed system
  59364. */
  59365. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59366. /**
  59367. * Serialize the current Lens Flare System into a JSON representation.
  59368. * @returns the serialized JSON
  59369. */
  59370. serialize(): any;
  59371. }
  59372. }
  59373. declare module BABYLON {
  59374. /**
  59375. * This represents one of the lens effect in a `lensFlareSystem`.
  59376. * It controls one of the indiviual texture used in the effect.
  59377. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59378. */
  59379. export class LensFlare {
  59380. /**
  59381. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59382. */
  59383. size: number;
  59384. /**
  59385. * 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.
  59386. */
  59387. position: number;
  59388. /**
  59389. * Define the lens color.
  59390. */
  59391. color: Color3;
  59392. /**
  59393. * Define the lens texture.
  59394. */
  59395. texture: Nullable<Texture>;
  59396. /**
  59397. * Define the alpha mode to render this particular lens.
  59398. */
  59399. alphaMode: number;
  59400. private _system;
  59401. /**
  59402. * Creates a new Lens Flare.
  59403. * This represents one of the lens effect in a `lensFlareSystem`.
  59404. * It controls one of the indiviual texture used in the effect.
  59405. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59406. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59407. * @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.
  59408. * @param color Define the lens color
  59409. * @param imgUrl Define the lens texture url
  59410. * @param system Define the `lensFlareSystem` this flare is part of
  59411. * @returns The newly created Lens Flare
  59412. */
  59413. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59414. /**
  59415. * Instantiates a new Lens Flare.
  59416. * This represents one of the lens effect in a `lensFlareSystem`.
  59417. * It controls one of the indiviual texture used in the effect.
  59418. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59419. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59420. * @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.
  59421. * @param color Define the lens color
  59422. * @param imgUrl Define the lens texture url
  59423. * @param system Define the `lensFlareSystem` this flare is part of
  59424. */
  59425. constructor(
  59426. /**
  59427. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59428. */
  59429. size: number,
  59430. /**
  59431. * 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.
  59432. */
  59433. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59434. /**
  59435. * Dispose and release the lens flare with its associated resources.
  59436. */
  59437. dispose(): void;
  59438. }
  59439. }
  59440. declare module BABYLON {
  59441. interface AbstractScene {
  59442. /**
  59443. * The list of lens flare system added to the scene
  59444. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59445. */
  59446. lensFlareSystems: Array<LensFlareSystem>;
  59447. /**
  59448. * Removes the given lens flare system from this scene.
  59449. * @param toRemove The lens flare system to remove
  59450. * @returns The index of the removed lens flare system
  59451. */
  59452. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59453. /**
  59454. * Adds the given lens flare system to this scene
  59455. * @param newLensFlareSystem The lens flare system to add
  59456. */
  59457. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59458. /**
  59459. * Gets a lens flare system using its name
  59460. * @param name defines the name to look for
  59461. * @returns the lens flare system or null if not found
  59462. */
  59463. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59464. /**
  59465. * Gets a lens flare system using its id
  59466. * @param id defines the id to look for
  59467. * @returns the lens flare system or null if not found
  59468. */
  59469. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59470. }
  59471. /**
  59472. * Defines the lens flare scene component responsible to manage any lens flares
  59473. * in a given scene.
  59474. */
  59475. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59476. /**
  59477. * The component name helpfull to identify the component in the list of scene components.
  59478. */
  59479. readonly name: string;
  59480. /**
  59481. * The scene the component belongs to.
  59482. */
  59483. scene: Scene;
  59484. /**
  59485. * Creates a new instance of the component for the given scene
  59486. * @param scene Defines the scene to register the component in
  59487. */
  59488. constructor(scene: Scene);
  59489. /**
  59490. * Registers the component in a given scene
  59491. */
  59492. register(): void;
  59493. /**
  59494. * Rebuilds the elements related to this component in case of
  59495. * context lost for instance.
  59496. */
  59497. rebuild(): void;
  59498. /**
  59499. * Adds all the elements from the container to the scene
  59500. * @param container the container holding the elements
  59501. */
  59502. addFromContainer(container: AbstractScene): void;
  59503. /**
  59504. * Removes all the elements in the container from the scene
  59505. * @param container contains the elements to remove
  59506. * @param dispose if the removed element should be disposed (default: false)
  59507. */
  59508. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59509. /**
  59510. * Serializes the component data to the specified json object
  59511. * @param serializationObject The object to serialize to
  59512. */
  59513. serialize(serializationObject: any): void;
  59514. /**
  59515. * Disposes the component and the associated ressources.
  59516. */
  59517. dispose(): void;
  59518. private _draw;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /** @hidden */
  59523. export var depthPixelShader: {
  59524. name: string;
  59525. shader: string;
  59526. };
  59527. }
  59528. declare module BABYLON {
  59529. /** @hidden */
  59530. export var depthVertexShader: {
  59531. name: string;
  59532. shader: string;
  59533. };
  59534. }
  59535. declare module BABYLON {
  59536. /**
  59537. * This represents a depth renderer in Babylon.
  59538. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59539. */
  59540. export class DepthRenderer {
  59541. private _scene;
  59542. private _depthMap;
  59543. private _effect;
  59544. private readonly _storeNonLinearDepth;
  59545. private readonly _clearColor;
  59546. /** Get if the depth renderer is using packed depth or not */
  59547. readonly isPacked: boolean;
  59548. private _cachedDefines;
  59549. private _camera;
  59550. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59551. enabled: boolean;
  59552. /**
  59553. * Specifiess that the depth renderer will only be used within
  59554. * the camera it is created for.
  59555. * This can help forcing its rendering during the camera processing.
  59556. */
  59557. useOnlyInActiveCamera: boolean;
  59558. /** @hidden */
  59559. static _SceneComponentInitialization: (scene: Scene) => void;
  59560. /**
  59561. * Instantiates a depth renderer
  59562. * @param scene The scene the renderer belongs to
  59563. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59564. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59565. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59566. */
  59567. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59568. /**
  59569. * Creates the depth rendering effect and checks if the effect is ready.
  59570. * @param subMesh The submesh to be used to render the depth map of
  59571. * @param useInstances If multiple world instances should be used
  59572. * @returns if the depth renderer is ready to render the depth map
  59573. */
  59574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59575. /**
  59576. * Gets the texture which the depth map will be written to.
  59577. * @returns The depth map texture
  59578. */
  59579. getDepthMap(): RenderTargetTexture;
  59580. /**
  59581. * Disposes of the depth renderer.
  59582. */
  59583. dispose(): void;
  59584. }
  59585. }
  59586. declare module BABYLON {
  59587. /** @hidden */
  59588. export var minmaxReduxPixelShader: {
  59589. name: string;
  59590. shader: string;
  59591. };
  59592. }
  59593. declare module BABYLON {
  59594. /**
  59595. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59596. * and maximum values from all values of the texture.
  59597. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59598. * The source values are read from the red channel of the texture.
  59599. */
  59600. export class MinMaxReducer {
  59601. /**
  59602. * Observable triggered when the computation has been performed
  59603. */
  59604. onAfterReductionPerformed: Observable<{
  59605. min: number;
  59606. max: number;
  59607. }>;
  59608. protected _camera: Camera;
  59609. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59610. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59611. protected _postProcessManager: PostProcessManager;
  59612. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59613. protected _forceFullscreenViewport: boolean;
  59614. /**
  59615. * Creates a min/max reducer
  59616. * @param camera The camera to use for the post processes
  59617. */
  59618. constructor(camera: Camera);
  59619. /**
  59620. * Gets the texture used to read the values from.
  59621. */
  59622. get sourceTexture(): Nullable<RenderTargetTexture>;
  59623. /**
  59624. * Sets the source texture to read the values from.
  59625. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59626. * because in such textures '1' value must not be taken into account to compute the maximum
  59627. * as this value is used to clear the texture.
  59628. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59629. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59630. * @param depthRedux Indicates if the texture is a depth texture or not
  59631. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59632. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59633. */
  59634. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59635. /**
  59636. * Defines the refresh rate of the computation.
  59637. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59638. */
  59639. get refreshRate(): number;
  59640. set refreshRate(value: number);
  59641. protected _activated: boolean;
  59642. /**
  59643. * Gets the activation status of the reducer
  59644. */
  59645. get activated(): boolean;
  59646. /**
  59647. * Activates the reduction computation.
  59648. * When activated, the observers registered in onAfterReductionPerformed are
  59649. * called after the compuation is performed
  59650. */
  59651. activate(): void;
  59652. /**
  59653. * Deactivates the reduction computation.
  59654. */
  59655. deactivate(): void;
  59656. /**
  59657. * Disposes the min/max reducer
  59658. * @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.
  59659. */
  59660. dispose(disposeAll?: boolean): void;
  59661. }
  59662. }
  59663. declare module BABYLON {
  59664. /**
  59665. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59666. */
  59667. export class DepthReducer extends MinMaxReducer {
  59668. private _depthRenderer;
  59669. private _depthRendererId;
  59670. /**
  59671. * Gets the depth renderer used for the computation.
  59672. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59673. */
  59674. get depthRenderer(): Nullable<DepthRenderer>;
  59675. /**
  59676. * Creates a depth reducer
  59677. * @param camera The camera used to render the depth texture
  59678. */
  59679. constructor(camera: Camera);
  59680. /**
  59681. * Sets the depth renderer to use to generate the depth map
  59682. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59683. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59684. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59685. */
  59686. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59687. /** @hidden */
  59688. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59689. /**
  59690. * Activates the reduction computation.
  59691. * When activated, the observers registered in onAfterReductionPerformed are
  59692. * called after the compuation is performed
  59693. */
  59694. activate(): void;
  59695. /**
  59696. * Deactivates the reduction computation.
  59697. */
  59698. deactivate(): void;
  59699. /**
  59700. * Disposes the depth reducer
  59701. * @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.
  59702. */
  59703. dispose(disposeAll?: boolean): void;
  59704. }
  59705. }
  59706. declare module BABYLON {
  59707. /**
  59708. * A CSM implementation allowing casting shadows on large scenes.
  59709. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59710. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59711. */
  59712. export class CascadedShadowGenerator extends ShadowGenerator {
  59713. private static readonly frustumCornersNDCSpace;
  59714. /**
  59715. * Name of the CSM class
  59716. */
  59717. static CLASSNAME: string;
  59718. /**
  59719. * Defines the default number of cascades used by the CSM.
  59720. */
  59721. static readonly DEFAULT_CASCADES_COUNT: number;
  59722. /**
  59723. * Defines the minimum number of cascades used by the CSM.
  59724. */
  59725. static readonly MIN_CASCADES_COUNT: number;
  59726. /**
  59727. * Defines the maximum number of cascades used by the CSM.
  59728. */
  59729. static readonly MAX_CASCADES_COUNT: number;
  59730. protected _validateFilter(filter: number): number;
  59731. /**
  59732. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59733. */
  59734. penumbraDarkness: number;
  59735. private _numCascades;
  59736. /**
  59737. * Gets or set the number of cascades used by the CSM.
  59738. */
  59739. get numCascades(): number;
  59740. set numCascades(value: number);
  59741. /**
  59742. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59743. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59744. */
  59745. stabilizeCascades: boolean;
  59746. private _freezeShadowCastersBoundingInfo;
  59747. private _freezeShadowCastersBoundingInfoObservable;
  59748. /**
  59749. * Enables or disables the shadow casters bounding info computation.
  59750. * If your shadow casters don't move, you can disable this feature.
  59751. * If it is enabled, the bounding box computation is done every frame.
  59752. */
  59753. get freezeShadowCastersBoundingInfo(): boolean;
  59754. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59755. private _scbiMin;
  59756. private _scbiMax;
  59757. protected _computeShadowCastersBoundingInfo(): void;
  59758. protected _shadowCastersBoundingInfo: BoundingInfo;
  59759. /**
  59760. * Gets or sets the shadow casters bounding info.
  59761. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59762. * so that the system won't overwrite the bounds you provide
  59763. */
  59764. get shadowCastersBoundingInfo(): BoundingInfo;
  59765. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59766. protected _breaksAreDirty: boolean;
  59767. protected _minDistance: number;
  59768. protected _maxDistance: number;
  59769. /**
  59770. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59771. *
  59772. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59773. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59774. * @param min minimal distance for the breaks (default to 0.)
  59775. * @param max maximal distance for the breaks (default to 1.)
  59776. */
  59777. setMinMaxDistance(min: number, max: number): void;
  59778. /** Gets the minimal distance used in the cascade break computation */
  59779. get minDistance(): number;
  59780. /** Gets the maximal distance used in the cascade break computation */
  59781. get maxDistance(): number;
  59782. /**
  59783. * Gets the class name of that object
  59784. * @returns "CascadedShadowGenerator"
  59785. */
  59786. getClassName(): string;
  59787. private _cascadeMinExtents;
  59788. private _cascadeMaxExtents;
  59789. /**
  59790. * Gets a cascade minimum extents
  59791. * @param cascadeIndex index of the cascade
  59792. * @returns the minimum cascade extents
  59793. */
  59794. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59795. /**
  59796. * Gets a cascade maximum extents
  59797. * @param cascadeIndex index of the cascade
  59798. * @returns the maximum cascade extents
  59799. */
  59800. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59801. private _cascades;
  59802. private _currentLayer;
  59803. private _viewSpaceFrustumsZ;
  59804. private _viewMatrices;
  59805. private _projectionMatrices;
  59806. private _transformMatrices;
  59807. private _transformMatricesAsArray;
  59808. private _frustumLengths;
  59809. private _lightSizeUVCorrection;
  59810. private _depthCorrection;
  59811. private _frustumCornersWorldSpace;
  59812. private _frustumCenter;
  59813. private _shadowCameraPos;
  59814. private _shadowMaxZ;
  59815. /**
  59816. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59817. * It defaults to camera.maxZ
  59818. */
  59819. get shadowMaxZ(): number;
  59820. /**
  59821. * Sets the shadow max z distance.
  59822. */
  59823. set shadowMaxZ(value: number);
  59824. protected _debug: boolean;
  59825. /**
  59826. * Gets or sets the debug flag.
  59827. * When enabled, the cascades are materialized by different colors on the screen.
  59828. */
  59829. get debug(): boolean;
  59830. set debug(dbg: boolean);
  59831. private _depthClamp;
  59832. /**
  59833. * Gets or sets the depth clamping value.
  59834. *
  59835. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59836. * to account for the shadow casters far away.
  59837. *
  59838. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59839. */
  59840. get depthClamp(): boolean;
  59841. set depthClamp(value: boolean);
  59842. private _cascadeBlendPercentage;
  59843. /**
  59844. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59845. * It defaults to 0.1 (10% blending).
  59846. */
  59847. get cascadeBlendPercentage(): number;
  59848. set cascadeBlendPercentage(value: number);
  59849. private _lambda;
  59850. /**
  59851. * Gets or set the lambda parameter.
  59852. * This parameter is used to split the camera frustum and create the cascades.
  59853. * 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.
  59854. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59855. */
  59856. get lambda(): number;
  59857. set lambda(value: number);
  59858. /**
  59859. * Gets the view matrix corresponding to a given cascade
  59860. * @param cascadeNum cascade to retrieve the view matrix from
  59861. * @returns the cascade view matrix
  59862. */
  59863. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59864. /**
  59865. * Gets the projection matrix corresponding to a given cascade
  59866. * @param cascadeNum cascade to retrieve the projection matrix from
  59867. * @returns the cascade projection matrix
  59868. */
  59869. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59870. /**
  59871. * Gets the transformation matrix corresponding to a given cascade
  59872. * @param cascadeNum cascade to retrieve the transformation matrix from
  59873. * @returns the cascade transformation matrix
  59874. */
  59875. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59876. private _depthRenderer;
  59877. /**
  59878. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59879. *
  59880. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59881. *
  59882. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59883. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59884. * @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
  59885. */
  59886. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59887. private _depthReducer;
  59888. private _autoCalcDepthBounds;
  59889. /**
  59890. * Gets or sets the autoCalcDepthBounds property.
  59891. *
  59892. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59893. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59894. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59895. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59896. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59897. */
  59898. get autoCalcDepthBounds(): boolean;
  59899. set autoCalcDepthBounds(value: boolean);
  59900. /**
  59901. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59902. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59903. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59904. * for setting the refresh rate on the renderer yourself!
  59905. */
  59906. get autoCalcDepthBoundsRefreshRate(): number;
  59907. set autoCalcDepthBoundsRefreshRate(value: number);
  59908. /**
  59909. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59910. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59911. * you change the camera near/far planes!
  59912. */
  59913. splitFrustum(): void;
  59914. private _splitFrustum;
  59915. private _computeMatrices;
  59916. private _computeFrustumInWorldSpace;
  59917. private _computeCascadeFrustum;
  59918. /**
  59919. * Support test.
  59920. */
  59921. static get IsSupported(): boolean;
  59922. /** @hidden */
  59923. static _SceneComponentInitialization: (scene: Scene) => void;
  59924. /**
  59925. * Creates a Cascaded Shadow Generator object.
  59926. * A ShadowGenerator is the required tool to use the shadows.
  59927. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59928. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59929. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59930. * @param light The directional light object generating the shadows.
  59931. * @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.
  59932. */
  59933. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59934. protected _initializeGenerator(): void;
  59935. protected _createTargetRenderTexture(): void;
  59936. protected _initializeShadowMap(): void;
  59937. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59938. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59939. /**
  59940. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59941. * @param defines Defines of the material we want to update
  59942. * @param lightIndex Index of the light in the enabled light list of the material
  59943. */
  59944. prepareDefines(defines: any, lightIndex: number): void;
  59945. /**
  59946. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59947. * defined in the generator but impacting the effect).
  59948. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59949. * @param effect The effect we are binfing the information for
  59950. */
  59951. bindShadowLight(lightIndex: string, effect: Effect): void;
  59952. /**
  59953. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59954. * (eq to view projection * shadow projection matrices)
  59955. * @returns The transform matrix used to create the shadow map
  59956. */
  59957. getTransformMatrix(): Matrix;
  59958. /**
  59959. * Disposes the ShadowGenerator.
  59960. * Returns nothing.
  59961. */
  59962. dispose(): void;
  59963. /**
  59964. * Serializes the shadow generator setup to a json object.
  59965. * @returns The serialized JSON object
  59966. */
  59967. serialize(): any;
  59968. /**
  59969. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59970. * @param parsedShadowGenerator The JSON object to parse
  59971. * @param scene The scene to create the shadow map for
  59972. * @returns The parsed shadow generator
  59973. */
  59974. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59975. }
  59976. }
  59977. declare module BABYLON {
  59978. /**
  59979. * Defines the shadow generator component responsible to manage any shadow generators
  59980. * in a given scene.
  59981. */
  59982. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59983. /**
  59984. * The component name helpfull to identify the component in the list of scene components.
  59985. */
  59986. readonly name: string;
  59987. /**
  59988. * The scene the component belongs to.
  59989. */
  59990. scene: Scene;
  59991. /**
  59992. * Creates a new instance of the component for the given scene
  59993. * @param scene Defines the scene to register the component in
  59994. */
  59995. constructor(scene: Scene);
  59996. /**
  59997. * Registers the component in a given scene
  59998. */
  59999. register(): void;
  60000. /**
  60001. * Rebuilds the elements related to this component in case of
  60002. * context lost for instance.
  60003. */
  60004. rebuild(): void;
  60005. /**
  60006. * Serializes the component data to the specified json object
  60007. * @param serializationObject The object to serialize to
  60008. */
  60009. serialize(serializationObject: any): void;
  60010. /**
  60011. * Adds all the elements from the container to the scene
  60012. * @param container the container holding the elements
  60013. */
  60014. addFromContainer(container: AbstractScene): void;
  60015. /**
  60016. * Removes all the elements in the container from the scene
  60017. * @param container contains the elements to remove
  60018. * @param dispose if the removed element should be disposed (default: false)
  60019. */
  60020. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60021. /**
  60022. * Rebuilds the elements related to this component in case of
  60023. * context lost for instance.
  60024. */
  60025. dispose(): void;
  60026. private _gatherRenderTargets;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * A point light is a light defined by an unique point in world space.
  60032. * The light is emitted in every direction from this point.
  60033. * A good example of a point light is a standard light bulb.
  60034. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60035. */
  60036. export class PointLight extends ShadowLight {
  60037. private _shadowAngle;
  60038. /**
  60039. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60040. * This specifies what angle the shadow will use to be created.
  60041. *
  60042. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60043. */
  60044. get shadowAngle(): number;
  60045. /**
  60046. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60047. * This specifies what angle the shadow will use to be created.
  60048. *
  60049. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60050. */
  60051. set shadowAngle(value: number);
  60052. /**
  60053. * Gets the direction if it has been set.
  60054. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60055. */
  60056. get direction(): Vector3;
  60057. /**
  60058. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60059. */
  60060. set direction(value: Vector3);
  60061. /**
  60062. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60063. * A PointLight emits the light in every direction.
  60064. * It can cast shadows.
  60065. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60066. * ```javascript
  60067. * var pointLight = new PointLight("pl", camera.position, scene);
  60068. * ```
  60069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60070. * @param name The light friendly name
  60071. * @param position The position of the point light in the scene
  60072. * @param scene The scene the lights belongs to
  60073. */
  60074. constructor(name: string, position: Vector3, scene: Scene);
  60075. /**
  60076. * Returns the string "PointLight"
  60077. * @returns the class name
  60078. */
  60079. getClassName(): string;
  60080. /**
  60081. * Returns the integer 0.
  60082. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60083. */
  60084. getTypeID(): number;
  60085. /**
  60086. * Specifies wether or not the shadowmap should be a cube texture.
  60087. * @returns true if the shadowmap needs to be a cube texture.
  60088. */
  60089. needCube(): boolean;
  60090. /**
  60091. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60094. */
  60095. getShadowDirection(faceIndex?: number): Vector3;
  60096. /**
  60097. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60098. * - fov = PI / 2
  60099. * - aspect ratio : 1.0
  60100. * - z-near and far equal to the active camera minZ and maxZ.
  60101. * Returns the PointLight.
  60102. */
  60103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60104. protected _buildUniformLayout(): void;
  60105. /**
  60106. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60107. * @param effect The effect to update
  60108. * @param lightIndex The index of the light in the effect to update
  60109. * @returns The point light
  60110. */
  60111. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60112. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60113. /**
  60114. * Prepares the list of defines specific to the light type.
  60115. * @param defines the list of defines
  60116. * @param lightIndex defines the index of the light for the effect
  60117. */
  60118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60119. }
  60120. }
  60121. declare module BABYLON {
  60122. /**
  60123. * Header information of HDR texture files.
  60124. */
  60125. export interface HDRInfo {
  60126. /**
  60127. * The height of the texture in pixels.
  60128. */
  60129. height: number;
  60130. /**
  60131. * The width of the texture in pixels.
  60132. */
  60133. width: number;
  60134. /**
  60135. * The index of the beginning of the data in the binary file.
  60136. */
  60137. dataPosition: number;
  60138. }
  60139. /**
  60140. * This groups tools to convert HDR texture to native colors array.
  60141. */
  60142. export class HDRTools {
  60143. private static Ldexp;
  60144. private static Rgbe2float;
  60145. private static readStringLine;
  60146. /**
  60147. * Reads header information from an RGBE texture stored in a native array.
  60148. * More information on this format are available here:
  60149. * https://en.wikipedia.org/wiki/RGBE_image_format
  60150. *
  60151. * @param uint8array The binary file stored in native array.
  60152. * @return The header information.
  60153. */
  60154. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60155. /**
  60156. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60157. * This RGBE texture needs to store the information as a panorama.
  60158. *
  60159. * More information on this format are available here:
  60160. * https://en.wikipedia.org/wiki/RGBE_image_format
  60161. *
  60162. * @param buffer The binary file stored in an array buffer.
  60163. * @param size The expected size of the extracted cubemap.
  60164. * @return The Cube Map information.
  60165. */
  60166. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60167. /**
  60168. * Returns the pixels data extracted from an RGBE texture.
  60169. * This pixels will be stored left to right up to down in the R G B order in one array.
  60170. *
  60171. * More information on this format are available here:
  60172. * https://en.wikipedia.org/wiki/RGBE_image_format
  60173. *
  60174. * @param uint8array The binary file stored in an array buffer.
  60175. * @param hdrInfo The header information of the file.
  60176. * @return The pixels data in RGB right to left up to down order.
  60177. */
  60178. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60179. private static RGBE_ReadPixels_RLE;
  60180. private static RGBE_ReadPixels_NOT_RLE;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Effect Render Options
  60186. */
  60187. export interface IEffectRendererOptions {
  60188. /**
  60189. * Defines the vertices positions.
  60190. */
  60191. positions?: number[];
  60192. /**
  60193. * Defines the indices.
  60194. */
  60195. indices?: number[];
  60196. }
  60197. /**
  60198. * Helper class to render one or more effects.
  60199. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60200. */
  60201. export class EffectRenderer {
  60202. private engine;
  60203. private static _DefaultOptions;
  60204. private _vertexBuffers;
  60205. private _indexBuffer;
  60206. private _fullscreenViewport;
  60207. /**
  60208. * Creates an effect renderer
  60209. * @param engine the engine to use for rendering
  60210. * @param options defines the options of the effect renderer
  60211. */
  60212. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60213. /**
  60214. * Sets the current viewport in normalized coordinates 0-1
  60215. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60216. */
  60217. setViewport(viewport?: Viewport): void;
  60218. /**
  60219. * Binds the embedded attributes buffer to the effect.
  60220. * @param effect Defines the effect to bind the attributes for
  60221. */
  60222. bindBuffers(effect: Effect): void;
  60223. /**
  60224. * Sets the current effect wrapper to use during draw.
  60225. * The effect needs to be ready before calling this api.
  60226. * This also sets the default full screen position attribute.
  60227. * @param effectWrapper Defines the effect to draw with
  60228. */
  60229. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60230. /**
  60231. * Restores engine states
  60232. */
  60233. restoreStates(): void;
  60234. /**
  60235. * Draws a full screen quad.
  60236. */
  60237. draw(): void;
  60238. private isRenderTargetTexture;
  60239. /**
  60240. * renders one or more effects to a specified texture
  60241. * @param effectWrapper the effect to renderer
  60242. * @param outputTexture texture to draw to, if null it will render to the screen.
  60243. */
  60244. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60245. /**
  60246. * Disposes of the effect renderer
  60247. */
  60248. dispose(): void;
  60249. }
  60250. /**
  60251. * Options to create an EffectWrapper
  60252. */
  60253. interface EffectWrapperCreationOptions {
  60254. /**
  60255. * Engine to use to create the effect
  60256. */
  60257. engine: ThinEngine;
  60258. /**
  60259. * Fragment shader for the effect
  60260. */
  60261. fragmentShader: string;
  60262. /**
  60263. * Use the shader store instead of direct source code
  60264. */
  60265. useShaderStore?: boolean;
  60266. /**
  60267. * Vertex shader for the effect
  60268. */
  60269. vertexShader?: string;
  60270. /**
  60271. * Attributes to use in the shader
  60272. */
  60273. attributeNames?: Array<string>;
  60274. /**
  60275. * Uniforms to use in the shader
  60276. */
  60277. uniformNames?: Array<string>;
  60278. /**
  60279. * Texture sampler names to use in the shader
  60280. */
  60281. samplerNames?: Array<string>;
  60282. /**
  60283. * Defines to use in the shader
  60284. */
  60285. defines?: Array<string>;
  60286. /**
  60287. * Callback when effect is compiled
  60288. */
  60289. onCompiled?: Nullable<(effect: Effect) => void>;
  60290. /**
  60291. * The friendly name of the effect displayed in Spector.
  60292. */
  60293. name?: string;
  60294. }
  60295. /**
  60296. * Wraps an effect to be used for rendering
  60297. */
  60298. export class EffectWrapper {
  60299. /**
  60300. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60301. */
  60302. onApplyObservable: Observable<{}>;
  60303. /**
  60304. * The underlying effect
  60305. */
  60306. effect: Effect;
  60307. /**
  60308. * Creates an effect to be renderer
  60309. * @param creationOptions options to create the effect
  60310. */
  60311. constructor(creationOptions: EffectWrapperCreationOptions);
  60312. /**
  60313. * Disposes of the effect wrapper
  60314. */
  60315. dispose(): void;
  60316. }
  60317. }
  60318. declare module BABYLON {
  60319. /** @hidden */
  60320. export var hdrFilteringVertexShader: {
  60321. name: string;
  60322. shader: string;
  60323. };
  60324. }
  60325. declare module BABYLON {
  60326. /** @hidden */
  60327. export var hdrFilteringPixelShader: {
  60328. name: string;
  60329. shader: string;
  60330. };
  60331. }
  60332. declare module BABYLON {
  60333. /**
  60334. * Options for texture filtering
  60335. */
  60336. interface IHDRFilteringOptions {
  60337. /**
  60338. * Scales pixel intensity for the input HDR map.
  60339. */
  60340. hdrScale?: number;
  60341. /**
  60342. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60343. */
  60344. quality?: number;
  60345. }
  60346. /**
  60347. * Filters HDR maps to get correct renderings of PBR reflections
  60348. */
  60349. export class HDRFiltering {
  60350. private _engine;
  60351. private _effectRenderer;
  60352. private _effectWrapper;
  60353. private _lodGenerationOffset;
  60354. private _lodGenerationScale;
  60355. /**
  60356. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60357. * you care about baking speed.
  60358. */
  60359. quality: number;
  60360. /**
  60361. * Scales pixel intensity for the input HDR map.
  60362. */
  60363. hdrScale: number;
  60364. /**
  60365. * Instantiates HDR filter for reflection maps
  60366. *
  60367. * @param engine Thin engine
  60368. * @param options Options
  60369. */
  60370. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60371. private _createRenderTarget;
  60372. private _prefilterInternal;
  60373. private _createEffect;
  60374. /**
  60375. * Get a value indicating if the filter is ready to be used
  60376. * @param texture Texture to filter
  60377. * @returns true if the filter is ready
  60378. */
  60379. isReady(texture: BaseTexture): boolean;
  60380. /**
  60381. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60382. * Prefiltering will be invoked at the end of next rendering pass.
  60383. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60384. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60385. * @param texture Texture to filter
  60386. * @param onFinished Callback when filtering is done
  60387. * @return Promise called when prefiltering is done
  60388. */
  60389. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60390. }
  60391. }
  60392. declare module BABYLON {
  60393. /**
  60394. * This represents a texture coming from an HDR input.
  60395. *
  60396. * The only supported format is currently panorama picture stored in RGBE format.
  60397. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60398. */
  60399. export class HDRCubeTexture extends BaseTexture {
  60400. private static _facesMapping;
  60401. private _generateHarmonics;
  60402. private _noMipmap;
  60403. private _prefilterOnLoad;
  60404. private _textureMatrix;
  60405. private _size;
  60406. private _onLoad;
  60407. private _onError;
  60408. /**
  60409. * The texture URL.
  60410. */
  60411. url: string;
  60412. protected _isBlocking: boolean;
  60413. /**
  60414. * Sets wether or not the texture is blocking during loading.
  60415. */
  60416. set isBlocking(value: boolean);
  60417. /**
  60418. * Gets wether or not the texture is blocking during loading.
  60419. */
  60420. get isBlocking(): boolean;
  60421. protected _rotationY: number;
  60422. /**
  60423. * Sets texture matrix rotation angle around Y axis in radians.
  60424. */
  60425. set rotationY(value: number);
  60426. /**
  60427. * Gets texture matrix rotation angle around Y axis radians.
  60428. */
  60429. get rotationY(): number;
  60430. /**
  60431. * Gets or sets the center of the bounding box associated with the cube texture
  60432. * It must define where the camera used to render the texture was set
  60433. */
  60434. boundingBoxPosition: Vector3;
  60435. private _boundingBoxSize;
  60436. /**
  60437. * Gets or sets the size of the bounding box associated with the cube texture
  60438. * When defined, the cubemap will switch to local mode
  60439. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60440. * @example https://www.babylonjs-playground.com/#RNASML
  60441. */
  60442. set boundingBoxSize(value: Vector3);
  60443. get boundingBoxSize(): Vector3;
  60444. /**
  60445. * Instantiates an HDRTexture from the following parameters.
  60446. *
  60447. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60448. * @param sceneOrEngine The scene or engine the texture will be used in
  60449. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60450. * @param noMipmap Forces to not generate the mipmap if true
  60451. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60452. * @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)
  60453. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60454. */
  60455. 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>);
  60456. /**
  60457. * Get the current class name of the texture useful for serialization or dynamic coding.
  60458. * @returns "HDRCubeTexture"
  60459. */
  60460. getClassName(): string;
  60461. /**
  60462. * Occurs when the file is raw .hdr file.
  60463. */
  60464. private loadTexture;
  60465. clone(): HDRCubeTexture;
  60466. delayLoad(): void;
  60467. /**
  60468. * Get the texture reflection matrix used to rotate/transform the reflection.
  60469. * @returns the reflection matrix
  60470. */
  60471. getReflectionTextureMatrix(): Matrix;
  60472. /**
  60473. * Set the texture reflection matrix used to rotate/transform the reflection.
  60474. * @param value Define the reflection matrix to set
  60475. */
  60476. setReflectionTextureMatrix(value: Matrix): void;
  60477. /**
  60478. * Parses a JSON representation of an HDR Texture in order to create the texture
  60479. * @param parsedTexture Define the JSON representation
  60480. * @param scene Define the scene the texture should be created in
  60481. * @param rootUrl Define the root url in case we need to load relative dependencies
  60482. * @returns the newly created texture after parsing
  60483. */
  60484. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60485. serialize(): any;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * Class used to control physics engine
  60491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60492. */
  60493. export class PhysicsEngine implements IPhysicsEngine {
  60494. private _physicsPlugin;
  60495. /**
  60496. * Global value used to control the smallest number supported by the simulation
  60497. */
  60498. static Epsilon: number;
  60499. private _impostors;
  60500. private _joints;
  60501. private _subTimeStep;
  60502. /**
  60503. * Gets the gravity vector used by the simulation
  60504. */
  60505. gravity: Vector3;
  60506. /**
  60507. * Factory used to create the default physics plugin.
  60508. * @returns The default physics plugin
  60509. */
  60510. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60511. /**
  60512. * Creates a new Physics Engine
  60513. * @param gravity defines the gravity vector used by the simulation
  60514. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60515. */
  60516. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60517. /**
  60518. * Sets the gravity vector used by the simulation
  60519. * @param gravity defines the gravity vector to use
  60520. */
  60521. setGravity(gravity: Vector3): void;
  60522. /**
  60523. * Set the time step of the physics engine.
  60524. * Default is 1/60.
  60525. * To slow it down, enter 1/600 for example.
  60526. * To speed it up, 1/30
  60527. * @param newTimeStep defines the new timestep to apply to this world.
  60528. */
  60529. setTimeStep(newTimeStep?: number): void;
  60530. /**
  60531. * Get the time step of the physics engine.
  60532. * @returns the current time step
  60533. */
  60534. getTimeStep(): number;
  60535. /**
  60536. * Set the sub time step of the physics engine.
  60537. * Default is 0 meaning there is no sub steps
  60538. * To increase physics resolution precision, set a small value (like 1 ms)
  60539. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60540. */
  60541. setSubTimeStep(subTimeStep?: number): void;
  60542. /**
  60543. * Get the sub time step of the physics engine.
  60544. * @returns the current sub time step
  60545. */
  60546. getSubTimeStep(): number;
  60547. /**
  60548. * Release all resources
  60549. */
  60550. dispose(): void;
  60551. /**
  60552. * Gets the name of the current physics plugin
  60553. * @returns the name of the plugin
  60554. */
  60555. getPhysicsPluginName(): string;
  60556. /**
  60557. * Adding a new impostor for the impostor tracking.
  60558. * This will be done by the impostor itself.
  60559. * @param impostor the impostor to add
  60560. */
  60561. addImpostor(impostor: PhysicsImpostor): void;
  60562. /**
  60563. * Remove an impostor from the engine.
  60564. * This impostor and its mesh will not longer be updated by the physics engine.
  60565. * @param impostor the impostor to remove
  60566. */
  60567. removeImpostor(impostor: PhysicsImpostor): void;
  60568. /**
  60569. * Add a joint to the physics engine
  60570. * @param mainImpostor defines the main impostor to which the joint is added.
  60571. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60572. * @param joint defines the joint that will connect both impostors.
  60573. */
  60574. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60575. /**
  60576. * Removes a joint from the simulation
  60577. * @param mainImpostor defines the impostor used with the joint
  60578. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60579. * @param joint defines the joint to remove
  60580. */
  60581. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60582. /**
  60583. * Called by the scene. No need to call it.
  60584. * @param delta defines the timespam between frames
  60585. */
  60586. _step(delta: number): void;
  60587. /**
  60588. * Gets the current plugin used to run the simulation
  60589. * @returns current plugin
  60590. */
  60591. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60592. /**
  60593. * Gets the list of physic impostors
  60594. * @returns an array of PhysicsImpostor
  60595. */
  60596. getImpostors(): Array<PhysicsImpostor>;
  60597. /**
  60598. * Gets the impostor for a physics enabled object
  60599. * @param object defines the object impersonated by the impostor
  60600. * @returns the PhysicsImpostor or null if not found
  60601. */
  60602. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60603. /**
  60604. * Gets the impostor for a physics body object
  60605. * @param body defines physics body used by the impostor
  60606. * @returns the PhysicsImpostor or null if not found
  60607. */
  60608. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60609. /**
  60610. * Does a raycast in the physics world
  60611. * @param from when should the ray start?
  60612. * @param to when should the ray end?
  60613. * @returns PhysicsRaycastResult
  60614. */
  60615. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60616. }
  60617. }
  60618. declare module BABYLON {
  60619. /** @hidden */
  60620. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60621. private _useDeltaForWorldStep;
  60622. world: any;
  60623. name: string;
  60624. private _physicsMaterials;
  60625. private _fixedTimeStep;
  60626. private _cannonRaycastResult;
  60627. private _raycastResult;
  60628. private _physicsBodysToRemoveAfterStep;
  60629. private _firstFrame;
  60630. BJSCANNON: any;
  60631. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60632. setGravity(gravity: Vector3): void;
  60633. setTimeStep(timeStep: number): void;
  60634. getTimeStep(): number;
  60635. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60636. private _removeMarkedPhysicsBodiesFromWorld;
  60637. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60638. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60639. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60640. private _processChildMeshes;
  60641. removePhysicsBody(impostor: PhysicsImpostor): void;
  60642. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60643. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60644. private _addMaterial;
  60645. private _checkWithEpsilon;
  60646. private _createShape;
  60647. private _createHeightmap;
  60648. private _minus90X;
  60649. private _plus90X;
  60650. private _tmpPosition;
  60651. private _tmpDeltaPosition;
  60652. private _tmpUnityRotation;
  60653. private _updatePhysicsBodyTransformation;
  60654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60656. isSupported(): boolean;
  60657. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60659. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60662. getBodyMass(impostor: PhysicsImpostor): number;
  60663. getBodyFriction(impostor: PhysicsImpostor): number;
  60664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60665. getBodyRestitution(impostor: PhysicsImpostor): number;
  60666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60667. sleepBody(impostor: PhysicsImpostor): void;
  60668. wakeUpBody(impostor: PhysicsImpostor): void;
  60669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60670. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60671. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60672. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60673. getRadius(impostor: PhysicsImpostor): number;
  60674. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60675. dispose(): void;
  60676. private _extendNamespace;
  60677. /**
  60678. * Does a raycast in the physics world
  60679. * @param from when should the ray start?
  60680. * @param to when should the ray end?
  60681. * @returns PhysicsRaycastResult
  60682. */
  60683. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60684. }
  60685. }
  60686. declare module BABYLON {
  60687. /** @hidden */
  60688. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60689. private _useDeltaForWorldStep;
  60690. world: any;
  60691. name: string;
  60692. BJSOIMO: any;
  60693. private _raycastResult;
  60694. private _fixedTimeStep;
  60695. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60696. setGravity(gravity: Vector3): void;
  60697. setTimeStep(timeStep: number): void;
  60698. getTimeStep(): number;
  60699. private _tmpImpostorsArray;
  60700. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60701. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60702. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60703. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60704. private _tmpPositionVector;
  60705. removePhysicsBody(impostor: PhysicsImpostor): void;
  60706. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60707. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60708. isSupported(): boolean;
  60709. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60710. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60711. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60712. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60713. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60714. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60715. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60716. getBodyMass(impostor: PhysicsImpostor): number;
  60717. getBodyFriction(impostor: PhysicsImpostor): number;
  60718. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60719. getBodyRestitution(impostor: PhysicsImpostor): number;
  60720. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60721. sleepBody(impostor: PhysicsImpostor): void;
  60722. wakeUpBody(impostor: PhysicsImpostor): void;
  60723. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60724. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60725. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60726. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60727. getRadius(impostor: PhysicsImpostor): number;
  60728. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60729. dispose(): void;
  60730. /**
  60731. * Does a raycast in the physics world
  60732. * @param from when should the ray start?
  60733. * @param to when should the ray end?
  60734. * @returns PhysicsRaycastResult
  60735. */
  60736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60737. }
  60738. }
  60739. declare module BABYLON {
  60740. /**
  60741. * AmmoJS Physics plugin
  60742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60743. * @see https://github.com/kripken/ammo.js/
  60744. */
  60745. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60746. private _useDeltaForWorldStep;
  60747. /**
  60748. * Reference to the Ammo library
  60749. */
  60750. bjsAMMO: any;
  60751. /**
  60752. * Created ammoJS world which physics bodies are added to
  60753. */
  60754. world: any;
  60755. /**
  60756. * Name of the plugin
  60757. */
  60758. name: string;
  60759. private _timeStep;
  60760. private _fixedTimeStep;
  60761. private _maxSteps;
  60762. private _tmpQuaternion;
  60763. private _tmpAmmoTransform;
  60764. private _tmpAmmoQuaternion;
  60765. private _tmpAmmoConcreteContactResultCallback;
  60766. private _collisionConfiguration;
  60767. private _dispatcher;
  60768. private _overlappingPairCache;
  60769. private _solver;
  60770. private _softBodySolver;
  60771. private _tmpAmmoVectorA;
  60772. private _tmpAmmoVectorB;
  60773. private _tmpAmmoVectorC;
  60774. private _tmpAmmoVectorD;
  60775. private _tmpContactCallbackResult;
  60776. private _tmpAmmoVectorRCA;
  60777. private _tmpAmmoVectorRCB;
  60778. private _raycastResult;
  60779. private static readonly DISABLE_COLLISION_FLAG;
  60780. private static readonly KINEMATIC_FLAG;
  60781. private static readonly DISABLE_DEACTIVATION_FLAG;
  60782. /**
  60783. * Initializes the ammoJS plugin
  60784. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60785. * @param ammoInjection can be used to inject your own ammo reference
  60786. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60787. */
  60788. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60789. /**
  60790. * Sets the gravity of the physics world (m/(s^2))
  60791. * @param gravity Gravity to set
  60792. */
  60793. setGravity(gravity: Vector3): void;
  60794. /**
  60795. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60796. * @param timeStep timestep to use in seconds
  60797. */
  60798. setTimeStep(timeStep: number): void;
  60799. /**
  60800. * 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)
  60801. * @param fixedTimeStep fixedTimeStep to use in seconds
  60802. */
  60803. setFixedTimeStep(fixedTimeStep: number): void;
  60804. /**
  60805. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60806. * @param maxSteps the maximum number of steps by the physics engine per frame
  60807. */
  60808. setMaxSteps(maxSteps: number): void;
  60809. /**
  60810. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60811. * @returns the current timestep in seconds
  60812. */
  60813. getTimeStep(): number;
  60814. /**
  60815. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60816. */
  60817. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60818. private _isImpostorInContact;
  60819. private _isImpostorPairInContact;
  60820. private _stepSimulation;
  60821. /**
  60822. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60823. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60824. * After the step the babylon meshes are set to the position of the physics imposters
  60825. * @param delta amount of time to step forward
  60826. * @param impostors array of imposters to update before/after the step
  60827. */
  60828. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60829. /**
  60830. * Update babylon mesh to match physics world object
  60831. * @param impostor imposter to match
  60832. */
  60833. private _afterSoftStep;
  60834. /**
  60835. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60836. * @param impostor imposter to match
  60837. */
  60838. private _ropeStep;
  60839. /**
  60840. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60841. * @param impostor imposter to match
  60842. */
  60843. private _softbodyOrClothStep;
  60844. private _tmpMatrix;
  60845. /**
  60846. * Applies an impulse on the imposter
  60847. * @param impostor imposter to apply impulse to
  60848. * @param force amount of force to be applied to the imposter
  60849. * @param contactPoint the location to apply the impulse on the imposter
  60850. */
  60851. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60852. /**
  60853. * Applies a force on the imposter
  60854. * @param impostor imposter to apply force
  60855. * @param force amount of force to be applied to the imposter
  60856. * @param contactPoint the location to apply the force on the imposter
  60857. */
  60858. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60859. /**
  60860. * Creates a physics body using the plugin
  60861. * @param impostor the imposter to create the physics body on
  60862. */
  60863. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60864. /**
  60865. * Removes the physics body from the imposter and disposes of the body's memory
  60866. * @param impostor imposter to remove the physics body from
  60867. */
  60868. removePhysicsBody(impostor: PhysicsImpostor): void;
  60869. /**
  60870. * Generates a joint
  60871. * @param impostorJoint the imposter joint to create the joint with
  60872. */
  60873. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60874. /**
  60875. * Removes a joint
  60876. * @param impostorJoint the imposter joint to remove the joint from
  60877. */
  60878. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60879. private _addMeshVerts;
  60880. /**
  60881. * Initialise the soft body vertices to match its object's (mesh) vertices
  60882. * Softbody vertices (nodes) are in world space and to match this
  60883. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60884. * @param impostor to create the softbody for
  60885. */
  60886. private _softVertexData;
  60887. /**
  60888. * Create an impostor's soft body
  60889. * @param impostor to create the softbody for
  60890. */
  60891. private _createSoftbody;
  60892. /**
  60893. * Create cloth for an impostor
  60894. * @param impostor to create the softbody for
  60895. */
  60896. private _createCloth;
  60897. /**
  60898. * Create rope for an impostor
  60899. * @param impostor to create the softbody for
  60900. */
  60901. private _createRope;
  60902. /**
  60903. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60904. * @param impostor to create the custom physics shape for
  60905. */
  60906. private _createCustom;
  60907. private _addHullVerts;
  60908. private _createShape;
  60909. /**
  60910. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60911. * @param impostor imposter containing the physics body and babylon object
  60912. */
  60913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60914. /**
  60915. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60916. * @param impostor imposter containing the physics body and babylon object
  60917. * @param newPosition new position
  60918. * @param newRotation new rotation
  60919. */
  60920. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60921. /**
  60922. * If this plugin is supported
  60923. * @returns true if its supported
  60924. */
  60925. isSupported(): boolean;
  60926. /**
  60927. * Sets the linear velocity of the physics body
  60928. * @param impostor imposter to set the velocity on
  60929. * @param velocity velocity to set
  60930. */
  60931. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60932. /**
  60933. * Sets the angular velocity of the physics body
  60934. * @param impostor imposter to set the velocity on
  60935. * @param velocity velocity to set
  60936. */
  60937. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60938. /**
  60939. * gets the linear velocity
  60940. * @param impostor imposter to get linear velocity from
  60941. * @returns linear velocity
  60942. */
  60943. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60944. /**
  60945. * gets the angular velocity
  60946. * @param impostor imposter to get angular velocity from
  60947. * @returns angular velocity
  60948. */
  60949. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60950. /**
  60951. * Sets the mass of physics body
  60952. * @param impostor imposter to set the mass on
  60953. * @param mass mass to set
  60954. */
  60955. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60956. /**
  60957. * Gets the mass of the physics body
  60958. * @param impostor imposter to get the mass from
  60959. * @returns mass
  60960. */
  60961. getBodyMass(impostor: PhysicsImpostor): number;
  60962. /**
  60963. * Gets friction of the impostor
  60964. * @param impostor impostor to get friction from
  60965. * @returns friction value
  60966. */
  60967. getBodyFriction(impostor: PhysicsImpostor): number;
  60968. /**
  60969. * Sets friction of the impostor
  60970. * @param impostor impostor to set friction on
  60971. * @param friction friction value
  60972. */
  60973. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60974. /**
  60975. * Gets restitution of the impostor
  60976. * @param impostor impostor to get restitution from
  60977. * @returns restitution value
  60978. */
  60979. getBodyRestitution(impostor: PhysicsImpostor): number;
  60980. /**
  60981. * Sets resitution of the impostor
  60982. * @param impostor impostor to set resitution on
  60983. * @param restitution resitution value
  60984. */
  60985. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60986. /**
  60987. * Gets pressure inside the impostor
  60988. * @param impostor impostor to get pressure from
  60989. * @returns pressure value
  60990. */
  60991. getBodyPressure(impostor: PhysicsImpostor): number;
  60992. /**
  60993. * Sets pressure inside a soft body impostor
  60994. * Cloth and rope must remain 0 pressure
  60995. * @param impostor impostor to set pressure on
  60996. * @param pressure pressure value
  60997. */
  60998. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60999. /**
  61000. * Gets stiffness of the impostor
  61001. * @param impostor impostor to get stiffness from
  61002. * @returns pressure value
  61003. */
  61004. getBodyStiffness(impostor: PhysicsImpostor): number;
  61005. /**
  61006. * Sets stiffness of the impostor
  61007. * @param impostor impostor to set stiffness on
  61008. * @param stiffness stiffness value from 0 to 1
  61009. */
  61010. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61011. /**
  61012. * Gets velocityIterations of the impostor
  61013. * @param impostor impostor to get velocity iterations from
  61014. * @returns velocityIterations value
  61015. */
  61016. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61017. /**
  61018. * Sets velocityIterations of the impostor
  61019. * @param impostor impostor to set velocity iterations on
  61020. * @param velocityIterations velocityIterations value
  61021. */
  61022. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61023. /**
  61024. * Gets positionIterations of the impostor
  61025. * @param impostor impostor to get position iterations from
  61026. * @returns positionIterations value
  61027. */
  61028. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61029. /**
  61030. * Sets positionIterations of the impostor
  61031. * @param impostor impostor to set position on
  61032. * @param positionIterations positionIterations value
  61033. */
  61034. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61035. /**
  61036. * Append an anchor to a cloth object
  61037. * @param impostor is the cloth impostor to add anchor to
  61038. * @param otherImpostor is the rigid impostor to anchor to
  61039. * @param width ratio across width from 0 to 1
  61040. * @param height ratio up height from 0 to 1
  61041. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61042. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61043. */
  61044. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61045. /**
  61046. * Append an hook to a rope object
  61047. * @param impostor is the rope impostor to add hook to
  61048. * @param otherImpostor is the rigid impostor to hook to
  61049. * @param length ratio along the rope from 0 to 1
  61050. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61051. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61052. */
  61053. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61054. /**
  61055. * Sleeps the physics body and stops it from being active
  61056. * @param impostor impostor to sleep
  61057. */
  61058. sleepBody(impostor: PhysicsImpostor): void;
  61059. /**
  61060. * Activates the physics body
  61061. * @param impostor impostor to activate
  61062. */
  61063. wakeUpBody(impostor: PhysicsImpostor): void;
  61064. /**
  61065. * Updates the distance parameters of the joint
  61066. * @param joint joint to update
  61067. * @param maxDistance maximum distance of the joint
  61068. * @param minDistance minimum distance of the joint
  61069. */
  61070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61071. /**
  61072. * Sets a motor on the joint
  61073. * @param joint joint to set motor on
  61074. * @param speed speed of the motor
  61075. * @param maxForce maximum force of the motor
  61076. * @param motorIndex index of the motor
  61077. */
  61078. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61079. /**
  61080. * Sets the motors limit
  61081. * @param joint joint to set limit on
  61082. * @param upperLimit upper limit
  61083. * @param lowerLimit lower limit
  61084. */
  61085. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61086. /**
  61087. * Syncs the position and rotation of a mesh with the impostor
  61088. * @param mesh mesh to sync
  61089. * @param impostor impostor to update the mesh with
  61090. */
  61091. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61092. /**
  61093. * Gets the radius of the impostor
  61094. * @param impostor impostor to get radius from
  61095. * @returns the radius
  61096. */
  61097. getRadius(impostor: PhysicsImpostor): number;
  61098. /**
  61099. * Gets the box size of the impostor
  61100. * @param impostor impostor to get box size from
  61101. * @param result the resulting box size
  61102. */
  61103. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61104. /**
  61105. * Disposes of the impostor
  61106. */
  61107. dispose(): void;
  61108. /**
  61109. * Does a raycast in the physics world
  61110. * @param from when should the ray start?
  61111. * @param to when should the ray end?
  61112. * @returns PhysicsRaycastResult
  61113. */
  61114. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61115. }
  61116. }
  61117. declare module BABYLON {
  61118. interface AbstractScene {
  61119. /**
  61120. * The list of reflection probes added to the scene
  61121. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61122. */
  61123. reflectionProbes: Array<ReflectionProbe>;
  61124. /**
  61125. * Removes the given reflection probe from this scene.
  61126. * @param toRemove The reflection probe to remove
  61127. * @returns The index of the removed reflection probe
  61128. */
  61129. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61130. /**
  61131. * Adds the given reflection probe to this scene.
  61132. * @param newReflectionProbe The reflection probe to add
  61133. */
  61134. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61135. }
  61136. /**
  61137. * Class used to generate realtime reflection / refraction cube textures
  61138. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61139. */
  61140. export class ReflectionProbe {
  61141. /** defines the name of the probe */
  61142. name: string;
  61143. private _scene;
  61144. private _renderTargetTexture;
  61145. private _projectionMatrix;
  61146. private _viewMatrix;
  61147. private _target;
  61148. private _add;
  61149. private _attachedMesh;
  61150. private _invertYAxis;
  61151. /** Gets or sets probe position (center of the cube map) */
  61152. position: Vector3;
  61153. /**
  61154. * Creates a new reflection probe
  61155. * @param name defines the name of the probe
  61156. * @param size defines the texture resolution (for each face)
  61157. * @param scene defines the hosting scene
  61158. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61159. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61160. */
  61161. constructor(
  61162. /** defines the name of the probe */
  61163. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61164. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61165. get samples(): number;
  61166. set samples(value: number);
  61167. /** Gets or sets the refresh rate to use (on every frame by default) */
  61168. get refreshRate(): number;
  61169. set refreshRate(value: number);
  61170. /**
  61171. * Gets the hosting scene
  61172. * @returns a Scene
  61173. */
  61174. getScene(): Scene;
  61175. /** Gets the internal CubeTexture used to render to */
  61176. get cubeTexture(): RenderTargetTexture;
  61177. /** Gets the list of meshes to render */
  61178. get renderList(): Nullable<AbstractMesh[]>;
  61179. /**
  61180. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61181. * @param mesh defines the mesh to attach to
  61182. */
  61183. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61184. /**
  61185. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61186. * @param renderingGroupId The rendering group id corresponding to its index
  61187. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61188. */
  61189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61190. /**
  61191. * Clean all associated resources
  61192. */
  61193. dispose(): void;
  61194. /**
  61195. * Converts the reflection probe information to a readable string for debug purpose.
  61196. * @param fullDetails Supports for multiple levels of logging within scene loading
  61197. * @returns the human readable reflection probe info
  61198. */
  61199. toString(fullDetails?: boolean): string;
  61200. /**
  61201. * Get the class name of the relfection probe.
  61202. * @returns "ReflectionProbe"
  61203. */
  61204. getClassName(): string;
  61205. /**
  61206. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61207. * @returns The JSON representation of the texture
  61208. */
  61209. serialize(): any;
  61210. /**
  61211. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61212. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61213. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61214. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61215. * @returns The parsed reflection probe if successful
  61216. */
  61217. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61218. }
  61219. }
  61220. declare module BABYLON {
  61221. /** @hidden */
  61222. export var _BabylonLoaderRegistered: boolean;
  61223. /**
  61224. * Helps setting up some configuration for the babylon file loader.
  61225. */
  61226. export class BabylonFileLoaderConfiguration {
  61227. /**
  61228. * The loader does not allow injecting custom physix engine into the plugins.
  61229. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61230. * So you could set this variable to your engine import to make it work.
  61231. */
  61232. static LoaderInjectedPhysicsEngine: any;
  61233. }
  61234. }
  61235. declare module BABYLON {
  61236. /**
  61237. * The Physically based simple base material of BJS.
  61238. *
  61239. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61240. * It is used as the base class for both the specGloss and metalRough conventions.
  61241. */
  61242. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61243. /**
  61244. * Number of Simultaneous lights allowed on the material.
  61245. */
  61246. maxSimultaneousLights: number;
  61247. /**
  61248. * If sets to true, disables all the lights affecting the material.
  61249. */
  61250. disableLighting: boolean;
  61251. /**
  61252. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61253. */
  61254. environmentTexture: BaseTexture;
  61255. /**
  61256. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61257. */
  61258. invertNormalMapX: boolean;
  61259. /**
  61260. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61261. */
  61262. invertNormalMapY: boolean;
  61263. /**
  61264. * Normal map used in the model.
  61265. */
  61266. normalTexture: BaseTexture;
  61267. /**
  61268. * Emissivie color used to self-illuminate the model.
  61269. */
  61270. emissiveColor: Color3;
  61271. /**
  61272. * Emissivie texture used to self-illuminate the model.
  61273. */
  61274. emissiveTexture: BaseTexture;
  61275. /**
  61276. * Occlusion Channel Strenght.
  61277. */
  61278. occlusionStrength: number;
  61279. /**
  61280. * Occlusion Texture of the material (adding extra occlusion effects).
  61281. */
  61282. occlusionTexture: BaseTexture;
  61283. /**
  61284. * Defines the alpha limits in alpha test mode.
  61285. */
  61286. alphaCutOff: number;
  61287. /**
  61288. * Gets the current double sided mode.
  61289. */
  61290. get doubleSided(): boolean;
  61291. /**
  61292. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61293. */
  61294. set doubleSided(value: boolean);
  61295. /**
  61296. * Stores the pre-calculated light information of a mesh in a texture.
  61297. */
  61298. lightmapTexture: BaseTexture;
  61299. /**
  61300. * If true, the light map contains occlusion information instead of lighting info.
  61301. */
  61302. useLightmapAsShadowmap: boolean;
  61303. /**
  61304. * Instantiates a new PBRMaterial instance.
  61305. *
  61306. * @param name The material name
  61307. * @param scene The scene the material will be use in.
  61308. */
  61309. constructor(name: string, scene: Scene);
  61310. getClassName(): string;
  61311. }
  61312. }
  61313. declare module BABYLON {
  61314. /**
  61315. * The PBR material of BJS following the metal roughness convention.
  61316. *
  61317. * This fits to the PBR convention in the GLTF definition:
  61318. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61319. */
  61320. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61321. /**
  61322. * The base color has two different interpretations depending on the value of metalness.
  61323. * When the material is a metal, the base color is the specific measured reflectance value
  61324. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61325. * of the material.
  61326. */
  61327. baseColor: Color3;
  61328. /**
  61329. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61330. * well as opacity information in the alpha channel.
  61331. */
  61332. baseTexture: BaseTexture;
  61333. /**
  61334. * Specifies the metallic scalar value of the material.
  61335. * Can also be used to scale the metalness values of the metallic texture.
  61336. */
  61337. metallic: number;
  61338. /**
  61339. * Specifies the roughness scalar value of the material.
  61340. * Can also be used to scale the roughness values of the metallic texture.
  61341. */
  61342. roughness: number;
  61343. /**
  61344. * Texture containing both the metallic value in the B channel and the
  61345. * roughness value in the G channel to keep better precision.
  61346. */
  61347. metallicRoughnessTexture: BaseTexture;
  61348. /**
  61349. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61350. *
  61351. * @param name The material name
  61352. * @param scene The scene the material will be use in.
  61353. */
  61354. constructor(name: string, scene: Scene);
  61355. /**
  61356. * Return the currrent class name of the material.
  61357. */
  61358. getClassName(): string;
  61359. /**
  61360. * Makes a duplicate of the current material.
  61361. * @param name - name to use for the new material.
  61362. */
  61363. clone(name: string): PBRMetallicRoughnessMaterial;
  61364. /**
  61365. * Serialize the material to a parsable JSON object.
  61366. */
  61367. serialize(): any;
  61368. /**
  61369. * Parses a JSON object correponding to the serialize function.
  61370. */
  61371. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61372. }
  61373. }
  61374. declare module BABYLON {
  61375. /**
  61376. * The PBR material of BJS following the specular glossiness convention.
  61377. *
  61378. * This fits to the PBR convention in the GLTF definition:
  61379. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61380. */
  61381. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61382. /**
  61383. * Specifies the diffuse color of the material.
  61384. */
  61385. diffuseColor: Color3;
  61386. /**
  61387. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61388. * channel.
  61389. */
  61390. diffuseTexture: BaseTexture;
  61391. /**
  61392. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61393. */
  61394. specularColor: Color3;
  61395. /**
  61396. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61397. */
  61398. glossiness: number;
  61399. /**
  61400. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61401. */
  61402. specularGlossinessTexture: BaseTexture;
  61403. /**
  61404. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61405. *
  61406. * @param name The material name
  61407. * @param scene The scene the material will be use in.
  61408. */
  61409. constructor(name: string, scene: Scene);
  61410. /**
  61411. * Return the currrent class name of the material.
  61412. */
  61413. getClassName(): string;
  61414. /**
  61415. * Makes a duplicate of the current material.
  61416. * @param name - name to use for the new material.
  61417. */
  61418. clone(name: string): PBRSpecularGlossinessMaterial;
  61419. /**
  61420. * Serialize the material to a parsable JSON object.
  61421. */
  61422. serialize(): any;
  61423. /**
  61424. * Parses a JSON object correponding to the serialize function.
  61425. */
  61426. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61427. }
  61428. }
  61429. declare module BABYLON {
  61430. /**
  61431. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61432. * It can help converting any input color in a desired output one. This can then be used to create effects
  61433. * from sepia, black and white to sixties or futuristic rendering...
  61434. *
  61435. * The only supported format is currently 3dl.
  61436. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61437. */
  61438. export class ColorGradingTexture extends BaseTexture {
  61439. /**
  61440. * The texture URL.
  61441. */
  61442. url: string;
  61443. /**
  61444. * Empty line regex stored for GC.
  61445. */
  61446. private static _noneEmptyLineRegex;
  61447. private _textureMatrix;
  61448. private _onLoad;
  61449. /**
  61450. * Instantiates a ColorGradingTexture from the following parameters.
  61451. *
  61452. * @param url The location of the color gradind data (currently only supporting 3dl)
  61453. * @param sceneOrEngine The scene or engine the texture will be used in
  61454. * @param onLoad defines a callback triggered when the texture has been loaded
  61455. */
  61456. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61457. /**
  61458. * Fires the onload event from the constructor if requested.
  61459. */
  61460. private _triggerOnLoad;
  61461. /**
  61462. * Returns the texture matrix used in most of the material.
  61463. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61464. */
  61465. getTextureMatrix(): Matrix;
  61466. /**
  61467. * Occurs when the file being loaded is a .3dl LUT file.
  61468. */
  61469. private load3dlTexture;
  61470. /**
  61471. * Starts the loading process of the texture.
  61472. */
  61473. private loadTexture;
  61474. /**
  61475. * Clones the color gradind texture.
  61476. */
  61477. clone(): ColorGradingTexture;
  61478. /**
  61479. * Called during delayed load for textures.
  61480. */
  61481. delayLoad(): void;
  61482. /**
  61483. * Parses a color grading texture serialized by Babylon.
  61484. * @param parsedTexture The texture information being parsedTexture
  61485. * @param scene The scene to load the texture in
  61486. * @param rootUrl The root url of the data assets to load
  61487. * @return A color gradind texture
  61488. */
  61489. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61490. /**
  61491. * Serializes the LUT texture to json format.
  61492. */
  61493. serialize(): any;
  61494. }
  61495. }
  61496. declare module BABYLON {
  61497. /**
  61498. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61499. */
  61500. export class EquiRectangularCubeTexture extends BaseTexture {
  61501. /** The six faces of the cube. */
  61502. private static _FacesMapping;
  61503. private _noMipmap;
  61504. private _onLoad;
  61505. private _onError;
  61506. /** The size of the cubemap. */
  61507. private _size;
  61508. /** The buffer of the image. */
  61509. private _buffer;
  61510. /** The width of the input image. */
  61511. private _width;
  61512. /** The height of the input image. */
  61513. private _height;
  61514. /** The URL to the image. */
  61515. url: string;
  61516. /**
  61517. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61518. * @param url The location of the image
  61519. * @param scene The scene the texture will be used in
  61520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61521. * @param noMipmap Forces to not generate the mipmap if true
  61522. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61523. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61524. * @param onLoad — defines a callback called when texture is loaded
  61525. * @param onError — defines a callback called if there is an error
  61526. */
  61527. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61528. /**
  61529. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61530. */
  61531. private loadImage;
  61532. /**
  61533. * Convert the image buffer into a cubemap and create a CubeTexture.
  61534. */
  61535. private loadTexture;
  61536. /**
  61537. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61538. * @param buffer The ArrayBuffer that should be converted.
  61539. * @returns The buffer as Float32Array.
  61540. */
  61541. private getFloat32ArrayFromArrayBuffer;
  61542. /**
  61543. * Get the current class name of the texture useful for serialization or dynamic coding.
  61544. * @returns "EquiRectangularCubeTexture"
  61545. */
  61546. getClassName(): string;
  61547. /**
  61548. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61549. * @returns A clone of the current EquiRectangularCubeTexture.
  61550. */
  61551. clone(): EquiRectangularCubeTexture;
  61552. }
  61553. }
  61554. declare module BABYLON {
  61555. /**
  61556. * Defines the options related to the creation of an HtmlElementTexture
  61557. */
  61558. export interface IHtmlElementTextureOptions {
  61559. /**
  61560. * Defines wether mip maps should be created or not.
  61561. */
  61562. generateMipMaps?: boolean;
  61563. /**
  61564. * Defines the sampling mode of the texture.
  61565. */
  61566. samplingMode?: number;
  61567. /**
  61568. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61569. */
  61570. engine: Nullable<ThinEngine>;
  61571. /**
  61572. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61573. */
  61574. scene: Nullable<Scene>;
  61575. }
  61576. /**
  61577. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61578. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61579. * is automatically managed.
  61580. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61581. * in your application.
  61582. *
  61583. * As the update is not automatic, you need to call them manually.
  61584. */
  61585. export class HtmlElementTexture extends BaseTexture {
  61586. /**
  61587. * The texture URL.
  61588. */
  61589. element: HTMLVideoElement | HTMLCanvasElement;
  61590. private static readonly DefaultOptions;
  61591. private _textureMatrix;
  61592. private _isVideo;
  61593. private _generateMipMaps;
  61594. private _samplingMode;
  61595. /**
  61596. * Instantiates a HtmlElementTexture from the following parameters.
  61597. *
  61598. * @param name Defines the name of the texture
  61599. * @param element Defines the video or canvas the texture is filled with
  61600. * @param options Defines the other none mandatory texture creation options
  61601. */
  61602. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61603. private _createInternalTexture;
  61604. /**
  61605. * Returns the texture matrix used in most of the material.
  61606. */
  61607. getTextureMatrix(): Matrix;
  61608. /**
  61609. * Updates the content of the texture.
  61610. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61611. */
  61612. update(invertY?: Nullable<boolean>): void;
  61613. }
  61614. }
  61615. declare module BABYLON {
  61616. /**
  61617. * Based on jsTGALoader - Javascript loader for TGA file
  61618. * By Vincent Thibault
  61619. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61620. */
  61621. export class TGATools {
  61622. private static _TYPE_INDEXED;
  61623. private static _TYPE_RGB;
  61624. private static _TYPE_GREY;
  61625. private static _TYPE_RLE_INDEXED;
  61626. private static _TYPE_RLE_RGB;
  61627. private static _TYPE_RLE_GREY;
  61628. private static _ORIGIN_MASK;
  61629. private static _ORIGIN_SHIFT;
  61630. private static _ORIGIN_BL;
  61631. private static _ORIGIN_BR;
  61632. private static _ORIGIN_UL;
  61633. private static _ORIGIN_UR;
  61634. /**
  61635. * Gets the header of a TGA file
  61636. * @param data defines the TGA data
  61637. * @returns the header
  61638. */
  61639. static GetTGAHeader(data: Uint8Array): any;
  61640. /**
  61641. * Uploads TGA content to a Babylon Texture
  61642. * @hidden
  61643. */
  61644. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61645. /** @hidden */
  61646. 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;
  61647. /** @hidden */
  61648. 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;
  61649. /** @hidden */
  61650. 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;
  61651. /** @hidden */
  61652. 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;
  61653. /** @hidden */
  61654. 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;
  61655. /** @hidden */
  61656. 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;
  61657. }
  61658. }
  61659. declare module BABYLON {
  61660. /**
  61661. * Implementation of the TGA Texture Loader.
  61662. * @hidden
  61663. */
  61664. export class _TGATextureLoader implements IInternalTextureLoader {
  61665. /**
  61666. * Defines wether the loader supports cascade loading the different faces.
  61667. */
  61668. readonly supportCascades: boolean;
  61669. /**
  61670. * This returns if the loader support the current file information.
  61671. * @param extension defines the file extension of the file being loaded
  61672. * @returns true if the loader can load the specified file
  61673. */
  61674. canLoad(extension: string): boolean;
  61675. /**
  61676. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61677. * @param data contains the texture data
  61678. * @param texture defines the BabylonJS internal texture
  61679. * @param createPolynomials will be true if polynomials have been requested
  61680. * @param onLoad defines the callback to trigger once the texture is ready
  61681. * @param onError defines the callback to trigger in case of error
  61682. */
  61683. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61684. /**
  61685. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61686. * @param data contains the texture data
  61687. * @param texture defines the BabylonJS internal texture
  61688. * @param callback defines the method to call once ready to upload
  61689. */
  61690. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61691. }
  61692. }
  61693. declare module BABYLON {
  61694. /**
  61695. * Info about the .basis files
  61696. */
  61697. class BasisFileInfo {
  61698. /**
  61699. * If the file has alpha
  61700. */
  61701. hasAlpha: boolean;
  61702. /**
  61703. * Info about each image of the basis file
  61704. */
  61705. images: Array<{
  61706. levels: Array<{
  61707. width: number;
  61708. height: number;
  61709. transcodedPixels: ArrayBufferView;
  61710. }>;
  61711. }>;
  61712. }
  61713. /**
  61714. * Result of transcoding a basis file
  61715. */
  61716. class TranscodeResult {
  61717. /**
  61718. * Info about the .basis file
  61719. */
  61720. fileInfo: BasisFileInfo;
  61721. /**
  61722. * Format to use when loading the file
  61723. */
  61724. format: number;
  61725. }
  61726. /**
  61727. * Configuration options for the Basis transcoder
  61728. */
  61729. export class BasisTranscodeConfiguration {
  61730. /**
  61731. * Supported compression formats used to determine the supported output format of the transcoder
  61732. */
  61733. supportedCompressionFormats?: {
  61734. /**
  61735. * etc1 compression format
  61736. */
  61737. etc1?: boolean;
  61738. /**
  61739. * s3tc compression format
  61740. */
  61741. s3tc?: boolean;
  61742. /**
  61743. * pvrtc compression format
  61744. */
  61745. pvrtc?: boolean;
  61746. /**
  61747. * etc2 compression format
  61748. */
  61749. etc2?: boolean;
  61750. };
  61751. /**
  61752. * If mipmap levels should be loaded for transcoded images (Default: true)
  61753. */
  61754. loadMipmapLevels?: boolean;
  61755. /**
  61756. * Index of a single image to load (Default: all images)
  61757. */
  61758. loadSingleImage?: number;
  61759. }
  61760. /**
  61761. * Used to load .Basis files
  61762. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61763. */
  61764. export class BasisTools {
  61765. private static _IgnoreSupportedFormats;
  61766. /**
  61767. * URL to use when loading the basis transcoder
  61768. */
  61769. static JSModuleURL: string;
  61770. /**
  61771. * URL to use when loading the wasm module for the transcoder
  61772. */
  61773. static WasmModuleURL: string;
  61774. /**
  61775. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61776. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61777. * @returns internal format corresponding to the Basis format
  61778. */
  61779. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61780. private static _WorkerPromise;
  61781. private static _Worker;
  61782. private static _actionId;
  61783. private static _CreateWorkerAsync;
  61784. /**
  61785. * Transcodes a loaded image file to compressed pixel data
  61786. * @param data image data to transcode
  61787. * @param config configuration options for the transcoding
  61788. * @returns a promise resulting in the transcoded image
  61789. */
  61790. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61791. /**
  61792. * Loads a texture from the transcode result
  61793. * @param texture texture load to
  61794. * @param transcodeResult the result of transcoding the basis file to load from
  61795. */
  61796. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61797. }
  61798. }
  61799. declare module BABYLON {
  61800. /**
  61801. * Loader for .basis file format
  61802. */
  61803. export class _BasisTextureLoader implements IInternalTextureLoader {
  61804. /**
  61805. * Defines whether the loader supports cascade loading the different faces.
  61806. */
  61807. readonly supportCascades: boolean;
  61808. /**
  61809. * This returns if the loader support the current file information.
  61810. * @param extension defines the file extension of the file being loaded
  61811. * @returns true if the loader can load the specified file
  61812. */
  61813. canLoad(extension: string): boolean;
  61814. /**
  61815. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61816. * @param data contains the texture data
  61817. * @param texture defines the BabylonJS internal texture
  61818. * @param createPolynomials will be true if polynomials have been requested
  61819. * @param onLoad defines the callback to trigger once the texture is ready
  61820. * @param onError defines the callback to trigger in case of error
  61821. */
  61822. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61823. /**
  61824. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61825. * @param data contains the texture data
  61826. * @param texture defines the BabylonJS internal texture
  61827. * @param callback defines the method to call once ready to upload
  61828. */
  61829. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61830. }
  61831. }
  61832. declare module BABYLON {
  61833. /**
  61834. * Defines the basic options interface of a TexturePacker Frame
  61835. */
  61836. export interface ITexturePackerFrame {
  61837. /**
  61838. * The frame ID
  61839. */
  61840. id: number;
  61841. /**
  61842. * The frames Scale
  61843. */
  61844. scale: Vector2;
  61845. /**
  61846. * The Frames offset
  61847. */
  61848. offset: Vector2;
  61849. }
  61850. /**
  61851. * This is a support class for frame Data on texture packer sets.
  61852. */
  61853. export class TexturePackerFrame implements ITexturePackerFrame {
  61854. /**
  61855. * The frame ID
  61856. */
  61857. id: number;
  61858. /**
  61859. * The frames Scale
  61860. */
  61861. scale: Vector2;
  61862. /**
  61863. * The Frames offset
  61864. */
  61865. offset: Vector2;
  61866. /**
  61867. * Initializes a texture package frame.
  61868. * @param id The numerical frame identifier
  61869. * @param scale Scalar Vector2 for UV frame
  61870. * @param offset Vector2 for the frame position in UV units.
  61871. * @returns TexturePackerFrame
  61872. */
  61873. constructor(id: number, scale: Vector2, offset: Vector2);
  61874. }
  61875. }
  61876. declare module BABYLON {
  61877. /**
  61878. * Defines the basic options interface of a TexturePacker
  61879. */
  61880. export interface ITexturePackerOptions {
  61881. /**
  61882. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61883. */
  61884. map?: string[];
  61885. /**
  61886. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61887. */
  61888. uvsIn?: string;
  61889. /**
  61890. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61891. */
  61892. uvsOut?: string;
  61893. /**
  61894. * number representing the layout style. Defaults to LAYOUT_STRIP
  61895. */
  61896. layout?: number;
  61897. /**
  61898. * number of columns if using custom column count layout(2). This defaults to 4.
  61899. */
  61900. colnum?: number;
  61901. /**
  61902. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61903. */
  61904. updateInputMeshes?: boolean;
  61905. /**
  61906. * boolean flag to dispose all the source textures. Defaults to true.
  61907. */
  61908. disposeSources?: boolean;
  61909. /**
  61910. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61911. */
  61912. fillBlanks?: boolean;
  61913. /**
  61914. * string value representing the context fill style color. Defaults to 'black'.
  61915. */
  61916. customFillColor?: string;
  61917. /**
  61918. * Width and Height Value of each Frame in the TexturePacker Sets
  61919. */
  61920. frameSize?: number;
  61921. /**
  61922. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61923. */
  61924. paddingRatio?: number;
  61925. /**
  61926. * Number that declares the fill method for the padding gutter.
  61927. */
  61928. paddingMode?: number;
  61929. /**
  61930. * If in SUBUV_COLOR padding mode what color to use.
  61931. */
  61932. paddingColor?: Color3 | Color4;
  61933. }
  61934. /**
  61935. * Defines the basic interface of a TexturePacker JSON File
  61936. */
  61937. export interface ITexturePackerJSON {
  61938. /**
  61939. * The frame ID
  61940. */
  61941. name: string;
  61942. /**
  61943. * The base64 channel data
  61944. */
  61945. sets: any;
  61946. /**
  61947. * The options of the Packer
  61948. */
  61949. options: ITexturePackerOptions;
  61950. /**
  61951. * The frame data of the Packer
  61952. */
  61953. frames: Array<number>;
  61954. }
  61955. /**
  61956. * This is a support class that generates a series of packed texture sets.
  61957. * @see https://doc.babylonjs.com/babylon101/materials
  61958. */
  61959. export class TexturePacker {
  61960. /** Packer Layout Constant 0 */
  61961. static readonly LAYOUT_STRIP: number;
  61962. /** Packer Layout Constant 1 */
  61963. static readonly LAYOUT_POWER2: number;
  61964. /** Packer Layout Constant 2 */
  61965. static readonly LAYOUT_COLNUM: number;
  61966. /** Packer Layout Constant 0 */
  61967. static readonly SUBUV_WRAP: number;
  61968. /** Packer Layout Constant 1 */
  61969. static readonly SUBUV_EXTEND: number;
  61970. /** Packer Layout Constant 2 */
  61971. static readonly SUBUV_COLOR: number;
  61972. /** The Name of the Texture Package */
  61973. name: string;
  61974. /** The scene scope of the TexturePacker */
  61975. scene: Scene;
  61976. /** The Meshes to target */
  61977. meshes: AbstractMesh[];
  61978. /** Arguments passed with the Constructor */
  61979. options: ITexturePackerOptions;
  61980. /** The promise that is started upon initialization */
  61981. promise: Nullable<Promise<TexturePacker | string>>;
  61982. /** The Container object for the channel sets that are generated */
  61983. sets: object;
  61984. /** The Container array for the frames that are generated */
  61985. frames: TexturePackerFrame[];
  61986. /** The expected number of textures the system is parsing. */
  61987. private _expecting;
  61988. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61989. private _paddingValue;
  61990. /**
  61991. * Initializes a texture package series from an array of meshes or a single mesh.
  61992. * @param name The name of the package
  61993. * @param meshes The target meshes to compose the package from
  61994. * @param options The arguments that texture packer should follow while building.
  61995. * @param scene The scene which the textures are scoped to.
  61996. * @returns TexturePacker
  61997. */
  61998. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61999. /**
  62000. * Starts the package process
  62001. * @param resolve The promises resolution function
  62002. * @returns TexturePacker
  62003. */
  62004. private _createFrames;
  62005. /**
  62006. * Calculates the Size of the Channel Sets
  62007. * @returns Vector2
  62008. */
  62009. private _calculateSize;
  62010. /**
  62011. * Calculates the UV data for the frames.
  62012. * @param baseSize the base frameSize
  62013. * @param padding the base frame padding
  62014. * @param dtSize size of the Dynamic Texture for that channel
  62015. * @param dtUnits is 1/dtSize
  62016. * @param update flag to update the input meshes
  62017. */
  62018. private _calculateMeshUVFrames;
  62019. /**
  62020. * Calculates the frames Offset.
  62021. * @param index of the frame
  62022. * @returns Vector2
  62023. */
  62024. private _getFrameOffset;
  62025. /**
  62026. * Updates a Mesh to the frame data
  62027. * @param mesh that is the target
  62028. * @param frameID or the frame index
  62029. */
  62030. private _updateMeshUV;
  62031. /**
  62032. * Updates a Meshes materials to use the texture packer channels
  62033. * @param m is the mesh to target
  62034. * @param force all channels on the packer to be set.
  62035. */
  62036. private _updateTextureReferences;
  62037. /**
  62038. * Public method to set a Mesh to a frame
  62039. * @param m that is the target
  62040. * @param frameID or the frame index
  62041. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62042. */
  62043. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62044. /**
  62045. * Starts the async promise to compile the texture packer.
  62046. * @returns Promise<void>
  62047. */
  62048. processAsync(): Promise<void>;
  62049. /**
  62050. * Disposes all textures associated with this packer
  62051. */
  62052. dispose(): void;
  62053. /**
  62054. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62055. * @param imageType is the image type to use.
  62056. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62057. */
  62058. download(imageType?: string, quality?: number): void;
  62059. /**
  62060. * Public method to load a texturePacker JSON file.
  62061. * @param data of the JSON file in string format.
  62062. */
  62063. updateFromJSON(data: string): void;
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /**
  62068. * 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.
  62069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62070. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62071. */
  62072. export class CustomProceduralTexture extends ProceduralTexture {
  62073. private _animate;
  62074. private _time;
  62075. private _config;
  62076. private _texturePath;
  62077. /**
  62078. * Instantiates a new Custom Procedural Texture.
  62079. * 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.
  62080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62081. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62082. * @param name Define the name of the texture
  62083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62084. * @param size Define the size of the texture to create
  62085. * @param scene Define the scene the texture belongs to
  62086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62087. * @param generateMipMaps Define if the texture should creates mip maps or not
  62088. */
  62089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62090. private _loadJson;
  62091. /**
  62092. * Is the texture ready to be used ? (rendered at least once)
  62093. * @returns true if ready, otherwise, false.
  62094. */
  62095. isReady(): boolean;
  62096. /**
  62097. * Render the texture to its associated render target.
  62098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62099. */
  62100. render(useCameraPostProcess?: boolean): void;
  62101. /**
  62102. * Update the list of dependant textures samplers in the shader.
  62103. */
  62104. updateTextures(): void;
  62105. /**
  62106. * Update the uniform values of the procedural texture in the shader.
  62107. */
  62108. updateShaderUniforms(): void;
  62109. /**
  62110. * Define if the texture animates or not.
  62111. */
  62112. get animate(): boolean;
  62113. set animate(value: boolean);
  62114. }
  62115. }
  62116. declare module BABYLON {
  62117. /** @hidden */
  62118. export var noisePixelShader: {
  62119. name: string;
  62120. shader: string;
  62121. };
  62122. }
  62123. declare module BABYLON {
  62124. /**
  62125. * Class used to generate noise procedural textures
  62126. */
  62127. export class NoiseProceduralTexture extends ProceduralTexture {
  62128. /** Gets or sets the start time (default is 0) */
  62129. time: number;
  62130. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62131. brightness: number;
  62132. /** Defines the number of octaves to process */
  62133. octaves: number;
  62134. /** Defines the level of persistence (0.8 by default) */
  62135. persistence: number;
  62136. /** Gets or sets animation speed factor (default is 1) */
  62137. animationSpeedFactor: number;
  62138. /**
  62139. * Creates a new NoiseProceduralTexture
  62140. * @param name defines the name fo the texture
  62141. * @param size defines the size of the texture (default is 256)
  62142. * @param scene defines the hosting scene
  62143. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62144. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62145. */
  62146. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62147. private _updateShaderUniforms;
  62148. protected _getDefines(): string;
  62149. /** Generate the current state of the procedural texture */
  62150. render(useCameraPostProcess?: boolean): void;
  62151. /**
  62152. * Serializes this noise procedural texture
  62153. * @returns a serialized noise procedural texture object
  62154. */
  62155. serialize(): any;
  62156. /**
  62157. * Clone the texture.
  62158. * @returns the cloned texture
  62159. */
  62160. clone(): NoiseProceduralTexture;
  62161. /**
  62162. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62163. * @param parsedTexture defines parsed texture data
  62164. * @param scene defines the current scene
  62165. * @param rootUrl defines the root URL containing noise procedural texture information
  62166. * @returns a parsed NoiseProceduralTexture
  62167. */
  62168. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62169. }
  62170. }
  62171. declare module BABYLON {
  62172. /**
  62173. * Raw cube texture where the raw buffers are passed in
  62174. */
  62175. export class RawCubeTexture extends CubeTexture {
  62176. /**
  62177. * Creates a cube texture where the raw buffers are passed in.
  62178. * @param scene defines the scene the texture is attached to
  62179. * @param data defines the array of data to use to create each face
  62180. * @param size defines the size of the textures
  62181. * @param format defines the format of the data
  62182. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62183. * @param generateMipMaps defines if the engine should generate the mip levels
  62184. * @param invertY defines if data must be stored with Y axis inverted
  62185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62186. * @param compression defines the compression used (null by default)
  62187. */
  62188. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62189. /**
  62190. * Updates the raw cube texture.
  62191. * @param data defines the data to store
  62192. * @param format defines the data format
  62193. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62194. * @param invertY defines if data must be stored with Y axis inverted
  62195. * @param compression defines the compression used (null by default)
  62196. * @param level defines which level of the texture to update
  62197. */
  62198. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62199. /**
  62200. * Updates a raw cube texture with RGBD encoded data.
  62201. * @param data defines the array of data [mipmap][face] to use to create each face
  62202. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62203. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62204. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62205. * @returns a promsie that resolves when the operation is complete
  62206. */
  62207. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62208. /**
  62209. * Clones the raw cube texture.
  62210. * @return a new cube texture
  62211. */
  62212. clone(): CubeTexture;
  62213. /** @hidden */
  62214. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62215. }
  62216. }
  62217. declare module BABYLON {
  62218. /**
  62219. * Class used to store 2D array textures containing user data
  62220. */
  62221. export class RawTexture2DArray extends Texture {
  62222. /** Gets or sets the texture format to use */
  62223. format: number;
  62224. /**
  62225. * Create a new RawTexture2DArray
  62226. * @param data defines the data of the texture
  62227. * @param width defines the width of the texture
  62228. * @param height defines the height of the texture
  62229. * @param depth defines the number of layers of the texture
  62230. * @param format defines the texture format to use
  62231. * @param scene defines the hosting scene
  62232. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62233. * @param invertY defines if texture must be stored with Y axis inverted
  62234. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62235. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62236. */
  62237. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62238. /** Gets or sets the texture format to use */
  62239. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62240. /**
  62241. * Update the texture with new data
  62242. * @param data defines the data to store in the texture
  62243. */
  62244. update(data: ArrayBufferView): void;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * Class used to store 3D textures containing user data
  62250. */
  62251. export class RawTexture3D extends Texture {
  62252. /** Gets or sets the texture format to use */
  62253. format: number;
  62254. /**
  62255. * Create a new RawTexture3D
  62256. * @param data defines the data of the texture
  62257. * @param width defines the width of the texture
  62258. * @param height defines the height of the texture
  62259. * @param depth defines the depth of the texture
  62260. * @param format defines the texture format to use
  62261. * @param scene defines the hosting scene
  62262. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62263. * @param invertY defines if texture must be stored with Y axis inverted
  62264. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62265. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62266. */
  62267. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62268. /** Gets or sets the texture format to use */
  62269. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62270. /**
  62271. * Update the texture with new data
  62272. * @param data defines the data to store in the texture
  62273. */
  62274. update(data: ArrayBufferView): void;
  62275. }
  62276. }
  62277. declare module BABYLON {
  62278. /**
  62279. * Creates a refraction texture used by refraction channel of the standard material.
  62280. * It is like a mirror but to see through a material.
  62281. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62282. */
  62283. export class RefractionTexture extends RenderTargetTexture {
  62284. /**
  62285. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62286. * 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.
  62287. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62288. */
  62289. refractionPlane: Plane;
  62290. /**
  62291. * Define how deep under the surface we should see.
  62292. */
  62293. depth: number;
  62294. /**
  62295. * Creates a refraction texture used by refraction channel of the standard material.
  62296. * It is like a mirror but to see through a material.
  62297. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62298. * @param name Define the texture name
  62299. * @param size Define the size of the underlying texture
  62300. * @param scene Define the scene the refraction belongs to
  62301. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62302. */
  62303. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62304. /**
  62305. * Clone the refraction texture.
  62306. * @returns the cloned texture
  62307. */
  62308. clone(): RefractionTexture;
  62309. /**
  62310. * Serialize the texture to a JSON representation you could use in Parse later on
  62311. * @returns the serialized JSON representation
  62312. */
  62313. serialize(): any;
  62314. }
  62315. }
  62316. declare module BABYLON {
  62317. /**
  62318. * Block used to add support for vertex skinning (bones)
  62319. */
  62320. export class BonesBlock extends NodeMaterialBlock {
  62321. /**
  62322. * Creates a new BonesBlock
  62323. * @param name defines the block name
  62324. */
  62325. constructor(name: string);
  62326. /**
  62327. * Initialize the block and prepare the context for build
  62328. * @param state defines the state that will be used for the build
  62329. */
  62330. initialize(state: NodeMaterialBuildState): void;
  62331. /**
  62332. * Gets the current class name
  62333. * @returns the class name
  62334. */
  62335. getClassName(): string;
  62336. /**
  62337. * Gets the matrix indices input component
  62338. */
  62339. get matricesIndices(): NodeMaterialConnectionPoint;
  62340. /**
  62341. * Gets the matrix weights input component
  62342. */
  62343. get matricesWeights(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the extra matrix indices input component
  62346. */
  62347. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the extra matrix weights input component
  62350. */
  62351. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the world input component
  62354. */
  62355. get world(): NodeMaterialConnectionPoint;
  62356. /**
  62357. * Gets the output component
  62358. */
  62359. get output(): NodeMaterialConnectionPoint;
  62360. autoConfigure(material: NodeMaterial): void;
  62361. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62364. protected _buildBlock(state: NodeMaterialBuildState): this;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /**
  62369. * Block used to add support for instances
  62370. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62371. */
  62372. export class InstancesBlock extends NodeMaterialBlock {
  62373. /**
  62374. * Creates a new InstancesBlock
  62375. * @param name defines the block name
  62376. */
  62377. constructor(name: string);
  62378. /**
  62379. * Gets the current class name
  62380. * @returns the class name
  62381. */
  62382. getClassName(): string;
  62383. /**
  62384. * Gets the first world row input component
  62385. */
  62386. get world0(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the second world row input component
  62389. */
  62390. get world1(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the third world row input component
  62393. */
  62394. get world2(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the forth world row input component
  62397. */
  62398. get world3(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the world input component
  62401. */
  62402. get world(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the output component
  62405. */
  62406. get output(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the isntanceID component
  62409. */
  62410. get instanceID(): NodeMaterialConnectionPoint;
  62411. autoConfigure(material: NodeMaterial): void;
  62412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62413. protected _buildBlock(state: NodeMaterialBuildState): this;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. /**
  62418. * Block used to add morph targets support to vertex shader
  62419. */
  62420. export class MorphTargetsBlock extends NodeMaterialBlock {
  62421. private _repeatableContentAnchor;
  62422. /**
  62423. * Create a new MorphTargetsBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the position input component
  62434. */
  62435. get position(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the normal input component
  62438. */
  62439. get normal(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the tangent input component
  62442. */
  62443. get tangent(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the tangent input component
  62446. */
  62447. get uv(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the position output component
  62450. */
  62451. get positionOutput(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the normal output component
  62454. */
  62455. get normalOutput(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the tangent output component
  62458. */
  62459. get tangentOutput(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the tangent output component
  62462. */
  62463. get uvOutput(): NodeMaterialConnectionPoint;
  62464. initialize(state: NodeMaterialBuildState): void;
  62465. autoConfigure(material: NodeMaterial): void;
  62466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62468. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62469. protected _buildBlock(state: NodeMaterialBuildState): this;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Block used to get data information from a light
  62475. */
  62476. export class LightInformationBlock extends NodeMaterialBlock {
  62477. private _lightDataUniformName;
  62478. private _lightColorUniformName;
  62479. private _lightTypeDefineName;
  62480. /**
  62481. * Gets or sets the light associated with this block
  62482. */
  62483. light: Nullable<Light>;
  62484. /**
  62485. * Creates a new LightInformationBlock
  62486. * @param name defines the block name
  62487. */
  62488. constructor(name: string);
  62489. /**
  62490. * Gets the current class name
  62491. * @returns the class name
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * Gets the world position input component
  62496. */
  62497. get worldPosition(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the direction output component
  62500. */
  62501. get direction(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the direction output component
  62504. */
  62505. get color(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the direction output component
  62508. */
  62509. get intensity(): NodeMaterialConnectionPoint;
  62510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62511. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62512. protected _buildBlock(state: NodeMaterialBuildState): this;
  62513. serialize(): any;
  62514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62515. }
  62516. }
  62517. declare module BABYLON {
  62518. /**
  62519. * Block used to add image processing support to fragment shader
  62520. */
  62521. export class ImageProcessingBlock extends NodeMaterialBlock {
  62522. /**
  62523. * Create a new ImageProcessingBlock
  62524. * @param name defines the block name
  62525. */
  62526. constructor(name: string);
  62527. /**
  62528. * Gets the current class name
  62529. * @returns the class name
  62530. */
  62531. getClassName(): string;
  62532. /**
  62533. * Gets the color input component
  62534. */
  62535. get color(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the output component
  62538. */
  62539. get output(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Initialize the block and prepare the context for build
  62542. * @param state defines the state that will be used for the build
  62543. */
  62544. initialize(state: NodeMaterialBuildState): void;
  62545. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62548. protected _buildBlock(state: NodeMaterialBuildState): this;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Block used to pertub normals based on a normal map
  62554. */
  62555. export class PerturbNormalBlock extends NodeMaterialBlock {
  62556. private _tangentSpaceParameterName;
  62557. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62558. invertX: boolean;
  62559. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62560. invertY: boolean;
  62561. /**
  62562. * Create a new PerturbNormalBlock
  62563. * @param name defines the block name
  62564. */
  62565. constructor(name: string);
  62566. /**
  62567. * Gets the current class name
  62568. * @returns the class name
  62569. */
  62570. getClassName(): string;
  62571. /**
  62572. * Gets the world position input component
  62573. */
  62574. get worldPosition(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the world normal input component
  62577. */
  62578. get worldNormal(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the world tangent input component
  62581. */
  62582. get worldTangent(): NodeMaterialConnectionPoint;
  62583. /**
  62584. * Gets the uv input component
  62585. */
  62586. get uv(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the normal map color input component
  62589. */
  62590. get normalMapColor(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the strength input component
  62593. */
  62594. get strength(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the output component
  62597. */
  62598. get output(): NodeMaterialConnectionPoint;
  62599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62601. autoConfigure(material: NodeMaterial): void;
  62602. protected _buildBlock(state: NodeMaterialBuildState): this;
  62603. protected _dumpPropertiesCode(): string;
  62604. serialize(): any;
  62605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62606. }
  62607. }
  62608. declare module BABYLON {
  62609. /**
  62610. * Block used to discard a pixel if a value is smaller than a cutoff
  62611. */
  62612. export class DiscardBlock extends NodeMaterialBlock {
  62613. /**
  62614. * Create a new DiscardBlock
  62615. * @param name defines the block name
  62616. */
  62617. constructor(name: string);
  62618. /**
  62619. * Gets the current class name
  62620. * @returns the class name
  62621. */
  62622. getClassName(): string;
  62623. /**
  62624. * Gets the color input component
  62625. */
  62626. get value(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the cutoff input component
  62629. */
  62630. get cutoff(): NodeMaterialConnectionPoint;
  62631. protected _buildBlock(state: NodeMaterialBuildState): this;
  62632. }
  62633. }
  62634. declare module BABYLON {
  62635. /**
  62636. * Block used to test if the fragment shader is front facing
  62637. */
  62638. export class FrontFacingBlock extends NodeMaterialBlock {
  62639. /**
  62640. * Creates a new FrontFacingBlock
  62641. * @param name defines the block name
  62642. */
  62643. constructor(name: string);
  62644. /**
  62645. * Gets the current class name
  62646. * @returns the class name
  62647. */
  62648. getClassName(): string;
  62649. /**
  62650. * Gets the output component
  62651. */
  62652. get output(): NodeMaterialConnectionPoint;
  62653. protected _buildBlock(state: NodeMaterialBuildState): this;
  62654. }
  62655. }
  62656. declare module BABYLON {
  62657. /**
  62658. * Block used to get the derivative value on x and y of a given input
  62659. */
  62660. export class DerivativeBlock extends NodeMaterialBlock {
  62661. /**
  62662. * Create a new DerivativeBlock
  62663. * @param name defines the block name
  62664. */
  62665. constructor(name: string);
  62666. /**
  62667. * Gets the current class name
  62668. * @returns the class name
  62669. */
  62670. getClassName(): string;
  62671. /**
  62672. * Gets the input component
  62673. */
  62674. get input(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the derivative output on x
  62677. */
  62678. get dx(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the derivative output on y
  62681. */
  62682. get dy(): NodeMaterialConnectionPoint;
  62683. protected _buildBlock(state: NodeMaterialBuildState): this;
  62684. }
  62685. }
  62686. declare module BABYLON {
  62687. /**
  62688. * Block used to make gl_FragCoord available
  62689. */
  62690. export class FragCoordBlock extends NodeMaterialBlock {
  62691. /**
  62692. * Creates a new FragCoordBlock
  62693. * @param name defines the block name
  62694. */
  62695. constructor(name: string);
  62696. /**
  62697. * Gets the current class name
  62698. * @returns the class name
  62699. */
  62700. getClassName(): string;
  62701. /**
  62702. * Gets the xy component
  62703. */
  62704. get xy(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the xyz component
  62707. */
  62708. get xyz(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the xyzw component
  62711. */
  62712. get xyzw(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the x component
  62715. */
  62716. get x(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the y component
  62719. */
  62720. get y(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the z component
  62723. */
  62724. get z(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the w component
  62727. */
  62728. get output(): NodeMaterialConnectionPoint;
  62729. protected writeOutputs(state: NodeMaterialBuildState): string;
  62730. protected _buildBlock(state: NodeMaterialBuildState): this;
  62731. }
  62732. }
  62733. declare module BABYLON {
  62734. /**
  62735. * Block used to get the screen sizes
  62736. */
  62737. export class ScreenSizeBlock extends NodeMaterialBlock {
  62738. private _varName;
  62739. private _scene;
  62740. /**
  62741. * Creates a new ScreenSizeBlock
  62742. * @param name defines the block name
  62743. */
  62744. constructor(name: string);
  62745. /**
  62746. * Gets the current class name
  62747. * @returns the class name
  62748. */
  62749. getClassName(): string;
  62750. /**
  62751. * Gets the xy component
  62752. */
  62753. get xy(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the x component
  62756. */
  62757. get x(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the y component
  62760. */
  62761. get y(): NodeMaterialConnectionPoint;
  62762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62763. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62764. protected _buildBlock(state: NodeMaterialBuildState): this;
  62765. }
  62766. }
  62767. declare module BABYLON {
  62768. /**
  62769. * Block used to add support for scene fog
  62770. */
  62771. export class FogBlock extends NodeMaterialBlock {
  62772. private _fogDistanceName;
  62773. private _fogParameters;
  62774. /**
  62775. * Create a new FogBlock
  62776. * @param name defines the block name
  62777. */
  62778. constructor(name: string);
  62779. /**
  62780. * Gets the current class name
  62781. * @returns the class name
  62782. */
  62783. getClassName(): string;
  62784. /**
  62785. * Gets the world position input component
  62786. */
  62787. get worldPosition(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the view input component
  62790. */
  62791. get view(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the color input component
  62794. */
  62795. get input(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the fog color input component
  62798. */
  62799. get fogColor(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the output component
  62802. */
  62803. get output(): NodeMaterialConnectionPoint;
  62804. autoConfigure(material: NodeMaterial): void;
  62805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62807. protected _buildBlock(state: NodeMaterialBuildState): this;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Block used to add light in the fragment shader
  62813. */
  62814. export class LightBlock extends NodeMaterialBlock {
  62815. private _lightId;
  62816. /**
  62817. * Gets or sets the light associated with this block
  62818. */
  62819. light: Nullable<Light>;
  62820. /**
  62821. * Create a new LightBlock
  62822. * @param name defines the block name
  62823. */
  62824. constructor(name: string);
  62825. /**
  62826. * Gets the current class name
  62827. * @returns the class name
  62828. */
  62829. getClassName(): string;
  62830. /**
  62831. * Gets the world position input component
  62832. */
  62833. get worldPosition(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the world normal input component
  62836. */
  62837. get worldNormal(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the camera (or eye) position component
  62840. */
  62841. get cameraPosition(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the glossiness component
  62844. */
  62845. get glossiness(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the glossinness power component
  62848. */
  62849. get glossPower(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the diffuse color component
  62852. */
  62853. get diffuseColor(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the specular color component
  62856. */
  62857. get specularColor(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the diffuse output component
  62860. */
  62861. get diffuseOutput(): NodeMaterialConnectionPoint;
  62862. /**
  62863. * Gets the specular output component
  62864. */
  62865. get specularOutput(): NodeMaterialConnectionPoint;
  62866. /**
  62867. * Gets the shadow output component
  62868. */
  62869. get shadow(): NodeMaterialConnectionPoint;
  62870. autoConfigure(material: NodeMaterial): void;
  62871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62872. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62873. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62874. private _injectVertexCode;
  62875. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62876. serialize(): any;
  62877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62878. }
  62879. }
  62880. declare module BABYLON {
  62881. /**
  62882. * Block used to read a reflection texture from a sampler
  62883. */
  62884. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62885. /**
  62886. * Create a new ReflectionTextureBlock
  62887. * @param name defines the block name
  62888. */
  62889. constructor(name: string);
  62890. /**
  62891. * Gets the current class name
  62892. * @returns the class name
  62893. */
  62894. getClassName(): string;
  62895. /**
  62896. * Gets the world position input component
  62897. */
  62898. get position(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the world position input component
  62901. */
  62902. get worldPosition(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the world normal input component
  62905. */
  62906. get worldNormal(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the world input component
  62909. */
  62910. get world(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the camera (or eye) position component
  62913. */
  62914. get cameraPosition(): NodeMaterialConnectionPoint;
  62915. /**
  62916. * Gets the view input component
  62917. */
  62918. get view(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the rgb output component
  62921. */
  62922. get rgb(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the rgba output component
  62925. */
  62926. get rgba(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the r output component
  62929. */
  62930. get r(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the g output component
  62933. */
  62934. get g(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the b output component
  62937. */
  62938. get b(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the a output component
  62941. */
  62942. get a(): NodeMaterialConnectionPoint;
  62943. autoConfigure(material: NodeMaterial): void;
  62944. protected _buildBlock(state: NodeMaterialBuildState): this;
  62945. }
  62946. }
  62947. declare module BABYLON {
  62948. /**
  62949. * Block used to add 2 vectors
  62950. */
  62951. export class AddBlock extends NodeMaterialBlock {
  62952. /**
  62953. * Creates a new AddBlock
  62954. * @param name defines the block name
  62955. */
  62956. constructor(name: string);
  62957. /**
  62958. * Gets the current class name
  62959. * @returns the class name
  62960. */
  62961. getClassName(): string;
  62962. /**
  62963. * Gets the left operand input component
  62964. */
  62965. get left(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the right operand input component
  62968. */
  62969. get right(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the output component
  62972. */
  62973. get output(): NodeMaterialConnectionPoint;
  62974. protected _buildBlock(state: NodeMaterialBuildState): this;
  62975. }
  62976. }
  62977. declare module BABYLON {
  62978. /**
  62979. * Block used to scale a vector by a float
  62980. */
  62981. export class ScaleBlock extends NodeMaterialBlock {
  62982. /**
  62983. * Creates a new ScaleBlock
  62984. * @param name defines the block name
  62985. */
  62986. constructor(name: string);
  62987. /**
  62988. * Gets the current class name
  62989. * @returns the class name
  62990. */
  62991. getClassName(): string;
  62992. /**
  62993. * Gets the input component
  62994. */
  62995. get input(): NodeMaterialConnectionPoint;
  62996. /**
  62997. * Gets the factor input component
  62998. */
  62999. get factor(): NodeMaterialConnectionPoint;
  63000. /**
  63001. * Gets the output component
  63002. */
  63003. get output(): NodeMaterialConnectionPoint;
  63004. protected _buildBlock(state: NodeMaterialBuildState): this;
  63005. }
  63006. }
  63007. declare module BABYLON {
  63008. /**
  63009. * Block used to clamp a float
  63010. */
  63011. export class ClampBlock extends NodeMaterialBlock {
  63012. /** Gets or sets the minimum range */
  63013. minimum: number;
  63014. /** Gets or sets the maximum range */
  63015. maximum: number;
  63016. /**
  63017. * Creates a new ClampBlock
  63018. * @param name defines the block name
  63019. */
  63020. constructor(name: string);
  63021. /**
  63022. * Gets the current class name
  63023. * @returns the class name
  63024. */
  63025. getClassName(): string;
  63026. /**
  63027. * Gets the value input component
  63028. */
  63029. get value(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the output component
  63032. */
  63033. get output(): NodeMaterialConnectionPoint;
  63034. protected _buildBlock(state: NodeMaterialBuildState): this;
  63035. protected _dumpPropertiesCode(): string;
  63036. serialize(): any;
  63037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63038. }
  63039. }
  63040. declare module BABYLON {
  63041. /**
  63042. * Block used to apply a cross product between 2 vectors
  63043. */
  63044. export class CrossBlock extends NodeMaterialBlock {
  63045. /**
  63046. * Creates a new CrossBlock
  63047. * @param name defines the block name
  63048. */
  63049. constructor(name: string);
  63050. /**
  63051. * Gets the current class name
  63052. * @returns the class name
  63053. */
  63054. getClassName(): string;
  63055. /**
  63056. * Gets the left operand input component
  63057. */
  63058. get left(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the right operand input component
  63061. */
  63062. get right(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the output component
  63065. */
  63066. get output(): NodeMaterialConnectionPoint;
  63067. protected _buildBlock(state: NodeMaterialBuildState): this;
  63068. }
  63069. }
  63070. declare module BABYLON {
  63071. /**
  63072. * Block used to apply a dot product between 2 vectors
  63073. */
  63074. export class DotBlock extends NodeMaterialBlock {
  63075. /**
  63076. * Creates a new DotBlock
  63077. * @param name defines the block name
  63078. */
  63079. constructor(name: string);
  63080. /**
  63081. * Gets the current class name
  63082. * @returns the class name
  63083. */
  63084. getClassName(): string;
  63085. /**
  63086. * Gets the left operand input component
  63087. */
  63088. get left(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the right operand input component
  63091. */
  63092. get right(): NodeMaterialConnectionPoint;
  63093. /**
  63094. * Gets the output component
  63095. */
  63096. get output(): NodeMaterialConnectionPoint;
  63097. protected _buildBlock(state: NodeMaterialBuildState): this;
  63098. }
  63099. }
  63100. declare module BABYLON {
  63101. /**
  63102. * Block used to normalize a vector
  63103. */
  63104. export class NormalizeBlock extends NodeMaterialBlock {
  63105. /**
  63106. * Creates a new NormalizeBlock
  63107. * @param name defines the block name
  63108. */
  63109. constructor(name: string);
  63110. /**
  63111. * Gets the current class name
  63112. * @returns the class name
  63113. */
  63114. getClassName(): string;
  63115. /**
  63116. * Gets the input component
  63117. */
  63118. get input(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the output component
  63121. */
  63122. get output(): NodeMaterialConnectionPoint;
  63123. protected _buildBlock(state: NodeMaterialBuildState): this;
  63124. }
  63125. }
  63126. declare module BABYLON {
  63127. /**
  63128. * Operations supported by the Trigonometry block
  63129. */
  63130. export enum TrigonometryBlockOperations {
  63131. /** Cos */
  63132. Cos = 0,
  63133. /** Sin */
  63134. Sin = 1,
  63135. /** Abs */
  63136. Abs = 2,
  63137. /** Exp */
  63138. Exp = 3,
  63139. /** Exp2 */
  63140. Exp2 = 4,
  63141. /** Round */
  63142. Round = 5,
  63143. /** Floor */
  63144. Floor = 6,
  63145. /** Ceiling */
  63146. Ceiling = 7,
  63147. /** Square root */
  63148. Sqrt = 8,
  63149. /** Log */
  63150. Log = 9,
  63151. /** Tangent */
  63152. Tan = 10,
  63153. /** Arc tangent */
  63154. ArcTan = 11,
  63155. /** Arc cosinus */
  63156. ArcCos = 12,
  63157. /** Arc sinus */
  63158. ArcSin = 13,
  63159. /** Fraction */
  63160. Fract = 14,
  63161. /** Sign */
  63162. Sign = 15,
  63163. /** To radians (from degrees) */
  63164. Radians = 16,
  63165. /** To degrees (from radians) */
  63166. Degrees = 17
  63167. }
  63168. /**
  63169. * Block used to apply trigonometry operation to floats
  63170. */
  63171. export class TrigonometryBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Gets or sets the operation applied by the block
  63174. */
  63175. operation: TrigonometryBlockOperations;
  63176. /**
  63177. * Creates a new TrigonometryBlock
  63178. * @param name defines the block name
  63179. */
  63180. constructor(name: string);
  63181. /**
  63182. * Gets the current class name
  63183. * @returns the class name
  63184. */
  63185. getClassName(): string;
  63186. /**
  63187. * Gets the input component
  63188. */
  63189. get input(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the output component
  63192. */
  63193. get output(): NodeMaterialConnectionPoint;
  63194. protected _buildBlock(state: NodeMaterialBuildState): this;
  63195. serialize(): any;
  63196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63197. protected _dumpPropertiesCode(): string;
  63198. }
  63199. }
  63200. declare module BABYLON {
  63201. /**
  63202. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63203. */
  63204. export class ColorMergerBlock extends NodeMaterialBlock {
  63205. /**
  63206. * Create a new ColorMergerBlock
  63207. * @param name defines the block name
  63208. */
  63209. constructor(name: string);
  63210. /**
  63211. * Gets the current class name
  63212. * @returns the class name
  63213. */
  63214. getClassName(): string;
  63215. /**
  63216. * Gets the rgb component (input)
  63217. */
  63218. get rgbIn(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the r component (input)
  63221. */
  63222. get r(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the g component (input)
  63225. */
  63226. get g(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the b component (input)
  63229. */
  63230. get b(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the a component (input)
  63233. */
  63234. get a(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the rgba component (output)
  63237. */
  63238. get rgba(): NodeMaterialConnectionPoint;
  63239. /**
  63240. * Gets the rgb component (output)
  63241. */
  63242. get rgbOut(): NodeMaterialConnectionPoint;
  63243. /**
  63244. * Gets the rgb component (output)
  63245. * @deprecated Please use rgbOut instead.
  63246. */
  63247. get rgb(): NodeMaterialConnectionPoint;
  63248. protected _buildBlock(state: NodeMaterialBuildState): this;
  63249. }
  63250. }
  63251. declare module BABYLON {
  63252. /**
  63253. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63254. */
  63255. export class VectorSplitterBlock extends NodeMaterialBlock {
  63256. /**
  63257. * Create a new VectorSplitterBlock
  63258. * @param name defines the block name
  63259. */
  63260. constructor(name: string);
  63261. /**
  63262. * Gets the current class name
  63263. * @returns the class name
  63264. */
  63265. getClassName(): string;
  63266. /**
  63267. * Gets the xyzw component (input)
  63268. */
  63269. get xyzw(): NodeMaterialConnectionPoint;
  63270. /**
  63271. * Gets the xyz component (input)
  63272. */
  63273. get xyzIn(): NodeMaterialConnectionPoint;
  63274. /**
  63275. * Gets the xy component (input)
  63276. */
  63277. get xyIn(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the xyz component (output)
  63280. */
  63281. get xyzOut(): NodeMaterialConnectionPoint;
  63282. /**
  63283. * Gets the xy component (output)
  63284. */
  63285. get xyOut(): NodeMaterialConnectionPoint;
  63286. /**
  63287. * Gets the x component (output)
  63288. */
  63289. get x(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the y component (output)
  63292. */
  63293. get y(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the z component (output)
  63296. */
  63297. get z(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the w component (output)
  63300. */
  63301. get w(): NodeMaterialConnectionPoint;
  63302. protected _inputRename(name: string): string;
  63303. protected _outputRename(name: string): string;
  63304. protected _buildBlock(state: NodeMaterialBuildState): this;
  63305. }
  63306. }
  63307. declare module BABYLON {
  63308. /**
  63309. * Block used to lerp between 2 values
  63310. */
  63311. export class LerpBlock extends NodeMaterialBlock {
  63312. /**
  63313. * Creates a new LerpBlock
  63314. * @param name defines the block name
  63315. */
  63316. constructor(name: string);
  63317. /**
  63318. * Gets the current class name
  63319. * @returns the class name
  63320. */
  63321. getClassName(): string;
  63322. /**
  63323. * Gets the left operand input component
  63324. */
  63325. get left(): NodeMaterialConnectionPoint;
  63326. /**
  63327. * Gets the right operand input component
  63328. */
  63329. get right(): NodeMaterialConnectionPoint;
  63330. /**
  63331. * Gets the gradient operand input component
  63332. */
  63333. get gradient(): NodeMaterialConnectionPoint;
  63334. /**
  63335. * Gets the output component
  63336. */
  63337. get output(): NodeMaterialConnectionPoint;
  63338. protected _buildBlock(state: NodeMaterialBuildState): this;
  63339. }
  63340. }
  63341. declare module BABYLON {
  63342. /**
  63343. * Block used to divide 2 vectors
  63344. */
  63345. export class DivideBlock extends NodeMaterialBlock {
  63346. /**
  63347. * Creates a new DivideBlock
  63348. * @param name defines the block name
  63349. */
  63350. constructor(name: string);
  63351. /**
  63352. * Gets the current class name
  63353. * @returns the class name
  63354. */
  63355. getClassName(): string;
  63356. /**
  63357. * Gets the left operand input component
  63358. */
  63359. get left(): NodeMaterialConnectionPoint;
  63360. /**
  63361. * Gets the right operand input component
  63362. */
  63363. get right(): NodeMaterialConnectionPoint;
  63364. /**
  63365. * Gets the output component
  63366. */
  63367. get output(): NodeMaterialConnectionPoint;
  63368. protected _buildBlock(state: NodeMaterialBuildState): this;
  63369. }
  63370. }
  63371. declare module BABYLON {
  63372. /**
  63373. * Block used to subtract 2 vectors
  63374. */
  63375. export class SubtractBlock extends NodeMaterialBlock {
  63376. /**
  63377. * Creates a new SubtractBlock
  63378. * @param name defines the block name
  63379. */
  63380. constructor(name: string);
  63381. /**
  63382. * Gets the current class name
  63383. * @returns the class name
  63384. */
  63385. getClassName(): string;
  63386. /**
  63387. * Gets the left operand input component
  63388. */
  63389. get left(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the right operand input component
  63392. */
  63393. get right(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the output component
  63396. */
  63397. get output(): NodeMaterialConnectionPoint;
  63398. protected _buildBlock(state: NodeMaterialBuildState): this;
  63399. }
  63400. }
  63401. declare module BABYLON {
  63402. /**
  63403. * Block used to step a value
  63404. */
  63405. export class StepBlock extends NodeMaterialBlock {
  63406. /**
  63407. * Creates a new StepBlock
  63408. * @param name defines the block name
  63409. */
  63410. constructor(name: string);
  63411. /**
  63412. * Gets the current class name
  63413. * @returns the class name
  63414. */
  63415. getClassName(): string;
  63416. /**
  63417. * Gets the value operand input component
  63418. */
  63419. get value(): NodeMaterialConnectionPoint;
  63420. /**
  63421. * Gets the edge operand input component
  63422. */
  63423. get edge(): NodeMaterialConnectionPoint;
  63424. /**
  63425. * Gets the output component
  63426. */
  63427. get output(): NodeMaterialConnectionPoint;
  63428. protected _buildBlock(state: NodeMaterialBuildState): this;
  63429. }
  63430. }
  63431. declare module BABYLON {
  63432. /**
  63433. * Block used to get the opposite (1 - x) of a value
  63434. */
  63435. export class OneMinusBlock extends NodeMaterialBlock {
  63436. /**
  63437. * Creates a new OneMinusBlock
  63438. * @param name defines the block name
  63439. */
  63440. constructor(name: string);
  63441. /**
  63442. * Gets the current class name
  63443. * @returns the class name
  63444. */
  63445. getClassName(): string;
  63446. /**
  63447. * Gets the input component
  63448. */
  63449. get input(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the output component
  63452. */
  63453. get output(): NodeMaterialConnectionPoint;
  63454. protected _buildBlock(state: NodeMaterialBuildState): this;
  63455. }
  63456. }
  63457. declare module BABYLON {
  63458. /**
  63459. * Block used to get the view direction
  63460. */
  63461. export class ViewDirectionBlock extends NodeMaterialBlock {
  63462. /**
  63463. * Creates a new ViewDirectionBlock
  63464. * @param name defines the block name
  63465. */
  63466. constructor(name: string);
  63467. /**
  63468. * Gets the current class name
  63469. * @returns the class name
  63470. */
  63471. getClassName(): string;
  63472. /**
  63473. * Gets the world position component
  63474. */
  63475. get worldPosition(): NodeMaterialConnectionPoint;
  63476. /**
  63477. * Gets the camera position component
  63478. */
  63479. get cameraPosition(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the output component
  63482. */
  63483. get output(): NodeMaterialConnectionPoint;
  63484. autoConfigure(material: NodeMaterial): void;
  63485. protected _buildBlock(state: NodeMaterialBuildState): this;
  63486. }
  63487. }
  63488. declare module BABYLON {
  63489. /**
  63490. * Block used to compute fresnel value
  63491. */
  63492. export class FresnelBlock extends NodeMaterialBlock {
  63493. /**
  63494. * Create a new FresnelBlock
  63495. * @param name defines the block name
  63496. */
  63497. constructor(name: string);
  63498. /**
  63499. * Gets the current class name
  63500. * @returns the class name
  63501. */
  63502. getClassName(): string;
  63503. /**
  63504. * Gets the world normal input component
  63505. */
  63506. get worldNormal(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the view direction input component
  63509. */
  63510. get viewDirection(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the bias input component
  63513. */
  63514. get bias(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the camera (or eye) position component
  63517. */
  63518. get power(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the fresnel output component
  63521. */
  63522. get fresnel(): NodeMaterialConnectionPoint;
  63523. autoConfigure(material: NodeMaterial): void;
  63524. protected _buildBlock(state: NodeMaterialBuildState): this;
  63525. }
  63526. }
  63527. declare module BABYLON {
  63528. /**
  63529. * Block used to get the max of 2 values
  63530. */
  63531. export class MaxBlock extends NodeMaterialBlock {
  63532. /**
  63533. * Creates a new MaxBlock
  63534. * @param name defines the block name
  63535. */
  63536. constructor(name: string);
  63537. /**
  63538. * Gets the current class name
  63539. * @returns the class name
  63540. */
  63541. getClassName(): string;
  63542. /**
  63543. * Gets the left operand input component
  63544. */
  63545. get left(): NodeMaterialConnectionPoint;
  63546. /**
  63547. * Gets the right operand input component
  63548. */
  63549. get right(): NodeMaterialConnectionPoint;
  63550. /**
  63551. * Gets the output component
  63552. */
  63553. get output(): NodeMaterialConnectionPoint;
  63554. protected _buildBlock(state: NodeMaterialBuildState): this;
  63555. }
  63556. }
  63557. declare module BABYLON {
  63558. /**
  63559. * Block used to get the min of 2 values
  63560. */
  63561. export class MinBlock extends NodeMaterialBlock {
  63562. /**
  63563. * Creates a new MinBlock
  63564. * @param name defines the block name
  63565. */
  63566. constructor(name: string);
  63567. /**
  63568. * Gets the current class name
  63569. * @returns the class name
  63570. */
  63571. getClassName(): string;
  63572. /**
  63573. * Gets the left operand input component
  63574. */
  63575. get left(): NodeMaterialConnectionPoint;
  63576. /**
  63577. * Gets the right operand input component
  63578. */
  63579. get right(): NodeMaterialConnectionPoint;
  63580. /**
  63581. * Gets the output component
  63582. */
  63583. get output(): NodeMaterialConnectionPoint;
  63584. protected _buildBlock(state: NodeMaterialBuildState): this;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * Block used to get the distance between 2 values
  63590. */
  63591. export class DistanceBlock extends NodeMaterialBlock {
  63592. /**
  63593. * Creates a new DistanceBlock
  63594. * @param name defines the block name
  63595. */
  63596. constructor(name: string);
  63597. /**
  63598. * Gets the current class name
  63599. * @returns the class name
  63600. */
  63601. getClassName(): string;
  63602. /**
  63603. * Gets the left operand input component
  63604. */
  63605. get left(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the right operand input component
  63608. */
  63609. get right(): NodeMaterialConnectionPoint;
  63610. /**
  63611. * Gets the output component
  63612. */
  63613. get output(): NodeMaterialConnectionPoint;
  63614. protected _buildBlock(state: NodeMaterialBuildState): this;
  63615. }
  63616. }
  63617. declare module BABYLON {
  63618. /**
  63619. * Block used to get the length of a vector
  63620. */
  63621. export class LengthBlock extends NodeMaterialBlock {
  63622. /**
  63623. * Creates a new LengthBlock
  63624. * @param name defines the block name
  63625. */
  63626. constructor(name: string);
  63627. /**
  63628. * Gets the current class name
  63629. * @returns the class name
  63630. */
  63631. getClassName(): string;
  63632. /**
  63633. * Gets the value input component
  63634. */
  63635. get value(): NodeMaterialConnectionPoint;
  63636. /**
  63637. * Gets the output component
  63638. */
  63639. get output(): NodeMaterialConnectionPoint;
  63640. protected _buildBlock(state: NodeMaterialBuildState): this;
  63641. }
  63642. }
  63643. declare module BABYLON {
  63644. /**
  63645. * Block used to get negative version of a value (i.e. x * -1)
  63646. */
  63647. export class NegateBlock extends NodeMaterialBlock {
  63648. /**
  63649. * Creates a new NegateBlock
  63650. * @param name defines the block name
  63651. */
  63652. constructor(name: string);
  63653. /**
  63654. * Gets the current class name
  63655. * @returns the class name
  63656. */
  63657. getClassName(): string;
  63658. /**
  63659. * Gets the value input component
  63660. */
  63661. get value(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the output component
  63664. */
  63665. get output(): NodeMaterialConnectionPoint;
  63666. protected _buildBlock(state: NodeMaterialBuildState): this;
  63667. }
  63668. }
  63669. declare module BABYLON {
  63670. /**
  63671. * Block used to get the value of the first parameter raised to the power of the second
  63672. */
  63673. export class PowBlock extends NodeMaterialBlock {
  63674. /**
  63675. * Creates a new PowBlock
  63676. * @param name defines the block name
  63677. */
  63678. constructor(name: string);
  63679. /**
  63680. * Gets the current class name
  63681. * @returns the class name
  63682. */
  63683. getClassName(): string;
  63684. /**
  63685. * Gets the value operand input component
  63686. */
  63687. get value(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the power operand input component
  63690. */
  63691. get power(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the output component
  63694. */
  63695. get output(): NodeMaterialConnectionPoint;
  63696. protected _buildBlock(state: NodeMaterialBuildState): this;
  63697. }
  63698. }
  63699. declare module BABYLON {
  63700. /**
  63701. * Block used to get a random number
  63702. */
  63703. export class RandomNumberBlock extends NodeMaterialBlock {
  63704. /**
  63705. * Creates a new RandomNumberBlock
  63706. * @param name defines the block name
  63707. */
  63708. constructor(name: string);
  63709. /**
  63710. * Gets the current class name
  63711. * @returns the class name
  63712. */
  63713. getClassName(): string;
  63714. /**
  63715. * Gets the seed input component
  63716. */
  63717. get seed(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the output component
  63720. */
  63721. get output(): NodeMaterialConnectionPoint;
  63722. protected _buildBlock(state: NodeMaterialBuildState): this;
  63723. }
  63724. }
  63725. declare module BABYLON {
  63726. /**
  63727. * Block used to compute arc tangent of 2 values
  63728. */
  63729. export class ArcTan2Block extends NodeMaterialBlock {
  63730. /**
  63731. * Creates a new ArcTan2Block
  63732. * @param name defines the block name
  63733. */
  63734. constructor(name: string);
  63735. /**
  63736. * Gets the current class name
  63737. * @returns the class name
  63738. */
  63739. getClassName(): string;
  63740. /**
  63741. * Gets the x operand input component
  63742. */
  63743. get x(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the y operand input component
  63746. */
  63747. get y(): NodeMaterialConnectionPoint;
  63748. /**
  63749. * Gets the output component
  63750. */
  63751. get output(): NodeMaterialConnectionPoint;
  63752. protected _buildBlock(state: NodeMaterialBuildState): this;
  63753. }
  63754. }
  63755. declare module BABYLON {
  63756. /**
  63757. * Block used to smooth step a value
  63758. */
  63759. export class SmoothStepBlock extends NodeMaterialBlock {
  63760. /**
  63761. * Creates a new SmoothStepBlock
  63762. * @param name defines the block name
  63763. */
  63764. constructor(name: string);
  63765. /**
  63766. * Gets the current class name
  63767. * @returns the class name
  63768. */
  63769. getClassName(): string;
  63770. /**
  63771. * Gets the value operand input component
  63772. */
  63773. get value(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the first edge operand input component
  63776. */
  63777. get edge0(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the second edge operand input component
  63780. */
  63781. get edge1(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the output component
  63784. */
  63785. get output(): NodeMaterialConnectionPoint;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /**
  63791. * Block used to get the reciprocal (1 / x) of a value
  63792. */
  63793. export class ReciprocalBlock extends NodeMaterialBlock {
  63794. /**
  63795. * Creates a new ReciprocalBlock
  63796. * @param name defines the block name
  63797. */
  63798. constructor(name: string);
  63799. /**
  63800. * Gets the current class name
  63801. * @returns the class name
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Gets the input component
  63806. */
  63807. get input(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the output component
  63810. */
  63811. get output(): NodeMaterialConnectionPoint;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Block used to replace a color by another one
  63818. */
  63819. export class ReplaceColorBlock extends NodeMaterialBlock {
  63820. /**
  63821. * Creates a new ReplaceColorBlock
  63822. * @param name defines the block name
  63823. */
  63824. constructor(name: string);
  63825. /**
  63826. * Gets the current class name
  63827. * @returns the class name
  63828. */
  63829. getClassName(): string;
  63830. /**
  63831. * Gets the value input component
  63832. */
  63833. get value(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Gets the reference input component
  63836. */
  63837. get reference(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the distance input component
  63840. */
  63841. get distance(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the replacement input component
  63844. */
  63845. get replacement(): NodeMaterialConnectionPoint;
  63846. /**
  63847. * Gets the output component
  63848. */
  63849. get output(): NodeMaterialConnectionPoint;
  63850. protected _buildBlock(state: NodeMaterialBuildState): this;
  63851. }
  63852. }
  63853. declare module BABYLON {
  63854. /**
  63855. * Block used to posterize a value
  63856. * @see https://en.wikipedia.org/wiki/Posterization
  63857. */
  63858. export class PosterizeBlock extends NodeMaterialBlock {
  63859. /**
  63860. * Creates a new PosterizeBlock
  63861. * @param name defines the block name
  63862. */
  63863. constructor(name: string);
  63864. /**
  63865. * Gets the current class name
  63866. * @returns the class name
  63867. */
  63868. getClassName(): string;
  63869. /**
  63870. * Gets the value input component
  63871. */
  63872. get value(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the steps input component
  63875. */
  63876. get steps(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the output component
  63879. */
  63880. get output(): NodeMaterialConnectionPoint;
  63881. protected _buildBlock(state: NodeMaterialBuildState): this;
  63882. }
  63883. }
  63884. declare module BABYLON {
  63885. /**
  63886. * Operations supported by the Wave block
  63887. */
  63888. export enum WaveBlockKind {
  63889. /** SawTooth */
  63890. SawTooth = 0,
  63891. /** Square */
  63892. Square = 1,
  63893. /** Triangle */
  63894. Triangle = 2
  63895. }
  63896. /**
  63897. * Block used to apply wave operation to floats
  63898. */
  63899. export class WaveBlock extends NodeMaterialBlock {
  63900. /**
  63901. * Gets or sets the kibnd of wave to be applied by the block
  63902. */
  63903. kind: WaveBlockKind;
  63904. /**
  63905. * Creates a new WaveBlock
  63906. * @param name defines the block name
  63907. */
  63908. constructor(name: string);
  63909. /**
  63910. * Gets the current class name
  63911. * @returns the class name
  63912. */
  63913. getClassName(): string;
  63914. /**
  63915. * Gets the input component
  63916. */
  63917. get input(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the output component
  63920. */
  63921. get output(): NodeMaterialConnectionPoint;
  63922. protected _buildBlock(state: NodeMaterialBuildState): this;
  63923. serialize(): any;
  63924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * Class used to store a color step for the GradientBlock
  63930. */
  63931. export class GradientBlockColorStep {
  63932. /**
  63933. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63934. */
  63935. step: number;
  63936. /**
  63937. * Gets or sets the color associated with this step
  63938. */
  63939. color: Color3;
  63940. /**
  63941. * Creates a new GradientBlockColorStep
  63942. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63943. * @param color defines the color associated with this step
  63944. */
  63945. constructor(
  63946. /**
  63947. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63948. */
  63949. step: number,
  63950. /**
  63951. * Gets or sets the color associated with this step
  63952. */
  63953. color: Color3);
  63954. }
  63955. /**
  63956. * Block used to return a color from a gradient based on an input value between 0 and 1
  63957. */
  63958. export class GradientBlock extends NodeMaterialBlock {
  63959. /**
  63960. * Gets or sets the list of color steps
  63961. */
  63962. colorSteps: GradientBlockColorStep[];
  63963. /**
  63964. * Creates a new GradientBlock
  63965. * @param name defines the block name
  63966. */
  63967. constructor(name: string);
  63968. /**
  63969. * Gets the current class name
  63970. * @returns the class name
  63971. */
  63972. getClassName(): string;
  63973. /**
  63974. * Gets the gradient input component
  63975. */
  63976. get gradient(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the output component
  63979. */
  63980. get output(): NodeMaterialConnectionPoint;
  63981. private _writeColorConstant;
  63982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63983. serialize(): any;
  63984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63985. protected _dumpPropertiesCode(): string;
  63986. }
  63987. }
  63988. declare module BABYLON {
  63989. /**
  63990. * Block used to normalize lerp between 2 values
  63991. */
  63992. export class NLerpBlock extends NodeMaterialBlock {
  63993. /**
  63994. * Creates a new NLerpBlock
  63995. * @param name defines the block name
  63996. */
  63997. constructor(name: string);
  63998. /**
  63999. * Gets the current class name
  64000. * @returns the class name
  64001. */
  64002. getClassName(): string;
  64003. /**
  64004. * Gets the left operand input component
  64005. */
  64006. get left(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the right operand input component
  64009. */
  64010. get right(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the gradient operand input component
  64013. */
  64014. get gradient(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the output component
  64017. */
  64018. get output(): NodeMaterialConnectionPoint;
  64019. protected _buildBlock(state: NodeMaterialBuildState): this;
  64020. }
  64021. }
  64022. declare module BABYLON {
  64023. /**
  64024. * block used to Generate a Worley Noise 3D Noise Pattern
  64025. */
  64026. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64027. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64028. manhattanDistance: boolean;
  64029. /**
  64030. * Creates a new WorleyNoise3DBlock
  64031. * @param name defines the block name
  64032. */
  64033. constructor(name: string);
  64034. /**
  64035. * Gets the current class name
  64036. * @returns the class name
  64037. */
  64038. getClassName(): string;
  64039. /**
  64040. * Gets the seed input component
  64041. */
  64042. get seed(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the jitter input component
  64045. */
  64046. get jitter(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the output component
  64049. */
  64050. get output(): NodeMaterialConnectionPoint;
  64051. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64052. /**
  64053. * Exposes the properties to the UI?
  64054. */
  64055. protected _dumpPropertiesCode(): string;
  64056. /**
  64057. * Exposes the properties to the Seralize?
  64058. */
  64059. serialize(): any;
  64060. /**
  64061. * Exposes the properties to the deseralize?
  64062. */
  64063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64064. }
  64065. }
  64066. declare module BABYLON {
  64067. /**
  64068. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64069. */
  64070. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64071. /**
  64072. * Creates a new SimplexPerlin3DBlock
  64073. * @param name defines the block name
  64074. */
  64075. constructor(name: string);
  64076. /**
  64077. * Gets the current class name
  64078. * @returns the class name
  64079. */
  64080. getClassName(): string;
  64081. /**
  64082. * Gets the seed operand input component
  64083. */
  64084. get seed(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the output component
  64087. */
  64088. get output(): NodeMaterialConnectionPoint;
  64089. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64090. }
  64091. }
  64092. declare module BABYLON {
  64093. /**
  64094. * Block used to blend normals
  64095. */
  64096. export class NormalBlendBlock extends NodeMaterialBlock {
  64097. /**
  64098. * Creates a new NormalBlendBlock
  64099. * @param name defines the block name
  64100. */
  64101. constructor(name: string);
  64102. /**
  64103. * Gets the current class name
  64104. * @returns the class name
  64105. */
  64106. getClassName(): string;
  64107. /**
  64108. * Gets the first input component
  64109. */
  64110. get normalMap0(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the second input component
  64113. */
  64114. get normalMap1(): NodeMaterialConnectionPoint;
  64115. /**
  64116. * Gets the output component
  64117. */
  64118. get output(): NodeMaterialConnectionPoint;
  64119. protected _buildBlock(state: NodeMaterialBuildState): this;
  64120. }
  64121. }
  64122. declare module BABYLON {
  64123. /**
  64124. * Block used to rotate a 2d vector by a given angle
  64125. */
  64126. export class Rotate2dBlock extends NodeMaterialBlock {
  64127. /**
  64128. * Creates a new Rotate2dBlock
  64129. * @param name defines the block name
  64130. */
  64131. constructor(name: string);
  64132. /**
  64133. * Gets the current class name
  64134. * @returns the class name
  64135. */
  64136. getClassName(): string;
  64137. /**
  64138. * Gets the input vector
  64139. */
  64140. get input(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the input angle
  64143. */
  64144. get angle(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the output component
  64147. */
  64148. get output(): NodeMaterialConnectionPoint;
  64149. autoConfigure(material: NodeMaterial): void;
  64150. protected _buildBlock(state: NodeMaterialBuildState): this;
  64151. }
  64152. }
  64153. declare module BABYLON {
  64154. /**
  64155. * Block used to get the reflected vector from a direction and a normal
  64156. */
  64157. export class ReflectBlock extends NodeMaterialBlock {
  64158. /**
  64159. * Creates a new ReflectBlock
  64160. * @param name defines the block name
  64161. */
  64162. constructor(name: string);
  64163. /**
  64164. * Gets the current class name
  64165. * @returns the class name
  64166. */
  64167. getClassName(): string;
  64168. /**
  64169. * Gets the incident component
  64170. */
  64171. get incident(): NodeMaterialConnectionPoint;
  64172. /**
  64173. * Gets the normal component
  64174. */
  64175. get normal(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the output component
  64178. */
  64179. get output(): NodeMaterialConnectionPoint;
  64180. protected _buildBlock(state: NodeMaterialBuildState): this;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * Block used to get the refracted vector from a direction and a normal
  64186. */
  64187. export class RefractBlock extends NodeMaterialBlock {
  64188. /**
  64189. * Creates a new RefractBlock
  64190. * @param name defines the block name
  64191. */
  64192. constructor(name: string);
  64193. /**
  64194. * Gets the current class name
  64195. * @returns the class name
  64196. */
  64197. getClassName(): string;
  64198. /**
  64199. * Gets the incident component
  64200. */
  64201. get incident(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the normal component
  64204. */
  64205. get normal(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the index of refraction component
  64208. */
  64209. get ior(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the output component
  64212. */
  64213. get output(): NodeMaterialConnectionPoint;
  64214. protected _buildBlock(state: NodeMaterialBuildState): this;
  64215. }
  64216. }
  64217. declare module BABYLON {
  64218. /**
  64219. * Block used to desaturate a color
  64220. */
  64221. export class DesaturateBlock extends NodeMaterialBlock {
  64222. /**
  64223. * Creates a new DesaturateBlock
  64224. * @param name defines the block name
  64225. */
  64226. constructor(name: string);
  64227. /**
  64228. * Gets the current class name
  64229. * @returns the class name
  64230. */
  64231. getClassName(): string;
  64232. /**
  64233. * Gets the color operand input component
  64234. */
  64235. get color(): NodeMaterialConnectionPoint;
  64236. /**
  64237. * Gets the level operand input component
  64238. */
  64239. get level(): NodeMaterialConnectionPoint;
  64240. /**
  64241. * Gets the output component
  64242. */
  64243. get output(): NodeMaterialConnectionPoint;
  64244. protected _buildBlock(state: NodeMaterialBuildState): this;
  64245. }
  64246. }
  64247. declare module BABYLON {
  64248. /**
  64249. * Block used to implement the ambient occlusion module of the PBR material
  64250. */
  64251. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64252. /**
  64253. * Create a new AmbientOcclusionBlock
  64254. * @param name defines the block name
  64255. */
  64256. constructor(name: string);
  64257. /**
  64258. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64259. */
  64260. useAmbientInGrayScale: boolean;
  64261. /**
  64262. * Initialize the block and prepare the context for build
  64263. * @param state defines the state that will be used for the build
  64264. */
  64265. initialize(state: NodeMaterialBuildState): void;
  64266. /**
  64267. * Gets the current class name
  64268. * @returns the class name
  64269. */
  64270. getClassName(): string;
  64271. /**
  64272. * Gets the texture input component
  64273. */
  64274. get texture(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the texture intensity component
  64277. */
  64278. get intensity(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the direct light intensity input component
  64281. */
  64282. get directLightIntensity(): NodeMaterialConnectionPoint;
  64283. /**
  64284. * Gets the ambient occlusion object output component
  64285. */
  64286. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64287. /**
  64288. * Gets the main code of the block (fragment side)
  64289. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64290. * @returns the shader code
  64291. */
  64292. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64294. protected _buildBlock(state: NodeMaterialBuildState): this;
  64295. protected _dumpPropertiesCode(): string;
  64296. serialize(): any;
  64297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64298. }
  64299. }
  64300. declare module BABYLON {
  64301. /**
  64302. * Block used to implement the reflection module of the PBR material
  64303. */
  64304. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64305. /** @hidden */
  64306. _defineLODReflectionAlpha: string;
  64307. /** @hidden */
  64308. _defineLinearSpecularReflection: string;
  64309. private _vEnvironmentIrradianceName;
  64310. /** @hidden */
  64311. _vReflectionMicrosurfaceInfosName: string;
  64312. /** @hidden */
  64313. _vReflectionInfosName: string;
  64314. /** @hidden */
  64315. _vReflectionFilteringInfoName: string;
  64316. private _scene;
  64317. /**
  64318. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64319. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64320. * It's less burden on the user side in the editor part.
  64321. */
  64322. /** @hidden */
  64323. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64324. /** @hidden */
  64325. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64326. /** @hidden */
  64327. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64328. /**
  64329. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64330. * diffuse part of the IBL.
  64331. */
  64332. useSphericalHarmonics: boolean;
  64333. /**
  64334. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64335. */
  64336. forceIrradianceInFragment: boolean;
  64337. /**
  64338. * Create a new ReflectionBlock
  64339. * @param name defines the block name
  64340. */
  64341. constructor(name: string);
  64342. /**
  64343. * Gets the current class name
  64344. * @returns the class name
  64345. */
  64346. getClassName(): string;
  64347. /**
  64348. * Gets the position input component
  64349. */
  64350. get position(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the world position input component
  64353. */
  64354. get worldPosition(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the world normal input component
  64357. */
  64358. get worldNormal(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the world input component
  64361. */
  64362. get world(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the camera (or eye) position component
  64365. */
  64366. get cameraPosition(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the view input component
  64369. */
  64370. get view(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the color input component
  64373. */
  64374. get color(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the reflection object output component
  64377. */
  64378. get reflection(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64381. */
  64382. get hasTexture(): boolean;
  64383. /**
  64384. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64385. */
  64386. get reflectionColor(): string;
  64387. protected _getTexture(): Nullable<BaseTexture>;
  64388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64390. /**
  64391. * Gets the code to inject in the vertex shader
  64392. * @param state current state of the node material building
  64393. * @returns the shader code
  64394. */
  64395. handleVertexSide(state: NodeMaterialBuildState): string;
  64396. /**
  64397. * Gets the main code of the block (fragment side)
  64398. * @param state current state of the node material building
  64399. * @param normalVarName name of the existing variable corresponding to the normal
  64400. * @returns the shader code
  64401. */
  64402. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64403. protected _buildBlock(state: NodeMaterialBuildState): this;
  64404. protected _dumpPropertiesCode(): string;
  64405. serialize(): any;
  64406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64407. }
  64408. }
  64409. declare module BABYLON {
  64410. /**
  64411. * Block used to implement the sheen module of the PBR material
  64412. */
  64413. export class SheenBlock extends NodeMaterialBlock {
  64414. /**
  64415. * Create a new SheenBlock
  64416. * @param name defines the block name
  64417. */
  64418. constructor(name: string);
  64419. /**
  64420. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64421. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64422. * making it easier to setup and tweak the effect
  64423. */
  64424. albedoScaling: boolean;
  64425. /**
  64426. * Defines if the sheen is linked to the sheen color.
  64427. */
  64428. linkSheenWithAlbedo: boolean;
  64429. /**
  64430. * Initialize the block and prepare the context for build
  64431. * @param state defines the state that will be used for the build
  64432. */
  64433. initialize(state: NodeMaterialBuildState): void;
  64434. /**
  64435. * Gets the current class name
  64436. * @returns the class name
  64437. */
  64438. getClassName(): string;
  64439. /**
  64440. * Gets the intensity input component
  64441. */
  64442. get intensity(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the color input component
  64445. */
  64446. get color(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the roughness input component
  64449. */
  64450. get roughness(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the sheen object output component
  64453. */
  64454. get sheen(): NodeMaterialConnectionPoint;
  64455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64456. /**
  64457. * Gets the main code of the block (fragment side)
  64458. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64459. * @returns the shader code
  64460. */
  64461. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64462. protected _buildBlock(state: NodeMaterialBuildState): this;
  64463. protected _dumpPropertiesCode(): string;
  64464. serialize(): any;
  64465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /**
  64470. * Block used to implement the reflectivity module of the PBR material
  64471. */
  64472. export class ReflectivityBlock extends NodeMaterialBlock {
  64473. private _metallicReflectanceColor;
  64474. private _metallicF0Factor;
  64475. /** @hidden */
  64476. _vMetallicReflectanceFactorsName: string;
  64477. /**
  64478. * The property below is set by the main PBR block prior to calling methods of this class.
  64479. */
  64480. /** @hidden */
  64481. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64482. /**
  64483. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64484. */
  64485. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64486. /**
  64487. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64488. */
  64489. useMetallnessFromMetallicTextureBlue: boolean;
  64490. /**
  64491. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64492. */
  64493. useRoughnessFromMetallicTextureAlpha: boolean;
  64494. /**
  64495. * Specifies if the metallic texture contains the roughness information in its green channel.
  64496. */
  64497. useRoughnessFromMetallicTextureGreen: boolean;
  64498. /**
  64499. * Create a new ReflectivityBlock
  64500. * @param name defines the block name
  64501. */
  64502. constructor(name: string);
  64503. /**
  64504. * Initialize the block and prepare the context for build
  64505. * @param state defines the state that will be used for the build
  64506. */
  64507. initialize(state: NodeMaterialBuildState): void;
  64508. /**
  64509. * Gets the current class name
  64510. * @returns the class name
  64511. */
  64512. getClassName(): string;
  64513. /**
  64514. * Gets the metallic input component
  64515. */
  64516. get metallic(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the roughness input component
  64519. */
  64520. get roughness(): NodeMaterialConnectionPoint;
  64521. /**
  64522. * Gets the texture input component
  64523. */
  64524. get texture(): NodeMaterialConnectionPoint;
  64525. /**
  64526. * Gets the reflectivity object output component
  64527. */
  64528. get reflectivity(): NodeMaterialConnectionPoint;
  64529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64530. /**
  64531. * Gets the main code of the block (fragment side)
  64532. * @param state current state of the node material building
  64533. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64534. * @returns the shader code
  64535. */
  64536. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64538. protected _buildBlock(state: NodeMaterialBuildState): this;
  64539. protected _dumpPropertiesCode(): string;
  64540. serialize(): any;
  64541. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64542. }
  64543. }
  64544. declare module BABYLON {
  64545. /**
  64546. * Block used to implement the anisotropy module of the PBR material
  64547. */
  64548. export class AnisotropyBlock extends NodeMaterialBlock {
  64549. /**
  64550. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64551. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64552. * It's less burden on the user side in the editor part.
  64553. */
  64554. /** @hidden */
  64555. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64556. /** @hidden */
  64557. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64558. /**
  64559. * Create a new AnisotropyBlock
  64560. * @param name defines the block name
  64561. */
  64562. constructor(name: string);
  64563. /**
  64564. * Initialize the block and prepare the context for build
  64565. * @param state defines the state that will be used for the build
  64566. */
  64567. initialize(state: NodeMaterialBuildState): void;
  64568. /**
  64569. * Gets the current class name
  64570. * @returns the class name
  64571. */
  64572. getClassName(): string;
  64573. /**
  64574. * Gets the intensity input component
  64575. */
  64576. get intensity(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the direction input component
  64579. */
  64580. get direction(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the texture input component
  64583. */
  64584. get texture(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the uv input component
  64587. */
  64588. get uv(): NodeMaterialConnectionPoint;
  64589. /**
  64590. * Gets the worldTangent input component
  64591. */
  64592. get worldTangent(): NodeMaterialConnectionPoint;
  64593. /**
  64594. * Gets the anisotropy object output component
  64595. */
  64596. get anisotropy(): NodeMaterialConnectionPoint;
  64597. private _generateTBNSpace;
  64598. /**
  64599. * Gets the main code of the block (fragment side)
  64600. * @param state current state of the node material building
  64601. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64602. * @returns the shader code
  64603. */
  64604. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64606. protected _buildBlock(state: NodeMaterialBuildState): this;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Block used to implement the clear coat module of the PBR material
  64612. */
  64613. export class ClearCoatBlock extends NodeMaterialBlock {
  64614. private _scene;
  64615. /**
  64616. * Create a new ClearCoatBlock
  64617. * @param name defines the block name
  64618. */
  64619. constructor(name: string);
  64620. /**
  64621. * Initialize the block and prepare the context for build
  64622. * @param state defines the state that will be used for the build
  64623. */
  64624. initialize(state: NodeMaterialBuildState): void;
  64625. /**
  64626. * Gets the current class name
  64627. * @returns the class name
  64628. */
  64629. getClassName(): string;
  64630. /**
  64631. * Gets the intensity input component
  64632. */
  64633. get intensity(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the roughness input component
  64636. */
  64637. get roughness(): NodeMaterialConnectionPoint;
  64638. /**
  64639. * Gets the ior input component
  64640. */
  64641. get ior(): NodeMaterialConnectionPoint;
  64642. /**
  64643. * Gets the texture input component
  64644. */
  64645. get texture(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the bump texture input component
  64648. */
  64649. get bumpTexture(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the uv input component
  64652. */
  64653. get uv(): NodeMaterialConnectionPoint;
  64654. /**
  64655. * Gets the tint color input component
  64656. */
  64657. get tintColor(): NodeMaterialConnectionPoint;
  64658. /**
  64659. * Gets the tint "at distance" input component
  64660. */
  64661. get tintAtDistance(): NodeMaterialConnectionPoint;
  64662. /**
  64663. * Gets the tint thickness input component
  64664. */
  64665. get tintThickness(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the world tangent input component
  64668. */
  64669. get worldTangent(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the clear coat object output component
  64672. */
  64673. get clearcoat(): NodeMaterialConnectionPoint;
  64674. autoConfigure(material: NodeMaterial): void;
  64675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64677. private _generateTBNSpace;
  64678. /**
  64679. * Gets the main code of the block (fragment side)
  64680. * @param state current state of the node material building
  64681. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64682. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64683. * @param worldPosVarName name of the variable holding the world position
  64684. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64685. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64686. * @param worldNormalVarName name of the variable holding the world normal
  64687. * @returns the shader code
  64688. */
  64689. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64690. protected _buildBlock(state: NodeMaterialBuildState): this;
  64691. }
  64692. }
  64693. declare module BABYLON {
  64694. /**
  64695. * Block used to implement the sub surface module of the PBR material
  64696. */
  64697. export class SubSurfaceBlock extends NodeMaterialBlock {
  64698. /**
  64699. * Create a new SubSurfaceBlock
  64700. * @param name defines the block name
  64701. */
  64702. constructor(name: string);
  64703. /**
  64704. * Stores the intensity of the different subsurface effects in the thickness texture.
  64705. * * the green channel is the translucency intensity.
  64706. * * the blue channel is the scattering intensity.
  64707. * * the alpha channel is the refraction intensity.
  64708. */
  64709. useMaskFromThicknessTexture: boolean;
  64710. /**
  64711. * Initialize the block and prepare the context for build
  64712. * @param state defines the state that will be used for the build
  64713. */
  64714. initialize(state: NodeMaterialBuildState): void;
  64715. /**
  64716. * Gets the current class name
  64717. * @returns the class name
  64718. */
  64719. getClassName(): string;
  64720. /**
  64721. * Gets the min thickness input component
  64722. */
  64723. get minThickness(): NodeMaterialConnectionPoint;
  64724. /**
  64725. * Gets the max thickness input component
  64726. */
  64727. get maxThickness(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the thickness texture component
  64730. */
  64731. get thicknessTexture(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the tint color input component
  64734. */
  64735. get tintColor(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the translucency intensity input component
  64738. */
  64739. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the translucency diffusion distance input component
  64742. */
  64743. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the refraction object parameters
  64746. */
  64747. get refraction(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the sub surface object output component
  64750. */
  64751. get subsurface(): NodeMaterialConnectionPoint;
  64752. autoConfigure(material: NodeMaterial): void;
  64753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64754. /**
  64755. * Gets the main code of the block (fragment side)
  64756. * @param state current state of the node material building
  64757. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64758. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64759. * @param worldPosVarName name of the variable holding the world position
  64760. * @returns the shader code
  64761. */
  64762. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64763. protected _buildBlock(state: NodeMaterialBuildState): this;
  64764. }
  64765. }
  64766. declare module BABYLON {
  64767. /**
  64768. * Block used to implement the PBR metallic/roughness model
  64769. */
  64770. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64771. /**
  64772. * Gets or sets the light associated with this block
  64773. */
  64774. light: Nullable<Light>;
  64775. private _lightId;
  64776. private _scene;
  64777. private _environmentBRDFTexture;
  64778. private _environmentBrdfSamplerName;
  64779. private _vNormalWName;
  64780. private _invertNormalName;
  64781. /**
  64782. * Create a new ReflectionBlock
  64783. * @param name defines the block name
  64784. */
  64785. constructor(name: string);
  64786. /**
  64787. * Intensity of the direct lights e.g. the four lights available in your scene.
  64788. * This impacts both the direct diffuse and specular highlights.
  64789. */
  64790. directIntensity: number;
  64791. /**
  64792. * Intensity of the environment e.g. how much the environment will light the object
  64793. * either through harmonics for rough material or through the refelction for shiny ones.
  64794. */
  64795. environmentIntensity: number;
  64796. /**
  64797. * This is a special control allowing the reduction of the specular highlights coming from the
  64798. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64799. */
  64800. specularIntensity: number;
  64801. /**
  64802. * Defines the falloff type used in this material.
  64803. * It by default is Physical.
  64804. */
  64805. lightFalloff: number;
  64806. /**
  64807. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64808. */
  64809. useAlphaFromAlbedoTexture: boolean;
  64810. /**
  64811. * Specifies that alpha test should be used
  64812. */
  64813. useAlphaTest: boolean;
  64814. /**
  64815. * Defines the alpha limits in alpha test mode.
  64816. */
  64817. alphaTestCutoff: number;
  64818. /**
  64819. * Specifies that alpha blending should be used
  64820. */
  64821. useAlphaBlending: boolean;
  64822. /**
  64823. * Defines if the alpha value should be determined via the rgb values.
  64824. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64825. */
  64826. opacityRGB: boolean;
  64827. /**
  64828. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64829. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64830. */
  64831. useRadianceOverAlpha: boolean;
  64832. /**
  64833. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64834. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64835. */
  64836. useSpecularOverAlpha: boolean;
  64837. /**
  64838. * Enables specular anti aliasing in the PBR shader.
  64839. * It will both interacts on the Geometry for analytical and IBL lighting.
  64840. * It also prefilter the roughness map based on the bump values.
  64841. */
  64842. enableSpecularAntiAliasing: boolean;
  64843. /**
  64844. * Enables realtime filtering on the texture.
  64845. */
  64846. realTimeFiltering: boolean;
  64847. /**
  64848. * Quality switch for realtime filtering
  64849. */
  64850. realTimeFilteringQuality: number;
  64851. /**
  64852. * Defines if the material uses energy conservation.
  64853. */
  64854. useEnergyConservation: boolean;
  64855. /**
  64856. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64857. * too much the area relying on ambient texture to define their ambient occlusion.
  64858. */
  64859. useRadianceOcclusion: boolean;
  64860. /**
  64861. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64862. * makes the reflect vector face the model (under horizon).
  64863. */
  64864. useHorizonOcclusion: boolean;
  64865. /**
  64866. * If set to true, no lighting calculations will be applied.
  64867. */
  64868. unlit: boolean;
  64869. /**
  64870. * Force normal to face away from face.
  64871. */
  64872. forceNormalForward: boolean;
  64873. /**
  64874. * Defines the material debug mode.
  64875. * It helps seeing only some components of the material while troubleshooting.
  64876. */
  64877. debugMode: number;
  64878. /**
  64879. * Specify from where on screen the debug mode should start.
  64880. * The value goes from -1 (full screen) to 1 (not visible)
  64881. * It helps with side by side comparison against the final render
  64882. * This defaults to 0
  64883. */
  64884. debugLimit: number;
  64885. /**
  64886. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64887. * You can use the factor to better multiply the final value.
  64888. */
  64889. debugFactor: number;
  64890. /**
  64891. * Initialize the block and prepare the context for build
  64892. * @param state defines the state that will be used for the build
  64893. */
  64894. initialize(state: NodeMaterialBuildState): void;
  64895. /**
  64896. * Gets the current class name
  64897. * @returns the class name
  64898. */
  64899. getClassName(): string;
  64900. /**
  64901. * Gets the world position input component
  64902. */
  64903. get worldPosition(): NodeMaterialConnectionPoint;
  64904. /**
  64905. * Gets the world normal input component
  64906. */
  64907. get worldNormal(): NodeMaterialConnectionPoint;
  64908. /**
  64909. * Gets the perturbed normal input component
  64910. */
  64911. get perturbedNormal(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the camera position input component
  64914. */
  64915. get cameraPosition(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the base color input component
  64918. */
  64919. get baseColor(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the opacity texture input component
  64922. */
  64923. get opacityTexture(): NodeMaterialConnectionPoint;
  64924. /**
  64925. * Gets the ambient color input component
  64926. */
  64927. get ambientColor(): NodeMaterialConnectionPoint;
  64928. /**
  64929. * Gets the reflectivity object parameters
  64930. */
  64931. get reflectivity(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the ambient occlusion object parameters
  64934. */
  64935. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the reflection object parameters
  64938. */
  64939. get reflection(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the sheen object parameters
  64942. */
  64943. get sheen(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the clear coat object parameters
  64946. */
  64947. get clearcoat(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the sub surface object parameters
  64950. */
  64951. get subsurface(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the anisotropy object parameters
  64954. */
  64955. get anisotropy(): NodeMaterialConnectionPoint;
  64956. /**
  64957. * Gets the ambient output component
  64958. */
  64959. get ambient(): NodeMaterialConnectionPoint;
  64960. /**
  64961. * Gets the diffuse output component
  64962. */
  64963. get diffuse(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the specular output component
  64966. */
  64967. get specular(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the sheen output component
  64970. */
  64971. get sheenDir(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the clear coat output component
  64974. */
  64975. get clearcoatDir(): NodeMaterialConnectionPoint;
  64976. /**
  64977. * Gets the indirect diffuse output component
  64978. */
  64979. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the indirect specular output component
  64982. */
  64983. get specularIndirect(): NodeMaterialConnectionPoint;
  64984. /**
  64985. * Gets the indirect sheen output component
  64986. */
  64987. get sheenIndirect(): NodeMaterialConnectionPoint;
  64988. /**
  64989. * Gets the indirect clear coat output component
  64990. */
  64991. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64992. /**
  64993. * Gets the refraction output component
  64994. */
  64995. get refraction(): NodeMaterialConnectionPoint;
  64996. /**
  64997. * Gets the global lighting output component
  64998. */
  64999. get lighting(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the shadow output component
  65002. */
  65003. get shadow(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the alpha output component
  65006. */
  65007. get alpha(): NodeMaterialConnectionPoint;
  65008. autoConfigure(material: NodeMaterial): void;
  65009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65010. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65012. private _injectVertexCode;
  65013. /**
  65014. * Gets the code corresponding to the albedo/opacity module
  65015. * @returns the shader code
  65016. */
  65017. getAlbedoOpacityCode(): string;
  65018. protected _buildBlock(state: NodeMaterialBuildState): this;
  65019. protected _dumpPropertiesCode(): string;
  65020. serialize(): any;
  65021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /**
  65026. * Block used to compute value of one parameter modulo another
  65027. */
  65028. export class ModBlock extends NodeMaterialBlock {
  65029. /**
  65030. * Creates a new ModBlock
  65031. * @param name defines the block name
  65032. */
  65033. constructor(name: string);
  65034. /**
  65035. * Gets the current class name
  65036. * @returns the class name
  65037. */
  65038. getClassName(): string;
  65039. /**
  65040. * Gets the left operand input component
  65041. */
  65042. get left(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the right operand input component
  65045. */
  65046. get right(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the output component
  65049. */
  65050. get output(): NodeMaterialConnectionPoint;
  65051. protected _buildBlock(state: NodeMaterialBuildState): this;
  65052. }
  65053. }
  65054. declare module BABYLON {
  65055. /**
  65056. * Configuration for Draco compression
  65057. */
  65058. export interface IDracoCompressionConfiguration {
  65059. /**
  65060. * Configuration for the decoder.
  65061. */
  65062. decoder: {
  65063. /**
  65064. * The url to the WebAssembly module.
  65065. */
  65066. wasmUrl?: string;
  65067. /**
  65068. * The url to the WebAssembly binary.
  65069. */
  65070. wasmBinaryUrl?: string;
  65071. /**
  65072. * The url to the fallback JavaScript module.
  65073. */
  65074. fallbackUrl?: string;
  65075. };
  65076. }
  65077. /**
  65078. * Draco compression (https://google.github.io/draco/)
  65079. *
  65080. * This class wraps the Draco module.
  65081. *
  65082. * **Encoder**
  65083. *
  65084. * The encoder is not currently implemented.
  65085. *
  65086. * **Decoder**
  65087. *
  65088. * 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.
  65089. *
  65090. * To update the configuration, use the following code:
  65091. * ```javascript
  65092. * DracoCompression.Configuration = {
  65093. * decoder: {
  65094. * wasmUrl: "<url to the WebAssembly library>",
  65095. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65096. * fallbackUrl: "<url to the fallback JavaScript library>",
  65097. * }
  65098. * };
  65099. * ```
  65100. *
  65101. * 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.
  65102. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65103. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65104. *
  65105. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65106. * ```javascript
  65107. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65108. * ```
  65109. *
  65110. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65111. */
  65112. export class DracoCompression implements IDisposable {
  65113. private _workerPoolPromise?;
  65114. private _decoderModulePromise?;
  65115. /**
  65116. * The configuration. Defaults to the following urls:
  65117. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65118. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65119. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65120. */
  65121. static Configuration: IDracoCompressionConfiguration;
  65122. /**
  65123. * Returns true if the decoder configuration is available.
  65124. */
  65125. static get DecoderAvailable(): boolean;
  65126. /**
  65127. * Default number of workers to create when creating the draco compression object.
  65128. */
  65129. static DefaultNumWorkers: number;
  65130. private static GetDefaultNumWorkers;
  65131. private static _Default;
  65132. /**
  65133. * Default instance for the draco compression object.
  65134. */
  65135. static get Default(): DracoCompression;
  65136. /**
  65137. * Constructor
  65138. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65139. */
  65140. constructor(numWorkers?: number);
  65141. /**
  65142. * Stop all async operations and release resources.
  65143. */
  65144. dispose(): void;
  65145. /**
  65146. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65147. * @returns a promise that resolves when ready
  65148. */
  65149. whenReadyAsync(): Promise<void>;
  65150. /**
  65151. * Decode Draco compressed mesh data to vertex data.
  65152. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65153. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65154. * @returns A promise that resolves with the decoded vertex data
  65155. */
  65156. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65157. [kind: string]: number;
  65158. }): Promise<VertexData>;
  65159. }
  65160. }
  65161. declare module BABYLON {
  65162. /**
  65163. * Class for building Constructive Solid Geometry
  65164. */
  65165. export class CSG {
  65166. private polygons;
  65167. /**
  65168. * The world matrix
  65169. */
  65170. matrix: Matrix;
  65171. /**
  65172. * Stores the position
  65173. */
  65174. position: Vector3;
  65175. /**
  65176. * Stores the rotation
  65177. */
  65178. rotation: Vector3;
  65179. /**
  65180. * Stores the rotation quaternion
  65181. */
  65182. rotationQuaternion: Nullable<Quaternion>;
  65183. /**
  65184. * Stores the scaling vector
  65185. */
  65186. scaling: Vector3;
  65187. /**
  65188. * Convert the Mesh to CSG
  65189. * @param mesh The Mesh to convert to CSG
  65190. * @returns A new CSG from the Mesh
  65191. */
  65192. static FromMesh(mesh: Mesh): CSG;
  65193. /**
  65194. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65195. * @param polygons Polygons used to construct a CSG solid
  65196. */
  65197. private static FromPolygons;
  65198. /**
  65199. * Clones, or makes a deep copy, of the CSG
  65200. * @returns A new CSG
  65201. */
  65202. clone(): CSG;
  65203. /**
  65204. * Unions this CSG with another CSG
  65205. * @param csg The CSG to union against this CSG
  65206. * @returns The unioned CSG
  65207. */
  65208. union(csg: CSG): CSG;
  65209. /**
  65210. * Unions this CSG with another CSG in place
  65211. * @param csg The CSG to union against this CSG
  65212. */
  65213. unionInPlace(csg: CSG): void;
  65214. /**
  65215. * Subtracts this CSG with another CSG
  65216. * @param csg The CSG to subtract against this CSG
  65217. * @returns A new CSG
  65218. */
  65219. subtract(csg: CSG): CSG;
  65220. /**
  65221. * Subtracts this CSG with another CSG in place
  65222. * @param csg The CSG to subtact against this CSG
  65223. */
  65224. subtractInPlace(csg: CSG): void;
  65225. /**
  65226. * Intersect this CSG with another CSG
  65227. * @param csg The CSG to intersect against this CSG
  65228. * @returns A new CSG
  65229. */
  65230. intersect(csg: CSG): CSG;
  65231. /**
  65232. * Intersects this CSG with another CSG in place
  65233. * @param csg The CSG to intersect against this CSG
  65234. */
  65235. intersectInPlace(csg: CSG): void;
  65236. /**
  65237. * Return a new CSG solid with solid and empty space switched. This solid is
  65238. * not modified.
  65239. * @returns A new CSG solid with solid and empty space switched
  65240. */
  65241. inverse(): CSG;
  65242. /**
  65243. * Inverses the CSG in place
  65244. */
  65245. inverseInPlace(): void;
  65246. /**
  65247. * This is used to keep meshes transformations so they can be restored
  65248. * when we build back a Babylon Mesh
  65249. * NB : All CSG operations are performed in world coordinates
  65250. * @param csg The CSG to copy the transform attributes from
  65251. * @returns This CSG
  65252. */
  65253. copyTransformAttributes(csg: CSG): CSG;
  65254. /**
  65255. * Build Raw mesh from CSG
  65256. * Coordinates here are in world space
  65257. * @param name The name of the mesh geometry
  65258. * @param scene The Scene
  65259. * @param keepSubMeshes Specifies if the submeshes should be kept
  65260. * @returns A new Mesh
  65261. */
  65262. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65263. /**
  65264. * Build Mesh from CSG taking material and transforms into account
  65265. * @param name The name of the Mesh
  65266. * @param material The material of the Mesh
  65267. * @param scene The Scene
  65268. * @param keepSubMeshes Specifies if submeshes should be kept
  65269. * @returns The new Mesh
  65270. */
  65271. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65272. }
  65273. }
  65274. declare module BABYLON {
  65275. /**
  65276. * Class used to create a trail following a mesh
  65277. */
  65278. export class TrailMesh extends Mesh {
  65279. private _generator;
  65280. private _autoStart;
  65281. private _running;
  65282. private _diameter;
  65283. private _length;
  65284. private _sectionPolygonPointsCount;
  65285. private _sectionVectors;
  65286. private _sectionNormalVectors;
  65287. private _beforeRenderObserver;
  65288. /**
  65289. * @constructor
  65290. * @param name The value used by scene.getMeshByName() to do a lookup.
  65291. * @param generator The mesh or transform node to generate a trail.
  65292. * @param scene The scene to add this mesh to.
  65293. * @param diameter Diameter of trailing mesh. Default is 1.
  65294. * @param length Length of trailing mesh. Default is 60.
  65295. * @param autoStart Automatically start trailing mesh. Default true.
  65296. */
  65297. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65298. /**
  65299. * "TrailMesh"
  65300. * @returns "TrailMesh"
  65301. */
  65302. getClassName(): string;
  65303. private _createMesh;
  65304. /**
  65305. * Start trailing mesh.
  65306. */
  65307. start(): void;
  65308. /**
  65309. * Stop trailing mesh.
  65310. */
  65311. stop(): void;
  65312. /**
  65313. * Update trailing mesh geometry.
  65314. */
  65315. update(): void;
  65316. /**
  65317. * Returns a new TrailMesh object.
  65318. * @param name is a string, the name given to the new mesh
  65319. * @param newGenerator use new generator object for cloned trail mesh
  65320. * @returns a new mesh
  65321. */
  65322. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65323. /**
  65324. * Serializes this trail mesh
  65325. * @param serializationObject object to write serialization to
  65326. */
  65327. serialize(serializationObject: any): void;
  65328. /**
  65329. * Parses a serialized trail mesh
  65330. * @param parsedMesh the serialized mesh
  65331. * @param scene the scene to create the trail mesh in
  65332. * @returns the created trail mesh
  65333. */
  65334. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65335. }
  65336. }
  65337. declare module BABYLON {
  65338. /**
  65339. * Class containing static functions to help procedurally build meshes
  65340. */
  65341. export class TiledBoxBuilder {
  65342. /**
  65343. * Creates a box mesh
  65344. * 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)
  65345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65347. * * 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
  65348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65349. * @param name defines the name of the mesh
  65350. * @param options defines the options used to create the mesh
  65351. * @param scene defines the hosting scene
  65352. * @returns the box mesh
  65353. */
  65354. static CreateTiledBox(name: string, options: {
  65355. pattern?: number;
  65356. width?: number;
  65357. height?: number;
  65358. depth?: number;
  65359. tileSize?: number;
  65360. tileWidth?: number;
  65361. tileHeight?: number;
  65362. alignHorizontal?: number;
  65363. alignVertical?: number;
  65364. faceUV?: Vector4[];
  65365. faceColors?: Color4[];
  65366. sideOrientation?: number;
  65367. updatable?: boolean;
  65368. }, scene?: Nullable<Scene>): Mesh;
  65369. }
  65370. }
  65371. declare module BABYLON {
  65372. /**
  65373. * Class containing static functions to help procedurally build meshes
  65374. */
  65375. export class TorusKnotBuilder {
  65376. /**
  65377. * Creates a torus knot mesh
  65378. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65379. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65380. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65381. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65383. * * 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
  65384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65385. * @param name defines the name of the mesh
  65386. * @param options defines the options used to create the mesh
  65387. * @param scene defines the hosting scene
  65388. * @returns the torus knot mesh
  65389. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65390. */
  65391. static CreateTorusKnot(name: string, options: {
  65392. radius?: number;
  65393. tube?: number;
  65394. radialSegments?: number;
  65395. tubularSegments?: number;
  65396. p?: number;
  65397. q?: number;
  65398. updatable?: boolean;
  65399. sideOrientation?: number;
  65400. frontUVs?: Vector4;
  65401. backUVs?: Vector4;
  65402. }, scene: any): Mesh;
  65403. }
  65404. }
  65405. declare module BABYLON {
  65406. /**
  65407. * Polygon
  65408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65409. */
  65410. export class Polygon {
  65411. /**
  65412. * Creates a rectangle
  65413. * @param xmin bottom X coord
  65414. * @param ymin bottom Y coord
  65415. * @param xmax top X coord
  65416. * @param ymax top Y coord
  65417. * @returns points that make the resulting rectation
  65418. */
  65419. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65420. /**
  65421. * Creates a circle
  65422. * @param radius radius of circle
  65423. * @param cx scale in x
  65424. * @param cy scale in y
  65425. * @param numberOfSides number of sides that make up the circle
  65426. * @returns points that make the resulting circle
  65427. */
  65428. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65429. /**
  65430. * Creates a polygon from input string
  65431. * @param input Input polygon data
  65432. * @returns the parsed points
  65433. */
  65434. static Parse(input: string): Vector2[];
  65435. /**
  65436. * Starts building a polygon from x and y coordinates
  65437. * @param x x coordinate
  65438. * @param y y coordinate
  65439. * @returns the started path2
  65440. */
  65441. static StartingAt(x: number, y: number): Path2;
  65442. }
  65443. /**
  65444. * Builds a polygon
  65445. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65446. */
  65447. export class PolygonMeshBuilder {
  65448. private _points;
  65449. private _outlinepoints;
  65450. private _holes;
  65451. private _name;
  65452. private _scene;
  65453. private _epoints;
  65454. private _eholes;
  65455. private _addToepoint;
  65456. /**
  65457. * Babylon reference to the earcut plugin.
  65458. */
  65459. bjsEarcut: any;
  65460. /**
  65461. * Creates a PolygonMeshBuilder
  65462. * @param name name of the builder
  65463. * @param contours Path of the polygon
  65464. * @param scene scene to add to when creating the mesh
  65465. * @param earcutInjection can be used to inject your own earcut reference
  65466. */
  65467. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65468. /**
  65469. * Adds a whole within the polygon
  65470. * @param hole Array of points defining the hole
  65471. * @returns this
  65472. */
  65473. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65474. /**
  65475. * Creates the polygon
  65476. * @param updatable If the mesh should be updatable
  65477. * @param depth The depth of the mesh created
  65478. * @returns the created mesh
  65479. */
  65480. build(updatable?: boolean, depth?: number): Mesh;
  65481. /**
  65482. * Creates the polygon
  65483. * @param depth The depth of the mesh created
  65484. * @returns the created VertexData
  65485. */
  65486. buildVertexData(depth?: number): VertexData;
  65487. /**
  65488. * Adds a side to the polygon
  65489. * @param positions points that make the polygon
  65490. * @param normals normals of the polygon
  65491. * @param uvs uvs of the polygon
  65492. * @param indices indices of the polygon
  65493. * @param bounds bounds of the polygon
  65494. * @param points points of the polygon
  65495. * @param depth depth of the polygon
  65496. * @param flip flip of the polygon
  65497. */
  65498. private addSide;
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /**
  65503. * Class containing static functions to help procedurally build meshes
  65504. */
  65505. export class PolygonBuilder {
  65506. /**
  65507. * Creates a polygon mesh
  65508. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65509. * * 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
  65510. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65512. * * 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)
  65513. * * Remember you can only change the shape positions, not their number when updating a polygon
  65514. * @param name defines the name of the mesh
  65515. * @param options defines the options used to create the mesh
  65516. * @param scene defines the hosting scene
  65517. * @param earcutInjection can be used to inject your own earcut reference
  65518. * @returns the polygon mesh
  65519. */
  65520. static CreatePolygon(name: string, options: {
  65521. shape: Vector3[];
  65522. holes?: Vector3[][];
  65523. depth?: number;
  65524. faceUV?: Vector4[];
  65525. faceColors?: Color4[];
  65526. updatable?: boolean;
  65527. sideOrientation?: number;
  65528. frontUVs?: Vector4;
  65529. backUVs?: Vector4;
  65530. wrap?: boolean;
  65531. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65532. /**
  65533. * Creates an extruded polygon mesh, with depth in the Y direction.
  65534. * * 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)
  65535. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65536. * @param name defines the name of the mesh
  65537. * @param options defines the options used to create the mesh
  65538. * @param scene defines the hosting scene
  65539. * @param earcutInjection can be used to inject your own earcut reference
  65540. * @returns the polygon mesh
  65541. */
  65542. static ExtrudePolygon(name: string, options: {
  65543. shape: Vector3[];
  65544. holes?: Vector3[][];
  65545. depth?: number;
  65546. faceUV?: Vector4[];
  65547. faceColors?: Color4[];
  65548. updatable?: boolean;
  65549. sideOrientation?: number;
  65550. frontUVs?: Vector4;
  65551. backUVs?: Vector4;
  65552. wrap?: boolean;
  65553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65554. }
  65555. }
  65556. declare module BABYLON {
  65557. /**
  65558. * Class containing static functions to help procedurally build meshes
  65559. */
  65560. export class LatheBuilder {
  65561. /**
  65562. * Creates lathe mesh.
  65563. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65564. * * 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
  65565. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65566. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65567. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65568. * * 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
  65569. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65570. * * 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
  65571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65572. * * 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
  65573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65575. * @param name defines the name of the mesh
  65576. * @param options defines the options used to create the mesh
  65577. * @param scene defines the hosting scene
  65578. * @returns the lathe mesh
  65579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65580. */
  65581. static CreateLathe(name: string, options: {
  65582. shape: Vector3[];
  65583. radius?: number;
  65584. tessellation?: number;
  65585. clip?: number;
  65586. arc?: number;
  65587. closed?: boolean;
  65588. updatable?: boolean;
  65589. sideOrientation?: number;
  65590. frontUVs?: Vector4;
  65591. backUVs?: Vector4;
  65592. cap?: number;
  65593. invertUV?: boolean;
  65594. }, scene?: Nullable<Scene>): Mesh;
  65595. }
  65596. }
  65597. declare module BABYLON {
  65598. /**
  65599. * Class containing static functions to help procedurally build meshes
  65600. */
  65601. export class TiledPlaneBuilder {
  65602. /**
  65603. * Creates a tiled plane mesh
  65604. * * The parameter `pattern` will, depending on value, do nothing or
  65605. * * * flip (reflect about central vertical) alternate tiles across and up
  65606. * * * flip every tile on alternate rows
  65607. * * * rotate (180 degs) alternate tiles across and up
  65608. * * * rotate every tile on alternate rows
  65609. * * * flip and rotate alternate tiles across and up
  65610. * * * flip and rotate every tile on alternate rows
  65611. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65612. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65613. * * 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
  65614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65615. * * 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)
  65616. * * 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)
  65617. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65618. * @param name defines the name of the mesh
  65619. * @param options defines the options used to create the mesh
  65620. * @param scene defines the hosting scene
  65621. * @returns the box mesh
  65622. */
  65623. static CreateTiledPlane(name: string, options: {
  65624. pattern?: number;
  65625. tileSize?: number;
  65626. tileWidth?: number;
  65627. tileHeight?: number;
  65628. size?: number;
  65629. width?: number;
  65630. height?: number;
  65631. alignHorizontal?: number;
  65632. alignVertical?: number;
  65633. sideOrientation?: number;
  65634. frontUVs?: Vector4;
  65635. backUVs?: Vector4;
  65636. updatable?: boolean;
  65637. }, scene?: Nullable<Scene>): Mesh;
  65638. }
  65639. }
  65640. declare module BABYLON {
  65641. /**
  65642. * Class containing static functions to help procedurally build meshes
  65643. */
  65644. export class TubeBuilder {
  65645. /**
  65646. * Creates a tube mesh.
  65647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65652. * * 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)
  65653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65654. * * 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
  65655. * * 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
  65656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65657. * * 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
  65658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65660. * @param name defines the name of the mesh
  65661. * @param options defines the options used to create the mesh
  65662. * @param scene defines the hosting scene
  65663. * @returns the tube mesh
  65664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65666. */
  65667. static CreateTube(name: string, options: {
  65668. path: Vector3[];
  65669. radius?: number;
  65670. tessellation?: number;
  65671. radiusFunction?: {
  65672. (i: number, distance: number): number;
  65673. };
  65674. cap?: number;
  65675. arc?: number;
  65676. updatable?: boolean;
  65677. sideOrientation?: number;
  65678. frontUVs?: Vector4;
  65679. backUVs?: Vector4;
  65680. instance?: Mesh;
  65681. invertUV?: boolean;
  65682. }, scene?: Nullable<Scene>): Mesh;
  65683. }
  65684. }
  65685. declare module BABYLON {
  65686. /**
  65687. * Class containing static functions to help procedurally build meshes
  65688. */
  65689. export class IcoSphereBuilder {
  65690. /**
  65691. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65692. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65693. * * 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`)
  65694. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65695. * * 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
  65696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65697. * * 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
  65698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65699. * @param name defines the name of the mesh
  65700. * @param options defines the options used to create the mesh
  65701. * @param scene defines the hosting scene
  65702. * @returns the icosahedron mesh
  65703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65704. */
  65705. static CreateIcoSphere(name: string, options: {
  65706. radius?: number;
  65707. radiusX?: number;
  65708. radiusY?: number;
  65709. radiusZ?: number;
  65710. flat?: boolean;
  65711. subdivisions?: number;
  65712. sideOrientation?: number;
  65713. frontUVs?: Vector4;
  65714. backUVs?: Vector4;
  65715. updatable?: boolean;
  65716. }, scene?: Nullable<Scene>): Mesh;
  65717. }
  65718. }
  65719. declare module BABYLON {
  65720. /**
  65721. * Class containing static functions to help procedurally build meshes
  65722. */
  65723. export class DecalBuilder {
  65724. /**
  65725. * Creates a decal mesh.
  65726. * 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
  65727. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65728. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65729. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65730. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65731. * @param name defines the name of the mesh
  65732. * @param sourceMesh defines the mesh where the decal must be applied
  65733. * @param options defines the options used to create the mesh
  65734. * @param scene defines the hosting scene
  65735. * @returns the decal mesh
  65736. * @see https://doc.babylonjs.com/how_to/decals
  65737. */
  65738. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65739. position?: Vector3;
  65740. normal?: Vector3;
  65741. size?: Vector3;
  65742. angle?: number;
  65743. }): Mesh;
  65744. }
  65745. }
  65746. declare module BABYLON {
  65747. /**
  65748. * Class containing static functions to help procedurally build meshes
  65749. */
  65750. export class MeshBuilder {
  65751. /**
  65752. * Creates a box mesh
  65753. * * The parameter `size` sets the size (float) of each box side (default 1)
  65754. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65755. * * 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)
  65756. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65758. * * 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
  65759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65760. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65761. * @param name defines the name of the mesh
  65762. * @param options defines the options used to create the mesh
  65763. * @param scene defines the hosting scene
  65764. * @returns the box mesh
  65765. */
  65766. static CreateBox(name: string, options: {
  65767. size?: number;
  65768. width?: number;
  65769. height?: number;
  65770. depth?: number;
  65771. faceUV?: Vector4[];
  65772. faceColors?: Color4[];
  65773. sideOrientation?: number;
  65774. frontUVs?: Vector4;
  65775. backUVs?: Vector4;
  65776. wrap?: boolean;
  65777. topBaseAt?: number;
  65778. bottomBaseAt?: number;
  65779. updatable?: boolean;
  65780. }, scene?: Nullable<Scene>): Mesh;
  65781. /**
  65782. * Creates a tiled box mesh
  65783. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65785. * @param name defines the name of the mesh
  65786. * @param options defines the options used to create the mesh
  65787. * @param scene defines the hosting scene
  65788. * @returns the tiled box mesh
  65789. */
  65790. static CreateTiledBox(name: string, options: {
  65791. pattern?: number;
  65792. size?: number;
  65793. width?: number;
  65794. height?: number;
  65795. depth: number;
  65796. tileSize?: number;
  65797. tileWidth?: number;
  65798. tileHeight?: number;
  65799. faceUV?: Vector4[];
  65800. faceColors?: Color4[];
  65801. alignHorizontal?: number;
  65802. alignVertical?: number;
  65803. sideOrientation?: number;
  65804. updatable?: boolean;
  65805. }, scene?: Nullable<Scene>): Mesh;
  65806. /**
  65807. * Creates a sphere mesh
  65808. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65809. * * 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`)
  65810. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65811. * * 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
  65812. * * 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)
  65813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65814. * * 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
  65815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65816. * @param name defines the name of the mesh
  65817. * @param options defines the options used to create the mesh
  65818. * @param scene defines the hosting scene
  65819. * @returns the sphere mesh
  65820. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65821. */
  65822. static CreateSphere(name: string, options: {
  65823. segments?: number;
  65824. diameter?: number;
  65825. diameterX?: number;
  65826. diameterY?: number;
  65827. diameterZ?: number;
  65828. arc?: number;
  65829. slice?: number;
  65830. sideOrientation?: number;
  65831. frontUVs?: Vector4;
  65832. backUVs?: Vector4;
  65833. updatable?: boolean;
  65834. }, scene?: Nullable<Scene>): Mesh;
  65835. /**
  65836. * Creates a plane polygonal mesh. By default, this is a disc
  65837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65838. * * 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
  65839. * * 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
  65840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65841. * * 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
  65842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65843. * @param name defines the name of the mesh
  65844. * @param options defines the options used to create the mesh
  65845. * @param scene defines the hosting scene
  65846. * @returns the plane polygonal mesh
  65847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65848. */
  65849. static CreateDisc(name: string, options: {
  65850. radius?: number;
  65851. tessellation?: number;
  65852. arc?: number;
  65853. updatable?: boolean;
  65854. sideOrientation?: number;
  65855. frontUVs?: Vector4;
  65856. backUVs?: Vector4;
  65857. }, scene?: Nullable<Scene>): Mesh;
  65858. /**
  65859. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65860. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65861. * * 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`)
  65862. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65863. * * 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
  65864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65865. * * 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
  65866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65867. * @param name defines the name of the mesh
  65868. * @param options defines the options used to create the mesh
  65869. * @param scene defines the hosting scene
  65870. * @returns the icosahedron mesh
  65871. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65872. */
  65873. static CreateIcoSphere(name: string, options: {
  65874. radius?: number;
  65875. radiusX?: number;
  65876. radiusY?: number;
  65877. radiusZ?: number;
  65878. flat?: boolean;
  65879. subdivisions?: number;
  65880. sideOrientation?: number;
  65881. frontUVs?: Vector4;
  65882. backUVs?: Vector4;
  65883. updatable?: boolean;
  65884. }, scene?: Nullable<Scene>): Mesh;
  65885. /**
  65886. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65887. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65888. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65889. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65890. * * 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
  65891. * * 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
  65892. * * 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
  65893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65894. * * 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
  65895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65896. * * 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
  65897. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65898. * * 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
  65899. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65901. * @param name defines the name of the mesh
  65902. * @param options defines the options used to create the mesh
  65903. * @param scene defines the hosting scene
  65904. * @returns the ribbon mesh
  65905. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65907. */
  65908. static CreateRibbon(name: string, options: {
  65909. pathArray: Vector3[][];
  65910. closeArray?: boolean;
  65911. closePath?: boolean;
  65912. offset?: number;
  65913. updatable?: boolean;
  65914. sideOrientation?: number;
  65915. frontUVs?: Vector4;
  65916. backUVs?: Vector4;
  65917. instance?: Mesh;
  65918. invertUV?: boolean;
  65919. uvs?: Vector2[];
  65920. colors?: Color4[];
  65921. }, scene?: Nullable<Scene>): Mesh;
  65922. /**
  65923. * Creates a cylinder or a cone mesh
  65924. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65925. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65926. * * 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.
  65927. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65928. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65929. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65930. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65931. * * 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).
  65932. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65933. * * 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).
  65934. * * 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
  65935. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65936. * * 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
  65937. * * 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.
  65938. * * If `enclose` is false, a ring surface is one element.
  65939. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65940. * * 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
  65941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65942. * * 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
  65943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65944. * @param name defines the name of the mesh
  65945. * @param options defines the options used to create the mesh
  65946. * @param scene defines the hosting scene
  65947. * @returns the cylinder mesh
  65948. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65949. */
  65950. static CreateCylinder(name: string, options: {
  65951. height?: number;
  65952. diameterTop?: number;
  65953. diameterBottom?: number;
  65954. diameter?: number;
  65955. tessellation?: number;
  65956. subdivisions?: number;
  65957. arc?: number;
  65958. faceColors?: Color4[];
  65959. faceUV?: Vector4[];
  65960. updatable?: boolean;
  65961. hasRings?: boolean;
  65962. enclose?: boolean;
  65963. cap?: number;
  65964. sideOrientation?: number;
  65965. frontUVs?: Vector4;
  65966. backUVs?: Vector4;
  65967. }, scene?: Nullable<Scene>): Mesh;
  65968. /**
  65969. * Creates a torus mesh
  65970. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65971. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65972. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65974. * * 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
  65975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65976. * @param name defines the name of the mesh
  65977. * @param options defines the options used to create the mesh
  65978. * @param scene defines the hosting scene
  65979. * @returns the torus mesh
  65980. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65981. */
  65982. static CreateTorus(name: string, options: {
  65983. diameter?: number;
  65984. thickness?: number;
  65985. tessellation?: number;
  65986. updatable?: boolean;
  65987. sideOrientation?: number;
  65988. frontUVs?: Vector4;
  65989. backUVs?: Vector4;
  65990. }, scene?: Nullable<Scene>): Mesh;
  65991. /**
  65992. * Creates a torus knot mesh
  65993. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65994. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65995. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65996. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65998. * * 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
  65999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66000. * @param name defines the name of the mesh
  66001. * @param options defines the options used to create the mesh
  66002. * @param scene defines the hosting scene
  66003. * @returns the torus knot mesh
  66004. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66005. */
  66006. static CreateTorusKnot(name: string, options: {
  66007. radius?: number;
  66008. tube?: number;
  66009. radialSegments?: number;
  66010. tubularSegments?: number;
  66011. p?: number;
  66012. q?: number;
  66013. updatable?: boolean;
  66014. sideOrientation?: number;
  66015. frontUVs?: Vector4;
  66016. backUVs?: Vector4;
  66017. }, scene?: Nullable<Scene>): Mesh;
  66018. /**
  66019. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66020. * * 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
  66021. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66022. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66023. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66024. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66025. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66026. * * 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
  66027. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66030. * @param name defines the name of the new line system
  66031. * @param options defines the options used to create the line system
  66032. * @param scene defines the hosting scene
  66033. * @returns a new line system mesh
  66034. */
  66035. static CreateLineSystem(name: string, options: {
  66036. lines: Vector3[][];
  66037. updatable?: boolean;
  66038. instance?: Nullable<LinesMesh>;
  66039. colors?: Nullable<Color4[][]>;
  66040. useVertexAlpha?: boolean;
  66041. }, scene: Nullable<Scene>): LinesMesh;
  66042. /**
  66043. * Creates a line mesh
  66044. * 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
  66045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66046. * * The parameter `points` is an array successive Vector3
  66047. * * 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
  66048. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66050. * * When updating an instance, remember that only point positions can change, not the number of points
  66051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66053. * @param name defines the name of the new line system
  66054. * @param options defines the options used to create the line system
  66055. * @param scene defines the hosting scene
  66056. * @returns a new line mesh
  66057. */
  66058. static CreateLines(name: string, options: {
  66059. points: Vector3[];
  66060. updatable?: boolean;
  66061. instance?: Nullable<LinesMesh>;
  66062. colors?: Color4[];
  66063. useVertexAlpha?: boolean;
  66064. }, scene?: Nullable<Scene>): LinesMesh;
  66065. /**
  66066. * Creates a dashed line mesh
  66067. * * 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
  66068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66069. * * The parameter `points` is an array successive Vector3
  66070. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66071. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66072. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66073. * * 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
  66074. * * When updating an instance, remember that only point positions can change, not the number of points
  66075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66076. * @param name defines the name of the mesh
  66077. * @param options defines the options used to create the mesh
  66078. * @param scene defines the hosting scene
  66079. * @returns the dashed line mesh
  66080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66081. */
  66082. static CreateDashedLines(name: string, options: {
  66083. points: Vector3[];
  66084. dashSize?: number;
  66085. gapSize?: number;
  66086. dashNb?: number;
  66087. updatable?: boolean;
  66088. instance?: LinesMesh;
  66089. }, scene?: Nullable<Scene>): LinesMesh;
  66090. /**
  66091. * 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.
  66092. * * 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.
  66093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66094. * * 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.
  66095. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66096. * * 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
  66097. * * 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
  66098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66100. * * 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
  66101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66103. * @param name defines the name of the mesh
  66104. * @param options defines the options used to create the mesh
  66105. * @param scene defines the hosting scene
  66106. * @returns the extruded shape mesh
  66107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66109. */
  66110. static ExtrudeShape(name: string, options: {
  66111. shape: Vector3[];
  66112. path: Vector3[];
  66113. scale?: number;
  66114. rotation?: number;
  66115. cap?: number;
  66116. updatable?: boolean;
  66117. sideOrientation?: number;
  66118. frontUVs?: Vector4;
  66119. backUVs?: Vector4;
  66120. instance?: Mesh;
  66121. invertUV?: boolean;
  66122. }, scene?: Nullable<Scene>): Mesh;
  66123. /**
  66124. * Creates an custom extruded shape mesh.
  66125. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66126. * * 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.
  66127. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66128. * * 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
  66129. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66130. * * 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
  66131. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66132. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66133. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66134. * * 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
  66135. * * 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
  66136. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66138. * * 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
  66139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @returns the custom extruded shape mesh
  66145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66148. */
  66149. static ExtrudeShapeCustom(name: string, options: {
  66150. shape: Vector3[];
  66151. path: Vector3[];
  66152. scaleFunction?: any;
  66153. rotationFunction?: any;
  66154. ribbonCloseArray?: boolean;
  66155. ribbonClosePath?: boolean;
  66156. cap?: number;
  66157. updatable?: boolean;
  66158. sideOrientation?: number;
  66159. frontUVs?: Vector4;
  66160. backUVs?: Vector4;
  66161. instance?: Mesh;
  66162. invertUV?: boolean;
  66163. }, scene?: Nullable<Scene>): Mesh;
  66164. /**
  66165. * Creates lathe mesh.
  66166. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66167. * * 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
  66168. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66169. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66170. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66171. * * 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
  66172. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66173. * * 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
  66174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66175. * * 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
  66176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66178. * @param name defines the name of the mesh
  66179. * @param options defines the options used to create the mesh
  66180. * @param scene defines the hosting scene
  66181. * @returns the lathe mesh
  66182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66183. */
  66184. static CreateLathe(name: string, options: {
  66185. shape: Vector3[];
  66186. radius?: number;
  66187. tessellation?: number;
  66188. clip?: number;
  66189. arc?: number;
  66190. closed?: boolean;
  66191. updatable?: boolean;
  66192. sideOrientation?: number;
  66193. frontUVs?: Vector4;
  66194. backUVs?: Vector4;
  66195. cap?: number;
  66196. invertUV?: boolean;
  66197. }, scene?: Nullable<Scene>): Mesh;
  66198. /**
  66199. * Creates a tiled plane mesh
  66200. * * You can set a limited pattern arrangement with the tiles
  66201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66202. * * 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
  66203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66204. * @param name defines the name of the mesh
  66205. * @param options defines the options used to create the mesh
  66206. * @param scene defines the hosting scene
  66207. * @returns the plane mesh
  66208. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66209. */
  66210. static CreateTiledPlane(name: string, options: {
  66211. pattern?: number;
  66212. tileSize?: number;
  66213. tileWidth?: number;
  66214. tileHeight?: number;
  66215. size?: number;
  66216. width?: number;
  66217. height?: number;
  66218. alignHorizontal?: number;
  66219. alignVertical?: number;
  66220. sideOrientation?: number;
  66221. frontUVs?: Vector4;
  66222. backUVs?: Vector4;
  66223. updatable?: boolean;
  66224. }, scene?: Nullable<Scene>): Mesh;
  66225. /**
  66226. * Creates a plane mesh
  66227. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66228. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66229. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66231. * * 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
  66232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66233. * @param name defines the name of the mesh
  66234. * @param options defines the options used to create the mesh
  66235. * @param scene defines the hosting scene
  66236. * @returns the plane mesh
  66237. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66238. */
  66239. static CreatePlane(name: string, options: {
  66240. size?: number;
  66241. width?: number;
  66242. height?: number;
  66243. sideOrientation?: number;
  66244. frontUVs?: Vector4;
  66245. backUVs?: Vector4;
  66246. updatable?: boolean;
  66247. sourcePlane?: Plane;
  66248. }, scene?: Nullable<Scene>): Mesh;
  66249. /**
  66250. * Creates a ground mesh
  66251. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66252. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66254. * @param name defines the name of the mesh
  66255. * @param options defines the options used to create the mesh
  66256. * @param scene defines the hosting scene
  66257. * @returns the ground mesh
  66258. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66259. */
  66260. static CreateGround(name: string, options: {
  66261. width?: number;
  66262. height?: number;
  66263. subdivisions?: number;
  66264. subdivisionsX?: number;
  66265. subdivisionsY?: number;
  66266. updatable?: boolean;
  66267. }, scene?: Nullable<Scene>): Mesh;
  66268. /**
  66269. * Creates a tiled ground mesh
  66270. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66271. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66272. * * 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
  66273. * * 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
  66274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66275. * @param name defines the name of the mesh
  66276. * @param options defines the options used to create the mesh
  66277. * @param scene defines the hosting scene
  66278. * @returns the tiled ground mesh
  66279. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66280. */
  66281. static CreateTiledGround(name: string, options: {
  66282. xmin: number;
  66283. zmin: number;
  66284. xmax: number;
  66285. zmax: number;
  66286. subdivisions?: {
  66287. w: number;
  66288. h: number;
  66289. };
  66290. precision?: {
  66291. w: number;
  66292. h: number;
  66293. };
  66294. updatable?: boolean;
  66295. }, scene?: Nullable<Scene>): Mesh;
  66296. /**
  66297. * Creates a ground mesh from a height map
  66298. * * The parameter `url` sets the URL of the height map image resource.
  66299. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66300. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66301. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66302. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66303. * * 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.
  66304. * * 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).
  66305. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66307. * @param name defines the name of the mesh
  66308. * @param url defines the url to the height map
  66309. * @param options defines the options used to create the mesh
  66310. * @param scene defines the hosting scene
  66311. * @returns the ground mesh
  66312. * @see https://doc.babylonjs.com/babylon101/height_map
  66313. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66314. */
  66315. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66316. width?: number;
  66317. height?: number;
  66318. subdivisions?: number;
  66319. minHeight?: number;
  66320. maxHeight?: number;
  66321. colorFilter?: Color3;
  66322. alphaFilter?: number;
  66323. updatable?: boolean;
  66324. onReady?: (mesh: GroundMesh) => void;
  66325. }, scene?: Nullable<Scene>): GroundMesh;
  66326. /**
  66327. * Creates a polygon mesh
  66328. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66329. * * 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
  66330. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66332. * * 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)
  66333. * * Remember you can only change the shape positions, not their number when updating a polygon
  66334. * @param name defines the name of the mesh
  66335. * @param options defines the options used to create the mesh
  66336. * @param scene defines the hosting scene
  66337. * @param earcutInjection can be used to inject your own earcut reference
  66338. * @returns the polygon mesh
  66339. */
  66340. static CreatePolygon(name: string, options: {
  66341. shape: Vector3[];
  66342. holes?: Vector3[][];
  66343. depth?: number;
  66344. faceUV?: Vector4[];
  66345. faceColors?: Color4[];
  66346. updatable?: boolean;
  66347. sideOrientation?: number;
  66348. frontUVs?: Vector4;
  66349. backUVs?: Vector4;
  66350. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66351. /**
  66352. * Creates an extruded polygon mesh, with depth in the Y direction.
  66353. * * 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)
  66354. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66355. * @param name defines the name of the mesh
  66356. * @param options defines the options used to create the mesh
  66357. * @param scene defines the hosting scene
  66358. * @param earcutInjection can be used to inject your own earcut reference
  66359. * @returns the polygon mesh
  66360. */
  66361. static ExtrudePolygon(name: string, options: {
  66362. shape: Vector3[];
  66363. holes?: Vector3[][];
  66364. depth?: number;
  66365. faceUV?: Vector4[];
  66366. faceColors?: Color4[];
  66367. updatable?: boolean;
  66368. sideOrientation?: number;
  66369. frontUVs?: Vector4;
  66370. backUVs?: Vector4;
  66371. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66372. /**
  66373. * Creates a tube mesh.
  66374. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66375. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66376. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66377. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66378. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66379. * * 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)
  66380. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66381. * * 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
  66382. * * 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
  66383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66384. * * 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
  66385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66387. * @param name defines the name of the mesh
  66388. * @param options defines the options used to create the mesh
  66389. * @param scene defines the hosting scene
  66390. * @returns the tube mesh
  66391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66392. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66393. */
  66394. static CreateTube(name: string, options: {
  66395. path: Vector3[];
  66396. radius?: number;
  66397. tessellation?: number;
  66398. radiusFunction?: {
  66399. (i: number, distance: number): number;
  66400. };
  66401. cap?: number;
  66402. arc?: number;
  66403. updatable?: boolean;
  66404. sideOrientation?: number;
  66405. frontUVs?: Vector4;
  66406. backUVs?: Vector4;
  66407. instance?: Mesh;
  66408. invertUV?: boolean;
  66409. }, scene?: Nullable<Scene>): Mesh;
  66410. /**
  66411. * Creates a polyhedron mesh
  66412. * * 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
  66413. * * The parameter `size` (positive float, default 1) sets the polygon size
  66414. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66415. * * 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`
  66416. * * 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
  66417. * * 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)`)
  66418. * * 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
  66419. * * 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
  66420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66421. * * 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
  66422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66423. * @param name defines the name of the mesh
  66424. * @param options defines the options used to create the mesh
  66425. * @param scene defines the hosting scene
  66426. * @returns the polyhedron mesh
  66427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66428. */
  66429. static CreatePolyhedron(name: string, options: {
  66430. type?: number;
  66431. size?: number;
  66432. sizeX?: number;
  66433. sizeY?: number;
  66434. sizeZ?: number;
  66435. custom?: any;
  66436. faceUV?: Vector4[];
  66437. faceColors?: Color4[];
  66438. flat?: boolean;
  66439. updatable?: boolean;
  66440. sideOrientation?: number;
  66441. frontUVs?: Vector4;
  66442. backUVs?: Vector4;
  66443. }, scene?: Nullable<Scene>): Mesh;
  66444. /**
  66445. * Creates a decal mesh.
  66446. * 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
  66447. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66448. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66449. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66450. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66451. * @param name defines the name of the mesh
  66452. * @param sourceMesh defines the mesh where the decal must be applied
  66453. * @param options defines the options used to create the mesh
  66454. * @param scene defines the hosting scene
  66455. * @returns the decal mesh
  66456. * @see https://doc.babylonjs.com/how_to/decals
  66457. */
  66458. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66459. position?: Vector3;
  66460. normal?: Vector3;
  66461. size?: Vector3;
  66462. angle?: number;
  66463. }): Mesh;
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /**
  66468. * A simplifier interface for future simplification implementations
  66469. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66470. */
  66471. export interface ISimplifier {
  66472. /**
  66473. * Simplification of a given mesh according to the given settings.
  66474. * Since this requires computation, it is assumed that the function runs async.
  66475. * @param settings The settings of the simplification, including quality and distance
  66476. * @param successCallback A callback that will be called after the mesh was simplified.
  66477. * @param errorCallback in case of an error, this callback will be called. optional.
  66478. */
  66479. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66480. }
  66481. /**
  66482. * Expected simplification settings.
  66483. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66484. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66485. */
  66486. export interface ISimplificationSettings {
  66487. /**
  66488. * Gets or sets the expected quality
  66489. */
  66490. quality: number;
  66491. /**
  66492. * Gets or sets the distance when this optimized version should be used
  66493. */
  66494. distance: number;
  66495. /**
  66496. * Gets an already optimized mesh
  66497. */
  66498. optimizeMesh?: boolean;
  66499. }
  66500. /**
  66501. * Class used to specify simplification options
  66502. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66503. */
  66504. export class SimplificationSettings implements ISimplificationSettings {
  66505. /** expected quality */
  66506. quality: number;
  66507. /** distance when this optimized version should be used */
  66508. distance: number;
  66509. /** already optimized mesh */
  66510. optimizeMesh?: boolean | undefined;
  66511. /**
  66512. * Creates a SimplificationSettings
  66513. * @param quality expected quality
  66514. * @param distance distance when this optimized version should be used
  66515. * @param optimizeMesh already optimized mesh
  66516. */
  66517. constructor(
  66518. /** expected quality */
  66519. quality: number,
  66520. /** distance when this optimized version should be used */
  66521. distance: number,
  66522. /** already optimized mesh */
  66523. optimizeMesh?: boolean | undefined);
  66524. }
  66525. /**
  66526. * Interface used to define a simplification task
  66527. */
  66528. export interface ISimplificationTask {
  66529. /**
  66530. * Array of settings
  66531. */
  66532. settings: Array<ISimplificationSettings>;
  66533. /**
  66534. * Simplification type
  66535. */
  66536. simplificationType: SimplificationType;
  66537. /**
  66538. * Mesh to simplify
  66539. */
  66540. mesh: Mesh;
  66541. /**
  66542. * Callback called on success
  66543. */
  66544. successCallback?: () => void;
  66545. /**
  66546. * Defines if parallel processing can be used
  66547. */
  66548. parallelProcessing: boolean;
  66549. }
  66550. /**
  66551. * Queue used to order the simplification tasks
  66552. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66553. */
  66554. export class SimplificationQueue {
  66555. private _simplificationArray;
  66556. /**
  66557. * Gets a boolean indicating that the process is still running
  66558. */
  66559. running: boolean;
  66560. /**
  66561. * Creates a new queue
  66562. */
  66563. constructor();
  66564. /**
  66565. * Adds a new simplification task
  66566. * @param task defines a task to add
  66567. */
  66568. addTask(task: ISimplificationTask): void;
  66569. /**
  66570. * Execute next task
  66571. */
  66572. executeNext(): void;
  66573. /**
  66574. * Execute a simplification task
  66575. * @param task defines the task to run
  66576. */
  66577. runSimplification(task: ISimplificationTask): void;
  66578. private getSimplifier;
  66579. }
  66580. /**
  66581. * The implemented types of simplification
  66582. * At the moment only Quadratic Error Decimation is implemented
  66583. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66584. */
  66585. export enum SimplificationType {
  66586. /** Quadratic error decimation */
  66587. QUADRATIC = 0
  66588. }
  66589. /**
  66590. * An implementation of the Quadratic Error simplification algorithm.
  66591. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66592. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66593. * @author RaananW
  66594. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66595. */
  66596. export class QuadraticErrorSimplification implements ISimplifier {
  66597. private _mesh;
  66598. private triangles;
  66599. private vertices;
  66600. private references;
  66601. private _reconstructedMesh;
  66602. /** Gets or sets the number pf sync interations */
  66603. syncIterations: number;
  66604. /** Gets or sets the aggressiveness of the simplifier */
  66605. aggressiveness: number;
  66606. /** Gets or sets the number of allowed iterations for decimation */
  66607. decimationIterations: number;
  66608. /** Gets or sets the espilon to use for bounding box computation */
  66609. boundingBoxEpsilon: number;
  66610. /**
  66611. * Creates a new QuadraticErrorSimplification
  66612. * @param _mesh defines the target mesh
  66613. */
  66614. constructor(_mesh: Mesh);
  66615. /**
  66616. * Simplification of a given mesh according to the given settings.
  66617. * Since this requires computation, it is assumed that the function runs async.
  66618. * @param settings The settings of the simplification, including quality and distance
  66619. * @param successCallback A callback that will be called after the mesh was simplified.
  66620. */
  66621. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66622. private runDecimation;
  66623. private initWithMesh;
  66624. private init;
  66625. private reconstructMesh;
  66626. private initDecimatedMesh;
  66627. private isFlipped;
  66628. private updateTriangles;
  66629. private identifyBorder;
  66630. private updateMesh;
  66631. private vertexError;
  66632. private calculateError;
  66633. }
  66634. }
  66635. declare module BABYLON {
  66636. interface Scene {
  66637. /** @hidden (Backing field) */
  66638. _simplificationQueue: SimplificationQueue;
  66639. /**
  66640. * Gets or sets the simplification queue attached to the scene
  66641. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66642. */
  66643. simplificationQueue: SimplificationQueue;
  66644. }
  66645. interface Mesh {
  66646. /**
  66647. * Simplify the mesh according to the given array of settings.
  66648. * Function will return immediately and will simplify async
  66649. * @param settings a collection of simplification settings
  66650. * @param parallelProcessing should all levels calculate parallel or one after the other
  66651. * @param simplificationType the type of simplification to run
  66652. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66653. * @returns the current mesh
  66654. */
  66655. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66656. }
  66657. /**
  66658. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66659. * created in a scene
  66660. */
  66661. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66662. /**
  66663. * The component name helpfull to identify the component in the list of scene components.
  66664. */
  66665. readonly name: string;
  66666. /**
  66667. * The scene the component belongs to.
  66668. */
  66669. scene: Scene;
  66670. /**
  66671. * Creates a new instance of the component for the given scene
  66672. * @param scene Defines the scene to register the component in
  66673. */
  66674. constructor(scene: Scene);
  66675. /**
  66676. * Registers the component in a given scene
  66677. */
  66678. register(): void;
  66679. /**
  66680. * Rebuilds the elements related to this component in case of
  66681. * context lost for instance.
  66682. */
  66683. rebuild(): void;
  66684. /**
  66685. * Disposes the component and the associated ressources
  66686. */
  66687. dispose(): void;
  66688. private _beforeCameraUpdate;
  66689. }
  66690. }
  66691. declare module BABYLON {
  66692. interface Mesh {
  66693. /**
  66694. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66695. */
  66696. thinInstanceEnablePicking: boolean;
  66697. /**
  66698. * Creates a new thin instance
  66699. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66700. * @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
  66701. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66702. */
  66703. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66704. /**
  66705. * Adds the transformation (matrix) of the current mesh as a thin instance
  66706. * @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
  66707. * @returns the thin instance index number
  66708. */
  66709. thinInstanceAddSelf(refresh: boolean): number;
  66710. /**
  66711. * Registers a custom attribute to be used with thin instances
  66712. * @param kind name of the attribute
  66713. * @param stride size in floats of the attribute
  66714. */
  66715. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66716. /**
  66717. * Sets the matrix of a thin instance
  66718. * @param index index of the thin instance
  66719. * @param matrix matrix to set
  66720. * @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
  66721. */
  66722. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66723. /**
  66724. * Sets the value of a custom attribute for a thin instance
  66725. * @param kind name of the attribute
  66726. * @param index index of the thin instance
  66727. * @param value value to set
  66728. * @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
  66729. */
  66730. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66731. /**
  66732. * 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.
  66733. */
  66734. thinInstanceCount: number;
  66735. /**
  66736. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66737. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66738. * @param buffer buffer to set
  66739. * @param stride size in floats of each value of the buffer
  66740. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66741. */
  66742. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66743. /**
  66744. * Gets the list of world matrices
  66745. * @return an array containing all the world matrices from the thin instances
  66746. */
  66747. thinInstanceGetWorldMatrices(): Matrix[];
  66748. /**
  66749. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66750. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66751. */
  66752. thinInstanceBufferUpdated(kind: string): void;
  66753. /**
  66754. * Applies a partial update to a buffer directly on the GPU
  66755. * 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
  66756. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66757. * @param data the data to set in the GPU buffer
  66758. * @param offset the offset in the GPU buffer where to update the data
  66759. */
  66760. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66761. /**
  66762. * Refreshes the bounding info, taking into account all the thin instances defined
  66763. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66764. */
  66765. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66766. /** @hidden */
  66767. _thinInstanceInitializeUserStorage(): void;
  66768. /** @hidden */
  66769. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66770. /** @hidden */
  66771. _userThinInstanceBuffersStorage: {
  66772. data: {
  66773. [key: string]: Float32Array;
  66774. };
  66775. sizes: {
  66776. [key: string]: number;
  66777. };
  66778. vertexBuffers: {
  66779. [key: string]: Nullable<VertexBuffer>;
  66780. };
  66781. strides: {
  66782. [key: string]: number;
  66783. };
  66784. };
  66785. }
  66786. }
  66787. declare module BABYLON {
  66788. /**
  66789. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66790. */
  66791. export interface INavigationEnginePlugin {
  66792. /**
  66793. * plugin name
  66794. */
  66795. name: string;
  66796. /**
  66797. * Creates a navigation mesh
  66798. * @param meshes array of all the geometry used to compute the navigatio mesh
  66799. * @param parameters bunch of parameters used to filter geometry
  66800. */
  66801. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66802. /**
  66803. * Create a navigation mesh debug mesh
  66804. * @param scene is where the mesh will be added
  66805. * @returns debug display mesh
  66806. */
  66807. createDebugNavMesh(scene: Scene): Mesh;
  66808. /**
  66809. * Get a navigation mesh constrained position, closest to the parameter position
  66810. * @param position world position
  66811. * @returns the closest point to position constrained by the navigation mesh
  66812. */
  66813. getClosestPoint(position: Vector3): Vector3;
  66814. /**
  66815. * Get a navigation mesh constrained position, closest to the parameter position
  66816. * @param position world position
  66817. * @param result output the closest point to position constrained by the navigation mesh
  66818. */
  66819. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66820. /**
  66821. * Get a navigation mesh constrained position, within a particular radius
  66822. * @param position world position
  66823. * @param maxRadius the maximum distance to the constrained world position
  66824. * @returns the closest point to position constrained by the navigation mesh
  66825. */
  66826. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66827. /**
  66828. * Get a navigation mesh constrained position, within a particular radius
  66829. * @param position world position
  66830. * @param maxRadius the maximum distance to the constrained world position
  66831. * @param result output the closest point to position constrained by the navigation mesh
  66832. */
  66833. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66834. /**
  66835. * Compute the final position from a segment made of destination-position
  66836. * @param position world position
  66837. * @param destination world position
  66838. * @returns the resulting point along the navmesh
  66839. */
  66840. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66841. /**
  66842. * Compute the final position from a segment made of destination-position
  66843. * @param position world position
  66844. * @param destination world position
  66845. * @param result output the resulting point along the navmesh
  66846. */
  66847. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66848. /**
  66849. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66850. * @param start world position
  66851. * @param end world position
  66852. * @returns array containing world position composing the path
  66853. */
  66854. computePath(start: Vector3, end: Vector3): Vector3[];
  66855. /**
  66856. * If this plugin is supported
  66857. * @returns true if plugin is supported
  66858. */
  66859. isSupported(): boolean;
  66860. /**
  66861. * Create a new Crowd so you can add agents
  66862. * @param maxAgents the maximum agent count in the crowd
  66863. * @param maxAgentRadius the maximum radius an agent can have
  66864. * @param scene to attach the crowd to
  66865. * @returns the crowd you can add agents to
  66866. */
  66867. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66868. /**
  66869. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66870. * The queries will try to find a solution within those bounds
  66871. * default is (1,1,1)
  66872. * @param extent x,y,z value that define the extent around the queries point of reference
  66873. */
  66874. setDefaultQueryExtent(extent: Vector3): void;
  66875. /**
  66876. * Get the Bounding box extent specified by setDefaultQueryExtent
  66877. * @returns the box extent values
  66878. */
  66879. getDefaultQueryExtent(): Vector3;
  66880. /**
  66881. * build the navmesh from a previously saved state using getNavmeshData
  66882. * @param data the Uint8Array returned by getNavmeshData
  66883. */
  66884. buildFromNavmeshData(data: Uint8Array): void;
  66885. /**
  66886. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66887. * @returns data the Uint8Array that can be saved and reused
  66888. */
  66889. getNavmeshData(): Uint8Array;
  66890. /**
  66891. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66892. * @param result output the box extent values
  66893. */
  66894. getDefaultQueryExtentToRef(result: Vector3): void;
  66895. /**
  66896. * Release all resources
  66897. */
  66898. dispose(): void;
  66899. }
  66900. /**
  66901. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66902. */
  66903. export interface ICrowd {
  66904. /**
  66905. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66906. * You can attach anything to that node. The node position is updated in the scene update tick.
  66907. * @param pos world position that will be constrained by the navigation mesh
  66908. * @param parameters agent parameters
  66909. * @param transform hooked to the agent that will be update by the scene
  66910. * @returns agent index
  66911. */
  66912. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66913. /**
  66914. * Returns the agent position in world space
  66915. * @param index agent index returned by addAgent
  66916. * @returns world space position
  66917. */
  66918. getAgentPosition(index: number): Vector3;
  66919. /**
  66920. * Gets the agent position result in world space
  66921. * @param index agent index returned by addAgent
  66922. * @param result output world space position
  66923. */
  66924. getAgentPositionToRef(index: number, result: Vector3): void;
  66925. /**
  66926. * Gets the agent velocity in world space
  66927. * @param index agent index returned by addAgent
  66928. * @returns world space velocity
  66929. */
  66930. getAgentVelocity(index: number): Vector3;
  66931. /**
  66932. * Gets the agent velocity result in world space
  66933. * @param index agent index returned by addAgent
  66934. * @param result output world space velocity
  66935. */
  66936. getAgentVelocityToRef(index: number, result: Vector3): void;
  66937. /**
  66938. * remove a particular agent previously created
  66939. * @param index agent index returned by addAgent
  66940. */
  66941. removeAgent(index: number): void;
  66942. /**
  66943. * get the list of all agents attached to this crowd
  66944. * @returns list of agent indices
  66945. */
  66946. getAgents(): number[];
  66947. /**
  66948. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66949. * @param deltaTime in seconds
  66950. */
  66951. update(deltaTime: number): void;
  66952. /**
  66953. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66954. * @param index agent index returned by addAgent
  66955. * @param destination targeted world position
  66956. */
  66957. agentGoto(index: number, destination: Vector3): void;
  66958. /**
  66959. * Teleport the agent to a new position
  66960. * @param index agent index returned by addAgent
  66961. * @param destination targeted world position
  66962. */
  66963. agentTeleport(index: number, destination: Vector3): void;
  66964. /**
  66965. * Update agent parameters
  66966. * @param index agent index returned by addAgent
  66967. * @param parameters agent parameters
  66968. */
  66969. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66970. /**
  66971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66972. * The queries will try to find a solution within those bounds
  66973. * default is (1,1,1)
  66974. * @param extent x,y,z value that define the extent around the queries point of reference
  66975. */
  66976. setDefaultQueryExtent(extent: Vector3): void;
  66977. /**
  66978. * Get the Bounding box extent specified by setDefaultQueryExtent
  66979. * @returns the box extent values
  66980. */
  66981. getDefaultQueryExtent(): Vector3;
  66982. /**
  66983. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66984. * @param result output the box extent values
  66985. */
  66986. getDefaultQueryExtentToRef(result: Vector3): void;
  66987. /**
  66988. * Release all resources
  66989. */
  66990. dispose(): void;
  66991. }
  66992. /**
  66993. * Configures an agent
  66994. */
  66995. export interface IAgentParameters {
  66996. /**
  66997. * Agent radius. [Limit: >= 0]
  66998. */
  66999. radius: number;
  67000. /**
  67001. * Agent height. [Limit: > 0]
  67002. */
  67003. height: number;
  67004. /**
  67005. * Maximum allowed acceleration. [Limit: >= 0]
  67006. */
  67007. maxAcceleration: number;
  67008. /**
  67009. * Maximum allowed speed. [Limit: >= 0]
  67010. */
  67011. maxSpeed: number;
  67012. /**
  67013. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67014. */
  67015. collisionQueryRange: number;
  67016. /**
  67017. * The path visibility optimization range. [Limit: > 0]
  67018. */
  67019. pathOptimizationRange: number;
  67020. /**
  67021. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67022. */
  67023. separationWeight: number;
  67024. }
  67025. /**
  67026. * Configures the navigation mesh creation
  67027. */
  67028. export interface INavMeshParameters {
  67029. /**
  67030. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67031. */
  67032. cs: number;
  67033. /**
  67034. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67035. */
  67036. ch: number;
  67037. /**
  67038. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67039. */
  67040. walkableSlopeAngle: number;
  67041. /**
  67042. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67043. * be considered walkable. [Limit: >= 3] [Units: vx]
  67044. */
  67045. walkableHeight: number;
  67046. /**
  67047. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67048. */
  67049. walkableClimb: number;
  67050. /**
  67051. * The distance to erode/shrink the walkable area of the heightfield away from
  67052. * obstructions. [Limit: >=0] [Units: vx]
  67053. */
  67054. walkableRadius: number;
  67055. /**
  67056. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67057. */
  67058. maxEdgeLen: number;
  67059. /**
  67060. * The maximum distance a simplfied contour's border edges should deviate
  67061. * the original raw contour. [Limit: >=0] [Units: vx]
  67062. */
  67063. maxSimplificationError: number;
  67064. /**
  67065. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67066. */
  67067. minRegionArea: number;
  67068. /**
  67069. * Any regions with a span count smaller than this value will, if possible,
  67070. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67071. */
  67072. mergeRegionArea: number;
  67073. /**
  67074. * The maximum number of vertices allowed for polygons generated during the
  67075. * contour to polygon conversion process. [Limit: >= 3]
  67076. */
  67077. maxVertsPerPoly: number;
  67078. /**
  67079. * Sets the sampling distance to use when generating the detail mesh.
  67080. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67081. */
  67082. detailSampleDist: number;
  67083. /**
  67084. * The maximum distance the detail mesh surface should deviate from heightfield
  67085. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67086. */
  67087. detailSampleMaxError: number;
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /**
  67092. * RecastJS navigation plugin
  67093. */
  67094. export class RecastJSPlugin implements INavigationEnginePlugin {
  67095. /**
  67096. * Reference to the Recast library
  67097. */
  67098. bjsRECAST: any;
  67099. /**
  67100. * plugin name
  67101. */
  67102. name: string;
  67103. /**
  67104. * the first navmesh created. We might extend this to support multiple navmeshes
  67105. */
  67106. navMesh: any;
  67107. /**
  67108. * Initializes the recastJS plugin
  67109. * @param recastInjection can be used to inject your own recast reference
  67110. */
  67111. constructor(recastInjection?: any);
  67112. /**
  67113. * Creates a navigation mesh
  67114. * @param meshes array of all the geometry used to compute the navigatio mesh
  67115. * @param parameters bunch of parameters used to filter geometry
  67116. */
  67117. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67118. /**
  67119. * Create a navigation mesh debug mesh
  67120. * @param scene is where the mesh will be added
  67121. * @returns debug display mesh
  67122. */
  67123. createDebugNavMesh(scene: Scene): Mesh;
  67124. /**
  67125. * Get a navigation mesh constrained position, closest to the parameter position
  67126. * @param position world position
  67127. * @returns the closest point to position constrained by the navigation mesh
  67128. */
  67129. getClosestPoint(position: Vector3): Vector3;
  67130. /**
  67131. * Get a navigation mesh constrained position, closest to the parameter position
  67132. * @param position world position
  67133. * @param result output the closest point to position constrained by the navigation mesh
  67134. */
  67135. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67136. /**
  67137. * Get a navigation mesh constrained position, within a particular radius
  67138. * @param position world position
  67139. * @param maxRadius the maximum distance to the constrained world position
  67140. * @returns the closest point to position constrained by the navigation mesh
  67141. */
  67142. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67143. /**
  67144. * Get a navigation mesh constrained position, within a particular radius
  67145. * @param position world position
  67146. * @param maxRadius the maximum distance to the constrained world position
  67147. * @param result output the closest point to position constrained by the navigation mesh
  67148. */
  67149. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67150. /**
  67151. * Compute the final position from a segment made of destination-position
  67152. * @param position world position
  67153. * @param destination world position
  67154. * @returns the resulting point along the navmesh
  67155. */
  67156. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67157. /**
  67158. * Compute the final position from a segment made of destination-position
  67159. * @param position world position
  67160. * @param destination world position
  67161. * @param result output the resulting point along the navmesh
  67162. */
  67163. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67164. /**
  67165. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67166. * @param start world position
  67167. * @param end world position
  67168. * @returns array containing world position composing the path
  67169. */
  67170. computePath(start: Vector3, end: Vector3): Vector3[];
  67171. /**
  67172. * Create a new Crowd so you can add agents
  67173. * @param maxAgents the maximum agent count in the crowd
  67174. * @param maxAgentRadius the maximum radius an agent can have
  67175. * @param scene to attach the crowd to
  67176. * @returns the crowd you can add agents to
  67177. */
  67178. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67179. /**
  67180. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67181. * The queries will try to find a solution within those bounds
  67182. * default is (1,1,1)
  67183. * @param extent x,y,z value that define the extent around the queries point of reference
  67184. */
  67185. setDefaultQueryExtent(extent: Vector3): void;
  67186. /**
  67187. * Get the Bounding box extent specified by setDefaultQueryExtent
  67188. * @returns the box extent values
  67189. */
  67190. getDefaultQueryExtent(): Vector3;
  67191. /**
  67192. * build the navmesh from a previously saved state using getNavmeshData
  67193. * @param data the Uint8Array returned by getNavmeshData
  67194. */
  67195. buildFromNavmeshData(data: Uint8Array): void;
  67196. /**
  67197. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67198. * @returns data the Uint8Array that can be saved and reused
  67199. */
  67200. getNavmeshData(): Uint8Array;
  67201. /**
  67202. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67203. * @param result output the box extent values
  67204. */
  67205. getDefaultQueryExtentToRef(result: Vector3): void;
  67206. /**
  67207. * Disposes
  67208. */
  67209. dispose(): void;
  67210. /**
  67211. * If this plugin is supported
  67212. * @returns true if plugin is supported
  67213. */
  67214. isSupported(): boolean;
  67215. }
  67216. /**
  67217. * Recast detour crowd implementation
  67218. */
  67219. export class RecastJSCrowd implements ICrowd {
  67220. /**
  67221. * Recast/detour plugin
  67222. */
  67223. bjsRECASTPlugin: RecastJSPlugin;
  67224. /**
  67225. * Link to the detour crowd
  67226. */
  67227. recastCrowd: any;
  67228. /**
  67229. * One transform per agent
  67230. */
  67231. transforms: TransformNode[];
  67232. /**
  67233. * All agents created
  67234. */
  67235. agents: number[];
  67236. /**
  67237. * Link to the scene is kept to unregister the crowd from the scene
  67238. */
  67239. private _scene;
  67240. /**
  67241. * Observer for crowd updates
  67242. */
  67243. private _onBeforeAnimationsObserver;
  67244. /**
  67245. * Constructor
  67246. * @param plugin recastJS plugin
  67247. * @param maxAgents the maximum agent count in the crowd
  67248. * @param maxAgentRadius the maximum radius an agent can have
  67249. * @param scene to attach the crowd to
  67250. * @returns the crowd you can add agents to
  67251. */
  67252. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67253. /**
  67254. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67255. * You can attach anything to that node. The node position is updated in the scene update tick.
  67256. * @param pos world position that will be constrained by the navigation mesh
  67257. * @param parameters agent parameters
  67258. * @param transform hooked to the agent that will be update by the scene
  67259. * @returns agent index
  67260. */
  67261. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67262. /**
  67263. * Returns the agent position in world space
  67264. * @param index agent index returned by addAgent
  67265. * @returns world space position
  67266. */
  67267. getAgentPosition(index: number): Vector3;
  67268. /**
  67269. * Returns the agent position result in world space
  67270. * @param index agent index returned by addAgent
  67271. * @param result output world space position
  67272. */
  67273. getAgentPositionToRef(index: number, result: Vector3): void;
  67274. /**
  67275. * Returns the agent velocity in world space
  67276. * @param index agent index returned by addAgent
  67277. * @returns world space velocity
  67278. */
  67279. getAgentVelocity(index: number): Vector3;
  67280. /**
  67281. * Returns the agent velocity result in world space
  67282. * @param index agent index returned by addAgent
  67283. * @param result output world space velocity
  67284. */
  67285. getAgentVelocityToRef(index: number, result: Vector3): void;
  67286. /**
  67287. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67288. * @param index agent index returned by addAgent
  67289. * @param destination targeted world position
  67290. */
  67291. agentGoto(index: number, destination: Vector3): void;
  67292. /**
  67293. * Teleport the agent to a new position
  67294. * @param index agent index returned by addAgent
  67295. * @param destination targeted world position
  67296. */
  67297. agentTeleport(index: number, destination: Vector3): void;
  67298. /**
  67299. * Update agent parameters
  67300. * @param index agent index returned by addAgent
  67301. * @param parameters agent parameters
  67302. */
  67303. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67304. /**
  67305. * remove a particular agent previously created
  67306. * @param index agent index returned by addAgent
  67307. */
  67308. removeAgent(index: number): void;
  67309. /**
  67310. * get the list of all agents attached to this crowd
  67311. * @returns list of agent indices
  67312. */
  67313. getAgents(): number[];
  67314. /**
  67315. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67316. * @param deltaTime in seconds
  67317. */
  67318. update(deltaTime: number): void;
  67319. /**
  67320. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67321. * The queries will try to find a solution within those bounds
  67322. * default is (1,1,1)
  67323. * @param extent x,y,z value that define the extent around the queries point of reference
  67324. */
  67325. setDefaultQueryExtent(extent: Vector3): void;
  67326. /**
  67327. * Get the Bounding box extent specified by setDefaultQueryExtent
  67328. * @returns the box extent values
  67329. */
  67330. getDefaultQueryExtent(): Vector3;
  67331. /**
  67332. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67333. * @param result output the box extent values
  67334. */
  67335. getDefaultQueryExtentToRef(result: Vector3): void;
  67336. /**
  67337. * Release all resources
  67338. */
  67339. dispose(): void;
  67340. }
  67341. }
  67342. declare module BABYLON {
  67343. /**
  67344. * Class used to enable access to IndexedDB
  67345. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67346. */
  67347. export class Database implements IOfflineProvider {
  67348. private _callbackManifestChecked;
  67349. private _currentSceneUrl;
  67350. private _db;
  67351. private _enableSceneOffline;
  67352. private _enableTexturesOffline;
  67353. private _manifestVersionFound;
  67354. private _mustUpdateRessources;
  67355. private _hasReachedQuota;
  67356. private _isSupported;
  67357. private _idbFactory;
  67358. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67359. private static IsUASupportingBlobStorage;
  67360. /**
  67361. * Gets a boolean indicating if Database storate is enabled (off by default)
  67362. */
  67363. static IDBStorageEnabled: boolean;
  67364. /**
  67365. * Gets a boolean indicating if scene must be saved in the database
  67366. */
  67367. get enableSceneOffline(): boolean;
  67368. /**
  67369. * Gets a boolean indicating if textures must be saved in the database
  67370. */
  67371. get enableTexturesOffline(): boolean;
  67372. /**
  67373. * Creates a new Database
  67374. * @param urlToScene defines the url to load the scene
  67375. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67376. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67377. */
  67378. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67379. private static _ParseURL;
  67380. private static _ReturnFullUrlLocation;
  67381. private _checkManifestFile;
  67382. /**
  67383. * Open the database and make it available
  67384. * @param successCallback defines the callback to call on success
  67385. * @param errorCallback defines the callback to call on error
  67386. */
  67387. open(successCallback: () => void, errorCallback: () => void): void;
  67388. /**
  67389. * Loads an image from the database
  67390. * @param url defines the url to load from
  67391. * @param image defines the target DOM image
  67392. */
  67393. loadImage(url: string, image: HTMLImageElement): void;
  67394. private _loadImageFromDBAsync;
  67395. private _saveImageIntoDBAsync;
  67396. private _checkVersionFromDB;
  67397. private _loadVersionFromDBAsync;
  67398. private _saveVersionIntoDBAsync;
  67399. /**
  67400. * Loads a file from database
  67401. * @param url defines the URL to load from
  67402. * @param sceneLoaded defines a callback to call on success
  67403. * @param progressCallBack defines a callback to call when progress changed
  67404. * @param errorCallback defines a callback to call on error
  67405. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67406. */
  67407. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67408. private _loadFileAsync;
  67409. private _saveFileAsync;
  67410. /**
  67411. * Validates if xhr data is correct
  67412. * @param xhr defines the request to validate
  67413. * @param dataType defines the expected data type
  67414. * @returns true if data is correct
  67415. */
  67416. private static _ValidateXHRData;
  67417. }
  67418. }
  67419. declare module BABYLON {
  67420. /** @hidden */
  67421. export var gpuUpdateParticlesPixelShader: {
  67422. name: string;
  67423. shader: string;
  67424. };
  67425. }
  67426. declare module BABYLON {
  67427. /** @hidden */
  67428. export var gpuUpdateParticlesVertexShader: {
  67429. name: string;
  67430. shader: string;
  67431. };
  67432. }
  67433. declare module BABYLON {
  67434. /** @hidden */
  67435. export var clipPlaneFragmentDeclaration2: {
  67436. name: string;
  67437. shader: string;
  67438. };
  67439. }
  67440. declare module BABYLON {
  67441. /** @hidden */
  67442. export var gpuRenderParticlesPixelShader: {
  67443. name: string;
  67444. shader: string;
  67445. };
  67446. }
  67447. declare module BABYLON {
  67448. /** @hidden */
  67449. export var clipPlaneVertexDeclaration2: {
  67450. name: string;
  67451. shader: string;
  67452. };
  67453. }
  67454. declare module BABYLON {
  67455. /** @hidden */
  67456. export var gpuRenderParticlesVertexShader: {
  67457. name: string;
  67458. shader: string;
  67459. };
  67460. }
  67461. declare module BABYLON {
  67462. /**
  67463. * This represents a GPU particle system in Babylon
  67464. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67465. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67466. */
  67467. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67468. /**
  67469. * The layer mask we are rendering the particles through.
  67470. */
  67471. layerMask: number;
  67472. private _capacity;
  67473. private _activeCount;
  67474. private _currentActiveCount;
  67475. private _accumulatedCount;
  67476. private _renderEffect;
  67477. private _updateEffect;
  67478. private _buffer0;
  67479. private _buffer1;
  67480. private _spriteBuffer;
  67481. private _updateVAO;
  67482. private _renderVAO;
  67483. private _targetIndex;
  67484. private _sourceBuffer;
  67485. private _targetBuffer;
  67486. private _currentRenderId;
  67487. private _started;
  67488. private _stopped;
  67489. private _timeDelta;
  67490. private _randomTexture;
  67491. private _randomTexture2;
  67492. private _attributesStrideSize;
  67493. private _updateEffectOptions;
  67494. private _randomTextureSize;
  67495. private _actualFrame;
  67496. private _customEffect;
  67497. private readonly _rawTextureWidth;
  67498. /**
  67499. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67500. */
  67501. static get IsSupported(): boolean;
  67502. /**
  67503. * An event triggered when the system is disposed.
  67504. */
  67505. onDisposeObservable: Observable<IParticleSystem>;
  67506. /**
  67507. * Gets the maximum number of particles active at the same time.
  67508. * @returns The max number of active particles.
  67509. */
  67510. getCapacity(): number;
  67511. /**
  67512. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67513. * to override the particles.
  67514. */
  67515. forceDepthWrite: boolean;
  67516. /**
  67517. * Gets or set the number of active particles
  67518. */
  67519. get activeParticleCount(): number;
  67520. set activeParticleCount(value: number);
  67521. private _preWarmDone;
  67522. /**
  67523. * Specifies if the particles are updated in emitter local space or world space.
  67524. */
  67525. isLocal: boolean;
  67526. /** Gets or sets a matrix to use to compute projection */
  67527. defaultProjectionMatrix: Matrix;
  67528. /**
  67529. * Is this system ready to be used/rendered
  67530. * @return true if the system is ready
  67531. */
  67532. isReady(): boolean;
  67533. /**
  67534. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67535. * @returns True if it has been started, otherwise false.
  67536. */
  67537. isStarted(): boolean;
  67538. /**
  67539. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67540. * @returns True if it has been stopped, otherwise false.
  67541. */
  67542. isStopped(): boolean;
  67543. /**
  67544. * Gets a boolean indicating that the system is stopping
  67545. * @returns true if the system is currently stopping
  67546. */
  67547. isStopping(): boolean;
  67548. /**
  67549. * Gets the number of particles active at the same time.
  67550. * @returns The number of active particles.
  67551. */
  67552. getActiveCount(): number;
  67553. /**
  67554. * Starts the particle system and begins to emit
  67555. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67556. */
  67557. start(delay?: number): void;
  67558. /**
  67559. * Stops the particle system.
  67560. */
  67561. stop(): void;
  67562. /**
  67563. * Remove all active particles
  67564. */
  67565. reset(): void;
  67566. /**
  67567. * Returns the string "GPUParticleSystem"
  67568. * @returns a string containing the class name
  67569. */
  67570. getClassName(): string;
  67571. /**
  67572. * Gets the custom effect used to render the particles
  67573. * @param blendMode Blend mode for which the effect should be retrieved
  67574. * @returns The effect
  67575. */
  67576. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67577. /**
  67578. * Sets the custom effect used to render the particles
  67579. * @param effect The effect to set
  67580. * @param blendMode Blend mode for which the effect should be set
  67581. */
  67582. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67583. /** @hidden */
  67584. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67585. /**
  67586. * Observable that will be called just before the particles are drawn
  67587. */
  67588. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67589. /**
  67590. * Gets the name of the particle vertex shader
  67591. */
  67592. get vertexShaderName(): string;
  67593. private _colorGradientsTexture;
  67594. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67595. /**
  67596. * Adds a new color gradient
  67597. * @param gradient defines the gradient to use (between 0 and 1)
  67598. * @param color1 defines the color to affect to the specified gradient
  67599. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67600. * @returns the current particle system
  67601. */
  67602. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67603. private _refreshColorGradient;
  67604. /** Force the system to rebuild all gradients that need to be resync */
  67605. forceRefreshGradients(): void;
  67606. /**
  67607. * Remove a specific color gradient
  67608. * @param gradient defines the gradient to remove
  67609. * @returns the current particle system
  67610. */
  67611. removeColorGradient(gradient: number): GPUParticleSystem;
  67612. private _angularSpeedGradientsTexture;
  67613. private _sizeGradientsTexture;
  67614. private _velocityGradientsTexture;
  67615. private _limitVelocityGradientsTexture;
  67616. private _dragGradientsTexture;
  67617. private _addFactorGradient;
  67618. /**
  67619. * Adds a new size gradient
  67620. * @param gradient defines the gradient to use (between 0 and 1)
  67621. * @param factor defines the size factor to affect to the specified gradient
  67622. * @returns the current particle system
  67623. */
  67624. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67625. /**
  67626. * Remove a specific size gradient
  67627. * @param gradient defines the gradient to remove
  67628. * @returns the current particle system
  67629. */
  67630. removeSizeGradient(gradient: number): GPUParticleSystem;
  67631. private _refreshFactorGradient;
  67632. /**
  67633. * Adds a new angular speed gradient
  67634. * @param gradient defines the gradient to use (between 0 and 1)
  67635. * @param factor defines the angular speed to affect to the specified gradient
  67636. * @returns the current particle system
  67637. */
  67638. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67639. /**
  67640. * Remove a specific angular speed gradient
  67641. * @param gradient defines the gradient to remove
  67642. * @returns the current particle system
  67643. */
  67644. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67645. /**
  67646. * Adds a new velocity gradient
  67647. * @param gradient defines the gradient to use (between 0 and 1)
  67648. * @param factor defines the velocity to affect to the specified gradient
  67649. * @returns the current particle system
  67650. */
  67651. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67652. /**
  67653. * Remove a specific velocity gradient
  67654. * @param gradient defines the gradient to remove
  67655. * @returns the current particle system
  67656. */
  67657. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67658. /**
  67659. * Adds a new limit velocity gradient
  67660. * @param gradient defines the gradient to use (between 0 and 1)
  67661. * @param factor defines the limit velocity value to affect to the specified gradient
  67662. * @returns the current particle system
  67663. */
  67664. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67665. /**
  67666. * Remove a specific limit velocity gradient
  67667. * @param gradient defines the gradient to remove
  67668. * @returns the current particle system
  67669. */
  67670. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67671. /**
  67672. * Adds a new drag gradient
  67673. * @param gradient defines the gradient to use (between 0 and 1)
  67674. * @param factor defines the drag value to affect to the specified gradient
  67675. * @returns the current particle system
  67676. */
  67677. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67678. /**
  67679. * Remove a specific drag gradient
  67680. * @param gradient defines the gradient to remove
  67681. * @returns the current particle system
  67682. */
  67683. removeDragGradient(gradient: number): GPUParticleSystem;
  67684. /**
  67685. * Not supported by GPUParticleSystem
  67686. * @param gradient defines the gradient to use (between 0 and 1)
  67687. * @param factor defines the emit rate value to affect to the specified gradient
  67688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67689. * @returns the current particle system
  67690. */
  67691. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67692. /**
  67693. * Not supported by GPUParticleSystem
  67694. * @param gradient defines the gradient to remove
  67695. * @returns the current particle system
  67696. */
  67697. removeEmitRateGradient(gradient: number): IParticleSystem;
  67698. /**
  67699. * Not supported by GPUParticleSystem
  67700. * @param gradient defines the gradient to use (between 0 and 1)
  67701. * @param factor defines the start size value to affect to the specified gradient
  67702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67703. * @returns the current particle system
  67704. */
  67705. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67706. /**
  67707. * Not supported by GPUParticleSystem
  67708. * @param gradient defines the gradient to remove
  67709. * @returns the current particle system
  67710. */
  67711. removeStartSizeGradient(gradient: number): IParticleSystem;
  67712. /**
  67713. * Not supported by GPUParticleSystem
  67714. * @param gradient defines the gradient to use (between 0 and 1)
  67715. * @param min defines the color remap minimal range
  67716. * @param max defines the color remap maximal range
  67717. * @returns the current particle system
  67718. */
  67719. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67720. /**
  67721. * Not supported by GPUParticleSystem
  67722. * @param gradient defines the gradient to remove
  67723. * @returns the current particle system
  67724. */
  67725. removeColorRemapGradient(): IParticleSystem;
  67726. /**
  67727. * Not supported by GPUParticleSystem
  67728. * @param gradient defines the gradient to use (between 0 and 1)
  67729. * @param min defines the alpha remap minimal range
  67730. * @param max defines the alpha remap maximal range
  67731. * @returns the current particle system
  67732. */
  67733. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67734. /**
  67735. * Not supported by GPUParticleSystem
  67736. * @param gradient defines the gradient to remove
  67737. * @returns the current particle system
  67738. */
  67739. removeAlphaRemapGradient(): IParticleSystem;
  67740. /**
  67741. * Not supported by GPUParticleSystem
  67742. * @param gradient defines the gradient to use (between 0 and 1)
  67743. * @param color defines the color to affect to the specified gradient
  67744. * @returns the current particle system
  67745. */
  67746. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67747. /**
  67748. * Not supported by GPUParticleSystem
  67749. * @param gradient defines the gradient to remove
  67750. * @returns the current particle system
  67751. */
  67752. removeRampGradient(): IParticleSystem;
  67753. /**
  67754. * Not supported by GPUParticleSystem
  67755. * @returns the list of ramp gradients
  67756. */
  67757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67758. /**
  67759. * Not supported by GPUParticleSystem
  67760. * Gets or sets a boolean indicating that ramp gradients must be used
  67761. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67762. */
  67763. get useRampGradients(): boolean;
  67764. set useRampGradients(value: boolean);
  67765. /**
  67766. * Not supported by GPUParticleSystem
  67767. * @param gradient defines the gradient to use (between 0 and 1)
  67768. * @param factor defines the life time factor to affect to the specified gradient
  67769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67770. * @returns the current particle system
  67771. */
  67772. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67773. /**
  67774. * Not supported by GPUParticleSystem
  67775. * @param gradient defines the gradient to remove
  67776. * @returns the current particle system
  67777. */
  67778. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67779. /**
  67780. * Instantiates a GPU particle system.
  67781. * 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.
  67782. * @param name The name of the particle system
  67783. * @param options The options used to create the system
  67784. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67785. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67786. * @param customEffect a custom effect used to change the way particles are rendered by default
  67787. */
  67788. constructor(name: string, options: Partial<{
  67789. capacity: number;
  67790. randomTextureSize: number;
  67791. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67792. protected _reset(): void;
  67793. private _createUpdateVAO;
  67794. private _createRenderVAO;
  67795. private _initialize;
  67796. /** @hidden */
  67797. _recreateUpdateEffect(): void;
  67798. private _getEffect;
  67799. /**
  67800. * Fill the defines array according to the current settings of the particle system
  67801. * @param defines Array to be updated
  67802. * @param blendMode blend mode to take into account when updating the array
  67803. */
  67804. fillDefines(defines: Array<string>, blendMode?: number): void;
  67805. /**
  67806. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67807. * @param uniforms Uniforms array to fill
  67808. * @param attributes Attributes array to fill
  67809. * @param samplers Samplers array to fill
  67810. */
  67811. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67812. /** @hidden */
  67813. _recreateRenderEffect(): Effect;
  67814. /**
  67815. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67816. * @param preWarm defines if we are in the pre-warmimg phase
  67817. */
  67818. animate(preWarm?: boolean): void;
  67819. private _createFactorGradientTexture;
  67820. private _createSizeGradientTexture;
  67821. private _createAngularSpeedGradientTexture;
  67822. private _createVelocityGradientTexture;
  67823. private _createLimitVelocityGradientTexture;
  67824. private _createDragGradientTexture;
  67825. private _createColorGradientTexture;
  67826. /**
  67827. * Renders the particle system in its current state
  67828. * @param preWarm defines if the system should only update the particles but not render them
  67829. * @returns the current number of particles
  67830. */
  67831. render(preWarm?: boolean): number;
  67832. /**
  67833. * Rebuilds the particle system
  67834. */
  67835. rebuild(): void;
  67836. private _releaseBuffers;
  67837. private _releaseVAOs;
  67838. /**
  67839. * Disposes the particle system and free the associated resources
  67840. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67841. */
  67842. dispose(disposeTexture?: boolean): void;
  67843. /**
  67844. * Clones the particle system.
  67845. * @param name The name of the cloned object
  67846. * @param newEmitter The new emitter to use
  67847. * @returns the cloned particle system
  67848. */
  67849. clone(name: string, newEmitter: any): GPUParticleSystem;
  67850. /**
  67851. * Serializes the particle system to a JSON object
  67852. * @param serializeTexture defines if the texture must be serialized as well
  67853. * @returns the JSON object
  67854. */
  67855. serialize(serializeTexture?: boolean): any;
  67856. /**
  67857. * Parses a JSON object to create a GPU particle system.
  67858. * @param parsedParticleSystem The JSON object to parse
  67859. * @param sceneOrEngine The scene or the engine to create the particle system in
  67860. * @param rootUrl The root url to use to load external dependencies like texture
  67861. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67862. * @returns the parsed GPU particle system
  67863. */
  67864. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67865. }
  67866. }
  67867. declare module BABYLON {
  67868. /**
  67869. * Represents a set of particle systems working together to create a specific effect
  67870. */
  67871. export class ParticleSystemSet implements IDisposable {
  67872. /**
  67873. * Gets or sets base Assets URL
  67874. */
  67875. static BaseAssetsUrl: string;
  67876. private _emitterCreationOptions;
  67877. private _emitterNode;
  67878. /**
  67879. * Gets the particle system list
  67880. */
  67881. systems: IParticleSystem[];
  67882. /**
  67883. * Gets the emitter node used with this set
  67884. */
  67885. get emitterNode(): Nullable<TransformNode>;
  67886. /**
  67887. * Creates a new emitter mesh as a sphere
  67888. * @param options defines the options used to create the sphere
  67889. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67890. * @param scene defines the hosting scene
  67891. */
  67892. setEmitterAsSphere(options: {
  67893. diameter: number;
  67894. segments: number;
  67895. color: Color3;
  67896. }, renderingGroupId: number, scene: Scene): void;
  67897. /**
  67898. * Starts all particle systems of the set
  67899. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67900. */
  67901. start(emitter?: AbstractMesh): void;
  67902. /**
  67903. * Release all associated resources
  67904. */
  67905. dispose(): void;
  67906. /**
  67907. * Serialize the set into a JSON compatible object
  67908. * @param serializeTexture defines if the texture must be serialized as well
  67909. * @returns a JSON compatible representation of the set
  67910. */
  67911. serialize(serializeTexture?: boolean): any;
  67912. /**
  67913. * Parse a new ParticleSystemSet from a serialized source
  67914. * @param data defines a JSON compatible representation of the set
  67915. * @param scene defines the hosting scene
  67916. * @param gpu defines if we want GPU particles or CPU particles
  67917. * @returns a new ParticleSystemSet
  67918. */
  67919. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67920. }
  67921. }
  67922. declare module BABYLON {
  67923. /**
  67924. * This class is made for on one-liner static method to help creating particle system set.
  67925. */
  67926. export class ParticleHelper {
  67927. /**
  67928. * Gets or sets base Assets URL
  67929. */
  67930. static BaseAssetsUrl: string;
  67931. /** Define the Url to load snippets */
  67932. static SnippetUrl: string;
  67933. /**
  67934. * Create a default particle system that you can tweak
  67935. * @param emitter defines the emitter to use
  67936. * @param capacity defines the system capacity (default is 500 particles)
  67937. * @param scene defines the hosting scene
  67938. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67939. * @returns the new Particle system
  67940. */
  67941. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67942. /**
  67943. * This is the main static method (one-liner) of this helper to create different particle systems
  67944. * @param type This string represents the type to the particle system to create
  67945. * @param scene The scene where the particle system should live
  67946. * @param gpu If the system will use gpu
  67947. * @returns the ParticleSystemSet created
  67948. */
  67949. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67950. /**
  67951. * Static function used to export a particle system to a ParticleSystemSet variable.
  67952. * Please note that the emitter shape is not exported
  67953. * @param systems defines the particle systems to export
  67954. * @returns the created particle system set
  67955. */
  67956. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67957. /**
  67958. * Creates a particle system from a snippet saved in a remote file
  67959. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67960. * @param url defines the url to load from
  67961. * @param scene defines the hosting scene
  67962. * @param gpu If the system will use gpu
  67963. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67964. * @returns a promise that will resolve to the new particle system
  67965. */
  67966. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67967. /**
  67968. * Creates a particle system from a snippet saved by the particle system editor
  67969. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67970. * @param scene defines the hosting scene
  67971. * @param gpu If the system will use gpu
  67972. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67973. * @returns a promise that will resolve to the new particle system
  67974. */
  67975. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67976. }
  67977. }
  67978. declare module BABYLON {
  67979. interface Engine {
  67980. /**
  67981. * Create an effect to use with particle systems.
  67982. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67983. * the particle system for which you want to create a custom effect in the last parameter
  67984. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67985. * @param uniformsNames defines a list of attribute names
  67986. * @param samplers defines an array of string used to represent textures
  67987. * @param defines defines the string containing the defines to use to compile the shaders
  67988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67989. * @param onCompiled defines a function to call when the effect creation is successful
  67990. * @param onError defines a function to call when the effect creation has failed
  67991. * @param particleSystem the particle system you want to create the effect for
  67992. * @returns the new Effect
  67993. */
  67994. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67995. }
  67996. interface Mesh {
  67997. /**
  67998. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67999. * @returns an array of IParticleSystem
  68000. */
  68001. getEmittedParticleSystems(): IParticleSystem[];
  68002. /**
  68003. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68004. * @returns an array of IParticleSystem
  68005. */
  68006. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /** Defines the 4 color options */
  68011. export enum PointColor {
  68012. /** color value */
  68013. Color = 2,
  68014. /** uv value */
  68015. UV = 1,
  68016. /** random value */
  68017. Random = 0,
  68018. /** stated value */
  68019. Stated = 3
  68020. }
  68021. /**
  68022. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68023. * 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.
  68024. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68025. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68026. *
  68027. * Full documentation here : TO BE ENTERED
  68028. */
  68029. export class PointsCloudSystem implements IDisposable {
  68030. /**
  68031. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68032. * Example : var p = SPS.particles[i];
  68033. */
  68034. particles: CloudPoint[];
  68035. /**
  68036. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68037. */
  68038. nbParticles: number;
  68039. /**
  68040. * This a counter for your own usage. It's not set by any SPS functions.
  68041. */
  68042. counter: number;
  68043. /**
  68044. * The PCS name. This name is also given to the underlying mesh.
  68045. */
  68046. name: string;
  68047. /**
  68048. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68049. */
  68050. mesh: Mesh;
  68051. /**
  68052. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68053. * Please read :
  68054. */
  68055. vars: any;
  68056. /**
  68057. * @hidden
  68058. */
  68059. _size: number;
  68060. private _scene;
  68061. private _promises;
  68062. private _positions;
  68063. private _indices;
  68064. private _normals;
  68065. private _colors;
  68066. private _uvs;
  68067. private _indices32;
  68068. private _positions32;
  68069. private _colors32;
  68070. private _uvs32;
  68071. private _updatable;
  68072. private _isVisibilityBoxLocked;
  68073. private _alwaysVisible;
  68074. private _groups;
  68075. private _groupCounter;
  68076. private _computeParticleColor;
  68077. private _computeParticleTexture;
  68078. private _computeParticleRotation;
  68079. private _computeBoundingBox;
  68080. private _isReady;
  68081. /**
  68082. * Creates a PCS (Points Cloud System) object
  68083. * @param name (String) is the PCS name, this will be the underlying mesh name
  68084. * @param pointSize (number) is the size for each point
  68085. * @param scene (Scene) is the scene in which the PCS is added
  68086. * @param options defines the options of the PCS e.g.
  68087. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68088. */
  68089. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68090. updatable?: boolean;
  68091. });
  68092. /**
  68093. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68094. * If no points were added to the PCS, the returned mesh is just a single point.
  68095. * @returns a promise for the created mesh
  68096. */
  68097. buildMeshAsync(): Promise<Mesh>;
  68098. /**
  68099. * @hidden
  68100. */
  68101. private _buildMesh;
  68102. private _addParticle;
  68103. private _randomUnitVector;
  68104. private _getColorIndicesForCoord;
  68105. private _setPointsColorOrUV;
  68106. private _colorFromTexture;
  68107. private _calculateDensity;
  68108. /**
  68109. * Adds points to the PCS in random positions within a unit sphere
  68110. * @param nb (positive integer) the number of particles to be created from this model
  68111. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68112. * @returns the number of groups in the system
  68113. */
  68114. addPoints(nb: number, pointFunction?: any): number;
  68115. /**
  68116. * Adds points to the PCS from the surface of the model shape
  68117. * @param mesh is any Mesh object that will be used as a surface model for the points
  68118. * @param nb (positive integer) the number of particles to be created from this model
  68119. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68120. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68121. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68122. * @returns the number of groups in the system
  68123. */
  68124. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68125. /**
  68126. * Adds points to the PCS inside the model shape
  68127. * @param mesh is any Mesh object that will be used as a surface model for the points
  68128. * @param nb (positive integer) the number of particles to be created from this model
  68129. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68130. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68131. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68132. * @returns the number of groups in the system
  68133. */
  68134. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68135. /**
  68136. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68137. * This method calls `updateParticle()` for each particle of the SPS.
  68138. * For an animated SPS, it is usually called within the render loop.
  68139. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68140. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68141. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68142. * @returns the PCS.
  68143. */
  68144. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68145. /**
  68146. * Disposes the PCS.
  68147. */
  68148. dispose(): void;
  68149. /**
  68150. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68151. * doc :
  68152. * @returns the PCS.
  68153. */
  68154. refreshVisibleSize(): PointsCloudSystem;
  68155. /**
  68156. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68157. * @param size the size (float) of the visibility box
  68158. * note : this doesn't lock the PCS mesh bounding box.
  68159. * doc :
  68160. */
  68161. setVisibilityBox(size: number): void;
  68162. /**
  68163. * Gets whether the PCS is always visible or not
  68164. * doc :
  68165. */
  68166. get isAlwaysVisible(): boolean;
  68167. /**
  68168. * Sets the PCS as always visible or not
  68169. * doc :
  68170. */
  68171. set isAlwaysVisible(val: boolean);
  68172. /**
  68173. * Tells to `setParticles()` to compute the particle rotations or not
  68174. * Default value : false. The PCS is faster when it's set to false
  68175. * Note : particle rotations are only applied to parent particles
  68176. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68177. */
  68178. set computeParticleRotation(val: boolean);
  68179. /**
  68180. * Tells to `setParticles()` to compute the particle colors or not.
  68181. * Default value : true. The PCS is faster when it's set to false.
  68182. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68183. */
  68184. set computeParticleColor(val: boolean);
  68185. set computeParticleTexture(val: boolean);
  68186. /**
  68187. * Gets if `setParticles()` computes the particle colors or not.
  68188. * Default value : false. The PCS is faster when it's set to false.
  68189. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68190. */
  68191. get computeParticleColor(): boolean;
  68192. /**
  68193. * Gets if `setParticles()` computes the particle textures or not.
  68194. * Default value : false. The PCS is faster when it's set to false.
  68195. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68196. */
  68197. get computeParticleTexture(): boolean;
  68198. /**
  68199. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68200. */
  68201. set computeBoundingBox(val: boolean);
  68202. /**
  68203. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68204. */
  68205. get computeBoundingBox(): boolean;
  68206. /**
  68207. * This function does nothing. It may be overwritten to set all the particle first values.
  68208. * The PCS doesn't call this function, you may have to call it by your own.
  68209. * doc :
  68210. */
  68211. initParticles(): void;
  68212. /**
  68213. * This function does nothing. It may be overwritten to recycle a particle
  68214. * The PCS doesn't call this function, you can to call it
  68215. * doc :
  68216. * @param particle The particle to recycle
  68217. * @returns the recycled particle
  68218. */
  68219. recycleParticle(particle: CloudPoint): CloudPoint;
  68220. /**
  68221. * Updates a particle : this function should be overwritten by the user.
  68222. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68223. * doc :
  68224. * @example : just set a particle position or velocity and recycle conditions
  68225. * @param particle The particle to update
  68226. * @returns the updated particle
  68227. */
  68228. updateParticle(particle: CloudPoint): CloudPoint;
  68229. /**
  68230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68231. * This does nothing and may be overwritten by the user.
  68232. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68234. * @param update the boolean update value actually passed to setParticles()
  68235. */
  68236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68237. /**
  68238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68239. * This will be passed three parameters.
  68240. * This does nothing and may be overwritten by the user.
  68241. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68243. * @param update the boolean update value actually passed to setParticles()
  68244. */
  68245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * Represents one particle of a points cloud system.
  68251. */
  68252. export class CloudPoint {
  68253. /**
  68254. * particle global index
  68255. */
  68256. idx: number;
  68257. /**
  68258. * The color of the particle
  68259. */
  68260. color: Nullable<Color4>;
  68261. /**
  68262. * The world space position of the particle.
  68263. */
  68264. position: Vector3;
  68265. /**
  68266. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68267. */
  68268. rotation: Vector3;
  68269. /**
  68270. * The world space rotation quaternion of the particle.
  68271. */
  68272. rotationQuaternion: Nullable<Quaternion>;
  68273. /**
  68274. * The uv of the particle.
  68275. */
  68276. uv: Nullable<Vector2>;
  68277. /**
  68278. * The current speed of the particle.
  68279. */
  68280. velocity: Vector3;
  68281. /**
  68282. * The pivot point in the particle local space.
  68283. */
  68284. pivot: Vector3;
  68285. /**
  68286. * Must the particle be translated from its pivot point in its local space ?
  68287. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68288. * Default : false
  68289. */
  68290. translateFromPivot: boolean;
  68291. /**
  68292. * Index of this particle in the global "positions" array (Internal use)
  68293. * @hidden
  68294. */
  68295. _pos: number;
  68296. /**
  68297. * @hidden Index of this particle in the global "indices" array (Internal use)
  68298. */
  68299. _ind: number;
  68300. /**
  68301. * Group this particle belongs to
  68302. */
  68303. _group: PointsGroup;
  68304. /**
  68305. * Group id of this particle
  68306. */
  68307. groupId: number;
  68308. /**
  68309. * Index of the particle in its group id (Internal use)
  68310. */
  68311. idxInGroup: number;
  68312. /**
  68313. * @hidden Particle BoundingInfo object (Internal use)
  68314. */
  68315. _boundingInfo: BoundingInfo;
  68316. /**
  68317. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68318. */
  68319. _pcs: PointsCloudSystem;
  68320. /**
  68321. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68322. */
  68323. _stillInvisible: boolean;
  68324. /**
  68325. * @hidden Last computed particle rotation matrix
  68326. */
  68327. _rotationMatrix: number[];
  68328. /**
  68329. * Parent particle Id, if any.
  68330. * Default null.
  68331. */
  68332. parentId: Nullable<number>;
  68333. /**
  68334. * @hidden Internal global position in the PCS.
  68335. */
  68336. _globalPosition: Vector3;
  68337. /**
  68338. * Creates a Point Cloud object.
  68339. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68340. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68341. * @param group (PointsGroup) is the group the particle belongs to
  68342. * @param groupId (integer) is the group identifier in the PCS.
  68343. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68344. * @param pcs defines the PCS it is associated to
  68345. */
  68346. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68347. /**
  68348. * get point size
  68349. */
  68350. get size(): Vector3;
  68351. /**
  68352. * Set point size
  68353. */
  68354. set size(scale: Vector3);
  68355. /**
  68356. * Legacy support, changed quaternion to rotationQuaternion
  68357. */
  68358. get quaternion(): Nullable<Quaternion>;
  68359. /**
  68360. * Legacy support, changed quaternion to rotationQuaternion
  68361. */
  68362. set quaternion(q: Nullable<Quaternion>);
  68363. /**
  68364. * Returns a boolean. True if the particle intersects a mesh, else false
  68365. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68366. * @param target is the object (point or mesh) what the intersection is computed against
  68367. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68368. * @returns true if it intersects
  68369. */
  68370. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68371. /**
  68372. * get the rotation matrix of the particle
  68373. * @hidden
  68374. */
  68375. getRotationMatrix(m: Matrix): void;
  68376. }
  68377. /**
  68378. * Represents a group of points in a points cloud system
  68379. * * PCS internal tool, don't use it manually.
  68380. */
  68381. export class PointsGroup {
  68382. /**
  68383. * The group id
  68384. * @hidden
  68385. */
  68386. groupID: number;
  68387. /**
  68388. * image data for group (internal use)
  68389. * @hidden
  68390. */
  68391. _groupImageData: Nullable<ArrayBufferView>;
  68392. /**
  68393. * Image Width (internal use)
  68394. * @hidden
  68395. */
  68396. _groupImgWidth: number;
  68397. /**
  68398. * Image Height (internal use)
  68399. * @hidden
  68400. */
  68401. _groupImgHeight: number;
  68402. /**
  68403. * Custom position function (internal use)
  68404. * @hidden
  68405. */
  68406. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68407. /**
  68408. * density per facet for surface points
  68409. * @hidden
  68410. */
  68411. _groupDensity: number[];
  68412. /**
  68413. * Only when points are colored by texture carries pointer to texture list array
  68414. * @hidden
  68415. */
  68416. _textureNb: number;
  68417. /**
  68418. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68419. * PCS internal tool, don't use it manually.
  68420. * @hidden
  68421. */
  68422. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. interface Scene {
  68427. /** @hidden (Backing field) */
  68428. _physicsEngine: Nullable<IPhysicsEngine>;
  68429. /** @hidden */
  68430. _physicsTimeAccumulator: number;
  68431. /**
  68432. * Gets the current physics engine
  68433. * @returns a IPhysicsEngine or null if none attached
  68434. */
  68435. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68436. /**
  68437. * Enables physics to the current scene
  68438. * @param gravity defines the scene's gravity for the physics engine
  68439. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68440. * @return a boolean indicating if the physics engine was initialized
  68441. */
  68442. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68443. /**
  68444. * Disables and disposes the physics engine associated with the scene
  68445. */
  68446. disablePhysicsEngine(): void;
  68447. /**
  68448. * Gets a boolean indicating if there is an active physics engine
  68449. * @returns a boolean indicating if there is an active physics engine
  68450. */
  68451. isPhysicsEnabled(): boolean;
  68452. /**
  68453. * Deletes a physics compound impostor
  68454. * @param compound defines the compound to delete
  68455. */
  68456. deleteCompoundImpostor(compound: any): void;
  68457. /**
  68458. * An event triggered when physic simulation is about to be run
  68459. */
  68460. onBeforePhysicsObservable: Observable<Scene>;
  68461. /**
  68462. * An event triggered when physic simulation has been done
  68463. */
  68464. onAfterPhysicsObservable: Observable<Scene>;
  68465. }
  68466. interface AbstractMesh {
  68467. /** @hidden */
  68468. _physicsImpostor: Nullable<PhysicsImpostor>;
  68469. /**
  68470. * Gets or sets impostor used for physic simulation
  68471. * @see https://doc.babylonjs.com/features/physics_engine
  68472. */
  68473. physicsImpostor: Nullable<PhysicsImpostor>;
  68474. /**
  68475. * Gets the current physics impostor
  68476. * @see https://doc.babylonjs.com/features/physics_engine
  68477. * @returns a physics impostor or null
  68478. */
  68479. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68480. /** Apply a physic impulse to the mesh
  68481. * @param force defines the force to apply
  68482. * @param contactPoint defines where to apply the force
  68483. * @returns the current mesh
  68484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68485. */
  68486. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68487. /**
  68488. * Creates a physic joint between two meshes
  68489. * @param otherMesh defines the other mesh to use
  68490. * @param pivot1 defines the pivot to use on this mesh
  68491. * @param pivot2 defines the pivot to use on the other mesh
  68492. * @param options defines additional options (can be plugin dependent)
  68493. * @returns the current mesh
  68494. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68495. */
  68496. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68497. /** @hidden */
  68498. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68499. }
  68500. /**
  68501. * Defines the physics engine scene component responsible to manage a physics engine
  68502. */
  68503. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68504. /**
  68505. * The component name helpful to identify the component in the list of scene components.
  68506. */
  68507. readonly name: string;
  68508. /**
  68509. * The scene the component belongs to.
  68510. */
  68511. scene: Scene;
  68512. /**
  68513. * Creates a new instance of the component for the given scene
  68514. * @param scene Defines the scene to register the component in
  68515. */
  68516. constructor(scene: Scene);
  68517. /**
  68518. * Registers the component in a given scene
  68519. */
  68520. register(): void;
  68521. /**
  68522. * Rebuilds the elements related to this component in case of
  68523. * context lost for instance.
  68524. */
  68525. rebuild(): void;
  68526. /**
  68527. * Disposes the component and the associated ressources
  68528. */
  68529. dispose(): void;
  68530. }
  68531. }
  68532. declare module BABYLON {
  68533. /**
  68534. * A helper for physics simulations
  68535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68536. */
  68537. export class PhysicsHelper {
  68538. private _scene;
  68539. private _physicsEngine;
  68540. /**
  68541. * Initializes the Physics helper
  68542. * @param scene Babylon.js scene
  68543. */
  68544. constructor(scene: Scene);
  68545. /**
  68546. * Applies a radial explosion impulse
  68547. * @param origin the origin of the explosion
  68548. * @param radiusOrEventOptions the radius or the options of radial explosion
  68549. * @param strength the explosion strength
  68550. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68551. * @returns A physics radial explosion event, or null
  68552. */
  68553. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68554. /**
  68555. * Applies a radial explosion force
  68556. * @param origin the origin of the explosion
  68557. * @param radiusOrEventOptions the radius or the options of radial explosion
  68558. * @param strength the explosion strength
  68559. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68560. * @returns A physics radial explosion event, or null
  68561. */
  68562. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68563. /**
  68564. * Creates a gravitational field
  68565. * @param origin the origin of the explosion
  68566. * @param radiusOrEventOptions the radius or the options of radial explosion
  68567. * @param strength the explosion strength
  68568. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68569. * @returns A physics gravitational field event, or null
  68570. */
  68571. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68572. /**
  68573. * Creates a physics updraft event
  68574. * @param origin the origin of the updraft
  68575. * @param radiusOrEventOptions the radius or the options of the updraft
  68576. * @param strength the strength of the updraft
  68577. * @param height the height of the updraft
  68578. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68579. * @returns A physics updraft event, or null
  68580. */
  68581. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68582. /**
  68583. * Creates a physics vortex event
  68584. * @param origin the of the vortex
  68585. * @param radiusOrEventOptions the radius or the options of the vortex
  68586. * @param strength the strength of the vortex
  68587. * @param height the height of the vortex
  68588. * @returns a Physics vortex event, or null
  68589. * A physics vortex event or null
  68590. */
  68591. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68592. }
  68593. /**
  68594. * Represents a physics radial explosion event
  68595. */
  68596. class PhysicsRadialExplosionEvent {
  68597. private _scene;
  68598. private _options;
  68599. private _sphere;
  68600. private _dataFetched;
  68601. /**
  68602. * Initializes a radial explosioin event
  68603. * @param _scene BabylonJS scene
  68604. * @param _options The options for the vortex event
  68605. */
  68606. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68607. /**
  68608. * Returns the data related to the radial explosion event (sphere).
  68609. * @returns The radial explosion event data
  68610. */
  68611. getData(): PhysicsRadialExplosionEventData;
  68612. /**
  68613. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68614. * @param impostor A physics imposter
  68615. * @param origin the origin of the explosion
  68616. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68617. */
  68618. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68619. /**
  68620. * Triggers affecterd impostors callbacks
  68621. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68622. */
  68623. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68624. /**
  68625. * Disposes the sphere.
  68626. * @param force Specifies if the sphere should be disposed by force
  68627. */
  68628. dispose(force?: boolean): void;
  68629. /*** Helpers ***/
  68630. private _prepareSphere;
  68631. private _intersectsWithSphere;
  68632. }
  68633. /**
  68634. * Represents a gravitational field event
  68635. */
  68636. class PhysicsGravitationalFieldEvent {
  68637. private _physicsHelper;
  68638. private _scene;
  68639. private _origin;
  68640. private _options;
  68641. private _tickCallback;
  68642. private _sphere;
  68643. private _dataFetched;
  68644. /**
  68645. * Initializes the physics gravitational field event
  68646. * @param _physicsHelper A physics helper
  68647. * @param _scene BabylonJS scene
  68648. * @param _origin The origin position of the gravitational field event
  68649. * @param _options The options for the vortex event
  68650. */
  68651. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68652. /**
  68653. * Returns the data related to the gravitational field event (sphere).
  68654. * @returns A gravitational field event
  68655. */
  68656. getData(): PhysicsGravitationalFieldEventData;
  68657. /**
  68658. * Enables the gravitational field.
  68659. */
  68660. enable(): void;
  68661. /**
  68662. * Disables the gravitational field.
  68663. */
  68664. disable(): void;
  68665. /**
  68666. * Disposes the sphere.
  68667. * @param force The force to dispose from the gravitational field event
  68668. */
  68669. dispose(force?: boolean): void;
  68670. private _tick;
  68671. }
  68672. /**
  68673. * Represents a physics updraft event
  68674. */
  68675. class PhysicsUpdraftEvent {
  68676. private _scene;
  68677. private _origin;
  68678. private _options;
  68679. private _physicsEngine;
  68680. private _originTop;
  68681. private _originDirection;
  68682. private _tickCallback;
  68683. private _cylinder;
  68684. private _cylinderPosition;
  68685. private _dataFetched;
  68686. /**
  68687. * Initializes the physics updraft event
  68688. * @param _scene BabylonJS scene
  68689. * @param _origin The origin position of the updraft
  68690. * @param _options The options for the updraft event
  68691. */
  68692. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68693. /**
  68694. * Returns the data related to the updraft event (cylinder).
  68695. * @returns A physics updraft event
  68696. */
  68697. getData(): PhysicsUpdraftEventData;
  68698. /**
  68699. * Enables the updraft.
  68700. */
  68701. enable(): void;
  68702. /**
  68703. * Disables the updraft.
  68704. */
  68705. disable(): void;
  68706. /**
  68707. * Disposes the cylinder.
  68708. * @param force Specifies if the updraft should be disposed by force
  68709. */
  68710. dispose(force?: boolean): void;
  68711. private getImpostorHitData;
  68712. private _tick;
  68713. /*** Helpers ***/
  68714. private _prepareCylinder;
  68715. private _intersectsWithCylinder;
  68716. }
  68717. /**
  68718. * Represents a physics vortex event
  68719. */
  68720. class PhysicsVortexEvent {
  68721. private _scene;
  68722. private _origin;
  68723. private _options;
  68724. private _physicsEngine;
  68725. private _originTop;
  68726. private _tickCallback;
  68727. private _cylinder;
  68728. private _cylinderPosition;
  68729. private _dataFetched;
  68730. /**
  68731. * Initializes the physics vortex event
  68732. * @param _scene The BabylonJS scene
  68733. * @param _origin The origin position of the vortex
  68734. * @param _options The options for the vortex event
  68735. */
  68736. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68737. /**
  68738. * Returns the data related to the vortex event (cylinder).
  68739. * @returns The physics vortex event data
  68740. */
  68741. getData(): PhysicsVortexEventData;
  68742. /**
  68743. * Enables the vortex.
  68744. */
  68745. enable(): void;
  68746. /**
  68747. * Disables the cortex.
  68748. */
  68749. disable(): void;
  68750. /**
  68751. * Disposes the sphere.
  68752. * @param force
  68753. */
  68754. dispose(force?: boolean): void;
  68755. private getImpostorHitData;
  68756. private _tick;
  68757. /*** Helpers ***/
  68758. private _prepareCylinder;
  68759. private _intersectsWithCylinder;
  68760. }
  68761. /**
  68762. * Options fot the radial explosion event
  68763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68764. */
  68765. export class PhysicsRadialExplosionEventOptions {
  68766. /**
  68767. * The radius of the sphere for the radial explosion.
  68768. */
  68769. radius: number;
  68770. /**
  68771. * The strenth of the explosion.
  68772. */
  68773. strength: number;
  68774. /**
  68775. * The strenght of the force in correspondence to the distance of the affected object
  68776. */
  68777. falloff: PhysicsRadialImpulseFalloff;
  68778. /**
  68779. * Sphere options for the radial explosion.
  68780. */
  68781. sphere: {
  68782. segments: number;
  68783. diameter: number;
  68784. };
  68785. /**
  68786. * Sphere options for the radial explosion.
  68787. */
  68788. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68789. }
  68790. /**
  68791. * Options fot the updraft event
  68792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68793. */
  68794. export class PhysicsUpdraftEventOptions {
  68795. /**
  68796. * The radius of the cylinder for the vortex
  68797. */
  68798. radius: number;
  68799. /**
  68800. * The strenth of the updraft.
  68801. */
  68802. strength: number;
  68803. /**
  68804. * The height of the cylinder for the updraft.
  68805. */
  68806. height: number;
  68807. /**
  68808. * The mode for the the updraft.
  68809. */
  68810. updraftMode: PhysicsUpdraftMode;
  68811. }
  68812. /**
  68813. * Options fot the vortex event
  68814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68815. */
  68816. export class PhysicsVortexEventOptions {
  68817. /**
  68818. * The radius of the cylinder for the vortex
  68819. */
  68820. radius: number;
  68821. /**
  68822. * The strenth of the vortex.
  68823. */
  68824. strength: number;
  68825. /**
  68826. * The height of the cylinder for the vortex.
  68827. */
  68828. height: number;
  68829. /**
  68830. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68831. */
  68832. centripetalForceThreshold: number;
  68833. /**
  68834. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68835. */
  68836. centripetalForceMultiplier: number;
  68837. /**
  68838. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68839. */
  68840. centrifugalForceMultiplier: number;
  68841. /**
  68842. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68843. */
  68844. updraftForceMultiplier: number;
  68845. }
  68846. /**
  68847. * The strenght of the force in correspondence to the distance of the affected object
  68848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68849. */
  68850. export enum PhysicsRadialImpulseFalloff {
  68851. /** Defines that impulse is constant in strength across it's whole radius */
  68852. Constant = 0,
  68853. /** Defines that impulse gets weaker if it's further from the origin */
  68854. Linear = 1
  68855. }
  68856. /**
  68857. * The strength of the force in correspondence to the distance of the affected object
  68858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68859. */
  68860. export enum PhysicsUpdraftMode {
  68861. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68862. Center = 0,
  68863. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68864. Perpendicular = 1
  68865. }
  68866. /**
  68867. * Interface for a physics hit data
  68868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68869. */
  68870. export interface PhysicsHitData {
  68871. /**
  68872. * The force applied at the contact point
  68873. */
  68874. force: Vector3;
  68875. /**
  68876. * The contact point
  68877. */
  68878. contactPoint: Vector3;
  68879. /**
  68880. * The distance from the origin to the contact point
  68881. */
  68882. distanceFromOrigin: number;
  68883. }
  68884. /**
  68885. * Interface for radial explosion event data
  68886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68887. */
  68888. export interface PhysicsRadialExplosionEventData {
  68889. /**
  68890. * A sphere used for the radial explosion event
  68891. */
  68892. sphere: Mesh;
  68893. }
  68894. /**
  68895. * Interface for gravitational field event data
  68896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68897. */
  68898. export interface PhysicsGravitationalFieldEventData {
  68899. /**
  68900. * A sphere mesh used for the gravitational field event
  68901. */
  68902. sphere: Mesh;
  68903. }
  68904. /**
  68905. * Interface for updraft event data
  68906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68907. */
  68908. export interface PhysicsUpdraftEventData {
  68909. /**
  68910. * A cylinder used for the updraft event
  68911. */
  68912. cylinder: Mesh;
  68913. }
  68914. /**
  68915. * Interface for vortex event data
  68916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68917. */
  68918. export interface PhysicsVortexEventData {
  68919. /**
  68920. * A cylinder used for the vortex event
  68921. */
  68922. cylinder: Mesh;
  68923. }
  68924. /**
  68925. * Interface for an affected physics impostor
  68926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68927. */
  68928. export interface PhysicsAffectedImpostorWithData {
  68929. /**
  68930. * The impostor affected by the effect
  68931. */
  68932. impostor: PhysicsImpostor;
  68933. /**
  68934. * The data about the hit/horce from the explosion
  68935. */
  68936. hitData: PhysicsHitData;
  68937. }
  68938. }
  68939. declare module BABYLON {
  68940. /** @hidden */
  68941. export var blackAndWhitePixelShader: {
  68942. name: string;
  68943. shader: string;
  68944. };
  68945. }
  68946. declare module BABYLON {
  68947. /**
  68948. * Post process used to render in black and white
  68949. */
  68950. export class BlackAndWhitePostProcess extends PostProcess {
  68951. /**
  68952. * Linear about to convert he result to black and white (default: 1)
  68953. */
  68954. degree: number;
  68955. /**
  68956. * Gets a string identifying the name of the class
  68957. * @returns "BlackAndWhitePostProcess" string
  68958. */
  68959. getClassName(): string;
  68960. /**
  68961. * Creates a black and white post process
  68962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68963. * @param name The name of the effect.
  68964. * @param options The required width/height ratio to downsize to before computing the render pass.
  68965. * @param camera The camera to apply the render pass to.
  68966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68967. * @param engine The engine which the post process will be applied. (default: current engine)
  68968. * @param reusable If the post process can be reused on the same frame. (default: false)
  68969. */
  68970. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68971. /** @hidden */
  68972. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68973. }
  68974. }
  68975. declare module BABYLON {
  68976. /**
  68977. * This represents a set of one or more post processes in Babylon.
  68978. * A post process can be used to apply a shader to a texture after it is rendered.
  68979. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68980. */
  68981. export class PostProcessRenderEffect {
  68982. private _postProcesses;
  68983. private _getPostProcesses;
  68984. private _singleInstance;
  68985. private _cameras;
  68986. private _indicesForCamera;
  68987. /**
  68988. * Name of the effect
  68989. * @hidden
  68990. */
  68991. _name: string;
  68992. /**
  68993. * Instantiates a post process render effect.
  68994. * A post process can be used to apply a shader to a texture after it is rendered.
  68995. * @param engine The engine the effect is tied to
  68996. * @param name The name of the effect
  68997. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68998. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68999. */
  69000. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69001. /**
  69002. * Checks if all the post processes in the effect are supported.
  69003. */
  69004. get isSupported(): boolean;
  69005. /**
  69006. * Updates the current state of the effect
  69007. * @hidden
  69008. */
  69009. _update(): void;
  69010. /**
  69011. * Attaches the effect on cameras
  69012. * @param cameras The camera to attach to.
  69013. * @hidden
  69014. */
  69015. _attachCameras(cameras: Camera): void;
  69016. /**
  69017. * Attaches the effect on cameras
  69018. * @param cameras The camera to attach to.
  69019. * @hidden
  69020. */
  69021. _attachCameras(cameras: Camera[]): void;
  69022. /**
  69023. * Detaches the effect on cameras
  69024. * @param cameras The camera to detatch from.
  69025. * @hidden
  69026. */
  69027. _detachCameras(cameras: Camera): void;
  69028. /**
  69029. * Detatches the effect on cameras
  69030. * @param cameras The camera to detatch from.
  69031. * @hidden
  69032. */
  69033. _detachCameras(cameras: Camera[]): void;
  69034. /**
  69035. * Enables the effect on given cameras
  69036. * @param cameras The camera to enable.
  69037. * @hidden
  69038. */
  69039. _enable(cameras: Camera): void;
  69040. /**
  69041. * Enables the effect on given cameras
  69042. * @param cameras The camera to enable.
  69043. * @hidden
  69044. */
  69045. _enable(cameras: Nullable<Camera[]>): void;
  69046. /**
  69047. * Disables the effect on the given cameras
  69048. * @param cameras The camera to disable.
  69049. * @hidden
  69050. */
  69051. _disable(cameras: Camera): void;
  69052. /**
  69053. * Disables the effect on the given cameras
  69054. * @param cameras The camera to disable.
  69055. * @hidden
  69056. */
  69057. _disable(cameras: Nullable<Camera[]>): void;
  69058. /**
  69059. * Gets a list of the post processes contained in the effect.
  69060. * @param camera The camera to get the post processes on.
  69061. * @returns The list of the post processes in the effect.
  69062. */
  69063. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /** @hidden */
  69068. export var extractHighlightsPixelShader: {
  69069. name: string;
  69070. shader: string;
  69071. };
  69072. }
  69073. declare module BABYLON {
  69074. /**
  69075. * 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.
  69076. */
  69077. export class ExtractHighlightsPostProcess extends PostProcess {
  69078. /**
  69079. * The luminance threshold, pixels below this value will be set to black.
  69080. */
  69081. threshold: number;
  69082. /** @hidden */
  69083. _exposure: number;
  69084. /**
  69085. * Post process which has the input texture to be used when performing highlight extraction
  69086. * @hidden
  69087. */
  69088. _inputPostProcess: Nullable<PostProcess>;
  69089. /**
  69090. * Gets a string identifying the name of the class
  69091. * @returns "ExtractHighlightsPostProcess" string
  69092. */
  69093. getClassName(): string;
  69094. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69095. }
  69096. }
  69097. declare module BABYLON {
  69098. /** @hidden */
  69099. export var bloomMergePixelShader: {
  69100. name: string;
  69101. shader: string;
  69102. };
  69103. }
  69104. declare module BABYLON {
  69105. /**
  69106. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69107. */
  69108. export class BloomMergePostProcess extends PostProcess {
  69109. /** Weight of the bloom to be added to the original input. */
  69110. weight: number;
  69111. /**
  69112. * Gets a string identifying the name of the class
  69113. * @returns "BloomMergePostProcess" string
  69114. */
  69115. getClassName(): string;
  69116. /**
  69117. * Creates a new instance of @see BloomMergePostProcess
  69118. * @param name The name of the effect.
  69119. * @param originalFromInput Post process which's input will be used for the merge.
  69120. * @param blurred Blurred highlights post process which's output will be used.
  69121. * @param weight Weight of the bloom to be added to the original input.
  69122. * @param options The required width/height ratio to downsize to before computing the render pass.
  69123. * @param camera The camera to apply the render pass to.
  69124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69125. * @param engine The engine which the post process will be applied. (default: current engine)
  69126. * @param reusable If the post process can be reused on the same frame. (default: false)
  69127. * @param textureType Type of textures used when performing the post process. (default: 0)
  69128. * @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)
  69129. */
  69130. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69131. /** Weight of the bloom to be added to the original input. */
  69132. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69133. }
  69134. }
  69135. declare module BABYLON {
  69136. /**
  69137. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69138. */
  69139. export class BloomEffect extends PostProcessRenderEffect {
  69140. private bloomScale;
  69141. /**
  69142. * @hidden Internal
  69143. */
  69144. _effects: Array<PostProcess>;
  69145. /**
  69146. * @hidden Internal
  69147. */
  69148. _downscale: ExtractHighlightsPostProcess;
  69149. private _blurX;
  69150. private _blurY;
  69151. private _merge;
  69152. /**
  69153. * The luminance threshold to find bright areas of the image to bloom.
  69154. */
  69155. get threshold(): number;
  69156. set threshold(value: number);
  69157. /**
  69158. * The strength of the bloom.
  69159. */
  69160. get weight(): number;
  69161. set weight(value: number);
  69162. /**
  69163. * Specifies the size of the bloom blur kernel, relative to the final output size
  69164. */
  69165. get kernel(): number;
  69166. set kernel(value: number);
  69167. /**
  69168. * Creates a new instance of @see BloomEffect
  69169. * @param scene The scene the effect belongs to.
  69170. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69171. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69172. * @param bloomWeight The the strength of bloom.
  69173. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69174. * @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)
  69175. */
  69176. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69177. /**
  69178. * Disposes each of the internal effects for a given camera.
  69179. * @param camera The camera to dispose the effect on.
  69180. */
  69181. disposeEffects(camera: Camera): void;
  69182. /**
  69183. * @hidden Internal
  69184. */
  69185. _updateEffects(): void;
  69186. /**
  69187. * Internal
  69188. * @returns if all the contained post processes are ready.
  69189. * @hidden
  69190. */
  69191. _isReady(): boolean;
  69192. }
  69193. }
  69194. declare module BABYLON {
  69195. /** @hidden */
  69196. export var chromaticAberrationPixelShader: {
  69197. name: string;
  69198. shader: string;
  69199. };
  69200. }
  69201. declare module BABYLON {
  69202. /**
  69203. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69204. */
  69205. export class ChromaticAberrationPostProcess extends PostProcess {
  69206. /**
  69207. * The amount of seperation of rgb channels (default: 30)
  69208. */
  69209. aberrationAmount: number;
  69210. /**
  69211. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69212. */
  69213. radialIntensity: number;
  69214. /**
  69215. * 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))
  69216. */
  69217. direction: Vector2;
  69218. /**
  69219. * 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))
  69220. */
  69221. centerPosition: Vector2;
  69222. /** The width of the screen to apply the effect on */
  69223. screenWidth: number;
  69224. /** The height of the screen to apply the effect on */
  69225. screenHeight: number;
  69226. /**
  69227. * Gets a string identifying the name of the class
  69228. * @returns "ChromaticAberrationPostProcess" string
  69229. */
  69230. getClassName(): string;
  69231. /**
  69232. * Creates a new instance ChromaticAberrationPostProcess
  69233. * @param name The name of the effect.
  69234. * @param screenWidth The width of the screen to apply the effect on.
  69235. * @param screenHeight The height of the screen to apply the effect on.
  69236. * @param options The required width/height ratio to downsize to before computing the render pass.
  69237. * @param camera The camera to apply the render pass to.
  69238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69239. * @param engine The engine which the post process will be applied. (default: current engine)
  69240. * @param reusable If the post process can be reused on the same frame. (default: false)
  69241. * @param textureType Type of textures used when performing the post process. (default: 0)
  69242. * @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)
  69243. */
  69244. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69245. /** @hidden */
  69246. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69247. }
  69248. }
  69249. declare module BABYLON {
  69250. /** @hidden */
  69251. export var circleOfConfusionPixelShader: {
  69252. name: string;
  69253. shader: string;
  69254. };
  69255. }
  69256. declare module BABYLON {
  69257. /**
  69258. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69259. */
  69260. export class CircleOfConfusionPostProcess extends PostProcess {
  69261. /**
  69262. * 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.
  69263. */
  69264. lensSize: number;
  69265. /**
  69266. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69267. */
  69268. fStop: number;
  69269. /**
  69270. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69271. */
  69272. focusDistance: number;
  69273. /**
  69274. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69275. */
  69276. focalLength: number;
  69277. /**
  69278. * Gets a string identifying the name of the class
  69279. * @returns "CircleOfConfusionPostProcess" string
  69280. */
  69281. getClassName(): string;
  69282. private _depthTexture;
  69283. /**
  69284. * Creates a new instance CircleOfConfusionPostProcess
  69285. * @param name The name of the effect.
  69286. * @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.
  69287. * @param options The required width/height ratio to downsize to before computing the render pass.
  69288. * @param camera The camera to apply the render pass to.
  69289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69290. * @param engine The engine which the post process will be applied. (default: current engine)
  69291. * @param reusable If the post process can be reused on the same frame. (default: false)
  69292. * @param textureType Type of textures used when performing the post process. (default: 0)
  69293. * @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)
  69294. */
  69295. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69296. /**
  69297. * 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.
  69298. */
  69299. set depthTexture(value: RenderTargetTexture);
  69300. }
  69301. }
  69302. declare module BABYLON {
  69303. /** @hidden */
  69304. export var colorCorrectionPixelShader: {
  69305. name: string;
  69306. shader: string;
  69307. };
  69308. }
  69309. declare module BABYLON {
  69310. /**
  69311. *
  69312. * This post-process allows the modification of rendered colors by using
  69313. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69314. *
  69315. * The object needs to be provided an url to a texture containing the color
  69316. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69317. * Use an image editing software to tweak the LUT to match your needs.
  69318. *
  69319. * For an example of a color LUT, see here:
  69320. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69321. * For explanations on color grading, see here:
  69322. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69323. *
  69324. */
  69325. export class ColorCorrectionPostProcess extends PostProcess {
  69326. private _colorTableTexture;
  69327. /**
  69328. * Gets the color table url used to create the LUT texture
  69329. */
  69330. colorTableUrl: string;
  69331. /**
  69332. * Gets a string identifying the name of the class
  69333. * @returns "ColorCorrectionPostProcess" string
  69334. */
  69335. getClassName(): string;
  69336. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69337. /** @hidden */
  69338. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69339. }
  69340. }
  69341. declare module BABYLON {
  69342. /** @hidden */
  69343. export var convolutionPixelShader: {
  69344. name: string;
  69345. shader: string;
  69346. };
  69347. }
  69348. declare module BABYLON {
  69349. /**
  69350. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69351. * input texture to perform effects such as edge detection or sharpening
  69352. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69353. */
  69354. export class ConvolutionPostProcess extends PostProcess {
  69355. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69356. kernel: number[];
  69357. /**
  69358. * Gets a string identifying the name of the class
  69359. * @returns "ConvolutionPostProcess" string
  69360. */
  69361. getClassName(): string;
  69362. /**
  69363. * Creates a new instance ConvolutionPostProcess
  69364. * @param name The name of the effect.
  69365. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69366. * @param options The required width/height ratio to downsize to before computing the render pass.
  69367. * @param camera The camera to apply the render pass to.
  69368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69369. * @param engine The engine which the post process will be applied. (default: current engine)
  69370. * @param reusable If the post process can be reused on the same frame. (default: false)
  69371. * @param textureType Type of textures used when performing the post process. (default: 0)
  69372. */
  69373. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69374. /** @hidden */
  69375. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69376. /**
  69377. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69378. */
  69379. static EdgeDetect0Kernel: number[];
  69380. /**
  69381. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69382. */
  69383. static EdgeDetect1Kernel: number[];
  69384. /**
  69385. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69386. */
  69387. static EdgeDetect2Kernel: number[];
  69388. /**
  69389. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69390. */
  69391. static SharpenKernel: number[];
  69392. /**
  69393. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69394. */
  69395. static EmbossKernel: number[];
  69396. /**
  69397. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69398. */
  69399. static GaussianKernel: number[];
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /**
  69404. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69405. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69406. * based on samples that have a large difference in distance than the center pixel.
  69407. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69408. */
  69409. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69410. /**
  69411. * The direction the blur should be applied
  69412. */
  69413. direction: Vector2;
  69414. /**
  69415. * Gets a string identifying the name of the class
  69416. * @returns "DepthOfFieldBlurPostProcess" string
  69417. */
  69418. getClassName(): string;
  69419. /**
  69420. * Creates a new instance CircleOfConfusionPostProcess
  69421. * @param name The name of the effect.
  69422. * @param scene The scene the effect belongs to.
  69423. * @param direction The direction the blur should be applied.
  69424. * @param kernel The size of the kernel used to blur.
  69425. * @param options The required width/height ratio to downsize to before computing the render pass.
  69426. * @param camera The camera to apply the render pass to.
  69427. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69428. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69430. * @param engine The engine which the post process will be applied. (default: current engine)
  69431. * @param reusable If the post process can be reused on the same frame. (default: false)
  69432. * @param textureType Type of textures used when performing the post process. (default: 0)
  69433. * @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)
  69434. */
  69435. 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);
  69436. }
  69437. }
  69438. declare module BABYLON {
  69439. /** @hidden */
  69440. export var depthOfFieldMergePixelShader: {
  69441. name: string;
  69442. shader: string;
  69443. };
  69444. }
  69445. declare module BABYLON {
  69446. /**
  69447. * Options to be set when merging outputs from the default pipeline.
  69448. */
  69449. export class DepthOfFieldMergePostProcessOptions {
  69450. /**
  69451. * The original image to merge on top of
  69452. */
  69453. originalFromInput: PostProcess;
  69454. /**
  69455. * Parameters to perform the merge of the depth of field effect
  69456. */
  69457. depthOfField?: {
  69458. circleOfConfusion: PostProcess;
  69459. blurSteps: Array<PostProcess>;
  69460. };
  69461. /**
  69462. * Parameters to perform the merge of bloom effect
  69463. */
  69464. bloom?: {
  69465. blurred: PostProcess;
  69466. weight: number;
  69467. };
  69468. }
  69469. /**
  69470. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69471. */
  69472. export class DepthOfFieldMergePostProcess extends PostProcess {
  69473. private blurSteps;
  69474. /**
  69475. * Gets a string identifying the name of the class
  69476. * @returns "DepthOfFieldMergePostProcess" string
  69477. */
  69478. getClassName(): string;
  69479. /**
  69480. * Creates a new instance of DepthOfFieldMergePostProcess
  69481. * @param name The name of the effect.
  69482. * @param originalFromInput Post process which's input will be used for the merge.
  69483. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69484. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69485. * @param options The required width/height ratio to downsize to before computing the render pass.
  69486. * @param camera The camera to apply the render pass to.
  69487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69488. * @param engine The engine which the post process will be applied. (default: current engine)
  69489. * @param reusable If the post process can be reused on the same frame. (default: false)
  69490. * @param textureType Type of textures used when performing the post process. (default: 0)
  69491. * @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)
  69492. */
  69493. 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);
  69494. /**
  69495. * Updates the effect with the current post process compile time values and recompiles the shader.
  69496. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69497. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69498. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69499. * @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
  69500. * @param onCompiled Called when the shader has been compiled.
  69501. * @param onError Called if there is an error when compiling a shader.
  69502. */
  69503. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69504. }
  69505. }
  69506. declare module BABYLON {
  69507. /**
  69508. * Specifies the level of max blur that should be applied when using the depth of field effect
  69509. */
  69510. export enum DepthOfFieldEffectBlurLevel {
  69511. /**
  69512. * Subtle blur
  69513. */
  69514. Low = 0,
  69515. /**
  69516. * Medium blur
  69517. */
  69518. Medium = 1,
  69519. /**
  69520. * Large blur
  69521. */
  69522. High = 2
  69523. }
  69524. /**
  69525. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69526. */
  69527. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69528. private _circleOfConfusion;
  69529. /**
  69530. * @hidden Internal, blurs from high to low
  69531. */
  69532. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69533. private _depthOfFieldBlurY;
  69534. private _dofMerge;
  69535. /**
  69536. * @hidden Internal post processes in depth of field effect
  69537. */
  69538. _effects: Array<PostProcess>;
  69539. /**
  69540. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69541. */
  69542. set focalLength(value: number);
  69543. get focalLength(): number;
  69544. /**
  69545. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69546. */
  69547. set fStop(value: number);
  69548. get fStop(): number;
  69549. /**
  69550. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69551. */
  69552. set focusDistance(value: number);
  69553. get focusDistance(): number;
  69554. /**
  69555. * 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.
  69556. */
  69557. set lensSize(value: number);
  69558. get lensSize(): number;
  69559. /**
  69560. * Creates a new instance DepthOfFieldEffect
  69561. * @param scene The scene the effect belongs to.
  69562. * @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.
  69563. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69564. * @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)
  69565. */
  69566. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69567. /**
  69568. * Get the current class name of the current effet
  69569. * @returns "DepthOfFieldEffect"
  69570. */
  69571. getClassName(): string;
  69572. /**
  69573. * 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.
  69574. */
  69575. set depthTexture(value: RenderTargetTexture);
  69576. /**
  69577. * Disposes each of the internal effects for a given camera.
  69578. * @param camera The camera to dispose the effect on.
  69579. */
  69580. disposeEffects(camera: Camera): void;
  69581. /**
  69582. * @hidden Internal
  69583. */
  69584. _updateEffects(): void;
  69585. /**
  69586. * Internal
  69587. * @returns if all the contained post processes are ready.
  69588. * @hidden
  69589. */
  69590. _isReady(): boolean;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export var displayPassPixelShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module BABYLON {
  69601. /**
  69602. * DisplayPassPostProcess which produces an output the same as it's input
  69603. */
  69604. export class DisplayPassPostProcess extends PostProcess {
  69605. /**
  69606. * Gets a string identifying the name of the class
  69607. * @returns "DisplayPassPostProcess" string
  69608. */
  69609. getClassName(): string;
  69610. /**
  69611. * Creates the DisplayPassPostProcess
  69612. * @param name The name of the effect.
  69613. * @param options The required width/height ratio to downsize to before computing the render pass.
  69614. * @param camera The camera to apply the render pass to.
  69615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69616. * @param engine The engine which the post process will be applied. (default: current engine)
  69617. * @param reusable If the post process can be reused on the same frame. (default: false)
  69618. */
  69619. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69620. /** @hidden */
  69621. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69622. }
  69623. }
  69624. declare module BABYLON {
  69625. /** @hidden */
  69626. export var filterPixelShader: {
  69627. name: string;
  69628. shader: string;
  69629. };
  69630. }
  69631. declare module BABYLON {
  69632. /**
  69633. * Applies a kernel filter to the image
  69634. */
  69635. export class FilterPostProcess extends PostProcess {
  69636. /** The matrix to be applied to the image */
  69637. kernelMatrix: Matrix;
  69638. /**
  69639. * Gets a string identifying the name of the class
  69640. * @returns "FilterPostProcess" string
  69641. */
  69642. getClassName(): string;
  69643. /**
  69644. *
  69645. * @param name The name of the effect.
  69646. * @param kernelMatrix The matrix to be applied to the image
  69647. * @param options The required width/height ratio to downsize to before computing the render pass.
  69648. * @param camera The camera to apply the render pass to.
  69649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69650. * @param engine The engine which the post process will be applied. (default: current engine)
  69651. * @param reusable If the post process can be reused on the same frame. (default: false)
  69652. */
  69653. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69654. /** @hidden */
  69655. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69656. }
  69657. }
  69658. declare module BABYLON {
  69659. /** @hidden */
  69660. export var fxaaPixelShader: {
  69661. name: string;
  69662. shader: string;
  69663. };
  69664. }
  69665. declare module BABYLON {
  69666. /** @hidden */
  69667. export var fxaaVertexShader: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module BABYLON {
  69673. /**
  69674. * Fxaa post process
  69675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69676. */
  69677. export class FxaaPostProcess extends PostProcess {
  69678. /**
  69679. * Gets a string identifying the name of the class
  69680. * @returns "FxaaPostProcess" string
  69681. */
  69682. getClassName(): string;
  69683. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69684. private _getDefines;
  69685. /** @hidden */
  69686. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /** @hidden */
  69691. export var grainPixelShader: {
  69692. name: string;
  69693. shader: string;
  69694. };
  69695. }
  69696. declare module BABYLON {
  69697. /**
  69698. * The GrainPostProcess adds noise to the image at mid luminance levels
  69699. */
  69700. export class GrainPostProcess extends PostProcess {
  69701. /**
  69702. * The intensity of the grain added (default: 30)
  69703. */
  69704. intensity: number;
  69705. /**
  69706. * If the grain should be randomized on every frame
  69707. */
  69708. animated: boolean;
  69709. /**
  69710. * Gets a string identifying the name of the class
  69711. * @returns "GrainPostProcess" string
  69712. */
  69713. getClassName(): string;
  69714. /**
  69715. * Creates a new instance of @see GrainPostProcess
  69716. * @param name The name of the effect.
  69717. * @param options The required width/height ratio to downsize to before computing the render pass.
  69718. * @param camera The camera to apply the render pass to.
  69719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69720. * @param engine The engine which the post process will be applied. (default: current engine)
  69721. * @param reusable If the post process can be reused on the same frame. (default: false)
  69722. * @param textureType Type of textures used when performing the post process. (default: 0)
  69723. * @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)
  69724. */
  69725. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69726. /** @hidden */
  69727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69728. }
  69729. }
  69730. declare module BABYLON {
  69731. /** @hidden */
  69732. export var highlightsPixelShader: {
  69733. name: string;
  69734. shader: string;
  69735. };
  69736. }
  69737. declare module BABYLON {
  69738. /**
  69739. * Extracts highlights from the image
  69740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69741. */
  69742. export class HighlightsPostProcess extends PostProcess {
  69743. /**
  69744. * Gets a string identifying the name of the class
  69745. * @returns "HighlightsPostProcess" string
  69746. */
  69747. getClassName(): string;
  69748. /**
  69749. * Extracts highlights from the image
  69750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69751. * @param name The name of the effect.
  69752. * @param options The required width/height ratio to downsize to before computing the render pass.
  69753. * @param camera The camera to apply the render pass to.
  69754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69755. * @param engine The engine which the post process will be applied. (default: current engine)
  69756. * @param reusable If the post process can be reused on the same frame. (default: false)
  69757. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69758. */
  69759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69760. }
  69761. }
  69762. declare module BABYLON {
  69763. /** @hidden */
  69764. export var mrtFragmentDeclaration: {
  69765. name: string;
  69766. shader: string;
  69767. };
  69768. }
  69769. declare module BABYLON {
  69770. /** @hidden */
  69771. export var geometryPixelShader: {
  69772. name: string;
  69773. shader: string;
  69774. };
  69775. }
  69776. declare module BABYLON {
  69777. /** @hidden */
  69778. export var geometryVertexShader: {
  69779. name: string;
  69780. shader: string;
  69781. };
  69782. }
  69783. declare module BABYLON {
  69784. /** @hidden */
  69785. interface ISavedTransformationMatrix {
  69786. world: Matrix;
  69787. viewProjection: Matrix;
  69788. }
  69789. /**
  69790. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69791. */
  69792. export class GeometryBufferRenderer {
  69793. /**
  69794. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69795. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69796. */
  69797. static readonly POSITION_TEXTURE_TYPE: number;
  69798. /**
  69799. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69800. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69801. */
  69802. static readonly VELOCITY_TEXTURE_TYPE: number;
  69803. /**
  69804. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69805. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69806. */
  69807. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69808. /**
  69809. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69810. * in order to compute objects velocities when enableVelocity is set to "true"
  69811. * @hidden
  69812. */
  69813. _previousTransformationMatrices: {
  69814. [index: number]: ISavedTransformationMatrix;
  69815. };
  69816. /**
  69817. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69818. * in order to compute objects velocities when enableVelocity is set to "true"
  69819. * @hidden
  69820. */
  69821. _previousBonesTransformationMatrices: {
  69822. [index: number]: Float32Array;
  69823. };
  69824. /**
  69825. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69826. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69827. */
  69828. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69829. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69830. renderTransparentMeshes: boolean;
  69831. private _scene;
  69832. private _resizeObserver;
  69833. private _multiRenderTarget;
  69834. private _ratio;
  69835. private _enablePosition;
  69836. private _enableVelocity;
  69837. private _enableReflectivity;
  69838. private _positionIndex;
  69839. private _velocityIndex;
  69840. private _reflectivityIndex;
  69841. protected _effect: Effect;
  69842. protected _cachedDefines: string;
  69843. /**
  69844. * Set the render list (meshes to be rendered) used in the G buffer.
  69845. */
  69846. set renderList(meshes: Mesh[]);
  69847. /**
  69848. * Gets wether or not G buffer are supported by the running hardware.
  69849. * This requires draw buffer supports
  69850. */
  69851. get isSupported(): boolean;
  69852. /**
  69853. * Returns the index of the given texture type in the G-Buffer textures array
  69854. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69855. * @returns the index of the given texture type in the G-Buffer textures array
  69856. */
  69857. getTextureIndex(textureType: number): number;
  69858. /**
  69859. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69860. */
  69861. get enablePosition(): boolean;
  69862. /**
  69863. * Sets whether or not objects positions are enabled for the G buffer.
  69864. */
  69865. set enablePosition(enable: boolean);
  69866. /**
  69867. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69868. */
  69869. get enableVelocity(): boolean;
  69870. /**
  69871. * Sets wether or not objects velocities are enabled for the G buffer.
  69872. */
  69873. set enableVelocity(enable: boolean);
  69874. /**
  69875. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69876. */
  69877. get enableReflectivity(): boolean;
  69878. /**
  69879. * Sets wether or not objects roughness are enabled for the G buffer.
  69880. */
  69881. set enableReflectivity(enable: boolean);
  69882. /**
  69883. * Gets the scene associated with the buffer.
  69884. */
  69885. get scene(): Scene;
  69886. /**
  69887. * Gets the ratio used by the buffer during its creation.
  69888. * How big is the buffer related to the main canvas.
  69889. */
  69890. get ratio(): number;
  69891. /** @hidden */
  69892. static _SceneComponentInitialization: (scene: Scene) => void;
  69893. /**
  69894. * Creates a new G Buffer for the scene
  69895. * @param scene The scene the buffer belongs to
  69896. * @param ratio How big is the buffer related to the main canvas.
  69897. */
  69898. constructor(scene: Scene, ratio?: number);
  69899. /**
  69900. * Checks wether everything is ready to render a submesh to the G buffer.
  69901. * @param subMesh the submesh to check readiness for
  69902. * @param useInstances is the mesh drawn using instance or not
  69903. * @returns true if ready otherwise false
  69904. */
  69905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69906. /**
  69907. * Gets the current underlying G Buffer.
  69908. * @returns the buffer
  69909. */
  69910. getGBuffer(): MultiRenderTarget;
  69911. /**
  69912. * Gets the number of samples used to render the buffer (anti aliasing).
  69913. */
  69914. get samples(): number;
  69915. /**
  69916. * Sets the number of samples used to render the buffer (anti aliasing).
  69917. */
  69918. set samples(value: number);
  69919. /**
  69920. * Disposes the renderer and frees up associated resources.
  69921. */
  69922. dispose(): void;
  69923. protected _createRenderTargets(): void;
  69924. private _copyBonesTransformationMatrices;
  69925. }
  69926. }
  69927. declare module BABYLON {
  69928. interface Scene {
  69929. /** @hidden (Backing field) */
  69930. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69931. /**
  69932. * Gets or Sets the current geometry buffer associated to the scene.
  69933. */
  69934. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69935. /**
  69936. * Enables a GeometryBufferRender and associates it with the scene
  69937. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69938. * @returns the GeometryBufferRenderer
  69939. */
  69940. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69941. /**
  69942. * Disables the GeometryBufferRender associated with the scene
  69943. */
  69944. disableGeometryBufferRenderer(): void;
  69945. }
  69946. /**
  69947. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69948. * in several rendering techniques.
  69949. */
  69950. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69951. /**
  69952. * The component name helpful to identify the component in the list of scene components.
  69953. */
  69954. readonly name: string;
  69955. /**
  69956. * The scene the component belongs to.
  69957. */
  69958. scene: Scene;
  69959. /**
  69960. * Creates a new instance of the component for the given scene
  69961. * @param scene Defines the scene to register the component in
  69962. */
  69963. constructor(scene: Scene);
  69964. /**
  69965. * Registers the component in a given scene
  69966. */
  69967. register(): void;
  69968. /**
  69969. * Rebuilds the elements related to this component in case of
  69970. * context lost for instance.
  69971. */
  69972. rebuild(): void;
  69973. /**
  69974. * Disposes the component and the associated ressources
  69975. */
  69976. dispose(): void;
  69977. private _gatherRenderTargets;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /** @hidden */
  69982. export var motionBlurPixelShader: {
  69983. name: string;
  69984. shader: string;
  69985. };
  69986. }
  69987. declare module BABYLON {
  69988. /**
  69989. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69990. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69991. * As an example, all you have to do is to create the post-process:
  69992. * var mb = new BABYLON.MotionBlurPostProcess(
  69993. * 'mb', // The name of the effect.
  69994. * scene, // The scene containing the objects to blur according to their velocity.
  69995. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69996. * camera // The camera to apply the render pass to.
  69997. * );
  69998. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69999. */
  70000. export class MotionBlurPostProcess extends PostProcess {
  70001. /**
  70002. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70003. */
  70004. motionStrength: number;
  70005. /**
  70006. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70007. */
  70008. get motionBlurSamples(): number;
  70009. /**
  70010. * Sets the number of iterations to be used for motion blur quality
  70011. */
  70012. set motionBlurSamples(samples: number);
  70013. private _motionBlurSamples;
  70014. private _geometryBufferRenderer;
  70015. /**
  70016. * Gets a string identifying the name of the class
  70017. * @returns "MotionBlurPostProcess" string
  70018. */
  70019. getClassName(): string;
  70020. /**
  70021. * Creates a new instance MotionBlurPostProcess
  70022. * @param name The name of the effect.
  70023. * @param scene The scene containing the objects to blur according to their velocity.
  70024. * @param options The required width/height ratio to downsize to before computing the render pass.
  70025. * @param camera The camera to apply the render pass to.
  70026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70027. * @param engine The engine which the post process will be applied. (default: current engine)
  70028. * @param reusable If the post process can be reused on the same frame. (default: false)
  70029. * @param textureType Type of textures used when performing the post process. (default: 0)
  70030. * @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)
  70031. */
  70032. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70033. /**
  70034. * Excludes the given skinned mesh from computing bones velocities.
  70035. * 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.
  70036. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70037. */
  70038. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70039. /**
  70040. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70041. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70042. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70043. */
  70044. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70045. /**
  70046. * Disposes the post process.
  70047. * @param camera The camera to dispose the post process on.
  70048. */
  70049. dispose(camera?: Camera): void;
  70050. /** @hidden */
  70051. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. /** @hidden */
  70056. export var refractionPixelShader: {
  70057. name: string;
  70058. shader: string;
  70059. };
  70060. }
  70061. declare module BABYLON {
  70062. /**
  70063. * Post process which applies a refractin texture
  70064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70065. */
  70066. export class RefractionPostProcess extends PostProcess {
  70067. private _refTexture;
  70068. private _ownRefractionTexture;
  70069. /** the base color of the refraction (used to taint the rendering) */
  70070. color: Color3;
  70071. /** simulated refraction depth */
  70072. depth: number;
  70073. /** the coefficient of the base color (0 to remove base color tainting) */
  70074. colorLevel: number;
  70075. /** Gets the url used to load the refraction texture */
  70076. refractionTextureUrl: string;
  70077. /**
  70078. * Gets or sets the refraction texture
  70079. * Please note that you are responsible for disposing the texture if you set it manually
  70080. */
  70081. get refractionTexture(): Texture;
  70082. set refractionTexture(value: Texture);
  70083. /**
  70084. * Gets a string identifying the name of the class
  70085. * @returns "RefractionPostProcess" string
  70086. */
  70087. getClassName(): string;
  70088. /**
  70089. * Initializes the RefractionPostProcess
  70090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70091. * @param name The name of the effect.
  70092. * @param refractionTextureUrl Url of the refraction texture to use
  70093. * @param color the base color of the refraction (used to taint the rendering)
  70094. * @param depth simulated refraction depth
  70095. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70096. * @param camera The camera to apply the render pass to.
  70097. * @param options The required width/height ratio to downsize to before computing the render pass.
  70098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70099. * @param engine The engine which the post process will be applied. (default: current engine)
  70100. * @param reusable If the post process can be reused on the same frame. (default: false)
  70101. */
  70102. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70103. /**
  70104. * Disposes of the post process
  70105. * @param camera Camera to dispose post process on
  70106. */
  70107. dispose(camera: Camera): void;
  70108. /** @hidden */
  70109. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70110. }
  70111. }
  70112. declare module BABYLON {
  70113. /** @hidden */
  70114. export var sharpenPixelShader: {
  70115. name: string;
  70116. shader: string;
  70117. };
  70118. }
  70119. declare module BABYLON {
  70120. /**
  70121. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70122. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70123. */
  70124. export class SharpenPostProcess extends PostProcess {
  70125. /**
  70126. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70127. */
  70128. colorAmount: number;
  70129. /**
  70130. * How much sharpness should be applied (default: 0.3)
  70131. */
  70132. edgeAmount: number;
  70133. /**
  70134. * Gets a string identifying the name of the class
  70135. * @returns "SharpenPostProcess" string
  70136. */
  70137. getClassName(): string;
  70138. /**
  70139. * Creates a new instance ConvolutionPostProcess
  70140. * @param name The name of the effect.
  70141. * @param options The required width/height ratio to downsize to before computing the render pass.
  70142. * @param camera The camera to apply the render pass to.
  70143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70144. * @param engine The engine which the post process will be applied. (default: current engine)
  70145. * @param reusable If the post process can be reused on the same frame. (default: false)
  70146. * @param textureType Type of textures used when performing the post process. (default: 0)
  70147. * @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)
  70148. */
  70149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70150. /** @hidden */
  70151. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70152. }
  70153. }
  70154. declare module BABYLON {
  70155. /**
  70156. * PostProcessRenderPipeline
  70157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70158. */
  70159. export class PostProcessRenderPipeline {
  70160. private engine;
  70161. private _renderEffects;
  70162. private _renderEffectsForIsolatedPass;
  70163. /**
  70164. * List of inspectable custom properties (used by the Inspector)
  70165. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70166. */
  70167. inspectableCustomProperties: IInspectable[];
  70168. /**
  70169. * @hidden
  70170. */
  70171. protected _cameras: Camera[];
  70172. /** @hidden */
  70173. _name: string;
  70174. /**
  70175. * Gets pipeline name
  70176. */
  70177. get name(): string;
  70178. /** Gets the list of attached cameras */
  70179. get cameras(): Camera[];
  70180. /**
  70181. * Initializes a PostProcessRenderPipeline
  70182. * @param engine engine to add the pipeline to
  70183. * @param name name of the pipeline
  70184. */
  70185. constructor(engine: Engine, name: string);
  70186. /**
  70187. * Gets the class name
  70188. * @returns "PostProcessRenderPipeline"
  70189. */
  70190. getClassName(): string;
  70191. /**
  70192. * If all the render effects in the pipeline are supported
  70193. */
  70194. get isSupported(): boolean;
  70195. /**
  70196. * Adds an effect to the pipeline
  70197. * @param renderEffect the effect to add
  70198. */
  70199. addEffect(renderEffect: PostProcessRenderEffect): void;
  70200. /** @hidden */
  70201. _rebuild(): void;
  70202. /** @hidden */
  70203. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70204. /** @hidden */
  70205. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70206. /** @hidden */
  70207. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70208. /** @hidden */
  70209. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70210. /** @hidden */
  70211. _attachCameras(cameras: Camera, unique: boolean): void;
  70212. /** @hidden */
  70213. _attachCameras(cameras: Camera[], unique: boolean): void;
  70214. /** @hidden */
  70215. _detachCameras(cameras: Camera): void;
  70216. /** @hidden */
  70217. _detachCameras(cameras: Nullable<Camera[]>): void;
  70218. /** @hidden */
  70219. _update(): void;
  70220. /** @hidden */
  70221. _reset(): void;
  70222. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70223. /**
  70224. * Sets the required values to the prepass renderer.
  70225. * @param prePassRenderer defines the prepass renderer to setup.
  70226. * @returns true if the pre pass is needed.
  70227. */
  70228. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70229. /**
  70230. * Disposes of the pipeline
  70231. */
  70232. dispose(): void;
  70233. }
  70234. }
  70235. declare module BABYLON {
  70236. /**
  70237. * PostProcessRenderPipelineManager class
  70238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70239. */
  70240. export class PostProcessRenderPipelineManager {
  70241. private _renderPipelines;
  70242. /**
  70243. * Initializes a PostProcessRenderPipelineManager
  70244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70245. */
  70246. constructor();
  70247. /**
  70248. * Gets the list of supported render pipelines
  70249. */
  70250. get supportedPipelines(): PostProcessRenderPipeline[];
  70251. /**
  70252. * Adds a pipeline to the manager
  70253. * @param renderPipeline The pipeline to add
  70254. */
  70255. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70256. /**
  70257. * Attaches a camera to the pipeline
  70258. * @param renderPipelineName The name of the pipeline to attach to
  70259. * @param cameras the camera to attach
  70260. * @param unique if the camera can be attached multiple times to the pipeline
  70261. */
  70262. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70263. /**
  70264. * Detaches a camera from the pipeline
  70265. * @param renderPipelineName The name of the pipeline to detach from
  70266. * @param cameras the camera to detach
  70267. */
  70268. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70269. /**
  70270. * Enables an effect by name on a pipeline
  70271. * @param renderPipelineName the name of the pipeline to enable the effect in
  70272. * @param renderEffectName the name of the effect to enable
  70273. * @param cameras the cameras that the effect should be enabled on
  70274. */
  70275. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70276. /**
  70277. * Disables an effect by name on a pipeline
  70278. * @param renderPipelineName the name of the pipeline to disable the effect in
  70279. * @param renderEffectName the name of the effect to disable
  70280. * @param cameras the cameras that the effect should be disabled on
  70281. */
  70282. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70283. /**
  70284. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70285. */
  70286. update(): void;
  70287. /** @hidden */
  70288. _rebuild(): void;
  70289. /**
  70290. * Disposes of the manager and pipelines
  70291. */
  70292. dispose(): void;
  70293. }
  70294. }
  70295. declare module BABYLON {
  70296. interface Scene {
  70297. /** @hidden (Backing field) */
  70298. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70299. /**
  70300. * Gets the postprocess render pipeline manager
  70301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70302. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70303. */
  70304. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70305. }
  70306. /**
  70307. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70308. */
  70309. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70310. /**
  70311. * The component name helpfull to identify the component in the list of scene components.
  70312. */
  70313. readonly name: string;
  70314. /**
  70315. * The scene the component belongs to.
  70316. */
  70317. scene: Scene;
  70318. /**
  70319. * Creates a new instance of the component for the given scene
  70320. * @param scene Defines the scene to register the component in
  70321. */
  70322. constructor(scene: Scene);
  70323. /**
  70324. * Registers the component in a given scene
  70325. */
  70326. register(): void;
  70327. /**
  70328. * Rebuilds the elements related to this component in case of
  70329. * context lost for instance.
  70330. */
  70331. rebuild(): void;
  70332. /**
  70333. * Disposes the component and the associated ressources
  70334. */
  70335. dispose(): void;
  70336. private _gatherRenderTargets;
  70337. }
  70338. }
  70339. declare module BABYLON {
  70340. /**
  70341. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70342. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70343. */
  70344. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70345. private _scene;
  70346. private _camerasToBeAttached;
  70347. /**
  70348. * ID of the sharpen post process,
  70349. */
  70350. private readonly SharpenPostProcessId;
  70351. /**
  70352. * @ignore
  70353. * ID of the image processing post process;
  70354. */
  70355. readonly ImageProcessingPostProcessId: string;
  70356. /**
  70357. * @ignore
  70358. * ID of the Fast Approximate Anti-Aliasing post process;
  70359. */
  70360. readonly FxaaPostProcessId: string;
  70361. /**
  70362. * ID of the chromatic aberration post process,
  70363. */
  70364. private readonly ChromaticAberrationPostProcessId;
  70365. /**
  70366. * ID of the grain post process
  70367. */
  70368. private readonly GrainPostProcessId;
  70369. /**
  70370. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70371. */
  70372. sharpen: SharpenPostProcess;
  70373. private _sharpenEffect;
  70374. private bloom;
  70375. /**
  70376. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70377. */
  70378. depthOfField: DepthOfFieldEffect;
  70379. /**
  70380. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70381. */
  70382. fxaa: FxaaPostProcess;
  70383. /**
  70384. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70385. */
  70386. imageProcessing: ImageProcessingPostProcess;
  70387. /**
  70388. * Chromatic aberration post process which will shift rgb colors in the image
  70389. */
  70390. chromaticAberration: ChromaticAberrationPostProcess;
  70391. private _chromaticAberrationEffect;
  70392. /**
  70393. * Grain post process which add noise to the image
  70394. */
  70395. grain: GrainPostProcess;
  70396. private _grainEffect;
  70397. /**
  70398. * Glow post process which adds a glow to emissive areas of the image
  70399. */
  70400. private _glowLayer;
  70401. /**
  70402. * Animations which can be used to tweak settings over a period of time
  70403. */
  70404. animations: Animation[];
  70405. private _imageProcessingConfigurationObserver;
  70406. private _sharpenEnabled;
  70407. private _bloomEnabled;
  70408. private _depthOfFieldEnabled;
  70409. private _depthOfFieldBlurLevel;
  70410. private _fxaaEnabled;
  70411. private _imageProcessingEnabled;
  70412. private _defaultPipelineTextureType;
  70413. private _bloomScale;
  70414. private _chromaticAberrationEnabled;
  70415. private _grainEnabled;
  70416. private _buildAllowed;
  70417. /**
  70418. * Gets active scene
  70419. */
  70420. get scene(): Scene;
  70421. /**
  70422. * Enable or disable the sharpen process from the pipeline
  70423. */
  70424. set sharpenEnabled(enabled: boolean);
  70425. get sharpenEnabled(): boolean;
  70426. private _resizeObserver;
  70427. private _hardwareScaleLevel;
  70428. private _bloomKernel;
  70429. /**
  70430. * Specifies the size of the bloom blur kernel, relative to the final output size
  70431. */
  70432. get bloomKernel(): number;
  70433. set bloomKernel(value: number);
  70434. /**
  70435. * Specifies the weight of the bloom in the final rendering
  70436. */
  70437. private _bloomWeight;
  70438. /**
  70439. * Specifies the luma threshold for the area that will be blurred by the bloom
  70440. */
  70441. private _bloomThreshold;
  70442. private _hdr;
  70443. /**
  70444. * The strength of the bloom.
  70445. */
  70446. set bloomWeight(value: number);
  70447. get bloomWeight(): number;
  70448. /**
  70449. * The strength of the bloom.
  70450. */
  70451. set bloomThreshold(value: number);
  70452. get bloomThreshold(): number;
  70453. /**
  70454. * The scale of the bloom, lower value will provide better performance.
  70455. */
  70456. set bloomScale(value: number);
  70457. get bloomScale(): number;
  70458. /**
  70459. * Enable or disable the bloom from the pipeline
  70460. */
  70461. set bloomEnabled(enabled: boolean);
  70462. get bloomEnabled(): boolean;
  70463. private _rebuildBloom;
  70464. /**
  70465. * If the depth of field is enabled.
  70466. */
  70467. get depthOfFieldEnabled(): boolean;
  70468. set depthOfFieldEnabled(enabled: boolean);
  70469. /**
  70470. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70471. */
  70472. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70473. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70474. /**
  70475. * If the anti aliasing is enabled.
  70476. */
  70477. set fxaaEnabled(enabled: boolean);
  70478. get fxaaEnabled(): boolean;
  70479. private _samples;
  70480. /**
  70481. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70482. */
  70483. set samples(sampleCount: number);
  70484. get samples(): number;
  70485. /**
  70486. * If image processing is enabled.
  70487. */
  70488. set imageProcessingEnabled(enabled: boolean);
  70489. get imageProcessingEnabled(): boolean;
  70490. /**
  70491. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70492. */
  70493. set glowLayerEnabled(enabled: boolean);
  70494. get glowLayerEnabled(): boolean;
  70495. /**
  70496. * Gets the glow layer (or null if not defined)
  70497. */
  70498. get glowLayer(): Nullable<GlowLayer>;
  70499. /**
  70500. * Enable or disable the chromaticAberration process from the pipeline
  70501. */
  70502. set chromaticAberrationEnabled(enabled: boolean);
  70503. get chromaticAberrationEnabled(): boolean;
  70504. /**
  70505. * Enable or disable the grain process from the pipeline
  70506. */
  70507. set grainEnabled(enabled: boolean);
  70508. get grainEnabled(): boolean;
  70509. /**
  70510. * @constructor
  70511. * @param name - The rendering pipeline name (default: "")
  70512. * @param hdr - If high dynamic range textures should be used (default: true)
  70513. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70514. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70515. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70516. */
  70517. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70518. /**
  70519. * Get the class name
  70520. * @returns "DefaultRenderingPipeline"
  70521. */
  70522. getClassName(): string;
  70523. /**
  70524. * Force the compilation of the entire pipeline.
  70525. */
  70526. prepare(): void;
  70527. private _hasCleared;
  70528. private _prevPostProcess;
  70529. private _prevPrevPostProcess;
  70530. private _setAutoClearAndTextureSharing;
  70531. private _depthOfFieldSceneObserver;
  70532. private _buildPipeline;
  70533. private _disposePostProcesses;
  70534. /**
  70535. * Adds a camera to the pipeline
  70536. * @param camera the camera to be added
  70537. */
  70538. addCamera(camera: Camera): void;
  70539. /**
  70540. * Removes a camera from the pipeline
  70541. * @param camera the camera to remove
  70542. */
  70543. removeCamera(camera: Camera): void;
  70544. /**
  70545. * Dispose of the pipeline and stop all post processes
  70546. */
  70547. dispose(): void;
  70548. /**
  70549. * Serialize the rendering pipeline (Used when exporting)
  70550. * @returns the serialized object
  70551. */
  70552. serialize(): any;
  70553. /**
  70554. * Parse the serialized pipeline
  70555. * @param source Source pipeline.
  70556. * @param scene The scene to load the pipeline to.
  70557. * @param rootUrl The URL of the serialized pipeline.
  70558. * @returns An instantiated pipeline from the serialized object.
  70559. */
  70560. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70561. }
  70562. }
  70563. declare module BABYLON {
  70564. /** @hidden */
  70565. export var lensHighlightsPixelShader: {
  70566. name: string;
  70567. shader: string;
  70568. };
  70569. }
  70570. declare module BABYLON {
  70571. /** @hidden */
  70572. export var depthOfFieldPixelShader: {
  70573. name: string;
  70574. shader: string;
  70575. };
  70576. }
  70577. declare module BABYLON {
  70578. /**
  70579. * BABYLON.JS Chromatic Aberration GLSL Shader
  70580. * Author: Olivier Guyot
  70581. * Separates very slightly R, G and B colors on the edges of the screen
  70582. * Inspired by Francois Tarlier & Martins Upitis
  70583. */
  70584. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70585. /**
  70586. * @ignore
  70587. * The chromatic aberration PostProcess id in the pipeline
  70588. */
  70589. LensChromaticAberrationEffect: string;
  70590. /**
  70591. * @ignore
  70592. * The highlights enhancing PostProcess id in the pipeline
  70593. */
  70594. HighlightsEnhancingEffect: string;
  70595. /**
  70596. * @ignore
  70597. * The depth-of-field PostProcess id in the pipeline
  70598. */
  70599. LensDepthOfFieldEffect: string;
  70600. private _scene;
  70601. private _depthTexture;
  70602. private _grainTexture;
  70603. private _chromaticAberrationPostProcess;
  70604. private _highlightsPostProcess;
  70605. private _depthOfFieldPostProcess;
  70606. private _edgeBlur;
  70607. private _grainAmount;
  70608. private _chromaticAberration;
  70609. private _distortion;
  70610. private _highlightsGain;
  70611. private _highlightsThreshold;
  70612. private _dofDistance;
  70613. private _dofAperture;
  70614. private _dofDarken;
  70615. private _dofPentagon;
  70616. private _blurNoise;
  70617. /**
  70618. * @constructor
  70619. *
  70620. * Effect parameters are as follow:
  70621. * {
  70622. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70623. * edge_blur: number; // from 0 to x (1 for realism)
  70624. * distortion: number; // from 0 to x (1 for realism)
  70625. * grain_amount: number; // from 0 to 1
  70626. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70627. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70628. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70629. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70630. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70631. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70632. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70633. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70634. * }
  70635. * Note: if an effect parameter is unset, effect is disabled
  70636. *
  70637. * @param name The rendering pipeline name
  70638. * @param parameters - An object containing all parameters (see above)
  70639. * @param scene The scene linked to this pipeline
  70640. * @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)
  70641. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70642. */
  70643. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70644. /**
  70645. * Get the class name
  70646. * @returns "LensRenderingPipeline"
  70647. */
  70648. getClassName(): string;
  70649. /**
  70650. * Gets associated scene
  70651. */
  70652. get scene(): Scene;
  70653. /**
  70654. * Gets or sets the edge blur
  70655. */
  70656. get edgeBlur(): number;
  70657. set edgeBlur(value: number);
  70658. /**
  70659. * Gets or sets the grain amount
  70660. */
  70661. get grainAmount(): number;
  70662. set grainAmount(value: number);
  70663. /**
  70664. * Gets or sets the chromatic aberration amount
  70665. */
  70666. get chromaticAberration(): number;
  70667. set chromaticAberration(value: number);
  70668. /**
  70669. * Gets or sets the depth of field aperture
  70670. */
  70671. get dofAperture(): number;
  70672. set dofAperture(value: number);
  70673. /**
  70674. * Gets or sets the edge distortion
  70675. */
  70676. get edgeDistortion(): number;
  70677. set edgeDistortion(value: number);
  70678. /**
  70679. * Gets or sets the depth of field distortion
  70680. */
  70681. get dofDistortion(): number;
  70682. set dofDistortion(value: number);
  70683. /**
  70684. * Gets or sets the darken out of focus amount
  70685. */
  70686. get darkenOutOfFocus(): number;
  70687. set darkenOutOfFocus(value: number);
  70688. /**
  70689. * Gets or sets a boolean indicating if blur noise is enabled
  70690. */
  70691. get blurNoise(): boolean;
  70692. set blurNoise(value: boolean);
  70693. /**
  70694. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70695. */
  70696. get pentagonBokeh(): boolean;
  70697. set pentagonBokeh(value: boolean);
  70698. /**
  70699. * Gets or sets the highlight grain amount
  70700. */
  70701. get highlightsGain(): number;
  70702. set highlightsGain(value: number);
  70703. /**
  70704. * Gets or sets the highlight threshold
  70705. */
  70706. get highlightsThreshold(): number;
  70707. set highlightsThreshold(value: number);
  70708. /**
  70709. * Sets the amount of blur at the edges
  70710. * @param amount blur amount
  70711. */
  70712. setEdgeBlur(amount: number): void;
  70713. /**
  70714. * Sets edge blur to 0
  70715. */
  70716. disableEdgeBlur(): void;
  70717. /**
  70718. * Sets the amout of grain
  70719. * @param amount Amount of grain
  70720. */
  70721. setGrainAmount(amount: number): void;
  70722. /**
  70723. * Set grain amount to 0
  70724. */
  70725. disableGrain(): void;
  70726. /**
  70727. * Sets the chromatic aberration amount
  70728. * @param amount amount of chromatic aberration
  70729. */
  70730. setChromaticAberration(amount: number): void;
  70731. /**
  70732. * Sets chromatic aberration amount to 0
  70733. */
  70734. disableChromaticAberration(): void;
  70735. /**
  70736. * Sets the EdgeDistortion amount
  70737. * @param amount amount of EdgeDistortion
  70738. */
  70739. setEdgeDistortion(amount: number): void;
  70740. /**
  70741. * Sets edge distortion to 0
  70742. */
  70743. disableEdgeDistortion(): void;
  70744. /**
  70745. * Sets the FocusDistance amount
  70746. * @param amount amount of FocusDistance
  70747. */
  70748. setFocusDistance(amount: number): void;
  70749. /**
  70750. * Disables depth of field
  70751. */
  70752. disableDepthOfField(): void;
  70753. /**
  70754. * Sets the Aperture amount
  70755. * @param amount amount of Aperture
  70756. */
  70757. setAperture(amount: number): void;
  70758. /**
  70759. * Sets the DarkenOutOfFocus amount
  70760. * @param amount amount of DarkenOutOfFocus
  70761. */
  70762. setDarkenOutOfFocus(amount: number): void;
  70763. private _pentagonBokehIsEnabled;
  70764. /**
  70765. * Creates a pentagon bokeh effect
  70766. */
  70767. enablePentagonBokeh(): void;
  70768. /**
  70769. * Disables the pentagon bokeh effect
  70770. */
  70771. disablePentagonBokeh(): void;
  70772. /**
  70773. * Enables noise blur
  70774. */
  70775. enableNoiseBlur(): void;
  70776. /**
  70777. * Disables noise blur
  70778. */
  70779. disableNoiseBlur(): void;
  70780. /**
  70781. * Sets the HighlightsGain amount
  70782. * @param amount amount of HighlightsGain
  70783. */
  70784. setHighlightsGain(amount: number): void;
  70785. /**
  70786. * Sets the HighlightsThreshold amount
  70787. * @param amount amount of HighlightsThreshold
  70788. */
  70789. setHighlightsThreshold(amount: number): void;
  70790. /**
  70791. * Disables highlights
  70792. */
  70793. disableHighlights(): void;
  70794. /**
  70795. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70796. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70797. */
  70798. dispose(disableDepthRender?: boolean): void;
  70799. private _createChromaticAberrationPostProcess;
  70800. private _createHighlightsPostProcess;
  70801. private _createDepthOfFieldPostProcess;
  70802. private _createGrainTexture;
  70803. }
  70804. }
  70805. declare module BABYLON {
  70806. /** @hidden */
  70807. export var ssao2PixelShader: {
  70808. name: string;
  70809. shader: string;
  70810. };
  70811. }
  70812. declare module BABYLON {
  70813. /** @hidden */
  70814. export var ssaoCombinePixelShader: {
  70815. name: string;
  70816. shader: string;
  70817. };
  70818. }
  70819. declare module BABYLON {
  70820. /**
  70821. * Render pipeline to produce ssao effect
  70822. */
  70823. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70824. /**
  70825. * @ignore
  70826. * The PassPostProcess id in the pipeline that contains the original scene color
  70827. */
  70828. SSAOOriginalSceneColorEffect: string;
  70829. /**
  70830. * @ignore
  70831. * The SSAO PostProcess id in the pipeline
  70832. */
  70833. SSAORenderEffect: string;
  70834. /**
  70835. * @ignore
  70836. * The horizontal blur PostProcess id in the pipeline
  70837. */
  70838. SSAOBlurHRenderEffect: string;
  70839. /**
  70840. * @ignore
  70841. * The vertical blur PostProcess id in the pipeline
  70842. */
  70843. SSAOBlurVRenderEffect: string;
  70844. /**
  70845. * @ignore
  70846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70847. */
  70848. SSAOCombineRenderEffect: string;
  70849. /**
  70850. * The output strength of the SSAO post-process. Default value is 1.0.
  70851. */
  70852. totalStrength: number;
  70853. /**
  70854. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70855. */
  70856. maxZ: number;
  70857. /**
  70858. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70859. */
  70860. minZAspect: number;
  70861. private _samples;
  70862. /**
  70863. * Number of samples used for the SSAO calculations. Default value is 8
  70864. */
  70865. set samples(n: number);
  70866. get samples(): number;
  70867. private _textureSamples;
  70868. /**
  70869. * Number of samples to use for antialiasing
  70870. */
  70871. set textureSamples(n: number);
  70872. get textureSamples(): number;
  70873. /**
  70874. * Force rendering the geometry through geometry buffer
  70875. */
  70876. private _forceGeometryBuffer;
  70877. /**
  70878. * Ratio object used for SSAO ratio and blur ratio
  70879. */
  70880. private _ratio;
  70881. /**
  70882. * Dynamically generated sphere sampler.
  70883. */
  70884. private _sampleSphere;
  70885. /**
  70886. * Blur filter offsets
  70887. */
  70888. private _samplerOffsets;
  70889. private _expensiveBlur;
  70890. /**
  70891. * If bilateral blur should be used
  70892. */
  70893. set expensiveBlur(b: boolean);
  70894. get expensiveBlur(): boolean;
  70895. /**
  70896. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70897. */
  70898. radius: number;
  70899. /**
  70900. * The base color of the SSAO post-process
  70901. * The final result is "base + ssao" between [0, 1]
  70902. */
  70903. base: number;
  70904. /**
  70905. * Support test.
  70906. */
  70907. static get IsSupported(): boolean;
  70908. private _scene;
  70909. private _randomTexture;
  70910. private _originalColorPostProcess;
  70911. private _ssaoPostProcess;
  70912. private _blurHPostProcess;
  70913. private _blurVPostProcess;
  70914. private _ssaoCombinePostProcess;
  70915. private _prePassRenderer;
  70916. /**
  70917. * Gets active scene
  70918. */
  70919. get scene(): Scene;
  70920. /**
  70921. * @constructor
  70922. * @param name The rendering pipeline name
  70923. * @param scene The scene linked to this pipeline
  70924. * @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 }
  70925. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70926. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70927. */
  70928. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70929. /**
  70930. * Get the class name
  70931. * @returns "SSAO2RenderingPipeline"
  70932. */
  70933. getClassName(): string;
  70934. /**
  70935. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70936. */
  70937. dispose(disableGeometryBufferRenderer?: boolean): void;
  70938. private _createBlurPostProcess;
  70939. /** @hidden */
  70940. _rebuild(): void;
  70941. private _bits;
  70942. private _radicalInverse_VdC;
  70943. private _hammersley;
  70944. private _hemisphereSample_uniform;
  70945. private _generateHemisphere;
  70946. private _getDefinesForSSAO;
  70947. private _createSSAOPostProcess;
  70948. private _createSSAOCombinePostProcess;
  70949. private _createRandomTexture;
  70950. /**
  70951. * Serialize the rendering pipeline (Used when exporting)
  70952. * @returns the serialized object
  70953. */
  70954. serialize(): any;
  70955. /**
  70956. * Parse the serialized pipeline
  70957. * @param source Source pipeline.
  70958. * @param scene The scene to load the pipeline to.
  70959. * @param rootUrl The URL of the serialized pipeline.
  70960. * @returns An instantiated pipeline from the serialized object.
  70961. */
  70962. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70963. /**
  70964. * Sets the required values to the prepass renderer.
  70965. * @param prePassRenderer defines the prepass renderer to setup
  70966. * @returns true if the pre pass is needed.
  70967. */
  70968. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70969. }
  70970. }
  70971. declare module BABYLON {
  70972. /** @hidden */
  70973. export var ssaoPixelShader: {
  70974. name: string;
  70975. shader: string;
  70976. };
  70977. }
  70978. declare module BABYLON {
  70979. /**
  70980. * Render pipeline to produce ssao effect
  70981. */
  70982. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70983. /**
  70984. * @ignore
  70985. * The PassPostProcess id in the pipeline that contains the original scene color
  70986. */
  70987. SSAOOriginalSceneColorEffect: string;
  70988. /**
  70989. * @ignore
  70990. * The SSAO PostProcess id in the pipeline
  70991. */
  70992. SSAORenderEffect: string;
  70993. /**
  70994. * @ignore
  70995. * The horizontal blur PostProcess id in the pipeline
  70996. */
  70997. SSAOBlurHRenderEffect: string;
  70998. /**
  70999. * @ignore
  71000. * The vertical blur PostProcess id in the pipeline
  71001. */
  71002. SSAOBlurVRenderEffect: string;
  71003. /**
  71004. * @ignore
  71005. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71006. */
  71007. SSAOCombineRenderEffect: string;
  71008. /**
  71009. * The output strength of the SSAO post-process. Default value is 1.0.
  71010. */
  71011. totalStrength: number;
  71012. /**
  71013. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71014. */
  71015. radius: number;
  71016. /**
  71017. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71018. * Must not be equal to fallOff and superior to fallOff.
  71019. * Default value is 0.0075
  71020. */
  71021. area: number;
  71022. /**
  71023. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71024. * Must not be equal to area and inferior to area.
  71025. * Default value is 0.000001
  71026. */
  71027. fallOff: number;
  71028. /**
  71029. * The base color of the SSAO post-process
  71030. * The final result is "base + ssao" between [0, 1]
  71031. */
  71032. base: number;
  71033. private _scene;
  71034. private _depthTexture;
  71035. private _randomTexture;
  71036. private _originalColorPostProcess;
  71037. private _ssaoPostProcess;
  71038. private _blurHPostProcess;
  71039. private _blurVPostProcess;
  71040. private _ssaoCombinePostProcess;
  71041. private _firstUpdate;
  71042. /**
  71043. * Gets active scene
  71044. */
  71045. get scene(): Scene;
  71046. /**
  71047. * @constructor
  71048. * @param name - The rendering pipeline name
  71049. * @param scene - The scene linked to this pipeline
  71050. * @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 }
  71051. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71052. */
  71053. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71054. /**
  71055. * Get the class name
  71056. * @returns "SSAORenderingPipeline"
  71057. */
  71058. getClassName(): string;
  71059. /**
  71060. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71061. */
  71062. dispose(disableDepthRender?: boolean): void;
  71063. private _createBlurPostProcess;
  71064. /** @hidden */
  71065. _rebuild(): void;
  71066. private _createSSAOPostProcess;
  71067. private _createSSAOCombinePostProcess;
  71068. private _createRandomTexture;
  71069. }
  71070. }
  71071. declare module BABYLON {
  71072. /** @hidden */
  71073. export var screenSpaceReflectionPixelShader: {
  71074. name: string;
  71075. shader: string;
  71076. };
  71077. }
  71078. declare module BABYLON {
  71079. /**
  71080. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71081. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71082. */
  71083. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71084. /**
  71085. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71086. */
  71087. threshold: number;
  71088. /**
  71089. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71090. */
  71091. strength: number;
  71092. /**
  71093. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71094. */
  71095. reflectionSpecularFalloffExponent: number;
  71096. /**
  71097. * 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]
  71098. */
  71099. step: number;
  71100. /**
  71101. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71102. */
  71103. roughnessFactor: number;
  71104. private _geometryBufferRenderer;
  71105. private _enableSmoothReflections;
  71106. private _reflectionSamples;
  71107. private _smoothSteps;
  71108. /**
  71109. * Gets a string identifying the name of the class
  71110. * @returns "ScreenSpaceReflectionPostProcess" string
  71111. */
  71112. getClassName(): string;
  71113. /**
  71114. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71115. * @param name The name of the effect.
  71116. * @param scene The scene containing the objects to calculate reflections.
  71117. * @param options The required width/height ratio to downsize to before computing the render pass.
  71118. * @param camera The camera to apply the render pass to.
  71119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71120. * @param engine The engine which the post process will be applied. (default: current engine)
  71121. * @param reusable If the post process can be reused on the same frame. (default: false)
  71122. * @param textureType Type of textures used when performing the post process. (default: 0)
  71123. * @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)
  71124. */
  71125. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71126. /**
  71127. * Gets wether or not smoothing reflections is enabled.
  71128. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71129. */
  71130. get enableSmoothReflections(): boolean;
  71131. /**
  71132. * Sets wether or not smoothing reflections is enabled.
  71133. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71134. */
  71135. set enableSmoothReflections(enabled: boolean);
  71136. /**
  71137. * Gets the number of samples taken while computing reflections. More samples count is high,
  71138. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71139. */
  71140. get reflectionSamples(): number;
  71141. /**
  71142. * Sets the number of samples taken while computing reflections. More samples count is high,
  71143. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71144. */
  71145. set reflectionSamples(samples: number);
  71146. /**
  71147. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71148. * more the post-process will require GPU power and can generate a drop in FPS.
  71149. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71150. */
  71151. get smoothSteps(): number;
  71152. set smoothSteps(steps: number);
  71153. private _updateEffectDefines;
  71154. /** @hidden */
  71155. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71156. }
  71157. }
  71158. declare module BABYLON {
  71159. /** @hidden */
  71160. export var standardPixelShader: {
  71161. name: string;
  71162. shader: string;
  71163. };
  71164. }
  71165. declare module BABYLON {
  71166. /**
  71167. * Standard rendering pipeline
  71168. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71169. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71170. */
  71171. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71172. /**
  71173. * Public members
  71174. */
  71175. /**
  71176. * Post-process which contains the original scene color before the pipeline applies all the effects
  71177. */
  71178. originalPostProcess: Nullable<PostProcess>;
  71179. /**
  71180. * Post-process used to down scale an image x4
  71181. */
  71182. downSampleX4PostProcess: Nullable<PostProcess>;
  71183. /**
  71184. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71185. */
  71186. brightPassPostProcess: Nullable<PostProcess>;
  71187. /**
  71188. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71189. */
  71190. blurHPostProcesses: PostProcess[];
  71191. /**
  71192. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71193. */
  71194. blurVPostProcesses: PostProcess[];
  71195. /**
  71196. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71197. */
  71198. textureAdderPostProcess: Nullable<PostProcess>;
  71199. /**
  71200. * Post-process used to create volumetric lighting effect
  71201. */
  71202. volumetricLightPostProcess: Nullable<PostProcess>;
  71203. /**
  71204. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71205. */
  71206. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71207. /**
  71208. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71209. */
  71210. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71211. /**
  71212. * Post-process used to merge the volumetric light effect and the real scene color
  71213. */
  71214. volumetricLightMergePostProces: Nullable<PostProcess>;
  71215. /**
  71216. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71217. */
  71218. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71219. /**
  71220. * Base post-process used to calculate the average luminance of the final image for HDR
  71221. */
  71222. luminancePostProcess: Nullable<PostProcess>;
  71223. /**
  71224. * Post-processes used to create down sample post-processes in order to get
  71225. * the average luminance of the final image for HDR
  71226. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71227. */
  71228. luminanceDownSamplePostProcesses: PostProcess[];
  71229. /**
  71230. * Post-process used to create a HDR effect (light adaptation)
  71231. */
  71232. hdrPostProcess: Nullable<PostProcess>;
  71233. /**
  71234. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71235. */
  71236. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71237. /**
  71238. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71239. */
  71240. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71241. /**
  71242. * Post-process used to merge the final HDR post-process and the real scene color
  71243. */
  71244. hdrFinalPostProcess: Nullable<PostProcess>;
  71245. /**
  71246. * Post-process used to create a lens flare effect
  71247. */
  71248. lensFlarePostProcess: Nullable<PostProcess>;
  71249. /**
  71250. * Post-process that merges the result of the lens flare post-process and the real scene color
  71251. */
  71252. lensFlareComposePostProcess: Nullable<PostProcess>;
  71253. /**
  71254. * Post-process used to create a motion blur effect
  71255. */
  71256. motionBlurPostProcess: Nullable<PostProcess>;
  71257. /**
  71258. * Post-process used to create a depth of field effect
  71259. */
  71260. depthOfFieldPostProcess: Nullable<PostProcess>;
  71261. /**
  71262. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71263. */
  71264. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71265. /**
  71266. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71267. */
  71268. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71269. /**
  71270. * Represents the brightness threshold in order to configure the illuminated surfaces
  71271. */
  71272. brightThreshold: number;
  71273. /**
  71274. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71275. */
  71276. blurWidth: number;
  71277. /**
  71278. * Sets if the blur for highlighted surfaces must be only horizontal
  71279. */
  71280. horizontalBlur: boolean;
  71281. /**
  71282. * Gets the overall exposure used by the pipeline
  71283. */
  71284. get exposure(): number;
  71285. /**
  71286. * Sets the overall exposure used by the pipeline
  71287. */
  71288. set exposure(value: number);
  71289. /**
  71290. * Texture used typically to simulate "dirty" on camera lens
  71291. */
  71292. lensTexture: Nullable<Texture>;
  71293. /**
  71294. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71295. */
  71296. volumetricLightCoefficient: number;
  71297. /**
  71298. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71299. */
  71300. volumetricLightPower: number;
  71301. /**
  71302. * Used the set the blur intensity to smooth the volumetric lights
  71303. */
  71304. volumetricLightBlurScale: number;
  71305. /**
  71306. * Light (spot or directional) used to generate the volumetric lights rays
  71307. * The source light must have a shadow generate so the pipeline can get its
  71308. * depth map
  71309. */
  71310. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71311. /**
  71312. * For eye adaptation, represents the minimum luminance the eye can see
  71313. */
  71314. hdrMinimumLuminance: number;
  71315. /**
  71316. * For eye adaptation, represents the decrease luminance speed
  71317. */
  71318. hdrDecreaseRate: number;
  71319. /**
  71320. * For eye adaptation, represents the increase luminance speed
  71321. */
  71322. hdrIncreaseRate: number;
  71323. /**
  71324. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71325. */
  71326. get hdrAutoExposure(): boolean;
  71327. /**
  71328. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71329. */
  71330. set hdrAutoExposure(value: boolean);
  71331. /**
  71332. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71333. */
  71334. lensColorTexture: Nullable<Texture>;
  71335. /**
  71336. * The overall strengh for the lens flare effect
  71337. */
  71338. lensFlareStrength: number;
  71339. /**
  71340. * Dispersion coefficient for lens flare ghosts
  71341. */
  71342. lensFlareGhostDispersal: number;
  71343. /**
  71344. * Main lens flare halo width
  71345. */
  71346. lensFlareHaloWidth: number;
  71347. /**
  71348. * Based on the lens distortion effect, defines how much the lens flare result
  71349. * is distorted
  71350. */
  71351. lensFlareDistortionStrength: number;
  71352. /**
  71353. * Configures the blur intensity used for for lens flare (halo)
  71354. */
  71355. lensFlareBlurWidth: number;
  71356. /**
  71357. * Lens star texture must be used to simulate rays on the flares and is available
  71358. * in the documentation
  71359. */
  71360. lensStarTexture: Nullable<Texture>;
  71361. /**
  71362. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71363. * flare effect by taking account of the dirt texture
  71364. */
  71365. lensFlareDirtTexture: Nullable<Texture>;
  71366. /**
  71367. * Represents the focal length for the depth of field effect
  71368. */
  71369. depthOfFieldDistance: number;
  71370. /**
  71371. * Represents the blur intensity for the blurred part of the depth of field effect
  71372. */
  71373. depthOfFieldBlurWidth: number;
  71374. /**
  71375. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71376. */
  71377. get motionStrength(): number;
  71378. /**
  71379. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71380. */
  71381. set motionStrength(strength: number);
  71382. /**
  71383. * Gets wether or not the motion blur post-process is object based or screen based.
  71384. */
  71385. get objectBasedMotionBlur(): boolean;
  71386. /**
  71387. * Sets wether or not the motion blur post-process should be object based or screen based
  71388. */
  71389. set objectBasedMotionBlur(value: boolean);
  71390. /**
  71391. * List of animations for the pipeline (IAnimatable implementation)
  71392. */
  71393. animations: Animation[];
  71394. /**
  71395. * Private members
  71396. */
  71397. private _scene;
  71398. private _currentDepthOfFieldSource;
  71399. private _basePostProcess;
  71400. private _fixedExposure;
  71401. private _currentExposure;
  71402. private _hdrAutoExposure;
  71403. private _hdrCurrentLuminance;
  71404. private _motionStrength;
  71405. private _isObjectBasedMotionBlur;
  71406. private _floatTextureType;
  71407. private _camerasToBeAttached;
  71408. private _ratio;
  71409. private _bloomEnabled;
  71410. private _depthOfFieldEnabled;
  71411. private _vlsEnabled;
  71412. private _lensFlareEnabled;
  71413. private _hdrEnabled;
  71414. private _motionBlurEnabled;
  71415. private _fxaaEnabled;
  71416. private _screenSpaceReflectionsEnabled;
  71417. private _motionBlurSamples;
  71418. private _volumetricLightStepsCount;
  71419. private _samples;
  71420. /**
  71421. * @ignore
  71422. * Specifies if the bloom pipeline is enabled
  71423. */
  71424. get BloomEnabled(): boolean;
  71425. set BloomEnabled(enabled: boolean);
  71426. /**
  71427. * @ignore
  71428. * Specifies if the depth of field pipeline is enabed
  71429. */
  71430. get DepthOfFieldEnabled(): boolean;
  71431. set DepthOfFieldEnabled(enabled: boolean);
  71432. /**
  71433. * @ignore
  71434. * Specifies if the lens flare pipeline is enabed
  71435. */
  71436. get LensFlareEnabled(): boolean;
  71437. set LensFlareEnabled(enabled: boolean);
  71438. /**
  71439. * @ignore
  71440. * Specifies if the HDR pipeline is enabled
  71441. */
  71442. get HDREnabled(): boolean;
  71443. set HDREnabled(enabled: boolean);
  71444. /**
  71445. * @ignore
  71446. * Specifies if the volumetric lights scattering effect is enabled
  71447. */
  71448. get VLSEnabled(): boolean;
  71449. set VLSEnabled(enabled: boolean);
  71450. /**
  71451. * @ignore
  71452. * Specifies if the motion blur effect is enabled
  71453. */
  71454. get MotionBlurEnabled(): boolean;
  71455. set MotionBlurEnabled(enabled: boolean);
  71456. /**
  71457. * Specifies if anti-aliasing is enabled
  71458. */
  71459. get fxaaEnabled(): boolean;
  71460. set fxaaEnabled(enabled: boolean);
  71461. /**
  71462. * Specifies if screen space reflections are enabled.
  71463. */
  71464. get screenSpaceReflectionsEnabled(): boolean;
  71465. set screenSpaceReflectionsEnabled(enabled: boolean);
  71466. /**
  71467. * Specifies the number of steps used to calculate the volumetric lights
  71468. * Typically in interval [50, 200]
  71469. */
  71470. get volumetricLightStepsCount(): number;
  71471. set volumetricLightStepsCount(count: number);
  71472. /**
  71473. * Specifies the number of samples used for the motion blur effect
  71474. * Typically in interval [16, 64]
  71475. */
  71476. get motionBlurSamples(): number;
  71477. set motionBlurSamples(samples: number);
  71478. /**
  71479. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71480. */
  71481. get samples(): number;
  71482. set samples(sampleCount: number);
  71483. /**
  71484. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71485. * @constructor
  71486. * @param name The rendering pipeline name
  71487. * @param scene The scene linked to this pipeline
  71488. * @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)
  71489. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71490. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71491. */
  71492. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71493. private _buildPipeline;
  71494. private _createDownSampleX4PostProcess;
  71495. private _createBrightPassPostProcess;
  71496. private _createBlurPostProcesses;
  71497. private _createTextureAdderPostProcess;
  71498. private _createVolumetricLightPostProcess;
  71499. private _createLuminancePostProcesses;
  71500. private _createHdrPostProcess;
  71501. private _createLensFlarePostProcess;
  71502. private _createDepthOfFieldPostProcess;
  71503. private _createMotionBlurPostProcess;
  71504. private _getDepthTexture;
  71505. private _disposePostProcesses;
  71506. /**
  71507. * Dispose of the pipeline and stop all post processes
  71508. */
  71509. dispose(): void;
  71510. /**
  71511. * Serialize the rendering pipeline (Used when exporting)
  71512. * @returns the serialized object
  71513. */
  71514. serialize(): any;
  71515. /**
  71516. * Parse the serialized pipeline
  71517. * @param source Source pipeline.
  71518. * @param scene The scene to load the pipeline to.
  71519. * @param rootUrl The URL of the serialized pipeline.
  71520. * @returns An instantiated pipeline from the serialized object.
  71521. */
  71522. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71523. /**
  71524. * Luminance steps
  71525. */
  71526. static LuminanceSteps: number;
  71527. }
  71528. }
  71529. declare module BABYLON {
  71530. /** @hidden */
  71531. export var stereoscopicInterlacePixelShader: {
  71532. name: string;
  71533. shader: string;
  71534. };
  71535. }
  71536. declare module BABYLON {
  71537. /**
  71538. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71539. */
  71540. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71541. private _stepSize;
  71542. private _passedProcess;
  71543. /**
  71544. * Gets a string identifying the name of the class
  71545. * @returns "StereoscopicInterlacePostProcessI" string
  71546. */
  71547. getClassName(): string;
  71548. /**
  71549. * Initializes a StereoscopicInterlacePostProcessI
  71550. * @param name The name of the effect.
  71551. * @param rigCameras The rig cameras to be appled to the post process
  71552. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71553. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71555. * @param engine The engine which the post process will be applied. (default: current engine)
  71556. * @param reusable If the post process can be reused on the same frame. (default: false)
  71557. */
  71558. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71559. }
  71560. /**
  71561. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71562. */
  71563. export class StereoscopicInterlacePostProcess extends PostProcess {
  71564. private _stepSize;
  71565. private _passedProcess;
  71566. /**
  71567. * Gets a string identifying the name of the class
  71568. * @returns "StereoscopicInterlacePostProcess" string
  71569. */
  71570. getClassName(): string;
  71571. /**
  71572. * Initializes a StereoscopicInterlacePostProcess
  71573. * @param name The name of the effect.
  71574. * @param rigCameras The rig cameras to be appled to the post process
  71575. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71577. * @param engine The engine which the post process will be applied. (default: current engine)
  71578. * @param reusable If the post process can be reused on the same frame. (default: false)
  71579. */
  71580. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71581. }
  71582. }
  71583. declare module BABYLON {
  71584. /** @hidden */
  71585. export var tonemapPixelShader: {
  71586. name: string;
  71587. shader: string;
  71588. };
  71589. }
  71590. declare module BABYLON {
  71591. /** Defines operator used for tonemapping */
  71592. export enum TonemappingOperator {
  71593. /** Hable */
  71594. Hable = 0,
  71595. /** Reinhard */
  71596. Reinhard = 1,
  71597. /** HejiDawson */
  71598. HejiDawson = 2,
  71599. /** Photographic */
  71600. Photographic = 3
  71601. }
  71602. /**
  71603. * Defines a post process to apply tone mapping
  71604. */
  71605. export class TonemapPostProcess extends PostProcess {
  71606. private _operator;
  71607. /** Defines the required exposure adjustement */
  71608. exposureAdjustment: number;
  71609. /**
  71610. * Gets a string identifying the name of the class
  71611. * @returns "TonemapPostProcess" string
  71612. */
  71613. getClassName(): string;
  71614. /**
  71615. * Creates a new TonemapPostProcess
  71616. * @param name defines the name of the postprocess
  71617. * @param _operator defines the operator to use
  71618. * @param exposureAdjustment defines the required exposure adjustement
  71619. * @param camera defines the camera to use (can be null)
  71620. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71621. * @param engine defines the hosting engine (can be ignore if camera is set)
  71622. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71623. */
  71624. constructor(name: string, _operator: TonemappingOperator,
  71625. /** Defines the required exposure adjustement */
  71626. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71627. }
  71628. }
  71629. declare module BABYLON {
  71630. /** @hidden */
  71631. export var volumetricLightScatteringPixelShader: {
  71632. name: string;
  71633. shader: string;
  71634. };
  71635. }
  71636. declare module BABYLON {
  71637. /** @hidden */
  71638. export var volumetricLightScatteringPassVertexShader: {
  71639. name: string;
  71640. shader: string;
  71641. };
  71642. }
  71643. declare module BABYLON {
  71644. /** @hidden */
  71645. export var volumetricLightScatteringPassPixelShader: {
  71646. name: string;
  71647. shader: string;
  71648. };
  71649. }
  71650. declare module BABYLON {
  71651. /**
  71652. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71653. */
  71654. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71655. private _volumetricLightScatteringPass;
  71656. private _volumetricLightScatteringRTT;
  71657. private _viewPort;
  71658. private _screenCoordinates;
  71659. private _cachedDefines;
  71660. /**
  71661. * If not undefined, the mesh position is computed from the attached node position
  71662. */
  71663. attachedNode: {
  71664. position: Vector3;
  71665. };
  71666. /**
  71667. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71668. */
  71669. customMeshPosition: Vector3;
  71670. /**
  71671. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71672. */
  71673. useCustomMeshPosition: boolean;
  71674. /**
  71675. * If the post-process should inverse the light scattering direction
  71676. */
  71677. invert: boolean;
  71678. /**
  71679. * The internal mesh used by the post-process
  71680. */
  71681. mesh: Mesh;
  71682. /**
  71683. * @hidden
  71684. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71685. */
  71686. get useDiffuseColor(): boolean;
  71687. set useDiffuseColor(useDiffuseColor: boolean);
  71688. /**
  71689. * Array containing the excluded meshes not rendered in the internal pass
  71690. */
  71691. excludedMeshes: AbstractMesh[];
  71692. /**
  71693. * Controls the overall intensity of the post-process
  71694. */
  71695. exposure: number;
  71696. /**
  71697. * Dissipates each sample's contribution in range [0, 1]
  71698. */
  71699. decay: number;
  71700. /**
  71701. * Controls the overall intensity of each sample
  71702. */
  71703. weight: number;
  71704. /**
  71705. * Controls the density of each sample
  71706. */
  71707. density: number;
  71708. /**
  71709. * @constructor
  71710. * @param name The post-process name
  71711. * @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)
  71712. * @param camera The camera that the post-process will be attached to
  71713. * @param mesh The mesh used to create the light scattering
  71714. * @param samples The post-process quality, default 100
  71715. * @param samplingModeThe post-process filtering mode
  71716. * @param engine The babylon engine
  71717. * @param reusable If the post-process is reusable
  71718. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71719. */
  71720. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71721. /**
  71722. * Returns the string "VolumetricLightScatteringPostProcess"
  71723. * @returns "VolumetricLightScatteringPostProcess"
  71724. */
  71725. getClassName(): string;
  71726. private _isReady;
  71727. /**
  71728. * Sets the new light position for light scattering effect
  71729. * @param position The new custom light position
  71730. */
  71731. setCustomMeshPosition(position: Vector3): void;
  71732. /**
  71733. * Returns the light position for light scattering effect
  71734. * @return Vector3 The custom light position
  71735. */
  71736. getCustomMeshPosition(): Vector3;
  71737. /**
  71738. * Disposes the internal assets and detaches the post-process from the camera
  71739. */
  71740. dispose(camera: Camera): void;
  71741. /**
  71742. * Returns the render target texture used by the post-process
  71743. * @return the render target texture used by the post-process
  71744. */
  71745. getPass(): RenderTargetTexture;
  71746. private _meshExcluded;
  71747. private _createPass;
  71748. private _updateMeshScreenCoordinates;
  71749. /**
  71750. * Creates a default mesh for the Volumeric Light Scattering post-process
  71751. * @param name The mesh name
  71752. * @param scene The scene where to create the mesh
  71753. * @return the default mesh
  71754. */
  71755. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71756. }
  71757. }
  71758. declare module BABYLON {
  71759. /** @hidden */
  71760. export var screenSpaceCurvaturePixelShader: {
  71761. name: string;
  71762. shader: string;
  71763. };
  71764. }
  71765. declare module BABYLON {
  71766. /**
  71767. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71768. */
  71769. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71770. /**
  71771. * Defines how much ridge the curvature effect displays.
  71772. */
  71773. ridge: number;
  71774. /**
  71775. * Defines how much valley the curvature effect displays.
  71776. */
  71777. valley: number;
  71778. private _geometryBufferRenderer;
  71779. /**
  71780. * Gets a string identifying the name of the class
  71781. * @returns "ScreenSpaceCurvaturePostProcess" string
  71782. */
  71783. getClassName(): string;
  71784. /**
  71785. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71786. * @param name The name of the effect.
  71787. * @param scene The scene containing the objects to blur according to their velocity.
  71788. * @param options The required width/height ratio to downsize to before computing the render pass.
  71789. * @param camera The camera to apply the render pass to.
  71790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71791. * @param engine The engine which the post process will be applied. (default: current engine)
  71792. * @param reusable If the post process can be reused on the same frame. (default: false)
  71793. * @param textureType Type of textures used when performing the post process. (default: 0)
  71794. * @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)
  71795. */
  71796. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71797. /**
  71798. * Support test.
  71799. */
  71800. static get IsSupported(): boolean;
  71801. /** @hidden */
  71802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. interface Scene {
  71807. /** @hidden (Backing field) */
  71808. _boundingBoxRenderer: BoundingBoxRenderer;
  71809. /** @hidden (Backing field) */
  71810. _forceShowBoundingBoxes: boolean;
  71811. /**
  71812. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71813. */
  71814. forceShowBoundingBoxes: boolean;
  71815. /**
  71816. * Gets the bounding box renderer associated with the scene
  71817. * @returns a BoundingBoxRenderer
  71818. */
  71819. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71820. }
  71821. interface AbstractMesh {
  71822. /** @hidden (Backing field) */
  71823. _showBoundingBox: boolean;
  71824. /**
  71825. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71826. */
  71827. showBoundingBox: boolean;
  71828. }
  71829. /**
  71830. * Component responsible of rendering the bounding box of the meshes in a scene.
  71831. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71832. */
  71833. export class BoundingBoxRenderer implements ISceneComponent {
  71834. /**
  71835. * The component name helpfull to identify the component in the list of scene components.
  71836. */
  71837. readonly name: string;
  71838. /**
  71839. * The scene the component belongs to.
  71840. */
  71841. scene: Scene;
  71842. /**
  71843. * Color of the bounding box lines placed in front of an object
  71844. */
  71845. frontColor: Color3;
  71846. /**
  71847. * Color of the bounding box lines placed behind an object
  71848. */
  71849. backColor: Color3;
  71850. /**
  71851. * Defines if the renderer should show the back lines or not
  71852. */
  71853. showBackLines: boolean;
  71854. /**
  71855. * Observable raised before rendering a bounding box
  71856. */
  71857. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71858. /**
  71859. * Observable raised after rendering a bounding box
  71860. */
  71861. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71862. /**
  71863. * @hidden
  71864. */
  71865. renderList: SmartArray<BoundingBox>;
  71866. private _colorShader;
  71867. private _vertexBuffers;
  71868. private _indexBuffer;
  71869. private _fillIndexBuffer;
  71870. private _fillIndexData;
  71871. /**
  71872. * Instantiates a new bounding box renderer in a scene.
  71873. * @param scene the scene the renderer renders in
  71874. */
  71875. constructor(scene: Scene);
  71876. /**
  71877. * Registers the component in a given scene
  71878. */
  71879. register(): void;
  71880. private _evaluateSubMesh;
  71881. private _activeMesh;
  71882. private _prepareRessources;
  71883. private _createIndexBuffer;
  71884. /**
  71885. * Rebuilds the elements related to this component in case of
  71886. * context lost for instance.
  71887. */
  71888. rebuild(): void;
  71889. /**
  71890. * @hidden
  71891. */
  71892. reset(): void;
  71893. /**
  71894. * Render the bounding boxes of a specific rendering group
  71895. * @param renderingGroupId defines the rendering group to render
  71896. */
  71897. render(renderingGroupId: number): void;
  71898. /**
  71899. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71900. * @param mesh Define the mesh to render the occlusion bounding box for
  71901. */
  71902. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71903. /**
  71904. * Dispose and release the resources attached to this renderer.
  71905. */
  71906. dispose(): void;
  71907. }
  71908. }
  71909. declare module BABYLON {
  71910. interface Scene {
  71911. /** @hidden (Backing field) */
  71912. _depthRenderer: {
  71913. [id: string]: DepthRenderer;
  71914. };
  71915. /**
  71916. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71917. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71918. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71919. * @returns the created depth renderer
  71920. */
  71921. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71922. /**
  71923. * Disables a depth renderer for a given camera
  71924. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71925. */
  71926. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71927. }
  71928. /**
  71929. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71930. * in several rendering techniques.
  71931. */
  71932. export class DepthRendererSceneComponent implements ISceneComponent {
  71933. /**
  71934. * The component name helpfull to identify the component in the list of scene components.
  71935. */
  71936. readonly name: string;
  71937. /**
  71938. * The scene the component belongs to.
  71939. */
  71940. scene: Scene;
  71941. /**
  71942. * Creates a new instance of the component for the given scene
  71943. * @param scene Defines the scene to register the component in
  71944. */
  71945. constructor(scene: Scene);
  71946. /**
  71947. * Registers the component in a given scene
  71948. */
  71949. register(): void;
  71950. /**
  71951. * Rebuilds the elements related to this component in case of
  71952. * context lost for instance.
  71953. */
  71954. rebuild(): void;
  71955. /**
  71956. * Disposes the component and the associated ressources
  71957. */
  71958. dispose(): void;
  71959. private _gatherRenderTargets;
  71960. private _gatherActiveCameraRenderTargets;
  71961. }
  71962. }
  71963. declare module BABYLON {
  71964. interface AbstractScene {
  71965. /** @hidden (Backing field) */
  71966. _prePassRenderer: Nullable<PrePassRenderer>;
  71967. /**
  71968. * Gets or Sets the current prepass renderer associated to the scene.
  71969. */
  71970. prePassRenderer: Nullable<PrePassRenderer>;
  71971. /**
  71972. * Enables the prepass and associates it with the scene
  71973. * @returns the PrePassRenderer
  71974. */
  71975. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71976. /**
  71977. * Disables the prepass associated with the scene
  71978. */
  71979. disablePrePassRenderer(): void;
  71980. }
  71981. /**
  71982. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71983. * in several rendering techniques.
  71984. */
  71985. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71986. /**
  71987. * The component name helpful to identify the component in the list of scene components.
  71988. */
  71989. readonly name: string;
  71990. /**
  71991. * The scene the component belongs to.
  71992. */
  71993. scene: Scene;
  71994. /**
  71995. * Creates a new instance of the component for the given scene
  71996. * @param scene Defines the scene to register the component in
  71997. */
  71998. constructor(scene: Scene);
  71999. /**
  72000. * Registers the component in a given scene
  72001. */
  72002. register(): void;
  72003. private _beforeCameraDraw;
  72004. private _afterCameraDraw;
  72005. private _beforeClearStage;
  72006. /**
  72007. * Serializes the component data to the specified json object
  72008. * @param serializationObject The object to serialize to
  72009. */
  72010. serialize(serializationObject: any): void;
  72011. /**
  72012. * Adds all the elements from the container to the scene
  72013. * @param container the container holding the elements
  72014. */
  72015. addFromContainer(container: AbstractScene): void;
  72016. /**
  72017. * Removes all the elements in the container from the scene
  72018. * @param container contains the elements to remove
  72019. * @param dispose if the removed element should be disposed (default: false)
  72020. */
  72021. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72022. /**
  72023. * Rebuilds the elements related to this component in case of
  72024. * context lost for instance.
  72025. */
  72026. rebuild(): void;
  72027. /**
  72028. * Disposes the component and the associated ressources
  72029. */
  72030. dispose(): void;
  72031. }
  72032. }
  72033. declare module BABYLON {
  72034. /** @hidden */
  72035. export var outlinePixelShader: {
  72036. name: string;
  72037. shader: string;
  72038. };
  72039. }
  72040. declare module BABYLON {
  72041. /** @hidden */
  72042. export var outlineVertexShader: {
  72043. name: string;
  72044. shader: string;
  72045. };
  72046. }
  72047. declare module BABYLON {
  72048. interface Scene {
  72049. /** @hidden */
  72050. _outlineRenderer: OutlineRenderer;
  72051. /**
  72052. * Gets the outline renderer associated with the scene
  72053. * @returns a OutlineRenderer
  72054. */
  72055. getOutlineRenderer(): OutlineRenderer;
  72056. }
  72057. interface AbstractMesh {
  72058. /** @hidden (Backing field) */
  72059. _renderOutline: boolean;
  72060. /**
  72061. * Gets or sets a boolean indicating if the outline must be rendered as well
  72062. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72063. */
  72064. renderOutline: boolean;
  72065. /** @hidden (Backing field) */
  72066. _renderOverlay: boolean;
  72067. /**
  72068. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72069. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72070. */
  72071. renderOverlay: boolean;
  72072. }
  72073. /**
  72074. * This class is responsible to draw bothe outline/overlay of meshes.
  72075. * It should not be used directly but through the available method on mesh.
  72076. */
  72077. export class OutlineRenderer implements ISceneComponent {
  72078. /**
  72079. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72080. */
  72081. private static _StencilReference;
  72082. /**
  72083. * The name of the component. Each component must have a unique name.
  72084. */
  72085. name: string;
  72086. /**
  72087. * The scene the component belongs to.
  72088. */
  72089. scene: Scene;
  72090. /**
  72091. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72092. */
  72093. zOffset: number;
  72094. private _engine;
  72095. private _effect;
  72096. private _cachedDefines;
  72097. private _savedDepthWrite;
  72098. /**
  72099. * Instantiates a new outline renderer. (There could be only one per scene).
  72100. * @param scene Defines the scene it belongs to
  72101. */
  72102. constructor(scene: Scene);
  72103. /**
  72104. * Register the component to one instance of a scene.
  72105. */
  72106. register(): void;
  72107. /**
  72108. * Rebuilds the elements related to this component in case of
  72109. * context lost for instance.
  72110. */
  72111. rebuild(): void;
  72112. /**
  72113. * Disposes the component and the associated ressources.
  72114. */
  72115. dispose(): void;
  72116. /**
  72117. * Renders the outline in the canvas.
  72118. * @param subMesh Defines the sumesh to render
  72119. * @param batch Defines the batch of meshes in case of instances
  72120. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72121. */
  72122. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72123. /**
  72124. * Returns whether or not the outline renderer is ready for a given submesh.
  72125. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72126. * @param subMesh Defines the submesh to check readyness for
  72127. * @param useInstances Defines wheter wee are trying to render instances or not
  72128. * @returns true if ready otherwise false
  72129. */
  72130. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72131. private _beforeRenderingMesh;
  72132. private _afterRenderingMesh;
  72133. }
  72134. }
  72135. declare module BABYLON {
  72136. /**
  72137. * Defines the basic options interface of a Sprite Frame Source Size.
  72138. */
  72139. export interface ISpriteJSONSpriteSourceSize {
  72140. /**
  72141. * number of the original width of the Frame
  72142. */
  72143. w: number;
  72144. /**
  72145. * number of the original height of the Frame
  72146. */
  72147. h: number;
  72148. }
  72149. /**
  72150. * Defines the basic options interface of a Sprite Frame Data.
  72151. */
  72152. export interface ISpriteJSONSpriteFrameData {
  72153. /**
  72154. * number of the x offset of the Frame
  72155. */
  72156. x: number;
  72157. /**
  72158. * number of the y offset of the Frame
  72159. */
  72160. y: number;
  72161. /**
  72162. * number of the width of the Frame
  72163. */
  72164. w: number;
  72165. /**
  72166. * number of the height of the Frame
  72167. */
  72168. h: number;
  72169. }
  72170. /**
  72171. * Defines the basic options interface of a JSON Sprite.
  72172. */
  72173. export interface ISpriteJSONSprite {
  72174. /**
  72175. * string name of the Frame
  72176. */
  72177. filename: string;
  72178. /**
  72179. * ISpriteJSONSpriteFrame basic object of the frame data
  72180. */
  72181. frame: ISpriteJSONSpriteFrameData;
  72182. /**
  72183. * boolean to flag is the frame was rotated.
  72184. */
  72185. rotated: boolean;
  72186. /**
  72187. * boolean to flag is the frame was trimmed.
  72188. */
  72189. trimmed: boolean;
  72190. /**
  72191. * ISpriteJSONSpriteFrame basic object of the source data
  72192. */
  72193. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72194. /**
  72195. * ISpriteJSONSpriteFrame basic object of the source data
  72196. */
  72197. sourceSize: ISpriteJSONSpriteSourceSize;
  72198. }
  72199. /**
  72200. * Defines the basic options interface of a JSON atlas.
  72201. */
  72202. export interface ISpriteJSONAtlas {
  72203. /**
  72204. * Array of objects that contain the frame data.
  72205. */
  72206. frames: Array<ISpriteJSONSprite>;
  72207. /**
  72208. * object basic object containing the sprite meta data.
  72209. */
  72210. meta?: object;
  72211. }
  72212. }
  72213. declare module BABYLON {
  72214. /** @hidden */
  72215. export var spriteMapPixelShader: {
  72216. name: string;
  72217. shader: string;
  72218. };
  72219. }
  72220. declare module BABYLON {
  72221. /** @hidden */
  72222. export var spriteMapVertexShader: {
  72223. name: string;
  72224. shader: string;
  72225. };
  72226. }
  72227. declare module BABYLON {
  72228. /**
  72229. * Defines the basic options interface of a SpriteMap
  72230. */
  72231. export interface ISpriteMapOptions {
  72232. /**
  72233. * Vector2 of the number of cells in the grid.
  72234. */
  72235. stageSize?: Vector2;
  72236. /**
  72237. * Vector2 of the size of the output plane in World Units.
  72238. */
  72239. outputSize?: Vector2;
  72240. /**
  72241. * Vector3 of the position of the output plane in World Units.
  72242. */
  72243. outputPosition?: Vector3;
  72244. /**
  72245. * Vector3 of the rotation of the output plane.
  72246. */
  72247. outputRotation?: Vector3;
  72248. /**
  72249. * number of layers that the system will reserve in resources.
  72250. */
  72251. layerCount?: number;
  72252. /**
  72253. * number of max animation frames a single cell will reserve in resources.
  72254. */
  72255. maxAnimationFrames?: number;
  72256. /**
  72257. * number cell index of the base tile when the system compiles.
  72258. */
  72259. baseTile?: number;
  72260. /**
  72261. * boolean flip the sprite after its been repositioned by the framing data.
  72262. */
  72263. flipU?: boolean;
  72264. /**
  72265. * Vector3 scalar of the global RGB values of the SpriteMap.
  72266. */
  72267. colorMultiply?: Vector3;
  72268. }
  72269. /**
  72270. * Defines the IDisposable interface in order to be cleanable from resources.
  72271. */
  72272. export interface ISpriteMap extends IDisposable {
  72273. /**
  72274. * String name of the SpriteMap.
  72275. */
  72276. name: string;
  72277. /**
  72278. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72279. */
  72280. atlasJSON: ISpriteJSONAtlas;
  72281. /**
  72282. * Texture of the SpriteMap.
  72283. */
  72284. spriteSheet: Texture;
  72285. /**
  72286. * The parameters to initialize the SpriteMap with.
  72287. */
  72288. options: ISpriteMapOptions;
  72289. }
  72290. /**
  72291. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72292. */
  72293. export class SpriteMap implements ISpriteMap {
  72294. /** The Name of the spriteMap */
  72295. name: string;
  72296. /** The JSON file with the frame and meta data */
  72297. atlasJSON: ISpriteJSONAtlas;
  72298. /** The systems Sprite Sheet Texture */
  72299. spriteSheet: Texture;
  72300. /** Arguments passed with the Constructor */
  72301. options: ISpriteMapOptions;
  72302. /** Public Sprite Storage array, parsed from atlasJSON */
  72303. sprites: Array<ISpriteJSONSprite>;
  72304. /** Returns the Number of Sprites in the System */
  72305. get spriteCount(): number;
  72306. /** Returns the Position of Output Plane*/
  72307. get position(): Vector3;
  72308. /** Returns the Position of Output Plane*/
  72309. set position(v: Vector3);
  72310. /** Returns the Rotation of Output Plane*/
  72311. get rotation(): Vector3;
  72312. /** Returns the Rotation of Output Plane*/
  72313. set rotation(v: Vector3);
  72314. /** Sets the AnimationMap*/
  72315. get animationMap(): RawTexture;
  72316. /** Sets the AnimationMap*/
  72317. set animationMap(v: RawTexture);
  72318. /** Scene that the SpriteMap was created in */
  72319. private _scene;
  72320. /** Texture Buffer of Float32 that holds tile frame data*/
  72321. private _frameMap;
  72322. /** Texture Buffers of Float32 that holds tileMap data*/
  72323. private _tileMaps;
  72324. /** Texture Buffer of Float32 that holds Animation Data*/
  72325. private _animationMap;
  72326. /** Custom ShaderMaterial Central to the System*/
  72327. private _material;
  72328. /** Custom ShaderMaterial Central to the System*/
  72329. private _output;
  72330. /** Systems Time Ticker*/
  72331. private _time;
  72332. /**
  72333. * Creates a new SpriteMap
  72334. * @param name defines the SpriteMaps Name
  72335. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72336. * @param spriteSheet is the Texture that the Sprites are on.
  72337. * @param options a basic deployment configuration
  72338. * @param scene The Scene that the map is deployed on
  72339. */
  72340. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72341. /**
  72342. * Returns tileID location
  72343. * @returns Vector2 the cell position ID
  72344. */
  72345. getTileID(): Vector2;
  72346. /**
  72347. * Gets the UV location of the mouse over the SpriteMap.
  72348. * @returns Vector2 the UV position of the mouse interaction
  72349. */
  72350. getMousePosition(): Vector2;
  72351. /**
  72352. * Creates the "frame" texture Buffer
  72353. * -------------------------------------
  72354. * Structure of frames
  72355. * "filename": "Falling-Water-2.png",
  72356. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72357. * "rotated": true,
  72358. * "trimmed": true,
  72359. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72360. * "sourceSize": {"w":32,"h":32}
  72361. * @returns RawTexture of the frameMap
  72362. */
  72363. private _createFrameBuffer;
  72364. /**
  72365. * Creates the tileMap texture Buffer
  72366. * @param buffer normally and array of numbers, or a false to generate from scratch
  72367. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72368. * @returns RawTexture of the tileMap
  72369. */
  72370. private _createTileBuffer;
  72371. /**
  72372. * Modifies the data of the tileMaps
  72373. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72374. * @param pos is the iVector2 Coordinates of the Tile
  72375. * @param tile The SpriteIndex of the new Tile
  72376. */
  72377. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72378. /**
  72379. * Creates the animationMap texture Buffer
  72380. * @param buffer normally and array of numbers, or a false to generate from scratch
  72381. * @returns RawTexture of the animationMap
  72382. */
  72383. private _createTileAnimationBuffer;
  72384. /**
  72385. * Modifies the data of the animationMap
  72386. * @param cellID is the Index of the Sprite
  72387. * @param _frame is the target Animation frame
  72388. * @param toCell is the Target Index of the next frame of the animation
  72389. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72390. * @param speed is a global scalar of the time variable on the map.
  72391. */
  72392. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72393. /**
  72394. * Exports the .tilemaps file
  72395. */
  72396. saveTileMaps(): void;
  72397. /**
  72398. * Imports the .tilemaps file
  72399. * @param url of the .tilemaps file
  72400. */
  72401. loadTileMaps(url: string): void;
  72402. /**
  72403. * Release associated resources
  72404. */
  72405. dispose(): void;
  72406. }
  72407. }
  72408. declare module BABYLON {
  72409. /**
  72410. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72411. * @see https://doc.babylonjs.com/babylon101/sprites
  72412. */
  72413. export class SpritePackedManager extends SpriteManager {
  72414. /** defines the packed manager's name */
  72415. name: string;
  72416. /**
  72417. * Creates a new sprite manager from a packed sprite sheet
  72418. * @param name defines the manager's name
  72419. * @param imgUrl defines the sprite sheet url
  72420. * @param capacity defines the maximum allowed number of sprites
  72421. * @param scene defines the hosting scene
  72422. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72423. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72424. * @param samplingMode defines the smapling mode to use with spritesheet
  72425. * @param fromPacked set to true; do not alter
  72426. */
  72427. constructor(
  72428. /** defines the packed manager's name */
  72429. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. /**
  72434. * Defines the list of states available for a task inside a AssetsManager
  72435. */
  72436. export enum AssetTaskState {
  72437. /**
  72438. * Initialization
  72439. */
  72440. INIT = 0,
  72441. /**
  72442. * Running
  72443. */
  72444. RUNNING = 1,
  72445. /**
  72446. * Done
  72447. */
  72448. DONE = 2,
  72449. /**
  72450. * Error
  72451. */
  72452. ERROR = 3
  72453. }
  72454. /**
  72455. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72456. */
  72457. export abstract class AbstractAssetTask {
  72458. /**
  72459. * Task name
  72460. */ name: string;
  72461. /**
  72462. * Callback called when the task is successful
  72463. */
  72464. onSuccess: (task: any) => void;
  72465. /**
  72466. * Callback called when the task is not successful
  72467. */
  72468. onError: (task: any, message?: string, exception?: any) => void;
  72469. /**
  72470. * Creates a new AssetsManager
  72471. * @param name defines the name of the task
  72472. */
  72473. constructor(
  72474. /**
  72475. * Task name
  72476. */ name: string);
  72477. private _isCompleted;
  72478. private _taskState;
  72479. private _errorObject;
  72480. /**
  72481. * Get if the task is completed
  72482. */
  72483. get isCompleted(): boolean;
  72484. /**
  72485. * Gets the current state of the task
  72486. */
  72487. get taskState(): AssetTaskState;
  72488. /**
  72489. * Gets the current error object (if task is in error)
  72490. */
  72491. get errorObject(): {
  72492. message?: string;
  72493. exception?: any;
  72494. };
  72495. /**
  72496. * Internal only
  72497. * @hidden
  72498. */
  72499. _setErrorObject(message?: string, exception?: any): void;
  72500. /**
  72501. * Execute the current task
  72502. * @param scene defines the scene where you want your assets to be loaded
  72503. * @param onSuccess is a callback called when the task is successfully executed
  72504. * @param onError is a callback called if an error occurs
  72505. */
  72506. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72507. /**
  72508. * Execute the current task
  72509. * @param scene defines the scene where you want your assets to be loaded
  72510. * @param onSuccess is a callback called when the task is successfully executed
  72511. * @param onError is a callback called if an error occurs
  72512. */
  72513. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72514. /**
  72515. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72516. * This can be used with failed tasks that have the reason for failure fixed.
  72517. */
  72518. reset(): void;
  72519. private onErrorCallback;
  72520. private onDoneCallback;
  72521. }
  72522. /**
  72523. * Define the interface used by progress events raised during assets loading
  72524. */
  72525. export interface IAssetsProgressEvent {
  72526. /**
  72527. * Defines the number of remaining tasks to process
  72528. */
  72529. remainingCount: number;
  72530. /**
  72531. * Defines the total number of tasks
  72532. */
  72533. totalCount: number;
  72534. /**
  72535. * Defines the task that was just processed
  72536. */
  72537. task: AbstractAssetTask;
  72538. }
  72539. /**
  72540. * Class used to share progress information about assets loading
  72541. */
  72542. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72543. /**
  72544. * Defines the number of remaining tasks to process
  72545. */
  72546. remainingCount: number;
  72547. /**
  72548. * Defines the total number of tasks
  72549. */
  72550. totalCount: number;
  72551. /**
  72552. * Defines the task that was just processed
  72553. */
  72554. task: AbstractAssetTask;
  72555. /**
  72556. * Creates a AssetsProgressEvent
  72557. * @param remainingCount defines the number of remaining tasks to process
  72558. * @param totalCount defines the total number of tasks
  72559. * @param task defines the task that was just processed
  72560. */
  72561. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72562. }
  72563. /**
  72564. * Define a task used by AssetsManager to load assets into a container
  72565. */
  72566. export class ContainerAssetTask extends AbstractAssetTask {
  72567. /**
  72568. * Defines the name of the task
  72569. */
  72570. name: string;
  72571. /**
  72572. * Defines the list of mesh's names you want to load
  72573. */
  72574. meshesNames: any;
  72575. /**
  72576. * Defines the root url to use as a base to load your meshes and associated resources
  72577. */
  72578. rootUrl: string;
  72579. /**
  72580. * Defines the filename or File of the scene to load from
  72581. */
  72582. sceneFilename: string | File;
  72583. /**
  72584. * Get the loaded asset container
  72585. */
  72586. loadedContainer: AssetContainer;
  72587. /**
  72588. * Gets the list of loaded meshes
  72589. */
  72590. loadedMeshes: Array<AbstractMesh>;
  72591. /**
  72592. * Gets the list of loaded particle systems
  72593. */
  72594. loadedParticleSystems: Array<IParticleSystem>;
  72595. /**
  72596. * Gets the list of loaded skeletons
  72597. */
  72598. loadedSkeletons: Array<Skeleton>;
  72599. /**
  72600. * Gets the list of loaded animation groups
  72601. */
  72602. loadedAnimationGroups: Array<AnimationGroup>;
  72603. /**
  72604. * Callback called when the task is successful
  72605. */
  72606. onSuccess: (task: ContainerAssetTask) => void;
  72607. /**
  72608. * Callback called when the task is successful
  72609. */
  72610. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72611. /**
  72612. * Creates a new ContainerAssetTask
  72613. * @param name defines the name of the task
  72614. * @param meshesNames defines the list of mesh's names you want to load
  72615. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72616. * @param sceneFilename defines the filename or File of the scene to load from
  72617. */
  72618. constructor(
  72619. /**
  72620. * Defines the name of the task
  72621. */
  72622. name: string,
  72623. /**
  72624. * Defines the list of mesh's names you want to load
  72625. */
  72626. meshesNames: any,
  72627. /**
  72628. * Defines the root url to use as a base to load your meshes and associated resources
  72629. */
  72630. rootUrl: string,
  72631. /**
  72632. * Defines the filename or File of the scene to load from
  72633. */
  72634. sceneFilename: string | File);
  72635. /**
  72636. * Execute the current task
  72637. * @param scene defines the scene where you want your assets to be loaded
  72638. * @param onSuccess is a callback called when the task is successfully executed
  72639. * @param onError is a callback called if an error occurs
  72640. */
  72641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72642. }
  72643. /**
  72644. * Define a task used by AssetsManager to load meshes
  72645. */
  72646. export class MeshAssetTask extends AbstractAssetTask {
  72647. /**
  72648. * Defines the name of the task
  72649. */
  72650. name: string;
  72651. /**
  72652. * Defines the list of mesh's names you want to load
  72653. */
  72654. meshesNames: any;
  72655. /**
  72656. * Defines the root url to use as a base to load your meshes and associated resources
  72657. */
  72658. rootUrl: string;
  72659. /**
  72660. * Defines the filename or File of the scene to load from
  72661. */
  72662. sceneFilename: string | File;
  72663. /**
  72664. * Gets the list of loaded meshes
  72665. */
  72666. loadedMeshes: Array<AbstractMesh>;
  72667. /**
  72668. * Gets the list of loaded particle systems
  72669. */
  72670. loadedParticleSystems: Array<IParticleSystem>;
  72671. /**
  72672. * Gets the list of loaded skeletons
  72673. */
  72674. loadedSkeletons: Array<Skeleton>;
  72675. /**
  72676. * Gets the list of loaded animation groups
  72677. */
  72678. loadedAnimationGroups: Array<AnimationGroup>;
  72679. /**
  72680. * Callback called when the task is successful
  72681. */
  72682. onSuccess: (task: MeshAssetTask) => void;
  72683. /**
  72684. * Callback called when the task is successful
  72685. */
  72686. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72687. /**
  72688. * Creates a new MeshAssetTask
  72689. * @param name defines the name of the task
  72690. * @param meshesNames defines the list of mesh's names you want to load
  72691. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72692. * @param sceneFilename defines the filename or File of the scene to load from
  72693. */
  72694. constructor(
  72695. /**
  72696. * Defines the name of the task
  72697. */
  72698. name: string,
  72699. /**
  72700. * Defines the list of mesh's names you want to load
  72701. */
  72702. meshesNames: any,
  72703. /**
  72704. * Defines the root url to use as a base to load your meshes and associated resources
  72705. */
  72706. rootUrl: string,
  72707. /**
  72708. * Defines the filename or File of the scene to load from
  72709. */
  72710. sceneFilename: string | File);
  72711. /**
  72712. * Execute the current task
  72713. * @param scene defines the scene where you want your assets to be loaded
  72714. * @param onSuccess is a callback called when the task is successfully executed
  72715. * @param onError is a callback called if an error occurs
  72716. */
  72717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72718. }
  72719. /**
  72720. * Define a task used by AssetsManager to load text content
  72721. */
  72722. export class TextFileAssetTask extends AbstractAssetTask {
  72723. /**
  72724. * Defines the name of the task
  72725. */
  72726. name: string;
  72727. /**
  72728. * Defines the location of the file to load
  72729. */
  72730. url: string;
  72731. /**
  72732. * Gets the loaded text string
  72733. */
  72734. text: string;
  72735. /**
  72736. * Callback called when the task is successful
  72737. */
  72738. onSuccess: (task: TextFileAssetTask) => void;
  72739. /**
  72740. * Callback called when the task is successful
  72741. */
  72742. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72743. /**
  72744. * Creates a new TextFileAssetTask object
  72745. * @param name defines the name of the task
  72746. * @param url defines the location of the file to load
  72747. */
  72748. constructor(
  72749. /**
  72750. * Defines the name of the task
  72751. */
  72752. name: string,
  72753. /**
  72754. * Defines the location of the file to load
  72755. */
  72756. url: string);
  72757. /**
  72758. * Execute the current task
  72759. * @param scene defines the scene where you want your assets to be loaded
  72760. * @param onSuccess is a callback called when the task is successfully executed
  72761. * @param onError is a callback called if an error occurs
  72762. */
  72763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72764. }
  72765. /**
  72766. * Define a task used by AssetsManager to load binary data
  72767. */
  72768. export class BinaryFileAssetTask extends AbstractAssetTask {
  72769. /**
  72770. * Defines the name of the task
  72771. */
  72772. name: string;
  72773. /**
  72774. * Defines the location of the file to load
  72775. */
  72776. url: string;
  72777. /**
  72778. * Gets the lodaded data (as an array buffer)
  72779. */
  72780. data: ArrayBuffer;
  72781. /**
  72782. * Callback called when the task is successful
  72783. */
  72784. onSuccess: (task: BinaryFileAssetTask) => void;
  72785. /**
  72786. * Callback called when the task is successful
  72787. */
  72788. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72789. /**
  72790. * Creates a new BinaryFileAssetTask object
  72791. * @param name defines the name of the new task
  72792. * @param url defines the location of the file to load
  72793. */
  72794. constructor(
  72795. /**
  72796. * Defines the name of the task
  72797. */
  72798. name: string,
  72799. /**
  72800. * Defines the location of the file to load
  72801. */
  72802. url: string);
  72803. /**
  72804. * Execute the current task
  72805. * @param scene defines the scene where you want your assets to be loaded
  72806. * @param onSuccess is a callback called when the task is successfully executed
  72807. * @param onError is a callback called if an error occurs
  72808. */
  72809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72810. }
  72811. /**
  72812. * Define a task used by AssetsManager to load images
  72813. */
  72814. export class ImageAssetTask extends AbstractAssetTask {
  72815. /**
  72816. * Defines the name of the task
  72817. */
  72818. name: string;
  72819. /**
  72820. * Defines the location of the image to load
  72821. */
  72822. url: string;
  72823. /**
  72824. * Gets the loaded images
  72825. */
  72826. image: HTMLImageElement;
  72827. /**
  72828. * Callback called when the task is successful
  72829. */
  72830. onSuccess: (task: ImageAssetTask) => void;
  72831. /**
  72832. * Callback called when the task is successful
  72833. */
  72834. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72835. /**
  72836. * Creates a new ImageAssetTask
  72837. * @param name defines the name of the task
  72838. * @param url defines the location of the image to load
  72839. */
  72840. constructor(
  72841. /**
  72842. * Defines the name of the task
  72843. */
  72844. name: string,
  72845. /**
  72846. * Defines the location of the image to load
  72847. */
  72848. url: string);
  72849. /**
  72850. * Execute the current task
  72851. * @param scene defines the scene where you want your assets to be loaded
  72852. * @param onSuccess is a callback called when the task is successfully executed
  72853. * @param onError is a callback called if an error occurs
  72854. */
  72855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72856. }
  72857. /**
  72858. * Defines the interface used by texture loading tasks
  72859. */
  72860. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72861. /**
  72862. * Gets the loaded texture
  72863. */
  72864. texture: TEX;
  72865. }
  72866. /**
  72867. * Define a task used by AssetsManager to load 2D textures
  72868. */
  72869. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72870. /**
  72871. * Defines the name of the task
  72872. */
  72873. name: string;
  72874. /**
  72875. * Defines the location of the file to load
  72876. */
  72877. url: string;
  72878. /**
  72879. * Defines if mipmap should not be generated (default is false)
  72880. */
  72881. noMipmap?: boolean | undefined;
  72882. /**
  72883. * Defines if texture must be inverted on Y axis (default is true)
  72884. */
  72885. invertY: boolean;
  72886. /**
  72887. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72888. */
  72889. samplingMode: number;
  72890. /**
  72891. * Gets the loaded texture
  72892. */
  72893. texture: Texture;
  72894. /**
  72895. * Callback called when the task is successful
  72896. */
  72897. onSuccess: (task: TextureAssetTask) => void;
  72898. /**
  72899. * Callback called when the task is successful
  72900. */
  72901. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72902. /**
  72903. * Creates a new TextureAssetTask object
  72904. * @param name defines the name of the task
  72905. * @param url defines the location of the file to load
  72906. * @param noMipmap defines if mipmap should not be generated (default is false)
  72907. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72908. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72909. */
  72910. constructor(
  72911. /**
  72912. * Defines the name of the task
  72913. */
  72914. name: string,
  72915. /**
  72916. * Defines the location of the file to load
  72917. */
  72918. url: string,
  72919. /**
  72920. * Defines if mipmap should not be generated (default is false)
  72921. */
  72922. noMipmap?: boolean | undefined,
  72923. /**
  72924. * Defines if texture must be inverted on Y axis (default is true)
  72925. */
  72926. invertY?: boolean,
  72927. /**
  72928. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72929. */
  72930. samplingMode?: number);
  72931. /**
  72932. * Execute the current task
  72933. * @param scene defines the scene where you want your assets to be loaded
  72934. * @param onSuccess is a callback called when the task is successfully executed
  72935. * @param onError is a callback called if an error occurs
  72936. */
  72937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72938. }
  72939. /**
  72940. * Define a task used by AssetsManager to load cube textures
  72941. */
  72942. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72943. /**
  72944. * Defines the name of the task
  72945. */
  72946. name: string;
  72947. /**
  72948. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72949. */
  72950. url: string;
  72951. /**
  72952. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72953. */
  72954. extensions?: string[] | undefined;
  72955. /**
  72956. * Defines if mipmaps should not be generated (default is false)
  72957. */
  72958. noMipmap?: boolean | undefined;
  72959. /**
  72960. * Defines the explicit list of files (undefined by default)
  72961. */
  72962. files?: string[] | undefined;
  72963. /**
  72964. * Gets the loaded texture
  72965. */
  72966. texture: CubeTexture;
  72967. /**
  72968. * Callback called when the task is successful
  72969. */
  72970. onSuccess: (task: CubeTextureAssetTask) => void;
  72971. /**
  72972. * Callback called when the task is successful
  72973. */
  72974. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72975. /**
  72976. * Creates a new CubeTextureAssetTask
  72977. * @param name defines the name of the task
  72978. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72979. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72980. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72981. * @param files defines the explicit list of files (undefined by default)
  72982. */
  72983. constructor(
  72984. /**
  72985. * Defines the name of the task
  72986. */
  72987. name: string,
  72988. /**
  72989. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72990. */
  72991. url: string,
  72992. /**
  72993. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72994. */
  72995. extensions?: string[] | undefined,
  72996. /**
  72997. * Defines if mipmaps should not be generated (default is false)
  72998. */
  72999. noMipmap?: boolean | undefined,
  73000. /**
  73001. * Defines the explicit list of files (undefined by default)
  73002. */
  73003. files?: string[] | undefined);
  73004. /**
  73005. * Execute the current task
  73006. * @param scene defines the scene where you want your assets to be loaded
  73007. * @param onSuccess is a callback called when the task is successfully executed
  73008. * @param onError is a callback called if an error occurs
  73009. */
  73010. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73011. }
  73012. /**
  73013. * Define a task used by AssetsManager to load HDR cube textures
  73014. */
  73015. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73016. /**
  73017. * Defines the name of the task
  73018. */
  73019. name: string;
  73020. /**
  73021. * Defines the location of the file to load
  73022. */
  73023. url: string;
  73024. /**
  73025. * Defines the desired size (the more it increases the longer the generation will be)
  73026. */
  73027. size: number;
  73028. /**
  73029. * Defines if mipmaps should not be generated (default is false)
  73030. */
  73031. noMipmap: boolean;
  73032. /**
  73033. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73034. */
  73035. generateHarmonics: boolean;
  73036. /**
  73037. * 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)
  73038. */
  73039. gammaSpace: boolean;
  73040. /**
  73041. * Internal Use Only
  73042. */
  73043. reserved: boolean;
  73044. /**
  73045. * Gets the loaded texture
  73046. */
  73047. texture: HDRCubeTexture;
  73048. /**
  73049. * Callback called when the task is successful
  73050. */
  73051. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73052. /**
  73053. * Callback called when the task is successful
  73054. */
  73055. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73056. /**
  73057. * Creates a new HDRCubeTextureAssetTask object
  73058. * @param name defines the name of the task
  73059. * @param url defines the location of the file to load
  73060. * @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.
  73061. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73062. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73063. * @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)
  73064. * @param reserved Internal use only
  73065. */
  73066. constructor(
  73067. /**
  73068. * Defines the name of the task
  73069. */
  73070. name: string,
  73071. /**
  73072. * Defines the location of the file to load
  73073. */
  73074. url: string,
  73075. /**
  73076. * Defines the desired size (the more it increases the longer the generation will be)
  73077. */
  73078. size: number,
  73079. /**
  73080. * Defines if mipmaps should not be generated (default is false)
  73081. */
  73082. noMipmap?: boolean,
  73083. /**
  73084. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73085. */
  73086. generateHarmonics?: boolean,
  73087. /**
  73088. * 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)
  73089. */
  73090. gammaSpace?: boolean,
  73091. /**
  73092. * Internal Use Only
  73093. */
  73094. reserved?: boolean);
  73095. /**
  73096. * Execute the current task
  73097. * @param scene defines the scene where you want your assets to be loaded
  73098. * @param onSuccess is a callback called when the task is successfully executed
  73099. * @param onError is a callback called if an error occurs
  73100. */
  73101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73102. }
  73103. /**
  73104. * Define a task used by AssetsManager to load Equirectangular cube textures
  73105. */
  73106. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73107. /**
  73108. * Defines the name of the task
  73109. */
  73110. name: string;
  73111. /**
  73112. * Defines the location of the file to load
  73113. */
  73114. url: string;
  73115. /**
  73116. * Defines the desired size (the more it increases the longer the generation will be)
  73117. */
  73118. size: number;
  73119. /**
  73120. * Defines if mipmaps should not be generated (default is false)
  73121. */
  73122. noMipmap: boolean;
  73123. /**
  73124. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73125. * but the standard material would require them in Gamma space) (default is true)
  73126. */
  73127. gammaSpace: boolean;
  73128. /**
  73129. * Gets the loaded texture
  73130. */
  73131. texture: EquiRectangularCubeTexture;
  73132. /**
  73133. * Callback called when the task is successful
  73134. */
  73135. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73136. /**
  73137. * Callback called when the task is successful
  73138. */
  73139. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73140. /**
  73141. * Creates a new EquiRectangularCubeTextureAssetTask object
  73142. * @param name defines the name of the task
  73143. * @param url defines the location of the file to load
  73144. * @param size defines the desired size (the more it increases the longer the generation will be)
  73145. * If the size is omitted this implies you are using a preprocessed cubemap.
  73146. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73147. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73148. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73149. * (default is true)
  73150. */
  73151. constructor(
  73152. /**
  73153. * Defines the name of the task
  73154. */
  73155. name: string,
  73156. /**
  73157. * Defines the location of the file to load
  73158. */
  73159. url: string,
  73160. /**
  73161. * Defines the desired size (the more it increases the longer the generation will be)
  73162. */
  73163. size: number,
  73164. /**
  73165. * Defines if mipmaps should not be generated (default is false)
  73166. */
  73167. noMipmap?: boolean,
  73168. /**
  73169. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73170. * but the standard material would require them in Gamma space) (default is true)
  73171. */
  73172. gammaSpace?: boolean);
  73173. /**
  73174. * Execute the current task
  73175. * @param scene defines the scene where you want your assets to be loaded
  73176. * @param onSuccess is a callback called when the task is successfully executed
  73177. * @param onError is a callback called if an error occurs
  73178. */
  73179. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73180. }
  73181. /**
  73182. * This class can be used to easily import assets into a scene
  73183. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73184. */
  73185. export class AssetsManager {
  73186. private _scene;
  73187. private _isLoading;
  73188. protected _tasks: AbstractAssetTask[];
  73189. protected _waitingTasksCount: number;
  73190. protected _totalTasksCount: number;
  73191. /**
  73192. * Callback called when all tasks are processed
  73193. */
  73194. onFinish: (tasks: AbstractAssetTask[]) => void;
  73195. /**
  73196. * Callback called when a task is successful
  73197. */
  73198. onTaskSuccess: (task: AbstractAssetTask) => void;
  73199. /**
  73200. * Callback called when a task had an error
  73201. */
  73202. onTaskError: (task: AbstractAssetTask) => void;
  73203. /**
  73204. * Callback called when a task is done (whatever the result is)
  73205. */
  73206. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73207. /**
  73208. * Observable called when all tasks are processed
  73209. */
  73210. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73211. /**
  73212. * Observable called when a task had an error
  73213. */
  73214. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73215. /**
  73216. * Observable called when all tasks were executed
  73217. */
  73218. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73219. /**
  73220. * Observable called when a task is done (whatever the result is)
  73221. */
  73222. onProgressObservable: Observable<IAssetsProgressEvent>;
  73223. /**
  73224. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73225. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73226. */
  73227. useDefaultLoadingScreen: boolean;
  73228. /**
  73229. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73230. * when all assets have been downloaded.
  73231. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73232. */
  73233. autoHideLoadingUI: boolean;
  73234. /**
  73235. * Creates a new AssetsManager
  73236. * @param scene defines the scene to work on
  73237. */
  73238. constructor(scene: Scene);
  73239. /**
  73240. * Add a ContainerAssetTask to the list of active tasks
  73241. * @param taskName defines the name of the new task
  73242. * @param meshesNames defines the name of meshes to load
  73243. * @param rootUrl defines the root url to use to locate files
  73244. * @param sceneFilename defines the filename of the scene file
  73245. * @returns a new ContainerAssetTask object
  73246. */
  73247. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73248. /**
  73249. * Add a MeshAssetTask to the list of active tasks
  73250. * @param taskName defines the name of the new task
  73251. * @param meshesNames defines the name of meshes to load
  73252. * @param rootUrl defines the root url to use to locate files
  73253. * @param sceneFilename defines the filename of the scene file
  73254. * @returns a new MeshAssetTask object
  73255. */
  73256. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73257. /**
  73258. * Add a TextFileAssetTask to the list of active tasks
  73259. * @param taskName defines the name of the new task
  73260. * @param url defines the url of the file to load
  73261. * @returns a new TextFileAssetTask object
  73262. */
  73263. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73264. /**
  73265. * Add a BinaryFileAssetTask to the list of active tasks
  73266. * @param taskName defines the name of the new task
  73267. * @param url defines the url of the file to load
  73268. * @returns a new BinaryFileAssetTask object
  73269. */
  73270. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73271. /**
  73272. * Add a ImageAssetTask to the list of active tasks
  73273. * @param taskName defines the name of the new task
  73274. * @param url defines the url of the file to load
  73275. * @returns a new ImageAssetTask object
  73276. */
  73277. addImageTask(taskName: string, url: string): ImageAssetTask;
  73278. /**
  73279. * Add a TextureAssetTask to the list of active tasks
  73280. * @param taskName defines the name of the new task
  73281. * @param url defines the url of the file to load
  73282. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73283. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73284. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73285. * @returns a new TextureAssetTask object
  73286. */
  73287. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73288. /**
  73289. * Add a CubeTextureAssetTask to the list of active tasks
  73290. * @param taskName defines the name of the new task
  73291. * @param url defines the url of the file to load
  73292. * @param extensions defines the extension to use to load the cube map (can be null)
  73293. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73294. * @param files defines the list of files to load (can be null)
  73295. * @returns a new CubeTextureAssetTask object
  73296. */
  73297. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73298. /**
  73299. *
  73300. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73301. * @param taskName defines the name of the new task
  73302. * @param url defines the url of the file to load
  73303. * @param size defines the size you want for the cubemap (can be null)
  73304. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73305. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73306. * @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)
  73307. * @param reserved Internal use only
  73308. * @returns a new HDRCubeTextureAssetTask object
  73309. */
  73310. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73311. /**
  73312. *
  73313. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73314. * @param taskName defines the name of the new task
  73315. * @param url defines the url of the file to load
  73316. * @param size defines the size you want for the cubemap (can be null)
  73317. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73318. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73319. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73320. * @returns a new EquiRectangularCubeTextureAssetTask object
  73321. */
  73322. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73323. /**
  73324. * Remove a task from the assets manager.
  73325. * @param task the task to remove
  73326. */
  73327. removeTask(task: AbstractAssetTask): void;
  73328. private _decreaseWaitingTasksCount;
  73329. private _runTask;
  73330. /**
  73331. * Reset the AssetsManager and remove all tasks
  73332. * @return the current instance of the AssetsManager
  73333. */
  73334. reset(): AssetsManager;
  73335. /**
  73336. * Start the loading process
  73337. * @return the current instance of the AssetsManager
  73338. */
  73339. load(): AssetsManager;
  73340. /**
  73341. * Start the loading process as an async operation
  73342. * @return a promise returning the list of failed tasks
  73343. */
  73344. loadAsync(): Promise<void>;
  73345. }
  73346. }
  73347. declare module BABYLON {
  73348. /**
  73349. * Wrapper class for promise with external resolve and reject.
  73350. */
  73351. export class Deferred<T> {
  73352. /**
  73353. * The promise associated with this deferred object.
  73354. */
  73355. readonly promise: Promise<T>;
  73356. private _resolve;
  73357. private _reject;
  73358. /**
  73359. * The resolve method of the promise associated with this deferred object.
  73360. */
  73361. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73362. /**
  73363. * The reject method of the promise associated with this deferred object.
  73364. */
  73365. get reject(): (reason?: any) => void;
  73366. /**
  73367. * Constructor for this deferred object.
  73368. */
  73369. constructor();
  73370. }
  73371. }
  73372. declare module BABYLON {
  73373. /**
  73374. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73375. */
  73376. export class MeshExploder {
  73377. private _centerMesh;
  73378. private _meshes;
  73379. private _meshesOrigins;
  73380. private _toCenterVectors;
  73381. private _scaledDirection;
  73382. private _newPosition;
  73383. private _centerPosition;
  73384. /**
  73385. * Explodes meshes from a center mesh.
  73386. * @param meshes The meshes to explode.
  73387. * @param centerMesh The mesh to be center of explosion.
  73388. */
  73389. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73390. private _setCenterMesh;
  73391. /**
  73392. * Get class name
  73393. * @returns "MeshExploder"
  73394. */
  73395. getClassName(): string;
  73396. /**
  73397. * "Exploded meshes"
  73398. * @returns Array of meshes with the centerMesh at index 0.
  73399. */
  73400. getMeshes(): Array<Mesh>;
  73401. /**
  73402. * Explodes meshes giving a specific direction
  73403. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73404. */
  73405. explode(direction?: number): void;
  73406. }
  73407. }
  73408. declare module BABYLON {
  73409. /**
  73410. * Class used to help managing file picking and drag'n'drop
  73411. */
  73412. export class FilesInput {
  73413. /**
  73414. * List of files ready to be loaded
  73415. */
  73416. static get FilesToLoad(): {
  73417. [key: string]: File;
  73418. };
  73419. /**
  73420. * Callback called when a file is processed
  73421. */
  73422. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73423. private _engine;
  73424. private _currentScene;
  73425. private _sceneLoadedCallback;
  73426. private _progressCallback;
  73427. private _additionalRenderLoopLogicCallback;
  73428. private _textureLoadingCallback;
  73429. private _startingProcessingFilesCallback;
  73430. private _onReloadCallback;
  73431. private _errorCallback;
  73432. private _elementToMonitor;
  73433. private _sceneFileToLoad;
  73434. private _filesToLoad;
  73435. /**
  73436. * Creates a new FilesInput
  73437. * @param engine defines the rendering engine
  73438. * @param scene defines the hosting scene
  73439. * @param sceneLoadedCallback callback called when scene is loaded
  73440. * @param progressCallback callback called to track progress
  73441. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73442. * @param textureLoadingCallback callback called when a texture is loading
  73443. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73444. * @param onReloadCallback callback called when a reload is requested
  73445. * @param errorCallback callback call if an error occurs
  73446. */
  73447. 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>);
  73448. private _dragEnterHandler;
  73449. private _dragOverHandler;
  73450. private _dropHandler;
  73451. /**
  73452. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73453. * @param elementToMonitor defines the DOM element to track
  73454. */
  73455. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73456. /** Gets the current list of files to load */
  73457. get filesToLoad(): File[];
  73458. /**
  73459. * Release all associated resources
  73460. */
  73461. dispose(): void;
  73462. private renderFunction;
  73463. private drag;
  73464. private drop;
  73465. private _traverseFolder;
  73466. private _processFiles;
  73467. /**
  73468. * Load files from a drop event
  73469. * @param event defines the drop event to use as source
  73470. */
  73471. loadFiles(event: any): void;
  73472. private _processReload;
  73473. /**
  73474. * Reload the current scene from the loaded files
  73475. */
  73476. reload(): void;
  73477. }
  73478. }
  73479. declare module BABYLON {
  73480. /**
  73481. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73482. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73483. */
  73484. export class SceneOptimization {
  73485. /**
  73486. * Defines the priority of this optimization (0 by default which means first in the list)
  73487. */
  73488. priority: number;
  73489. /**
  73490. * Gets a string describing the action executed by the current optimization
  73491. * @returns description string
  73492. */
  73493. getDescription(): string;
  73494. /**
  73495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73496. * @param scene defines the current scene where to apply this optimization
  73497. * @param optimizer defines the current optimizer
  73498. * @returns true if everything that can be done was applied
  73499. */
  73500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73501. /**
  73502. * Creates the SceneOptimization object
  73503. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73504. * @param desc defines the description associated with the optimization
  73505. */
  73506. constructor(
  73507. /**
  73508. * Defines the priority of this optimization (0 by default which means first in the list)
  73509. */
  73510. priority?: number);
  73511. }
  73512. /**
  73513. * Defines an optimization used to reduce the size of render target textures
  73514. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73515. */
  73516. export class TextureOptimization extends SceneOptimization {
  73517. /**
  73518. * Defines the priority of this optimization (0 by default which means first in the list)
  73519. */
  73520. priority: number;
  73521. /**
  73522. * 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
  73523. */
  73524. maximumSize: number;
  73525. /**
  73526. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73527. */
  73528. step: number;
  73529. /**
  73530. * Gets a string describing the action executed by the current optimization
  73531. * @returns description string
  73532. */
  73533. getDescription(): string;
  73534. /**
  73535. * Creates the TextureOptimization object
  73536. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73537. * @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
  73538. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73539. */
  73540. constructor(
  73541. /**
  73542. * Defines the priority of this optimization (0 by default which means first in the list)
  73543. */
  73544. priority?: number,
  73545. /**
  73546. * 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
  73547. */
  73548. maximumSize?: number,
  73549. /**
  73550. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73551. */
  73552. step?: number);
  73553. /**
  73554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73555. * @param scene defines the current scene where to apply this optimization
  73556. * @param optimizer defines the current optimizer
  73557. * @returns true if everything that can be done was applied
  73558. */
  73559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73560. }
  73561. /**
  73562. * Defines an optimization used to increase or decrease the rendering resolution
  73563. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73564. */
  73565. export class HardwareScalingOptimization extends SceneOptimization {
  73566. /**
  73567. * Defines the priority of this optimization (0 by default which means first in the list)
  73568. */
  73569. priority: number;
  73570. /**
  73571. * Defines the maximum scale to use (2 by default)
  73572. */
  73573. maximumScale: number;
  73574. /**
  73575. * Defines the step to use between two passes (0.5 by default)
  73576. */
  73577. step: number;
  73578. private _currentScale;
  73579. private _directionOffset;
  73580. /**
  73581. * Gets a string describing the action executed by the current optimization
  73582. * @return description string
  73583. */
  73584. getDescription(): string;
  73585. /**
  73586. * Creates the HardwareScalingOptimization object
  73587. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73588. * @param maximumScale defines the maximum scale to use (2 by default)
  73589. * @param step defines the step to use between two passes (0.5 by default)
  73590. */
  73591. constructor(
  73592. /**
  73593. * Defines the priority of this optimization (0 by default which means first in the list)
  73594. */
  73595. priority?: number,
  73596. /**
  73597. * Defines the maximum scale to use (2 by default)
  73598. */
  73599. maximumScale?: number,
  73600. /**
  73601. * Defines the step to use between two passes (0.5 by default)
  73602. */
  73603. step?: number);
  73604. /**
  73605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73606. * @param scene defines the current scene where to apply this optimization
  73607. * @param optimizer defines the current optimizer
  73608. * @returns true if everything that can be done was applied
  73609. */
  73610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73611. }
  73612. /**
  73613. * Defines an optimization used to remove shadows
  73614. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73615. */
  73616. export class ShadowsOptimization extends SceneOptimization {
  73617. /**
  73618. * Gets a string describing the action executed by the current optimization
  73619. * @return description string
  73620. */
  73621. getDescription(): string;
  73622. /**
  73623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73624. * @param scene defines the current scene where to apply this optimization
  73625. * @param optimizer defines the current optimizer
  73626. * @returns true if everything that can be done was applied
  73627. */
  73628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73629. }
  73630. /**
  73631. * Defines an optimization used to turn post-processes off
  73632. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73633. */
  73634. export class PostProcessesOptimization extends SceneOptimization {
  73635. /**
  73636. * Gets a string describing the action executed by the current optimization
  73637. * @return description string
  73638. */
  73639. getDescription(): string;
  73640. /**
  73641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73642. * @param scene defines the current scene where to apply this optimization
  73643. * @param optimizer defines the current optimizer
  73644. * @returns true if everything that can be done was applied
  73645. */
  73646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73647. }
  73648. /**
  73649. * Defines an optimization used to turn lens flares off
  73650. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73651. */
  73652. export class LensFlaresOptimization extends SceneOptimization {
  73653. /**
  73654. * Gets a string describing the action executed by the current optimization
  73655. * @return description string
  73656. */
  73657. getDescription(): string;
  73658. /**
  73659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73660. * @param scene defines the current scene where to apply this optimization
  73661. * @param optimizer defines the current optimizer
  73662. * @returns true if everything that can be done was applied
  73663. */
  73664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73665. }
  73666. /**
  73667. * Defines an optimization based on user defined callback.
  73668. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73669. */
  73670. export class CustomOptimization extends SceneOptimization {
  73671. /**
  73672. * Callback called to apply the custom optimization.
  73673. */
  73674. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73675. /**
  73676. * Callback called to get custom description
  73677. */
  73678. onGetDescription: () => string;
  73679. /**
  73680. * Gets a string describing the action executed by the current optimization
  73681. * @returns description string
  73682. */
  73683. getDescription(): string;
  73684. /**
  73685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73686. * @param scene defines the current scene where to apply this optimization
  73687. * @param optimizer defines the current optimizer
  73688. * @returns true if everything that can be done was applied
  73689. */
  73690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73691. }
  73692. /**
  73693. * Defines an optimization used to turn particles off
  73694. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73695. */
  73696. export class ParticlesOptimization extends SceneOptimization {
  73697. /**
  73698. * Gets a string describing the action executed by the current optimization
  73699. * @return description string
  73700. */
  73701. getDescription(): string;
  73702. /**
  73703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73704. * @param scene defines the current scene where to apply this optimization
  73705. * @param optimizer defines the current optimizer
  73706. * @returns true if everything that can be done was applied
  73707. */
  73708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73709. }
  73710. /**
  73711. * Defines an optimization used to turn render targets off
  73712. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73713. */
  73714. export class RenderTargetsOptimization extends SceneOptimization {
  73715. /**
  73716. * Gets a string describing the action executed by the current optimization
  73717. * @return description string
  73718. */
  73719. getDescription(): string;
  73720. /**
  73721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73722. * @param scene defines the current scene where to apply this optimization
  73723. * @param optimizer defines the current optimizer
  73724. * @returns true if everything that can be done was applied
  73725. */
  73726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73727. }
  73728. /**
  73729. * Defines an optimization used to merge meshes with compatible materials
  73730. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73731. */
  73732. export class MergeMeshesOptimization extends SceneOptimization {
  73733. private static _UpdateSelectionTree;
  73734. /**
  73735. * Gets or sets a boolean which defines if optimization octree has to be updated
  73736. */
  73737. static get UpdateSelectionTree(): boolean;
  73738. /**
  73739. * Gets or sets a boolean which defines if optimization octree has to be updated
  73740. */
  73741. static set UpdateSelectionTree(value: boolean);
  73742. /**
  73743. * Gets a string describing the action executed by the current optimization
  73744. * @return description string
  73745. */
  73746. getDescription(): string;
  73747. private _canBeMerged;
  73748. /**
  73749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73750. * @param scene defines the current scene where to apply this optimization
  73751. * @param optimizer defines the current optimizer
  73752. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73753. * @returns true if everything that can be done was applied
  73754. */
  73755. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73756. }
  73757. /**
  73758. * Defines a list of options used by SceneOptimizer
  73759. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73760. */
  73761. export class SceneOptimizerOptions {
  73762. /**
  73763. * Defines the target frame rate to reach (60 by default)
  73764. */
  73765. targetFrameRate: number;
  73766. /**
  73767. * Defines the interval between two checkes (2000ms by default)
  73768. */
  73769. trackerDuration: number;
  73770. /**
  73771. * Gets the list of optimizations to apply
  73772. */
  73773. optimizations: SceneOptimization[];
  73774. /**
  73775. * Creates a new list of options used by SceneOptimizer
  73776. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73777. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73778. */
  73779. constructor(
  73780. /**
  73781. * Defines the target frame rate to reach (60 by default)
  73782. */
  73783. targetFrameRate?: number,
  73784. /**
  73785. * Defines the interval between two checkes (2000ms by default)
  73786. */
  73787. trackerDuration?: number);
  73788. /**
  73789. * Add a new optimization
  73790. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73791. * @returns the current SceneOptimizerOptions
  73792. */
  73793. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73794. /**
  73795. * Add a new custom optimization
  73796. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73797. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73798. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73799. * @returns the current SceneOptimizerOptions
  73800. */
  73801. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73802. /**
  73803. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73804. * @param targetFrameRate defines the target frame rate (60 by default)
  73805. * @returns a SceneOptimizerOptions object
  73806. */
  73807. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73808. /**
  73809. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73810. * @param targetFrameRate defines the target frame rate (60 by default)
  73811. * @returns a SceneOptimizerOptions object
  73812. */
  73813. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73814. /**
  73815. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73816. * @param targetFrameRate defines the target frame rate (60 by default)
  73817. * @returns a SceneOptimizerOptions object
  73818. */
  73819. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73820. }
  73821. /**
  73822. * Class used to run optimizations in order to reach a target frame rate
  73823. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73824. */
  73825. export class SceneOptimizer implements IDisposable {
  73826. private _isRunning;
  73827. private _options;
  73828. private _scene;
  73829. private _currentPriorityLevel;
  73830. private _targetFrameRate;
  73831. private _trackerDuration;
  73832. private _currentFrameRate;
  73833. private _sceneDisposeObserver;
  73834. private _improvementMode;
  73835. /**
  73836. * Defines an observable called when the optimizer reaches the target frame rate
  73837. */
  73838. onSuccessObservable: Observable<SceneOptimizer>;
  73839. /**
  73840. * Defines an observable called when the optimizer enables an optimization
  73841. */
  73842. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73843. /**
  73844. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73845. */
  73846. onFailureObservable: Observable<SceneOptimizer>;
  73847. /**
  73848. * Gets a boolean indicating if the optimizer is in improvement mode
  73849. */
  73850. get isInImprovementMode(): boolean;
  73851. /**
  73852. * Gets the current priority level (0 at start)
  73853. */
  73854. get currentPriorityLevel(): number;
  73855. /**
  73856. * Gets the current frame rate checked by the SceneOptimizer
  73857. */
  73858. get currentFrameRate(): number;
  73859. /**
  73860. * Gets or sets the current target frame rate (60 by default)
  73861. */
  73862. get targetFrameRate(): number;
  73863. /**
  73864. * Gets or sets the current target frame rate (60 by default)
  73865. */
  73866. set targetFrameRate(value: number);
  73867. /**
  73868. * Gets or sets the current interval between two checks (every 2000ms by default)
  73869. */
  73870. get trackerDuration(): number;
  73871. /**
  73872. * Gets or sets the current interval between two checks (every 2000ms by default)
  73873. */
  73874. set trackerDuration(value: number);
  73875. /**
  73876. * Gets the list of active optimizations
  73877. */
  73878. get optimizations(): SceneOptimization[];
  73879. /**
  73880. * Creates a new SceneOptimizer
  73881. * @param scene defines the scene to work on
  73882. * @param options defines the options to use with the SceneOptimizer
  73883. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73884. * @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)
  73885. */
  73886. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73887. /**
  73888. * Stops the current optimizer
  73889. */
  73890. stop(): void;
  73891. /**
  73892. * Reset the optimizer to initial step (current priority level = 0)
  73893. */
  73894. reset(): void;
  73895. /**
  73896. * Start the optimizer. By default it will try to reach a specific framerate
  73897. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73898. */
  73899. start(): void;
  73900. private _checkCurrentState;
  73901. /**
  73902. * Release all resources
  73903. */
  73904. dispose(): void;
  73905. /**
  73906. * Helper function to create a SceneOptimizer with one single line of code
  73907. * @param scene defines the scene to work on
  73908. * @param options defines the options to use with the SceneOptimizer
  73909. * @param onSuccess defines a callback to call on success
  73910. * @param onFailure defines a callback to call on failure
  73911. * @returns the new SceneOptimizer object
  73912. */
  73913. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73914. }
  73915. }
  73916. declare module BABYLON {
  73917. /**
  73918. * Class used to serialize a scene into a string
  73919. */
  73920. export class SceneSerializer {
  73921. /**
  73922. * Clear cache used by a previous serialization
  73923. */
  73924. static ClearCache(): void;
  73925. /**
  73926. * Serialize a scene into a JSON compatible object
  73927. * @param scene defines the scene to serialize
  73928. * @returns a JSON compatible object
  73929. */
  73930. static Serialize(scene: Scene): any;
  73931. /**
  73932. * Serialize a mesh into a JSON compatible object
  73933. * @param toSerialize defines the mesh to serialize
  73934. * @param withParents defines if parents must be serialized as well
  73935. * @param withChildren defines if children must be serialized as well
  73936. * @returns a JSON compatible object
  73937. */
  73938. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73939. }
  73940. }
  73941. declare module BABYLON {
  73942. /**
  73943. * Class used to host texture specific utilities
  73944. */
  73945. export class TextureTools {
  73946. /**
  73947. * Uses the GPU to create a copy texture rescaled at a given size
  73948. * @param texture Texture to copy from
  73949. * @param width defines the desired width
  73950. * @param height defines the desired height
  73951. * @param useBilinearMode defines if bilinear mode has to be used
  73952. * @return the generated texture
  73953. */
  73954. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73955. }
  73956. }
  73957. declare module BABYLON {
  73958. /**
  73959. * This represents the different options available for the video capture.
  73960. */
  73961. export interface VideoRecorderOptions {
  73962. /** Defines the mime type of the video. */
  73963. mimeType: string;
  73964. /** Defines the FPS the video should be recorded at. */
  73965. fps: number;
  73966. /** Defines the chunk size for the recording data. */
  73967. recordChunckSize: number;
  73968. /** The audio tracks to attach to the recording. */
  73969. audioTracks?: MediaStreamTrack[];
  73970. }
  73971. /**
  73972. * This can help with recording videos from BabylonJS.
  73973. * This is based on the available WebRTC functionalities of the browser.
  73974. *
  73975. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73976. */
  73977. export class VideoRecorder {
  73978. private static readonly _defaultOptions;
  73979. /**
  73980. * Returns whether or not the VideoRecorder is available in your browser.
  73981. * @param engine Defines the Babylon Engine.
  73982. * @returns true if supported otherwise false.
  73983. */
  73984. static IsSupported(engine: Engine): boolean;
  73985. private readonly _options;
  73986. private _canvas;
  73987. private _mediaRecorder;
  73988. private _recordedChunks;
  73989. private _fileName;
  73990. private _resolve;
  73991. private _reject;
  73992. /**
  73993. * True when a recording is already in progress.
  73994. */
  73995. get isRecording(): boolean;
  73996. /**
  73997. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73998. * @param engine Defines the BabylonJS Engine you wish to record.
  73999. * @param options Defines options that can be used to customize the capture.
  74000. */
  74001. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74002. /**
  74003. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74004. */
  74005. stopRecording(): void;
  74006. /**
  74007. * Starts recording the canvas for a max duration specified in parameters.
  74008. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74009. * If null no automatic download will start and you can rely on the promise to get the data back.
  74010. * @param maxDuration Defines the maximum recording time in seconds.
  74011. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74012. * @return A promise callback at the end of the recording with the video data in Blob.
  74013. */
  74014. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74015. /**
  74016. * Releases internal resources used during the recording.
  74017. */
  74018. dispose(): void;
  74019. private _handleDataAvailable;
  74020. private _handleError;
  74021. private _handleStop;
  74022. }
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * Class containing a set of static utilities functions for screenshots
  74027. */
  74028. export class ScreenshotTools {
  74029. /**
  74030. * Captures a screenshot of the current rendering
  74031. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74032. * @param engine defines the rendering engine
  74033. * @param camera defines the source camera
  74034. * @param size This parameter can be set to a single number or to an object with the
  74035. * following (optional) properties: precision, width, height. If a single number is passed,
  74036. * it will be used for both width and height. If an object is passed, the screenshot size
  74037. * will be derived from the parameters. The precision property is a multiplier allowing
  74038. * rendering at a higher or lower resolution
  74039. * @param successCallback defines the callback receives a single parameter which contains the
  74040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74041. * src parameter of an <img> to display it
  74042. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74043. * Check your browser for supported MIME types
  74044. */
  74045. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74046. /**
  74047. * Captures a screenshot of the current rendering
  74048. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74049. * @param engine defines the rendering engine
  74050. * @param camera defines the source camera
  74051. * @param size This parameter can be set to a single number or to an object with the
  74052. * following (optional) properties: precision, width, height. If a single number is passed,
  74053. * it will be used for both width and height. If an object is passed, the screenshot size
  74054. * will be derived from the parameters. The precision property is a multiplier allowing
  74055. * rendering at a higher or lower resolution
  74056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74057. * Check your browser for supported MIME types
  74058. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74059. * to the src parameter of an <img> to display it
  74060. */
  74061. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74062. /**
  74063. * Generates an image screenshot from the specified camera.
  74064. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74065. * @param engine The engine to use for rendering
  74066. * @param camera The camera to use for rendering
  74067. * @param size This parameter can be set to a single number or to an object with the
  74068. * following (optional) properties: precision, width, height. If a single number is passed,
  74069. * it will be used for both width and height. If an object is passed, the screenshot size
  74070. * will be derived from the parameters. The precision property is a multiplier allowing
  74071. * rendering at a higher or lower resolution
  74072. * @param successCallback The callback receives a single parameter which contains the
  74073. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74074. * src parameter of an <img> to display it
  74075. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74076. * Check your browser for supported MIME types
  74077. * @param samples Texture samples (default: 1)
  74078. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74079. * @param fileName A name for for the downloaded file.
  74080. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74081. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74082. */
  74083. 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;
  74084. /**
  74085. * Generates an image screenshot from the specified camera.
  74086. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74087. * @param engine The engine to use for rendering
  74088. * @param camera The camera to use for rendering
  74089. * @param size This parameter can be set to a single number or to an object with the
  74090. * following (optional) properties: precision, width, height. If a single number is passed,
  74091. * it will be used for both width and height. If an object is passed, the screenshot size
  74092. * will be derived from the parameters. The precision property is a multiplier allowing
  74093. * rendering at a higher or lower resolution
  74094. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74095. * Check your browser for supported MIME types
  74096. * @param samples Texture samples (default: 1)
  74097. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74098. * @param fileName A name for for the downloaded file.
  74099. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74100. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74101. * to the src parameter of an <img> to display it
  74102. */
  74103. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74104. /**
  74105. * Gets height and width for screenshot size
  74106. * @private
  74107. */
  74108. private static _getScreenshotSize;
  74109. }
  74110. }
  74111. declare module BABYLON {
  74112. /**
  74113. * Interface for a data buffer
  74114. */
  74115. export interface IDataBuffer {
  74116. /**
  74117. * Reads bytes from the data buffer.
  74118. * @param byteOffset The byte offset to read
  74119. * @param byteLength The byte length to read
  74120. * @returns A promise that resolves when the bytes are read
  74121. */
  74122. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74123. /**
  74124. * The byte length of the buffer.
  74125. */
  74126. readonly byteLength: number;
  74127. }
  74128. /**
  74129. * Utility class for reading from a data buffer
  74130. */
  74131. export class DataReader {
  74132. /**
  74133. * The data buffer associated with this data reader.
  74134. */
  74135. readonly buffer: IDataBuffer;
  74136. /**
  74137. * The current byte offset from the beginning of the data buffer.
  74138. */
  74139. byteOffset: number;
  74140. private _dataView;
  74141. private _dataByteOffset;
  74142. /**
  74143. * Constructor
  74144. * @param buffer The buffer to read
  74145. */
  74146. constructor(buffer: IDataBuffer);
  74147. /**
  74148. * Loads the given byte length.
  74149. * @param byteLength The byte length to load
  74150. * @returns A promise that resolves when the load is complete
  74151. */
  74152. loadAsync(byteLength: number): Promise<void>;
  74153. /**
  74154. * Read a unsigned 32-bit integer from the currently loaded data range.
  74155. * @returns The 32-bit integer read
  74156. */
  74157. readUint32(): number;
  74158. /**
  74159. * Read a byte array from the currently loaded data range.
  74160. * @param byteLength The byte length to read
  74161. * @returns The byte array read
  74162. */
  74163. readUint8Array(byteLength: number): Uint8Array;
  74164. /**
  74165. * Read a string from the currently loaded data range.
  74166. * @param byteLength The byte length to read
  74167. * @returns The string read
  74168. */
  74169. readString(byteLength: number): string;
  74170. /**
  74171. * Skips the given byte length the currently loaded data range.
  74172. * @param byteLength The byte length to skip
  74173. */
  74174. skipBytes(byteLength: number): void;
  74175. }
  74176. }
  74177. declare module BABYLON {
  74178. /**
  74179. * Class for storing data to local storage if available or in-memory storage otherwise
  74180. */
  74181. export class DataStorage {
  74182. private static _Storage;
  74183. private static _GetStorage;
  74184. /**
  74185. * Reads a string from the data storage
  74186. * @param key The key to read
  74187. * @param defaultValue The value if the key doesn't exist
  74188. * @returns The string value
  74189. */
  74190. static ReadString(key: string, defaultValue: string): string;
  74191. /**
  74192. * Writes a string to the data storage
  74193. * @param key The key to write
  74194. * @param value The value to write
  74195. */
  74196. static WriteString(key: string, value: string): void;
  74197. /**
  74198. * Reads a boolean from the data storage
  74199. * @param key The key to read
  74200. * @param defaultValue The value if the key doesn't exist
  74201. * @returns The boolean value
  74202. */
  74203. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74204. /**
  74205. * Writes a boolean to the data storage
  74206. * @param key The key to write
  74207. * @param value The value to write
  74208. */
  74209. static WriteBoolean(key: string, value: boolean): void;
  74210. /**
  74211. * Reads a number from the data storage
  74212. * @param key The key to read
  74213. * @param defaultValue The value if the key doesn't exist
  74214. * @returns The number value
  74215. */
  74216. static ReadNumber(key: string, defaultValue: number): number;
  74217. /**
  74218. * Writes a number to the data storage
  74219. * @param key The key to write
  74220. * @param value The value to write
  74221. */
  74222. static WriteNumber(key: string, value: number): void;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /**
  74227. * Class used to record delta files between 2 scene states
  74228. */
  74229. export class SceneRecorder {
  74230. private _trackedScene;
  74231. private _savedJSON;
  74232. /**
  74233. * Track a given scene. This means the current scene state will be considered the original state
  74234. * @param scene defines the scene to track
  74235. */
  74236. track(scene: Scene): void;
  74237. /**
  74238. * Get the delta between current state and original state
  74239. * @returns a string containing the delta
  74240. */
  74241. getDelta(): any;
  74242. private _compareArray;
  74243. private _compareObjects;
  74244. private _compareCollections;
  74245. private static GetShadowGeneratorById;
  74246. /**
  74247. * Apply a given delta to a given scene
  74248. * @param deltaJSON defines the JSON containing the delta
  74249. * @param scene defines the scene to apply the delta to
  74250. */
  74251. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74252. private static _ApplyPropertiesToEntity;
  74253. private static _ApplyDeltaForEntity;
  74254. }
  74255. }
  74256. declare module BABYLON {
  74257. /**
  74258. * An interface for all Hit test features
  74259. */
  74260. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74261. /**
  74262. * Triggered when new babylon (transformed) hit test results are available
  74263. */
  74264. onHitTestResultObservable: Observable<T[]>;
  74265. }
  74266. /**
  74267. * Options used for hit testing
  74268. */
  74269. export interface IWebXRLegacyHitTestOptions {
  74270. /**
  74271. * Only test when user interacted with the scene. Default - hit test every frame
  74272. */
  74273. testOnPointerDownOnly?: boolean;
  74274. /**
  74275. * The node to use to transform the local results to world coordinates
  74276. */
  74277. worldParentNode?: TransformNode;
  74278. }
  74279. /**
  74280. * Interface defining the babylon result of raycasting/hit-test
  74281. */
  74282. export interface IWebXRLegacyHitResult {
  74283. /**
  74284. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74285. */
  74286. transformationMatrix: Matrix;
  74287. /**
  74288. * The native hit test result
  74289. */
  74290. xrHitResult: XRHitResult | XRHitTestResult;
  74291. }
  74292. /**
  74293. * The currently-working hit-test module.
  74294. * Hit test (or Ray-casting) is used to interact with the real world.
  74295. * For further information read here - https://github.com/immersive-web/hit-test
  74296. */
  74297. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74298. /**
  74299. * options to use when constructing this feature
  74300. */
  74301. readonly options: IWebXRLegacyHitTestOptions;
  74302. private _direction;
  74303. private _mat;
  74304. private _onSelectEnabled;
  74305. private _origin;
  74306. /**
  74307. * The module's name
  74308. */
  74309. static readonly Name: string;
  74310. /**
  74311. * The (Babylon) version of this module.
  74312. * This is an integer representing the implementation version.
  74313. * This number does not correspond to the WebXR specs version
  74314. */
  74315. static readonly Version: number;
  74316. /**
  74317. * Populated with the last native XR Hit Results
  74318. */
  74319. lastNativeXRHitResults: XRHitResult[];
  74320. /**
  74321. * Triggered when new babylon (transformed) hit test results are available
  74322. */
  74323. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74324. /**
  74325. * Creates a new instance of the (legacy version) hit test feature
  74326. * @param _xrSessionManager an instance of WebXRSessionManager
  74327. * @param options options to use when constructing this feature
  74328. */
  74329. constructor(_xrSessionManager: WebXRSessionManager,
  74330. /**
  74331. * options to use when constructing this feature
  74332. */
  74333. options?: IWebXRLegacyHitTestOptions);
  74334. /**
  74335. * execute a hit test with an XR Ray
  74336. *
  74337. * @param xrSession a native xrSession that will execute this hit test
  74338. * @param xrRay the ray (position and direction) to use for ray-casting
  74339. * @param referenceSpace native XR reference space to use for the hit-test
  74340. * @param filter filter function that will filter the results
  74341. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74342. */
  74343. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74344. /**
  74345. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74346. * @param event the (select) event to use to select with
  74347. * @param referenceSpace the reference space to use for this hit test
  74348. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74349. */
  74350. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74351. /**
  74352. * attach this feature
  74353. * Will usually be called by the features manager
  74354. *
  74355. * @returns true if successful.
  74356. */
  74357. attach(): boolean;
  74358. /**
  74359. * detach this feature.
  74360. * Will usually be called by the features manager
  74361. *
  74362. * @returns true if successful.
  74363. */
  74364. detach(): boolean;
  74365. /**
  74366. * Dispose this feature and all of the resources attached
  74367. */
  74368. dispose(): void;
  74369. protected _onXRFrame(frame: XRFrame): void;
  74370. private _onHitTestResults;
  74371. private _onSelect;
  74372. }
  74373. }
  74374. declare module BABYLON {
  74375. /**
  74376. * Options used for hit testing (version 2)
  74377. */
  74378. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74379. /**
  74380. * Do not create a permanent hit test. Will usually be used when only
  74381. * transient inputs are needed.
  74382. */
  74383. disablePermanentHitTest?: boolean;
  74384. /**
  74385. * Enable transient (for example touch-based) hit test inspections
  74386. */
  74387. enableTransientHitTest?: boolean;
  74388. /**
  74389. * Offset ray for the permanent hit test
  74390. */
  74391. offsetRay?: Vector3;
  74392. /**
  74393. * Offset ray for the transient hit test
  74394. */
  74395. transientOffsetRay?: Vector3;
  74396. /**
  74397. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74398. */
  74399. useReferenceSpace?: boolean;
  74400. /**
  74401. * Override the default entity type(s) of the hit-test result
  74402. */
  74403. entityTypes?: XRHitTestTrackableType[];
  74404. }
  74405. /**
  74406. * Interface defining the babylon result of hit-test
  74407. */
  74408. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74409. /**
  74410. * The input source that generated this hit test (if transient)
  74411. */
  74412. inputSource?: XRInputSource;
  74413. /**
  74414. * Is this a transient hit test
  74415. */
  74416. isTransient?: boolean;
  74417. /**
  74418. * Position of the hit test result
  74419. */
  74420. position: Vector3;
  74421. /**
  74422. * Rotation of the hit test result
  74423. */
  74424. rotationQuaternion: Quaternion;
  74425. /**
  74426. * The native hit test result
  74427. */
  74428. xrHitResult: XRHitTestResult;
  74429. }
  74430. /**
  74431. * The currently-working hit-test module.
  74432. * Hit test (or Ray-casting) is used to interact with the real world.
  74433. * For further information read here - https://github.com/immersive-web/hit-test
  74434. *
  74435. * Tested on chrome (mobile) 80.
  74436. */
  74437. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74438. /**
  74439. * options to use when constructing this feature
  74440. */
  74441. readonly options: IWebXRHitTestOptions;
  74442. private _tmpMat;
  74443. private _tmpPos;
  74444. private _tmpQuat;
  74445. private _transientXrHitTestSource;
  74446. private _xrHitTestSource;
  74447. private initHitTestSource;
  74448. /**
  74449. * The module's name
  74450. */
  74451. static readonly Name: string;
  74452. /**
  74453. * The (Babylon) version of this module.
  74454. * This is an integer representing the implementation version.
  74455. * This number does not correspond to the WebXR specs version
  74456. */
  74457. static readonly Version: number;
  74458. /**
  74459. * When set to true, each hit test will have its own position/rotation objects
  74460. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74461. * the developers will clone them or copy them as they see fit.
  74462. */
  74463. autoCloneTransformation: boolean;
  74464. /**
  74465. * Triggered when new babylon (transformed) hit test results are available
  74466. */
  74467. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74468. /**
  74469. * Use this to temporarily pause hit test checks.
  74470. */
  74471. paused: boolean;
  74472. /**
  74473. * Creates a new instance of the hit test feature
  74474. * @param _xrSessionManager an instance of WebXRSessionManager
  74475. * @param options options to use when constructing this feature
  74476. */
  74477. constructor(_xrSessionManager: WebXRSessionManager,
  74478. /**
  74479. * options to use when constructing this feature
  74480. */
  74481. options?: IWebXRHitTestOptions);
  74482. /**
  74483. * attach this feature
  74484. * Will usually be called by the features manager
  74485. *
  74486. * @returns true if successful.
  74487. */
  74488. attach(): boolean;
  74489. /**
  74490. * detach this feature.
  74491. * Will usually be called by the features manager
  74492. *
  74493. * @returns true if successful.
  74494. */
  74495. detach(): boolean;
  74496. /**
  74497. * Dispose this feature and all of the resources attached
  74498. */
  74499. dispose(): void;
  74500. protected _onXRFrame(frame: XRFrame): void;
  74501. private _processWebXRHitTestResult;
  74502. }
  74503. }
  74504. declare module BABYLON {
  74505. /**
  74506. * Configuration options of the anchor system
  74507. */
  74508. export interface IWebXRAnchorSystemOptions {
  74509. /**
  74510. * a node that will be used to convert local to world coordinates
  74511. */
  74512. worldParentNode?: TransformNode;
  74513. /**
  74514. * If set to true a reference of the created anchors will be kept until the next session starts
  74515. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74516. */
  74517. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74518. }
  74519. /**
  74520. * A babylon container for an XR Anchor
  74521. */
  74522. export interface IWebXRAnchor {
  74523. /**
  74524. * A babylon-assigned ID for this anchor
  74525. */
  74526. id: number;
  74527. /**
  74528. * Transformation matrix to apply to an object attached to this anchor
  74529. */
  74530. transformationMatrix: Matrix;
  74531. /**
  74532. * The native anchor object
  74533. */
  74534. xrAnchor: XRAnchor;
  74535. /**
  74536. * if defined, this object will be constantly updated by the anchor's position and rotation
  74537. */
  74538. attachedNode?: TransformNode;
  74539. }
  74540. /**
  74541. * An implementation of the anchor system for WebXR.
  74542. * For further information see https://github.com/immersive-web/anchors/
  74543. */
  74544. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74545. private _options;
  74546. private _lastFrameDetected;
  74547. private _trackedAnchors;
  74548. private _referenceSpaceForFrameAnchors;
  74549. private _futureAnchors;
  74550. /**
  74551. * The module's name
  74552. */
  74553. static readonly Name: string;
  74554. /**
  74555. * The (Babylon) version of this module.
  74556. * This is an integer representing the implementation version.
  74557. * This number does not correspond to the WebXR specs version
  74558. */
  74559. static readonly Version: number;
  74560. /**
  74561. * Observers registered here will be executed when a new anchor was added to the session
  74562. */
  74563. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74564. /**
  74565. * Observers registered here will be executed when an anchor was removed from the session
  74566. */
  74567. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74568. /**
  74569. * Observers registered here will be executed when an existing anchor updates
  74570. * This can execute N times every frame
  74571. */
  74572. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74573. /**
  74574. * Set the reference space to use for anchor creation, when not using a hit test.
  74575. * Will default to the session's reference space if not defined
  74576. */
  74577. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74578. /**
  74579. * constructs a new anchor system
  74580. * @param _xrSessionManager an instance of WebXRSessionManager
  74581. * @param _options configuration object for this feature
  74582. */
  74583. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74584. private _tmpVector;
  74585. private _tmpQuaternion;
  74586. private _populateTmpTransformation;
  74587. /**
  74588. * Create a new anchor point using a hit test result at a specific point in the scene
  74589. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74590. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74591. *
  74592. * @param hitTestResult The hit test result to use for this anchor creation
  74593. * @param position an optional position offset for this anchor
  74594. * @param rotationQuaternion an optional rotation offset for this anchor
  74595. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74596. */
  74597. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74598. /**
  74599. * Add a new anchor at a specific position and rotation
  74600. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74601. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74602. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74603. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74604. *
  74605. * @param position the position in which to add an anchor
  74606. * @param rotationQuaternion an optional rotation for the anchor transformation
  74607. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74608. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74609. */
  74610. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74611. /**
  74612. * detach this feature.
  74613. * Will usually be called by the features manager
  74614. *
  74615. * @returns true if successful.
  74616. */
  74617. detach(): boolean;
  74618. /**
  74619. * Dispose this feature and all of the resources attached
  74620. */
  74621. dispose(): void;
  74622. protected _onXRFrame(frame: XRFrame): void;
  74623. /**
  74624. * avoiding using Array.find for global support.
  74625. * @param xrAnchor the plane to find in the array
  74626. */
  74627. private _findIndexInAnchorArray;
  74628. private _updateAnchorWithXRFrame;
  74629. private _createAnchorAtTransformation;
  74630. }
  74631. }
  74632. declare module BABYLON {
  74633. /**
  74634. * Options used in the plane detector module
  74635. */
  74636. export interface IWebXRPlaneDetectorOptions {
  74637. /**
  74638. * The node to use to transform the local results to world coordinates
  74639. */
  74640. worldParentNode?: TransformNode;
  74641. /**
  74642. * If set to true a reference of the created planes will be kept until the next session starts
  74643. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74644. */
  74645. doNotRemovePlanesOnSessionEnded?: boolean;
  74646. }
  74647. /**
  74648. * A babylon interface for a WebXR plane.
  74649. * A Plane is actually a polygon, built from N points in space
  74650. *
  74651. * Supported in chrome 79, not supported in canary 81 ATM
  74652. */
  74653. export interface IWebXRPlane {
  74654. /**
  74655. * a babylon-assigned ID for this polygon
  74656. */
  74657. id: number;
  74658. /**
  74659. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74660. */
  74661. polygonDefinition: Array<Vector3>;
  74662. /**
  74663. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74664. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74665. */
  74666. transformationMatrix: Matrix;
  74667. /**
  74668. * the native xr-plane object
  74669. */
  74670. xrPlane: XRPlane;
  74671. }
  74672. /**
  74673. * The plane detector is used to detect planes in the real world when in AR
  74674. * For more information see https://github.com/immersive-web/real-world-geometry/
  74675. */
  74676. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74677. private _options;
  74678. private _detectedPlanes;
  74679. private _enabled;
  74680. private _lastFrameDetected;
  74681. /**
  74682. * The module's name
  74683. */
  74684. static readonly Name: string;
  74685. /**
  74686. * The (Babylon) version of this module.
  74687. * This is an integer representing the implementation version.
  74688. * This number does not correspond to the WebXR specs version
  74689. */
  74690. static readonly Version: number;
  74691. /**
  74692. * Observers registered here will be executed when a new plane was added to the session
  74693. */
  74694. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74695. /**
  74696. * Observers registered here will be executed when a plane is no longer detected in the session
  74697. */
  74698. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74699. /**
  74700. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74701. * This can execute N times every frame
  74702. */
  74703. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74704. /**
  74705. * construct a new Plane Detector
  74706. * @param _xrSessionManager an instance of xr Session manager
  74707. * @param _options configuration to use when constructing this feature
  74708. */
  74709. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74710. /**
  74711. * detach this feature.
  74712. * Will usually be called by the features manager
  74713. *
  74714. * @returns true if successful.
  74715. */
  74716. detach(): boolean;
  74717. /**
  74718. * Dispose this feature and all of the resources attached
  74719. */
  74720. dispose(): void;
  74721. protected _onXRFrame(frame: XRFrame): void;
  74722. private _init;
  74723. private _updatePlaneWithXRPlane;
  74724. /**
  74725. * avoiding using Array.find for global support.
  74726. * @param xrPlane the plane to find in the array
  74727. */
  74728. private findIndexInPlaneArray;
  74729. }
  74730. }
  74731. declare module BABYLON {
  74732. /**
  74733. * Options interface for the background remover plugin
  74734. */
  74735. export interface IWebXRBackgroundRemoverOptions {
  74736. /**
  74737. * Further background meshes to disable when entering AR
  74738. */
  74739. backgroundMeshes?: AbstractMesh[];
  74740. /**
  74741. * flags to configure the removal of the environment helper.
  74742. * If not set, the entire background will be removed. If set, flags should be set as well.
  74743. */
  74744. environmentHelperRemovalFlags?: {
  74745. /**
  74746. * Should the skybox be removed (default false)
  74747. */
  74748. skyBox?: boolean;
  74749. /**
  74750. * Should the ground be removed (default false)
  74751. */
  74752. ground?: boolean;
  74753. };
  74754. /**
  74755. * don't disable the environment helper
  74756. */
  74757. ignoreEnvironmentHelper?: boolean;
  74758. }
  74759. /**
  74760. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74761. */
  74762. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74763. /**
  74764. * read-only options to be used in this module
  74765. */
  74766. readonly options: IWebXRBackgroundRemoverOptions;
  74767. /**
  74768. * The module's name
  74769. */
  74770. static readonly Name: string;
  74771. /**
  74772. * The (Babylon) version of this module.
  74773. * This is an integer representing the implementation version.
  74774. * This number does not correspond to the WebXR specs version
  74775. */
  74776. static readonly Version: number;
  74777. /**
  74778. * registered observers will be triggered when the background state changes
  74779. */
  74780. onBackgroundStateChangedObservable: Observable<boolean>;
  74781. /**
  74782. * constructs a new background remover module
  74783. * @param _xrSessionManager the session manager for this module
  74784. * @param options read-only options to be used in this module
  74785. */
  74786. constructor(_xrSessionManager: WebXRSessionManager,
  74787. /**
  74788. * read-only options to be used in this module
  74789. */
  74790. options?: IWebXRBackgroundRemoverOptions);
  74791. /**
  74792. * attach this feature
  74793. * Will usually be called by the features manager
  74794. *
  74795. * @returns true if successful.
  74796. */
  74797. attach(): boolean;
  74798. /**
  74799. * detach this feature.
  74800. * Will usually be called by the features manager
  74801. *
  74802. * @returns true if successful.
  74803. */
  74804. detach(): boolean;
  74805. /**
  74806. * Dispose this feature and all of the resources attached
  74807. */
  74808. dispose(): void;
  74809. protected _onXRFrame(_xrFrame: XRFrame): void;
  74810. private _setBackgroundState;
  74811. }
  74812. }
  74813. declare module BABYLON {
  74814. /**
  74815. * Options for the controller physics feature
  74816. */
  74817. export class IWebXRControllerPhysicsOptions {
  74818. /**
  74819. * Should the headset get its own impostor
  74820. */
  74821. enableHeadsetImpostor?: boolean;
  74822. /**
  74823. * Optional parameters for the headset impostor
  74824. */
  74825. headsetImpostorParams?: {
  74826. /**
  74827. * The type of impostor to create. Default is sphere
  74828. */
  74829. impostorType: number;
  74830. /**
  74831. * the size of the impostor. Defaults to 10cm
  74832. */
  74833. impostorSize?: number | {
  74834. width: number;
  74835. height: number;
  74836. depth: number;
  74837. };
  74838. /**
  74839. * Friction definitions
  74840. */
  74841. friction?: number;
  74842. /**
  74843. * Restitution
  74844. */
  74845. restitution?: number;
  74846. };
  74847. /**
  74848. * The physics properties of the future impostors
  74849. */
  74850. physicsProperties?: {
  74851. /**
  74852. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74853. * Note that this requires a physics engine that supports mesh impostors!
  74854. */
  74855. useControllerMesh?: boolean;
  74856. /**
  74857. * The type of impostor to create. Default is sphere
  74858. */
  74859. impostorType?: number;
  74860. /**
  74861. * the size of the impostor. Defaults to 10cm
  74862. */
  74863. impostorSize?: number | {
  74864. width: number;
  74865. height: number;
  74866. depth: number;
  74867. };
  74868. /**
  74869. * Friction definitions
  74870. */
  74871. friction?: number;
  74872. /**
  74873. * Restitution
  74874. */
  74875. restitution?: number;
  74876. };
  74877. /**
  74878. * the xr input to use with this pointer selection
  74879. */
  74880. xrInput: WebXRInput;
  74881. }
  74882. /**
  74883. * Add physics impostor to your webxr controllers,
  74884. * including naive calculation of their linear and angular velocity
  74885. */
  74886. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74887. private readonly _options;
  74888. private _attachController;
  74889. private _controllers;
  74890. private _debugMode;
  74891. private _delta;
  74892. private _headsetImpostor?;
  74893. private _headsetMesh?;
  74894. private _lastTimestamp;
  74895. private _tmpQuaternion;
  74896. private _tmpVector;
  74897. /**
  74898. * The module's name
  74899. */
  74900. static readonly Name: string;
  74901. /**
  74902. * The (Babylon) version of this module.
  74903. * This is an integer representing the implementation version.
  74904. * This number does not correspond to the webxr specs version
  74905. */
  74906. static readonly Version: number;
  74907. /**
  74908. * Construct a new Controller Physics Feature
  74909. * @param _xrSessionManager the corresponding xr session manager
  74910. * @param _options options to create this feature with
  74911. */
  74912. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74913. /**
  74914. * @hidden
  74915. * enable debugging - will show console outputs and the impostor mesh
  74916. */
  74917. _enablePhysicsDebug(): void;
  74918. /**
  74919. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74920. * @param xrController the controller to add
  74921. */
  74922. addController(xrController: WebXRInputSource): void;
  74923. /**
  74924. * attach this feature
  74925. * Will usually be called by the features manager
  74926. *
  74927. * @returns true if successful.
  74928. */
  74929. attach(): boolean;
  74930. /**
  74931. * detach this feature.
  74932. * Will usually be called by the features manager
  74933. *
  74934. * @returns true if successful.
  74935. */
  74936. detach(): boolean;
  74937. /**
  74938. * Get the headset impostor, if enabled
  74939. * @returns the impostor
  74940. */
  74941. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74942. /**
  74943. * Get the physics impostor of a specific controller.
  74944. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74945. * @param controller the controller or the controller id of which to get the impostor
  74946. * @returns the impostor or null
  74947. */
  74948. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74949. /**
  74950. * Update the physics properties provided in the constructor
  74951. * @param newProperties the new properties object
  74952. */
  74953. setPhysicsProperties(newProperties: {
  74954. impostorType?: number;
  74955. impostorSize?: number | {
  74956. width: number;
  74957. height: number;
  74958. depth: number;
  74959. };
  74960. friction?: number;
  74961. restitution?: number;
  74962. }): void;
  74963. protected _onXRFrame(_xrFrame: any): void;
  74964. private _detachController;
  74965. }
  74966. }
  74967. declare module BABYLON {
  74968. /**
  74969. * A babylon interface for a "WebXR" feature point.
  74970. * Represents the position and confidence value of a given feature point.
  74971. */
  74972. export interface IWebXRFeaturePoint {
  74973. /**
  74974. * Represents the position of the feature point in world space.
  74975. */
  74976. position: Vector3;
  74977. /**
  74978. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74979. */
  74980. confidenceValue: number;
  74981. }
  74982. /**
  74983. * The feature point system is used to detect feature points from real world geometry.
  74984. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74985. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74986. */
  74987. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74988. private _enabled;
  74989. private _featurePointCloud;
  74990. /**
  74991. * The module's name
  74992. */
  74993. static readonly Name: string;
  74994. /**
  74995. * The (Babylon) version of this module.
  74996. * This is an integer representing the implementation version.
  74997. * This number does not correspond to the WebXR specs version
  74998. */
  74999. static readonly Version: number;
  75000. /**
  75001. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75002. * Will notify the observers about which feature points have been added.
  75003. */
  75004. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75005. /**
  75006. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75007. * Will notify the observers about which feature points have been updated.
  75008. */
  75009. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75010. /**
  75011. * The current feature point cloud maintained across frames.
  75012. */
  75013. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75014. /**
  75015. * construct the feature point system
  75016. * @param _xrSessionManager an instance of xr Session manager
  75017. */
  75018. constructor(_xrSessionManager: WebXRSessionManager);
  75019. /**
  75020. * Detach this feature.
  75021. * Will usually be called by the features manager
  75022. *
  75023. * @returns true if successful.
  75024. */
  75025. detach(): boolean;
  75026. /**
  75027. * Dispose this feature and all of the resources attached
  75028. */
  75029. dispose(): void;
  75030. /**
  75031. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75032. */
  75033. protected _onXRFrame(frame: XRFrame): void;
  75034. /**
  75035. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75036. */
  75037. private _init;
  75038. }
  75039. }
  75040. declare module BABYLON {
  75041. /**
  75042. * Configuration interface for the hand tracking feature
  75043. */
  75044. export interface IWebXRHandTrackingOptions {
  75045. /**
  75046. * The xrInput that will be used as source for new hands
  75047. */
  75048. xrInput: WebXRInput;
  75049. /**
  75050. * Configuration object for the joint meshes
  75051. */
  75052. jointMeshes?: {
  75053. /**
  75054. * Should the meshes created be invisible (defaults to false)
  75055. */
  75056. invisible?: boolean;
  75057. /**
  75058. * A source mesh to be used to create instances. Defaults to a sphere.
  75059. * This mesh will be the source for all other (25) meshes.
  75060. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75061. */
  75062. sourceMesh?: Mesh;
  75063. /**
  75064. * Should the source mesh stay visible. Defaults to false
  75065. */
  75066. keepOriginalVisible?: boolean;
  75067. /**
  75068. * Scale factor for all instances (defaults to 2)
  75069. */
  75070. scaleFactor?: number;
  75071. /**
  75072. * Should each instance have its own physics impostor
  75073. */
  75074. enablePhysics?: boolean;
  75075. /**
  75076. * If enabled, override default physics properties
  75077. */
  75078. physicsProps?: {
  75079. friction?: number;
  75080. restitution?: number;
  75081. impostorType?: number;
  75082. };
  75083. /**
  75084. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75085. */
  75086. handMesh?: AbstractMesh;
  75087. };
  75088. }
  75089. /**
  75090. * Parts of the hands divided to writs and finger names
  75091. */
  75092. export const enum HandPart {
  75093. /**
  75094. * HandPart - Wrist
  75095. */
  75096. WRIST = "wrist",
  75097. /**
  75098. * HandPart - The THumb
  75099. */
  75100. THUMB = "thumb",
  75101. /**
  75102. * HandPart - Index finger
  75103. */
  75104. INDEX = "index",
  75105. /**
  75106. * HandPart - Middle finger
  75107. */
  75108. MIDDLE = "middle",
  75109. /**
  75110. * HandPart - Ring finger
  75111. */
  75112. RING = "ring",
  75113. /**
  75114. * HandPart - Little finger
  75115. */
  75116. LITTLE = "little"
  75117. }
  75118. /**
  75119. * Representing a single hand (with its corresponding native XRHand object)
  75120. */
  75121. export class WebXRHand implements IDisposable {
  75122. /** the controller to which the hand correlates */
  75123. readonly xrController: WebXRInputSource;
  75124. /** the meshes to be used to track the hand joints */
  75125. readonly trackedMeshes: AbstractMesh[];
  75126. /**
  75127. * Hand-parts definition (key is HandPart)
  75128. */
  75129. handPartsDefinition: {
  75130. [key: string]: number[];
  75131. };
  75132. /**
  75133. * Populate the HandPartsDefinition object.
  75134. * This is called as a side effect since certain browsers don't have XRHand defined.
  75135. */
  75136. private generateHandPartsDefinition;
  75137. /**
  75138. * Construct a new hand object
  75139. * @param xrController the controller to which the hand correlates
  75140. * @param trackedMeshes the meshes to be used to track the hand joints
  75141. */
  75142. constructor(
  75143. /** the controller to which the hand correlates */
  75144. xrController: WebXRInputSource,
  75145. /** the meshes to be used to track the hand joints */
  75146. trackedMeshes: AbstractMesh[]);
  75147. /**
  75148. * Update this hand from the latest xr frame
  75149. * @param xrFrame xrFrame to update from
  75150. * @param referenceSpace The current viewer reference space
  75151. * @param scaleFactor optional scale factor for the meshes
  75152. */
  75153. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75154. /**
  75155. * Get meshes of part of the hand
  75156. * @param part the part of hand to get
  75157. * @returns An array of meshes that correlate to the hand part requested
  75158. */
  75159. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75160. /**
  75161. * Dispose this Hand object
  75162. */
  75163. dispose(): void;
  75164. }
  75165. /**
  75166. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75167. */
  75168. export class WebXRHandTracking extends WebXRAbstractFeature {
  75169. /**
  75170. * options to use when constructing this feature
  75171. */
  75172. readonly options: IWebXRHandTrackingOptions;
  75173. private static _idCounter;
  75174. /**
  75175. * The module's name
  75176. */
  75177. static readonly Name: string;
  75178. /**
  75179. * The (Babylon) version of this module.
  75180. * This is an integer representing the implementation version.
  75181. * This number does not correspond to the WebXR specs version
  75182. */
  75183. static readonly Version: number;
  75184. /**
  75185. * This observable will notify registered observers when a new hand object was added and initialized
  75186. */
  75187. onHandAddedObservable: Observable<WebXRHand>;
  75188. /**
  75189. * This observable will notify its observers right before the hand object is disposed
  75190. */
  75191. onHandRemovedObservable: Observable<WebXRHand>;
  75192. private _hands;
  75193. /**
  75194. * Creates a new instance of the hit test feature
  75195. * @param _xrSessionManager an instance of WebXRSessionManager
  75196. * @param options options to use when constructing this feature
  75197. */
  75198. constructor(_xrSessionManager: WebXRSessionManager,
  75199. /**
  75200. * options to use when constructing this feature
  75201. */
  75202. options: IWebXRHandTrackingOptions);
  75203. /**
  75204. * Check if the needed objects are defined.
  75205. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75206. */
  75207. isCompatible(): boolean;
  75208. /**
  75209. * attach this feature
  75210. * Will usually be called by the features manager
  75211. *
  75212. * @returns true if successful.
  75213. */
  75214. attach(): boolean;
  75215. /**
  75216. * detach this feature.
  75217. * Will usually be called by the features manager
  75218. *
  75219. * @returns true if successful.
  75220. */
  75221. detach(): boolean;
  75222. /**
  75223. * Dispose this feature and all of the resources attached
  75224. */
  75225. dispose(): void;
  75226. /**
  75227. * Get the hand object according to the controller id
  75228. * @param controllerId the controller id to which we want to get the hand
  75229. * @returns null if not found or the WebXRHand object if found
  75230. */
  75231. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75232. /**
  75233. * Get a hand object according to the requested handedness
  75234. * @param handedness the handedness to request
  75235. * @returns null if not found or the WebXRHand object if found
  75236. */
  75237. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75238. protected _onXRFrame(_xrFrame: XRFrame): void;
  75239. private _attachHand;
  75240. private _detachHand;
  75241. }
  75242. }
  75243. declare module BABYLON {
  75244. /**
  75245. * The motion controller class for all microsoft mixed reality controllers
  75246. */
  75247. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75248. protected readonly _mapping: {
  75249. defaultButton: {
  75250. valueNodeName: string;
  75251. unpressedNodeName: string;
  75252. pressedNodeName: string;
  75253. };
  75254. defaultAxis: {
  75255. valueNodeName: string;
  75256. minNodeName: string;
  75257. maxNodeName: string;
  75258. };
  75259. buttons: {
  75260. "xr-standard-trigger": {
  75261. rootNodeName: string;
  75262. componentProperty: string;
  75263. states: string[];
  75264. };
  75265. "xr-standard-squeeze": {
  75266. rootNodeName: string;
  75267. componentProperty: string;
  75268. states: string[];
  75269. };
  75270. "xr-standard-touchpad": {
  75271. rootNodeName: string;
  75272. labelAnchorNodeName: string;
  75273. touchPointNodeName: string;
  75274. };
  75275. "xr-standard-thumbstick": {
  75276. rootNodeName: string;
  75277. componentProperty: string;
  75278. states: string[];
  75279. };
  75280. };
  75281. axes: {
  75282. "xr-standard-touchpad": {
  75283. "x-axis": {
  75284. rootNodeName: string;
  75285. };
  75286. "y-axis": {
  75287. rootNodeName: string;
  75288. };
  75289. };
  75290. "xr-standard-thumbstick": {
  75291. "x-axis": {
  75292. rootNodeName: string;
  75293. };
  75294. "y-axis": {
  75295. rootNodeName: string;
  75296. };
  75297. };
  75298. };
  75299. };
  75300. /**
  75301. * The base url used to load the left and right controller models
  75302. */
  75303. static MODEL_BASE_URL: string;
  75304. /**
  75305. * The name of the left controller model file
  75306. */
  75307. static MODEL_LEFT_FILENAME: string;
  75308. /**
  75309. * The name of the right controller model file
  75310. */
  75311. static MODEL_RIGHT_FILENAME: string;
  75312. profileId: string;
  75313. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75314. protected _getFilenameAndPath(): {
  75315. filename: string;
  75316. path: string;
  75317. };
  75318. protected _getModelLoadingConstraints(): boolean;
  75319. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75320. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75321. protected _updateModel(): void;
  75322. }
  75323. }
  75324. declare module BABYLON {
  75325. /**
  75326. * The motion controller class for oculus touch (quest, rift).
  75327. * This class supports legacy mapping as well the standard xr mapping
  75328. */
  75329. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75330. private _forceLegacyControllers;
  75331. private _modelRootNode;
  75332. /**
  75333. * The base url used to load the left and right controller models
  75334. */
  75335. static MODEL_BASE_URL: string;
  75336. /**
  75337. * The name of the left controller model file
  75338. */
  75339. static MODEL_LEFT_FILENAME: string;
  75340. /**
  75341. * The name of the right controller model file
  75342. */
  75343. static MODEL_RIGHT_FILENAME: string;
  75344. /**
  75345. * Base Url for the Quest controller model.
  75346. */
  75347. static QUEST_MODEL_BASE_URL: string;
  75348. profileId: string;
  75349. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75350. protected _getFilenameAndPath(): {
  75351. filename: string;
  75352. path: string;
  75353. };
  75354. protected _getModelLoadingConstraints(): boolean;
  75355. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75356. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75357. protected _updateModel(): void;
  75358. /**
  75359. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75360. * between the touch and touch 2.
  75361. */
  75362. private _isQuest;
  75363. }
  75364. }
  75365. declare module BABYLON {
  75366. /**
  75367. * The motion controller class for the standard HTC-Vive controllers
  75368. */
  75369. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75370. private _modelRootNode;
  75371. /**
  75372. * The base url used to load the left and right controller models
  75373. */
  75374. static MODEL_BASE_URL: string;
  75375. /**
  75376. * File name for the controller model.
  75377. */
  75378. static MODEL_FILENAME: string;
  75379. profileId: string;
  75380. /**
  75381. * Create a new Vive motion controller object
  75382. * @param scene the scene to use to create this controller
  75383. * @param gamepadObject the corresponding gamepad object
  75384. * @param handedness the handedness of the controller
  75385. */
  75386. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75387. protected _getFilenameAndPath(): {
  75388. filename: string;
  75389. path: string;
  75390. };
  75391. protected _getModelLoadingConstraints(): boolean;
  75392. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75393. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75394. protected _updateModel(): void;
  75395. }
  75396. }
  75397. declare module BABYLON {
  75398. /**
  75399. * A cursor which tracks a point on a path
  75400. */
  75401. export class PathCursor {
  75402. private path;
  75403. /**
  75404. * Stores path cursor callbacks for when an onchange event is triggered
  75405. */
  75406. private _onchange;
  75407. /**
  75408. * The value of the path cursor
  75409. */
  75410. value: number;
  75411. /**
  75412. * The animation array of the path cursor
  75413. */
  75414. animations: Animation[];
  75415. /**
  75416. * Initializes the path cursor
  75417. * @param path The path to track
  75418. */
  75419. constructor(path: Path2);
  75420. /**
  75421. * Gets the cursor point on the path
  75422. * @returns A point on the path cursor at the cursor location
  75423. */
  75424. getPoint(): Vector3;
  75425. /**
  75426. * Moves the cursor ahead by the step amount
  75427. * @param step The amount to move the cursor forward
  75428. * @returns This path cursor
  75429. */
  75430. moveAhead(step?: number): PathCursor;
  75431. /**
  75432. * Moves the cursor behind by the step amount
  75433. * @param step The amount to move the cursor back
  75434. * @returns This path cursor
  75435. */
  75436. moveBack(step?: number): PathCursor;
  75437. /**
  75438. * Moves the cursor by the step amount
  75439. * If the step amount is greater than one, an exception is thrown
  75440. * @param step The amount to move the cursor
  75441. * @returns This path cursor
  75442. */
  75443. move(step: number): PathCursor;
  75444. /**
  75445. * Ensures that the value is limited between zero and one
  75446. * @returns This path cursor
  75447. */
  75448. private ensureLimits;
  75449. /**
  75450. * Runs onchange callbacks on change (used by the animation engine)
  75451. * @returns This path cursor
  75452. */
  75453. private raiseOnChange;
  75454. /**
  75455. * Executes a function on change
  75456. * @param f A path cursor onchange callback
  75457. * @returns This path cursor
  75458. */
  75459. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75460. }
  75461. }
  75462. declare module BABYLON {
  75463. /** @hidden */
  75464. export var blurPixelShader: {
  75465. name: string;
  75466. shader: string;
  75467. };
  75468. }
  75469. declare module BABYLON {
  75470. /** @hidden */
  75471. export var pointCloudVertexDeclaration: {
  75472. name: string;
  75473. shader: string;
  75474. };
  75475. }
  75476. // Mixins
  75477. interface Window {
  75478. mozIndexedDB: IDBFactory;
  75479. webkitIndexedDB: IDBFactory;
  75480. msIndexedDB: IDBFactory;
  75481. webkitURL: typeof URL;
  75482. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75483. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75484. WebGLRenderingContext: WebGLRenderingContext;
  75485. MSGesture: MSGesture;
  75486. CANNON: any;
  75487. AudioContext: AudioContext;
  75488. webkitAudioContext: AudioContext;
  75489. PointerEvent: any;
  75490. Math: Math;
  75491. Uint8Array: Uint8ArrayConstructor;
  75492. Float32Array: Float32ArrayConstructor;
  75493. mozURL: typeof URL;
  75494. msURL: typeof URL;
  75495. VRFrameData: any; // WebVR, from specs 1.1
  75496. DracoDecoderModule: any;
  75497. setImmediate(handler: (...args: any[]) => void): number;
  75498. }
  75499. interface HTMLCanvasElement {
  75500. requestPointerLock(): void;
  75501. msRequestPointerLock?(): void;
  75502. mozRequestPointerLock?(): void;
  75503. webkitRequestPointerLock?(): void;
  75504. /** Track wether a record is in progress */
  75505. isRecording: boolean;
  75506. /** Capture Stream method defined by some browsers */
  75507. captureStream(fps?: number): MediaStream;
  75508. }
  75509. interface CanvasRenderingContext2D {
  75510. msImageSmoothingEnabled: boolean;
  75511. }
  75512. interface MouseEvent {
  75513. mozMovementX: number;
  75514. mozMovementY: number;
  75515. webkitMovementX: number;
  75516. webkitMovementY: number;
  75517. msMovementX: number;
  75518. msMovementY: number;
  75519. }
  75520. interface Navigator {
  75521. mozGetVRDevices: (any: any) => any;
  75522. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75523. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75524. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75525. webkitGetGamepads(): Gamepad[];
  75526. msGetGamepads(): Gamepad[];
  75527. webkitGamepads(): Gamepad[];
  75528. }
  75529. interface HTMLVideoElement {
  75530. mozSrcObject: any;
  75531. }
  75532. interface Math {
  75533. fround(x: number): number;
  75534. imul(a: number, b: number): number;
  75535. }
  75536. interface WebGLRenderingContext {
  75537. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75538. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75539. vertexAttribDivisor(index: number, divisor: number): void;
  75540. createVertexArray(): any;
  75541. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75542. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75543. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75544. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75545. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75546. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75547. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75548. // Queries
  75549. createQuery(): WebGLQuery;
  75550. deleteQuery(query: WebGLQuery): void;
  75551. beginQuery(target: number, query: WebGLQuery): void;
  75552. endQuery(target: number): void;
  75553. getQueryParameter(query: WebGLQuery, pname: number): any;
  75554. getQuery(target: number, pname: number): any;
  75555. MAX_SAMPLES: number;
  75556. RGBA8: number;
  75557. READ_FRAMEBUFFER: number;
  75558. DRAW_FRAMEBUFFER: number;
  75559. UNIFORM_BUFFER: number;
  75560. HALF_FLOAT_OES: number;
  75561. RGBA16F: number;
  75562. RGBA32F: number;
  75563. R32F: number;
  75564. RG32F: number;
  75565. RGB32F: number;
  75566. R16F: number;
  75567. RG16F: number;
  75568. RGB16F: number;
  75569. RED: number;
  75570. RG: number;
  75571. R8: number;
  75572. RG8: number;
  75573. UNSIGNED_INT_24_8: number;
  75574. DEPTH24_STENCIL8: number;
  75575. MIN: number;
  75576. MAX: number;
  75577. /* Multiple Render Targets */
  75578. drawBuffers(buffers: number[]): void;
  75579. readBuffer(src: number): void;
  75580. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75581. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75582. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75583. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75584. // Occlusion Query
  75585. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75586. ANY_SAMPLES_PASSED: number;
  75587. QUERY_RESULT_AVAILABLE: number;
  75588. QUERY_RESULT: number;
  75589. }
  75590. interface WebGLProgram {
  75591. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75592. }
  75593. interface EXT_disjoint_timer_query {
  75594. QUERY_COUNTER_BITS_EXT: number;
  75595. TIME_ELAPSED_EXT: number;
  75596. TIMESTAMP_EXT: number;
  75597. GPU_DISJOINT_EXT: number;
  75598. QUERY_RESULT_EXT: number;
  75599. QUERY_RESULT_AVAILABLE_EXT: number;
  75600. queryCounterEXT(query: WebGLQuery, target: number): void;
  75601. createQueryEXT(): WebGLQuery;
  75602. beginQueryEXT(target: number, query: WebGLQuery): void;
  75603. endQueryEXT(target: number): void;
  75604. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75605. deleteQueryEXT(query: WebGLQuery): void;
  75606. }
  75607. interface WebGLUniformLocation {
  75608. _currentState: any;
  75609. }
  75610. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75611. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75612. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75613. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75614. interface WebGLRenderingContext {
  75615. readonly RASTERIZER_DISCARD: number;
  75616. readonly DEPTH_COMPONENT24: number;
  75617. readonly TEXTURE_3D: number;
  75618. readonly TEXTURE_2D_ARRAY: number;
  75619. readonly TEXTURE_COMPARE_FUNC: number;
  75620. readonly TEXTURE_COMPARE_MODE: number;
  75621. readonly COMPARE_REF_TO_TEXTURE: number;
  75622. readonly TEXTURE_WRAP_R: number;
  75623. readonly HALF_FLOAT: number;
  75624. readonly RGB8: number;
  75625. readonly RED_INTEGER: number;
  75626. readonly RG_INTEGER: number;
  75627. readonly RGB_INTEGER: number;
  75628. readonly RGBA_INTEGER: number;
  75629. readonly R8_SNORM: number;
  75630. readonly RG8_SNORM: number;
  75631. readonly RGB8_SNORM: number;
  75632. readonly RGBA8_SNORM: number;
  75633. readonly R8I: number;
  75634. readonly RG8I: number;
  75635. readonly RGB8I: number;
  75636. readonly RGBA8I: number;
  75637. readonly R8UI: number;
  75638. readonly RG8UI: number;
  75639. readonly RGB8UI: number;
  75640. readonly RGBA8UI: number;
  75641. readonly R16I: number;
  75642. readonly RG16I: number;
  75643. readonly RGB16I: number;
  75644. readonly RGBA16I: number;
  75645. readonly R16UI: number;
  75646. readonly RG16UI: number;
  75647. readonly RGB16UI: number;
  75648. readonly RGBA16UI: number;
  75649. readonly R32I: number;
  75650. readonly RG32I: number;
  75651. readonly RGB32I: number;
  75652. readonly RGBA32I: number;
  75653. readonly R32UI: number;
  75654. readonly RG32UI: number;
  75655. readonly RGB32UI: number;
  75656. readonly RGBA32UI: number;
  75657. readonly RGB10_A2UI: number;
  75658. readonly R11F_G11F_B10F: number;
  75659. readonly RGB9_E5: number;
  75660. readonly RGB10_A2: number;
  75661. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75662. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75663. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75664. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75665. readonly DEPTH_COMPONENT32F: number;
  75666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75667. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75668. 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;
  75669. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75670. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75671. readonly TRANSFORM_FEEDBACK: number;
  75672. readonly INTERLEAVED_ATTRIBS: number;
  75673. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75674. createTransformFeedback(): WebGLTransformFeedback;
  75675. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75676. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75677. beginTransformFeedback(primitiveMode: number): void;
  75678. endTransformFeedback(): void;
  75679. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75680. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75681. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75682. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75683. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75684. }
  75685. interface ImageBitmap {
  75686. readonly width: number;
  75687. readonly height: number;
  75688. close(): void;
  75689. }
  75690. interface WebGLQuery extends WebGLObject {
  75691. }
  75692. declare var WebGLQuery: {
  75693. prototype: WebGLQuery;
  75694. new(): WebGLQuery;
  75695. };
  75696. interface WebGLSampler extends WebGLObject {
  75697. }
  75698. declare var WebGLSampler: {
  75699. prototype: WebGLSampler;
  75700. new(): WebGLSampler;
  75701. };
  75702. interface WebGLSync extends WebGLObject {
  75703. }
  75704. declare var WebGLSync: {
  75705. prototype: WebGLSync;
  75706. new(): WebGLSync;
  75707. };
  75708. interface WebGLTransformFeedback extends WebGLObject {
  75709. }
  75710. declare var WebGLTransformFeedback: {
  75711. prototype: WebGLTransformFeedback;
  75712. new(): WebGLTransformFeedback;
  75713. };
  75714. interface WebGLVertexArrayObject extends WebGLObject {
  75715. }
  75716. declare var WebGLVertexArrayObject: {
  75717. prototype: WebGLVertexArrayObject;
  75718. new(): WebGLVertexArrayObject;
  75719. };
  75720. // Type definitions for WebVR API
  75721. // Project: https://w3c.github.io/webvr/
  75722. // Definitions by: six a <https://github.com/lostfictions>
  75723. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75724. interface VRDisplay extends EventTarget {
  75725. /**
  75726. * Dictionary of capabilities describing the VRDisplay.
  75727. */
  75728. readonly capabilities: VRDisplayCapabilities;
  75729. /**
  75730. * z-depth defining the far plane of the eye view frustum
  75731. * enables mapping of values in the render target depth
  75732. * attachment to scene coordinates. Initially set to 10000.0.
  75733. */
  75734. depthFar: number;
  75735. /**
  75736. * z-depth defining the near plane of the eye view frustum
  75737. * enables mapping of values in the render target depth
  75738. * attachment to scene coordinates. Initially set to 0.01.
  75739. */
  75740. depthNear: number;
  75741. /**
  75742. * An identifier for this distinct VRDisplay. Used as an
  75743. * association point in the Gamepad API.
  75744. */
  75745. readonly displayId: number;
  75746. /**
  75747. * A display name, a user-readable name identifying it.
  75748. */
  75749. readonly displayName: string;
  75750. readonly isConnected: boolean;
  75751. readonly isPresenting: boolean;
  75752. /**
  75753. * If this VRDisplay supports room-scale experiences, the optional
  75754. * stage attribute contains details on the room-scale parameters.
  75755. */
  75756. readonly stageParameters: VRStageParameters | null;
  75757. /**
  75758. * Passing the value returned by `requestAnimationFrame` to
  75759. * `cancelAnimationFrame` will unregister the callback.
  75760. * @param handle Define the hanle of the request to cancel
  75761. */
  75762. cancelAnimationFrame(handle: number): void;
  75763. /**
  75764. * Stops presenting to the VRDisplay.
  75765. * @returns a promise to know when it stopped
  75766. */
  75767. exitPresent(): Promise<void>;
  75768. /**
  75769. * Return the current VREyeParameters for the given eye.
  75770. * @param whichEye Define the eye we want the parameter for
  75771. * @returns the eye parameters
  75772. */
  75773. getEyeParameters(whichEye: string): VREyeParameters;
  75774. /**
  75775. * Populates the passed VRFrameData with the information required to render
  75776. * the current frame.
  75777. * @param frameData Define the data structure to populate
  75778. * @returns true if ok otherwise false
  75779. */
  75780. getFrameData(frameData: VRFrameData): boolean;
  75781. /**
  75782. * Get the layers currently being presented.
  75783. * @returns the list of VR layers
  75784. */
  75785. getLayers(): VRLayer[];
  75786. /**
  75787. * Return a VRPose containing the future predicted pose of the VRDisplay
  75788. * when the current frame will be presented. The value returned will not
  75789. * change until JavaScript has returned control to the browser.
  75790. *
  75791. * The VRPose will contain the position, orientation, velocity,
  75792. * and acceleration of each of these properties.
  75793. * @returns the pose object
  75794. */
  75795. getPose(): VRPose;
  75796. /**
  75797. * Return the current instantaneous pose of the VRDisplay, with no
  75798. * prediction applied.
  75799. * @returns the current instantaneous pose
  75800. */
  75801. getImmediatePose(): VRPose;
  75802. /**
  75803. * The callback passed to `requestAnimationFrame` will be called
  75804. * any time a new frame should be rendered. When the VRDisplay is
  75805. * presenting the callback will be called at the native refresh
  75806. * rate of the HMD. When not presenting this function acts
  75807. * identically to how window.requestAnimationFrame acts. Content should
  75808. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75809. * asynchronously from other displays and at differing refresh rates.
  75810. * @param callback Define the eaction to run next frame
  75811. * @returns the request handle it
  75812. */
  75813. requestAnimationFrame(callback: FrameRequestCallback): number;
  75814. /**
  75815. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75816. * Repeat calls while already presenting will update the VRLayers being displayed.
  75817. * @param layers Define the list of layer to present
  75818. * @returns a promise to know when the request has been fulfilled
  75819. */
  75820. requestPresent(layers: VRLayer[]): Promise<void>;
  75821. /**
  75822. * Reset the pose for this display, treating its current position and
  75823. * orientation as the "origin/zero" values. VRPose.position,
  75824. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75825. * updated when calling resetPose(). This should be called in only
  75826. * sitting-space experiences.
  75827. */
  75828. resetPose(): void;
  75829. /**
  75830. * The VRLayer provided to the VRDisplay will be captured and presented
  75831. * in the HMD. Calling this function has the same effect on the source
  75832. * canvas as any other operation that uses its source image, and canvases
  75833. * created without preserveDrawingBuffer set to true will be cleared.
  75834. * @param pose Define the pose to submit
  75835. */
  75836. submitFrame(pose?: VRPose): void;
  75837. }
  75838. declare var VRDisplay: {
  75839. prototype: VRDisplay;
  75840. new(): VRDisplay;
  75841. };
  75842. interface VRLayer {
  75843. leftBounds?: number[] | Float32Array | null;
  75844. rightBounds?: number[] | Float32Array | null;
  75845. source?: HTMLCanvasElement | null;
  75846. }
  75847. interface VRDisplayCapabilities {
  75848. readonly canPresent: boolean;
  75849. readonly hasExternalDisplay: boolean;
  75850. readonly hasOrientation: boolean;
  75851. readonly hasPosition: boolean;
  75852. readonly maxLayers: number;
  75853. }
  75854. interface VREyeParameters {
  75855. /** @deprecated */
  75856. readonly fieldOfView: VRFieldOfView;
  75857. readonly offset: Float32Array;
  75858. readonly renderHeight: number;
  75859. readonly renderWidth: number;
  75860. }
  75861. interface VRFieldOfView {
  75862. readonly downDegrees: number;
  75863. readonly leftDegrees: number;
  75864. readonly rightDegrees: number;
  75865. readonly upDegrees: number;
  75866. }
  75867. interface VRFrameData {
  75868. readonly leftProjectionMatrix: Float32Array;
  75869. readonly leftViewMatrix: Float32Array;
  75870. readonly pose: VRPose;
  75871. readonly rightProjectionMatrix: Float32Array;
  75872. readonly rightViewMatrix: Float32Array;
  75873. readonly timestamp: number;
  75874. }
  75875. interface VRPose {
  75876. readonly angularAcceleration: Float32Array | null;
  75877. readonly angularVelocity: Float32Array | null;
  75878. readonly linearAcceleration: Float32Array | null;
  75879. readonly linearVelocity: Float32Array | null;
  75880. readonly orientation: Float32Array | null;
  75881. readonly position: Float32Array | null;
  75882. readonly timestamp: number;
  75883. }
  75884. interface VRStageParameters {
  75885. sittingToStandingTransform?: Float32Array;
  75886. sizeX?: number;
  75887. sizeY?: number;
  75888. }
  75889. interface Navigator {
  75890. getVRDisplays(): Promise<VRDisplay[]>;
  75891. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75892. }
  75893. interface Window {
  75894. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75895. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75896. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75897. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75898. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75899. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75900. }
  75901. interface Gamepad {
  75902. readonly displayId: number;
  75903. }
  75904. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75905. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75906. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75907. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75908. type XRHandedness = "none" | "left" | "right";
  75909. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75910. type XREye = "none" | "left" | "right";
  75911. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75912. interface XRSpace extends EventTarget {}
  75913. interface XRRenderState {
  75914. depthNear?: number;
  75915. depthFar?: number;
  75916. inlineVerticalFieldOfView?: number;
  75917. baseLayer?: XRWebGLLayer;
  75918. }
  75919. interface XRInputSource {
  75920. handedness: XRHandedness;
  75921. targetRayMode: XRTargetRayMode;
  75922. targetRaySpace: XRSpace;
  75923. gripSpace: XRSpace | undefined;
  75924. gamepad: Gamepad | undefined;
  75925. profiles: Array<string>;
  75926. hand: XRHand | undefined;
  75927. }
  75928. interface XRSessionInit {
  75929. optionalFeatures?: string[];
  75930. requiredFeatures?: string[];
  75931. }
  75932. interface XRSession {
  75933. addEventListener: Function;
  75934. removeEventListener: Function;
  75935. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75936. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75937. requestAnimationFrame: Function;
  75938. end(): Promise<void>;
  75939. renderState: XRRenderState;
  75940. inputSources: Array<XRInputSource>;
  75941. // hit test
  75942. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75943. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75944. // legacy AR hit test
  75945. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75946. // legacy plane detection
  75947. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75948. }
  75949. interface XRReferenceSpace extends XRSpace {
  75950. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75951. onreset: any;
  75952. }
  75953. type XRPlaneSet = Set<XRPlane>;
  75954. type XRAnchorSet = Set<XRAnchor>;
  75955. interface XRFrame {
  75956. session: XRSession;
  75957. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75958. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75959. // AR
  75960. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75961. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75962. // Anchors
  75963. trackedAnchors?: XRAnchorSet;
  75964. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75965. // Planes
  75966. worldInformation: {
  75967. detectedPlanes?: XRPlaneSet;
  75968. };
  75969. // Hand tracking
  75970. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75971. }
  75972. interface XRViewerPose extends XRPose {
  75973. views: Array<XRView>;
  75974. }
  75975. interface XRPose {
  75976. transform: XRRigidTransform;
  75977. emulatedPosition: boolean;
  75978. }
  75979. interface XRWebGLLayerOptions {
  75980. antialias?: boolean;
  75981. depth?: boolean;
  75982. stencil?: boolean;
  75983. alpha?: boolean;
  75984. multiview?: boolean;
  75985. framebufferScaleFactor?: number;
  75986. }
  75987. declare var XRWebGLLayer: {
  75988. prototype: XRWebGLLayer;
  75989. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75990. };
  75991. interface XRWebGLLayer {
  75992. framebuffer: WebGLFramebuffer;
  75993. framebufferWidth: number;
  75994. framebufferHeight: number;
  75995. getViewport: Function;
  75996. }
  75997. declare class XRRigidTransform {
  75998. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75999. position: DOMPointReadOnly;
  76000. orientation: DOMPointReadOnly;
  76001. matrix: Float32Array;
  76002. inverse: XRRigidTransform;
  76003. }
  76004. interface XRView {
  76005. eye: XREye;
  76006. projectionMatrix: Float32Array;
  76007. transform: XRRigidTransform;
  76008. }
  76009. interface XRInputSourceChangeEvent {
  76010. session: XRSession;
  76011. removed: Array<XRInputSource>;
  76012. added: Array<XRInputSource>;
  76013. }
  76014. interface XRInputSourceEvent extends Event {
  76015. readonly frame: XRFrame;
  76016. readonly inputSource: XRInputSource;
  76017. }
  76018. // Experimental(er) features
  76019. declare class XRRay {
  76020. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76021. origin: DOMPointReadOnly;
  76022. direction: DOMPointReadOnly;
  76023. matrix: Float32Array;
  76024. }
  76025. declare enum XRHitTestTrackableType {
  76026. "point",
  76027. "plane",
  76028. "mesh",
  76029. }
  76030. interface XRHitResult {
  76031. hitMatrix: Float32Array;
  76032. }
  76033. interface XRTransientInputHitTestResult {
  76034. readonly inputSource: XRInputSource;
  76035. readonly results: Array<XRHitTestResult>;
  76036. }
  76037. interface XRHitTestResult {
  76038. getPose(baseSpace: XRSpace): XRPose | undefined;
  76039. // When anchor system is enabled
  76040. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76041. }
  76042. interface XRHitTestSource {
  76043. cancel(): void;
  76044. }
  76045. interface XRTransientInputHitTestSource {
  76046. cancel(): void;
  76047. }
  76048. interface XRHitTestOptionsInit {
  76049. space: XRSpace;
  76050. entityTypes?: Array<XRHitTestTrackableType>;
  76051. offsetRay?: XRRay;
  76052. }
  76053. interface XRTransientInputHitTestOptionsInit {
  76054. profile: string;
  76055. entityTypes?: Array<XRHitTestTrackableType>;
  76056. offsetRay?: XRRay;
  76057. }
  76058. interface XRAnchor {
  76059. anchorSpace: XRSpace;
  76060. delete(): void;
  76061. }
  76062. interface XRPlane {
  76063. orientation: "Horizontal" | "Vertical";
  76064. planeSpace: XRSpace;
  76065. polygon: Array<DOMPointReadOnly>;
  76066. lastChangedTime: number;
  76067. }
  76068. interface XRJointSpace extends XRSpace {}
  76069. interface XRJointPose extends XRPose {
  76070. radius: number | undefined;
  76071. }
  76072. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76073. readonly length: number;
  76074. [index: number]: XRJointSpace;
  76075. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76076. readonly WRIST: number;
  76077. readonly THUMB_METACARPAL: number;
  76078. readonly THUMB_PHALANX_PROXIMAL: number;
  76079. readonly THUMB_PHALANX_DISTAL: number;
  76080. readonly THUMB_PHALANX_TIP: number;
  76081. readonly INDEX_METACARPAL: number;
  76082. readonly INDEX_PHALANX_PROXIMAL: number;
  76083. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76084. readonly INDEX_PHALANX_DISTAL: number;
  76085. readonly INDEX_PHALANX_TIP: number;
  76086. readonly MIDDLE_METACARPAL: number;
  76087. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76088. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76089. readonly MIDDLE_PHALANX_DISTAL: number;
  76090. readonly MIDDLE_PHALANX_TIP: number;
  76091. readonly RING_METACARPAL: number;
  76092. readonly RING_PHALANX_PROXIMAL: number;
  76093. readonly RING_PHALANX_INTERMEDIATE: number;
  76094. readonly RING_PHALANX_DISTAL: number;
  76095. readonly RING_PHALANX_TIP: number;
  76096. readonly LITTLE_METACARPAL: number;
  76097. readonly LITTLE_PHALANX_PROXIMAL: number;
  76098. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76099. readonly LITTLE_PHALANX_DISTAL: number;
  76100. readonly LITTLE_PHALANX_TIP: number;
  76101. }
  76102. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76103. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76104. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76105. interface XRSession {
  76106. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76107. }
  76108. interface XRFrame {
  76109. featurePointCloud? : Array<number>;
  76110. }