documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: AbstractActionManager;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /**
  10397. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10398. */
  10399. originMesh: Nullable<AbstractMesh>;
  10400. /**
  10401. * The ray that was used to perform the picking.
  10402. */
  10403. ray: Nullable<Ray>;
  10404. /**
  10405. * Gets the normal correspodning to the face the pick collided with
  10406. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10407. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10408. * @returns The normal correspodning to the face the pick collided with
  10409. */
  10410. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10411. /**
  10412. * Gets the texture coordinates of where the pick occured
  10413. * @returns the vector containing the coordnates of the texture
  10414. */
  10415. getTextureCoordinates(): Nullable<Vector2>;
  10416. }
  10417. }
  10418. declare module BABYLON {
  10419. /**
  10420. * Class representing a ray with position and direction
  10421. */
  10422. export class Ray {
  10423. /** origin point */
  10424. origin: Vector3;
  10425. /** direction */
  10426. direction: Vector3;
  10427. /** length of the ray */
  10428. length: number;
  10429. private static readonly TmpVector3;
  10430. private _tmpRay;
  10431. /**
  10432. * Creates a new ray
  10433. * @param origin origin point
  10434. * @param direction direction
  10435. * @param length length of the ray
  10436. */
  10437. constructor(
  10438. /** origin point */
  10439. origin: Vector3,
  10440. /** direction */
  10441. direction: Vector3,
  10442. /** length of the ray */
  10443. length?: number);
  10444. /**
  10445. * Checks if the ray intersects a box
  10446. * This does not account for the ray lenght by design to improve perfs.
  10447. * @param minimum bound of the box
  10448. * @param maximum bound of the box
  10449. * @param intersectionTreshold extra extend to be added to the box in all direction
  10450. * @returns if the box was hit
  10451. */
  10452. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10453. /**
  10454. * Checks if the ray intersects a box
  10455. * This does not account for the ray lenght by design to improve perfs.
  10456. * @param box the bounding box to check
  10457. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10458. * @returns if the box was hit
  10459. */
  10460. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10461. /**
  10462. * If the ray hits a sphere
  10463. * @param sphere the bounding sphere to check
  10464. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10465. * @returns true if it hits the sphere
  10466. */
  10467. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10468. /**
  10469. * If the ray hits a triange
  10470. * @param vertex0 triangle vertex
  10471. * @param vertex1 triangle vertex
  10472. * @param vertex2 triangle vertex
  10473. * @returns intersection information if hit
  10474. */
  10475. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10476. /**
  10477. * Checks if ray intersects a plane
  10478. * @param plane the plane to check
  10479. * @returns the distance away it was hit
  10480. */
  10481. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10482. /**
  10483. * Calculate the intercept of a ray on a given axis
  10484. * @param axis to check 'x' | 'y' | 'z'
  10485. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10486. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10487. */
  10488. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10489. /**
  10490. * Checks if ray intersects a mesh
  10491. * @param mesh the mesh to check
  10492. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10493. * @returns picking info of the intersecton
  10494. */
  10495. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10496. /**
  10497. * Checks if ray intersects a mesh
  10498. * @param meshes the meshes to check
  10499. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10500. * @param results array to store result in
  10501. * @returns Array of picking infos
  10502. */
  10503. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10504. private _comparePickingInfo;
  10505. private static smallnum;
  10506. private static rayl;
  10507. /**
  10508. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10509. * @param sega the first point of the segment to test the intersection against
  10510. * @param segb the second point of the segment to test the intersection against
  10511. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10512. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10513. */
  10514. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10515. /**
  10516. * Update the ray from viewport position
  10517. * @param x position
  10518. * @param y y position
  10519. * @param viewportWidth viewport width
  10520. * @param viewportHeight viewport height
  10521. * @param world world matrix
  10522. * @param view view matrix
  10523. * @param projection projection matrix
  10524. * @returns this ray updated
  10525. */
  10526. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10527. /**
  10528. * Creates a ray with origin and direction of 0,0,0
  10529. * @returns the new ray
  10530. */
  10531. static Zero(): Ray;
  10532. /**
  10533. * Creates a new ray from screen space and viewport
  10534. * @param x position
  10535. * @param y y position
  10536. * @param viewportWidth viewport width
  10537. * @param viewportHeight viewport height
  10538. * @param world world matrix
  10539. * @param view view matrix
  10540. * @param projection projection matrix
  10541. * @returns new ray
  10542. */
  10543. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10544. /**
  10545. * 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
  10546. * transformed to the given world matrix.
  10547. * @param origin The origin point
  10548. * @param end The end point
  10549. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10550. * @returns the new ray
  10551. */
  10552. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10553. /**
  10554. * Transforms a ray by a matrix
  10555. * @param ray ray to transform
  10556. * @param matrix matrix to apply
  10557. * @returns the resulting new ray
  10558. */
  10559. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10560. /**
  10561. * Transforms a ray by a matrix
  10562. * @param ray ray to transform
  10563. * @param matrix matrix to apply
  10564. * @param result ray to store result in
  10565. */
  10566. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10567. /**
  10568. * Unproject a ray from screen space to object space
  10569. * @param sourceX defines the screen space x coordinate to use
  10570. * @param sourceY defines the screen space y coordinate to use
  10571. * @param viewportWidth defines the current width of the viewport
  10572. * @param viewportHeight defines the current height of the viewport
  10573. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10574. * @param view defines the view matrix to use
  10575. * @param projection defines the projection matrix to use
  10576. */
  10577. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10578. }
  10579. /**
  10580. * Type used to define predicate used to select faces when a mesh intersection is detected
  10581. */
  10582. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10583. interface Scene {
  10584. /** @hidden */
  10585. _tempPickingRay: Nullable<Ray>;
  10586. /** @hidden */
  10587. _cachedRayForTransform: Ray;
  10588. /** @hidden */
  10589. _pickWithRayInverseMatrix: Matrix;
  10590. /** @hidden */
  10591. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10592. /** @hidden */
  10593. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10594. }
  10595. }
  10596. declare module BABYLON {
  10597. /**
  10598. * Groups all the scene component constants in one place to ease maintenance.
  10599. * @hidden
  10600. */
  10601. export class SceneComponentConstants {
  10602. static readonly NAME_EFFECTLAYER: string;
  10603. static readonly NAME_LAYER: string;
  10604. static readonly NAME_LENSFLARESYSTEM: string;
  10605. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10606. static readonly NAME_PARTICLESYSTEM: string;
  10607. static readonly NAME_GAMEPAD: string;
  10608. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10609. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10610. static readonly NAME_PREPASSRENDERER: string;
  10611. static readonly NAME_DEPTHRENDERER: string;
  10612. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10613. static readonly NAME_SPRITE: string;
  10614. static readonly NAME_OUTLINERENDERER: string;
  10615. static readonly NAME_PROCEDURALTEXTURE: string;
  10616. static readonly NAME_SHADOWGENERATOR: string;
  10617. static readonly NAME_OCTREE: string;
  10618. static readonly NAME_PHYSICSENGINE: string;
  10619. static readonly NAME_AUDIO: string;
  10620. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10621. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10622. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10623. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10624. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10625. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10627. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10642. static readonly STEP_AFTERRENDER_AUDIO: number;
  10643. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10644. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10645. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10646. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10647. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10649. static readonly STEP_POINTERMOVE_SPRITE: number;
  10650. static readonly STEP_POINTERDOWN_SPRITE: number;
  10651. static readonly STEP_POINTERUP_SPRITE: number;
  10652. }
  10653. /**
  10654. * This represents a scene component.
  10655. *
  10656. * This is used to decouple the dependency the scene is having on the different workloads like
  10657. * layers, post processes...
  10658. */
  10659. export interface ISceneComponent {
  10660. /**
  10661. * The name of the component. Each component must have a unique name.
  10662. */
  10663. name: string;
  10664. /**
  10665. * The scene the component belongs to.
  10666. */
  10667. scene: Scene;
  10668. /**
  10669. * Register the component to one instance of a scene.
  10670. */
  10671. register(): void;
  10672. /**
  10673. * Rebuilds the elements related to this component in case of
  10674. * context lost for instance.
  10675. */
  10676. rebuild(): void;
  10677. /**
  10678. * Disposes the component and the associated ressources.
  10679. */
  10680. dispose(): void;
  10681. }
  10682. /**
  10683. * This represents a SERIALIZABLE scene component.
  10684. *
  10685. * This extends Scene Component to add Serialization methods on top.
  10686. */
  10687. export interface ISceneSerializableComponent extends ISceneComponent {
  10688. /**
  10689. * Adds all the elements from the container to the scene
  10690. * @param container the container holding the elements
  10691. */
  10692. addFromContainer(container: AbstractScene): void;
  10693. /**
  10694. * Removes all the elements in the container from the scene
  10695. * @param container contains the elements to remove
  10696. * @param dispose if the removed element should be disposed (default: false)
  10697. */
  10698. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10699. /**
  10700. * Serializes the component data to the specified json object
  10701. * @param serializationObject The object to serialize to
  10702. */
  10703. serialize(serializationObject: any): void;
  10704. }
  10705. /**
  10706. * Strong typing of a Mesh related stage step action
  10707. */
  10708. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10709. /**
  10710. * Strong typing of a Evaluate Sub Mesh related stage step action
  10711. */
  10712. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10713. /**
  10714. * Strong typing of a Active Mesh related stage step action
  10715. */
  10716. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10717. /**
  10718. * Strong typing of a Camera related stage step action
  10719. */
  10720. export type CameraStageAction = (camera: Camera) => void;
  10721. /**
  10722. * Strong typing of a Camera Frame buffer related stage step action
  10723. */
  10724. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10725. /**
  10726. * Strong typing of a Render Target related stage step action
  10727. */
  10728. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10729. /**
  10730. * Strong typing of a RenderingGroup related stage step action
  10731. */
  10732. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10733. /**
  10734. * Strong typing of a Mesh Render related stage step action
  10735. */
  10736. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10737. /**
  10738. * Strong typing of a simple stage step action
  10739. */
  10740. export type SimpleStageAction = () => void;
  10741. /**
  10742. * Strong typing of a render target action.
  10743. */
  10744. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10745. /**
  10746. * Strong typing of a pointer move action.
  10747. */
  10748. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10749. /**
  10750. * Strong typing of a pointer up/down action.
  10751. */
  10752. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10753. /**
  10754. * Representation of a stage in the scene (Basically a list of ordered steps)
  10755. * @hidden
  10756. */
  10757. export class Stage<T extends Function> extends Array<{
  10758. index: number;
  10759. component: ISceneComponent;
  10760. action: T;
  10761. }> {
  10762. /**
  10763. * Hide ctor from the rest of the world.
  10764. * @param items The items to add.
  10765. */
  10766. private constructor();
  10767. /**
  10768. * Creates a new Stage.
  10769. * @returns A new instance of a Stage
  10770. */
  10771. static Create<T extends Function>(): Stage<T>;
  10772. /**
  10773. * Registers a step in an ordered way in the targeted stage.
  10774. * @param index Defines the position to register the step in
  10775. * @param component Defines the component attached to the step
  10776. * @param action Defines the action to launch during the step
  10777. */
  10778. registerStep(index: number, component: ISceneComponent, action: T): void;
  10779. /**
  10780. * Clears all the steps from the stage.
  10781. */
  10782. clear(): void;
  10783. }
  10784. }
  10785. declare module BABYLON {
  10786. interface Scene {
  10787. /** @hidden */
  10788. _pointerOverSprite: Nullable<Sprite>;
  10789. /** @hidden */
  10790. _pickedDownSprite: Nullable<Sprite>;
  10791. /** @hidden */
  10792. _tempSpritePickingRay: Nullable<Ray>;
  10793. /**
  10794. * All of the sprite managers added to this scene
  10795. * @see https://doc.babylonjs.com/babylon101/sprites
  10796. */
  10797. spriteManagers: Array<ISpriteManager>;
  10798. /**
  10799. * An event triggered when sprites rendering is about to start
  10800. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10801. */
  10802. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10803. /**
  10804. * An event triggered when sprites rendering is done
  10805. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10806. */
  10807. onAfterSpritesRenderingObservable: Observable<Scene>;
  10808. /** @hidden */
  10809. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10810. /** Launch a ray to try to pick a sprite in the scene
  10811. * @param x position on screen
  10812. * @param y position on screen
  10813. * @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
  10814. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10815. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10816. * @returns a PickingInfo
  10817. */
  10818. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10819. /** Use the given ray to pick a sprite in the scene
  10820. * @param ray The ray (in world space) to use to pick meshes
  10821. * @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
  10822. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10823. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10824. * @returns a PickingInfo
  10825. */
  10826. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10827. /** @hidden */
  10828. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10829. /** Launch a ray to try to pick sprites in the scene
  10830. * @param x position on screen
  10831. * @param y position on screen
  10832. * @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
  10833. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10834. * @returns a PickingInfo array
  10835. */
  10836. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10837. /** Use the given ray to pick sprites in the scene
  10838. * @param ray The ray (in world space) to use to pick meshes
  10839. * @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
  10840. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10841. * @returns a PickingInfo array
  10842. */
  10843. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10844. /**
  10845. * Force the sprite under the pointer
  10846. * @param sprite defines the sprite to use
  10847. */
  10848. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10849. /**
  10850. * Gets the sprite under the pointer
  10851. * @returns a Sprite or null if no sprite is under the pointer
  10852. */
  10853. getPointerOverSprite(): Nullable<Sprite>;
  10854. }
  10855. /**
  10856. * Defines the sprite scene component responsible to manage sprites
  10857. * in a given scene.
  10858. */
  10859. export class SpriteSceneComponent implements ISceneComponent {
  10860. /**
  10861. * The component name helpfull to identify the component in the list of scene components.
  10862. */
  10863. readonly name: string;
  10864. /**
  10865. * The scene the component belongs to.
  10866. */
  10867. scene: Scene;
  10868. /** @hidden */
  10869. private _spritePredicate;
  10870. /**
  10871. * Creates a new instance of the component for the given scene
  10872. * @param scene Defines the scene to register the component in
  10873. */
  10874. constructor(scene: Scene);
  10875. /**
  10876. * Registers the component in a given scene
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. private _pickSpriteButKeepRay;
  10889. private _pointerMove;
  10890. private _pointerDown;
  10891. private _pointerUp;
  10892. }
  10893. }
  10894. declare module BABYLON {
  10895. /** @hidden */
  10896. export var fogFragmentDeclaration: {
  10897. name: string;
  10898. shader: string;
  10899. };
  10900. }
  10901. declare module BABYLON {
  10902. /** @hidden */
  10903. export var fogFragment: {
  10904. name: string;
  10905. shader: string;
  10906. };
  10907. }
  10908. declare module BABYLON {
  10909. /** @hidden */
  10910. export var spritesPixelShader: {
  10911. name: string;
  10912. shader: string;
  10913. };
  10914. }
  10915. declare module BABYLON {
  10916. /** @hidden */
  10917. export var fogVertexDeclaration: {
  10918. name: string;
  10919. shader: string;
  10920. };
  10921. }
  10922. declare module BABYLON {
  10923. /** @hidden */
  10924. export var spritesVertexShader: {
  10925. name: string;
  10926. shader: string;
  10927. };
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10932. */
  10933. export interface ISpriteManager extends IDisposable {
  10934. /**
  10935. * Gets manager's name
  10936. */
  10937. name: string;
  10938. /**
  10939. * Restricts the camera to viewing objects with the same layerMask.
  10940. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10941. */
  10942. layerMask: number;
  10943. /**
  10944. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10945. */
  10946. isPickable: boolean;
  10947. /**
  10948. * Gets the hosting scene
  10949. */
  10950. scene: Scene;
  10951. /**
  10952. * Specifies the rendering group id for this mesh (0 by default)
  10953. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10954. */
  10955. renderingGroupId: number;
  10956. /**
  10957. * Defines the list of sprites managed by the manager.
  10958. */
  10959. sprites: Array<Sprite>;
  10960. /**
  10961. * Gets or sets the spritesheet texture
  10962. */
  10963. texture: Texture;
  10964. /** Defines the default width of a cell in the spritesheet */
  10965. cellWidth: number;
  10966. /** Defines the default height of a cell in the spritesheet */
  10967. cellHeight: number;
  10968. /**
  10969. * Tests the intersection of a sprite with a specific ray.
  10970. * @param ray The ray we are sending to test the collision
  10971. * @param camera The camera space we are sending rays in
  10972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10973. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10974. * @returns picking info or null.
  10975. */
  10976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10977. /**
  10978. * Intersects the sprites with a ray
  10979. * @param ray defines the ray to intersect with
  10980. * @param camera defines the current active camera
  10981. * @param predicate defines a predicate used to select candidate sprites
  10982. * @returns null if no hit or a PickingInfo array
  10983. */
  10984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10985. /**
  10986. * Renders the list of sprites on screen.
  10987. */
  10988. render(): void;
  10989. }
  10990. /**
  10991. * Class used to manage multiple sprites on the same spritesheet
  10992. * @see https://doc.babylonjs.com/babylon101/sprites
  10993. */
  10994. export class SpriteManager implements ISpriteManager {
  10995. /** defines the manager's name */
  10996. name: string;
  10997. /** Define the Url to load snippets */
  10998. static SnippetUrl: string;
  10999. /** Snippet ID if the manager was created from the snippet server */
  11000. snippetId: string;
  11001. /** Gets the list of sprites */
  11002. sprites: Sprite[];
  11003. /** Gets or sets the rendering group id (0 by default) */
  11004. renderingGroupId: number;
  11005. /** Gets or sets camera layer mask */
  11006. layerMask: number;
  11007. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11008. fogEnabled: boolean;
  11009. /** Gets or sets a boolean indicating if the sprites are pickable */
  11010. isPickable: boolean;
  11011. /** Defines the default width of a cell in the spritesheet */
  11012. cellWidth: number;
  11013. /** Defines the default height of a cell in the spritesheet */
  11014. cellHeight: number;
  11015. /** Associative array from JSON sprite data file */
  11016. private _cellData;
  11017. /** Array of sprite names from JSON sprite data file */
  11018. private _spriteMap;
  11019. /** True when packed cell data from JSON file is ready*/
  11020. private _packedAndReady;
  11021. private _textureContent;
  11022. /**
  11023. * An event triggered when the manager is disposed.
  11024. */
  11025. onDisposeObservable: Observable<SpriteManager>;
  11026. private _onDisposeObserver;
  11027. /**
  11028. * Callback called when the manager is disposed
  11029. */
  11030. set onDispose(callback: () => void);
  11031. private _capacity;
  11032. private _fromPacked;
  11033. private _spriteTexture;
  11034. private _epsilon;
  11035. private _scene;
  11036. private _vertexData;
  11037. private _buffer;
  11038. private _vertexBuffers;
  11039. private _indexBuffer;
  11040. private _effectBase;
  11041. private _effectFog;
  11042. /**
  11043. * Gets or sets the unique id of the sprite
  11044. */
  11045. uniqueId: number;
  11046. /**
  11047. * Gets the array of sprites
  11048. */
  11049. get children(): Sprite[];
  11050. /**
  11051. * Gets the hosting scene
  11052. */
  11053. get scene(): Scene;
  11054. /**
  11055. * Gets the capacity of the manager
  11056. */
  11057. get capacity(): number;
  11058. /**
  11059. * Gets or sets the spritesheet texture
  11060. */
  11061. get texture(): Texture;
  11062. set texture(value: Texture);
  11063. private _blendMode;
  11064. /**
  11065. * Blend mode use to render the particle, it can be any of
  11066. * the static Constants.ALPHA_x properties provided in this class.
  11067. * Default value is Constants.ALPHA_COMBINE
  11068. */
  11069. get blendMode(): number;
  11070. set blendMode(blendMode: number);
  11071. /** Disables writing to the depth buffer when rendering the sprites.
  11072. * It can be handy to disable depth writing when using textures without alpha channel
  11073. * and setting some specific blend modes.
  11074. */
  11075. disableDepthWrite: boolean;
  11076. /**
  11077. * Creates a new sprite manager
  11078. * @param name defines the manager's name
  11079. * @param imgUrl defines the sprite sheet url
  11080. * @param capacity defines the maximum allowed number of sprites
  11081. * @param cellSize defines the size of a sprite cell
  11082. * @param scene defines the hosting scene
  11083. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11084. * @param samplingMode defines the smapling mode to use with spritesheet
  11085. * @param fromPacked set to false; do not alter
  11086. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11087. */
  11088. constructor(
  11089. /** defines the manager's name */
  11090. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11091. /**
  11092. * Returns the string "SpriteManager"
  11093. * @returns "SpriteManager"
  11094. */
  11095. getClassName(): string;
  11096. private _makePacked;
  11097. private _appendSpriteVertex;
  11098. private _checkTextureAlpha;
  11099. /**
  11100. * Intersects the sprites with a ray
  11101. * @param ray defines the ray to intersect with
  11102. * @param camera defines the current active camera
  11103. * @param predicate defines a predicate used to select candidate sprites
  11104. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11105. * @returns null if no hit or a PickingInfo
  11106. */
  11107. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11108. /**
  11109. * Intersects the sprites with a ray
  11110. * @param ray defines the ray to intersect with
  11111. * @param camera defines the current active camera
  11112. * @param predicate defines a predicate used to select candidate sprites
  11113. * @returns null if no hit or a PickingInfo array
  11114. */
  11115. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11116. /**
  11117. * Render all child sprites
  11118. */
  11119. render(): void;
  11120. /**
  11121. * Release associated resources
  11122. */
  11123. dispose(): void;
  11124. /**
  11125. * Serializes the sprite manager to a JSON object
  11126. * @param serializeTexture defines if the texture must be serialized as well
  11127. * @returns the JSON object
  11128. */
  11129. serialize(serializeTexture?: boolean): any;
  11130. /**
  11131. * Parses a JSON object to create a new sprite manager.
  11132. * @param parsedManager The JSON object to parse
  11133. * @param scene The scene to create the sprite managerin
  11134. * @param rootUrl The root url to use to load external dependencies like texture
  11135. * @returns the new sprite manager
  11136. */
  11137. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11138. /**
  11139. * Creates a sprite manager from a snippet saved in a remote file
  11140. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11141. * @param url defines the url to load from
  11142. * @param scene defines the hosting scene
  11143. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11144. * @returns a promise that will resolve to the new sprite manager
  11145. */
  11146. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11147. /**
  11148. * Creates a sprite manager from a snippet saved by the sprite editor
  11149. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11150. * @param scene defines the hosting scene
  11151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11152. * @returns a promise that will resolve to the new sprite manager
  11153. */
  11154. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11155. }
  11156. }
  11157. declare module BABYLON {
  11158. /** Interface used by value gradients (color, factor, ...) */
  11159. export interface IValueGradient {
  11160. /**
  11161. * Gets or sets the gradient value (between 0 and 1)
  11162. */
  11163. gradient: number;
  11164. }
  11165. /** Class used to store color4 gradient */
  11166. export class ColorGradient implements IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. /**
  11172. * Gets or sets first associated color
  11173. */
  11174. color1: Color4;
  11175. /**
  11176. * Gets or sets second associated color
  11177. */
  11178. color2?: Color4 | undefined;
  11179. /**
  11180. * Creates a new color4 gradient
  11181. * @param gradient gets or sets the gradient value (between 0 and 1)
  11182. * @param color1 gets or sets first associated color
  11183. * @param color2 gets or sets first second color
  11184. */
  11185. constructor(
  11186. /**
  11187. * Gets or sets the gradient value (between 0 and 1)
  11188. */
  11189. gradient: number,
  11190. /**
  11191. * Gets or sets first associated color
  11192. */
  11193. color1: Color4,
  11194. /**
  11195. * Gets or sets second associated color
  11196. */
  11197. color2?: Color4 | undefined);
  11198. /**
  11199. * Will get a color picked randomly between color1 and color2.
  11200. * If color2 is undefined then color1 will be used
  11201. * @param result defines the target Color4 to store the result in
  11202. */
  11203. getColorToRef(result: Color4): void;
  11204. }
  11205. /** Class used to store color 3 gradient */
  11206. export class Color3Gradient implements IValueGradient {
  11207. /**
  11208. * Gets or sets the gradient value (between 0 and 1)
  11209. */
  11210. gradient: number;
  11211. /**
  11212. * Gets or sets the associated color
  11213. */
  11214. color: Color3;
  11215. /**
  11216. * Creates a new color3 gradient
  11217. * @param gradient gets or sets the gradient value (between 0 and 1)
  11218. * @param color gets or sets associated color
  11219. */
  11220. constructor(
  11221. /**
  11222. * Gets or sets the gradient value (between 0 and 1)
  11223. */
  11224. gradient: number,
  11225. /**
  11226. * Gets or sets the associated color
  11227. */
  11228. color: Color3);
  11229. }
  11230. /** Class used to store factor gradient */
  11231. export class FactorGradient implements IValueGradient {
  11232. /**
  11233. * Gets or sets the gradient value (between 0 and 1)
  11234. */
  11235. gradient: number;
  11236. /**
  11237. * Gets or sets first associated factor
  11238. */
  11239. factor1: number;
  11240. /**
  11241. * Gets or sets second associated factor
  11242. */
  11243. factor2?: number | undefined;
  11244. /**
  11245. * Creates a new factor gradient
  11246. * @param gradient gets or sets the gradient value (between 0 and 1)
  11247. * @param factor1 gets or sets first associated factor
  11248. * @param factor2 gets or sets second associated factor
  11249. */
  11250. constructor(
  11251. /**
  11252. * Gets or sets the gradient value (between 0 and 1)
  11253. */
  11254. gradient: number,
  11255. /**
  11256. * Gets or sets first associated factor
  11257. */
  11258. factor1: number,
  11259. /**
  11260. * Gets or sets second associated factor
  11261. */
  11262. factor2?: number | undefined);
  11263. /**
  11264. * Will get a number picked randomly between factor1 and factor2.
  11265. * If factor2 is undefined then factor1 will be used
  11266. * @returns the picked number
  11267. */
  11268. getFactor(): number;
  11269. }
  11270. /**
  11271. * Helper used to simplify some generic gradient tasks
  11272. */
  11273. export class GradientHelper {
  11274. /**
  11275. * Gets the current gradient from an array of IValueGradient
  11276. * @param ratio defines the current ratio to get
  11277. * @param gradients defines the array of IValueGradient
  11278. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11279. */
  11280. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface ThinEngine {
  11285. /**
  11286. * Creates a raw texture
  11287. * @param data defines the data to store in the texture
  11288. * @param width defines the width of the texture
  11289. * @param height defines the height of the texture
  11290. * @param format defines the format of the data
  11291. * @param generateMipMaps defines if the engine should generate the mip levels
  11292. * @param invertY defines if data must be stored with Y axis inverted
  11293. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11294. * @param compression defines the compression used (null by default)
  11295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11296. * @returns the raw texture inside an InternalTexture
  11297. */
  11298. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11299. /**
  11300. * Update a raw texture
  11301. * @param texture defines the texture to update
  11302. * @param data defines the data to store in the texture
  11303. * @param format defines the format of the data
  11304. * @param invertY defines if data must be stored with Y axis inverted
  11305. */
  11306. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11307. /**
  11308. * Update a raw texture
  11309. * @param texture defines the texture to update
  11310. * @param data defines the data to store in the texture
  11311. * @param format defines the format of the data
  11312. * @param invertY defines if data must be stored with Y axis inverted
  11313. * @param compression defines the compression used (null by default)
  11314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11315. */
  11316. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11317. /**
  11318. * Creates a new raw cube texture
  11319. * @param data defines the array of data to use to create each face
  11320. * @param size defines the size of the textures
  11321. * @param format defines the format of the data
  11322. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11323. * @param generateMipMaps defines if the engine should generate the mip levels
  11324. * @param invertY defines if data must be stored with Y axis inverted
  11325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11326. * @param compression defines the compression used (null by default)
  11327. * @returns the cube texture as an InternalTexture
  11328. */
  11329. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11330. /**
  11331. * Update a raw cube texture
  11332. * @param texture defines the texture to udpdate
  11333. * @param data defines the data to store
  11334. * @param format defines the data format
  11335. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11336. * @param invertY defines if data must be stored with Y axis inverted
  11337. */
  11338. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11339. /**
  11340. * Update a raw cube texture
  11341. * @param texture defines the texture to udpdate
  11342. * @param data defines the data to store
  11343. * @param format defines the data format
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. * @param invertY defines if data must be stored with Y axis inverted
  11346. * @param compression defines the compression used (null by default)
  11347. */
  11348. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11349. /**
  11350. * Update a raw cube texture
  11351. * @param texture defines the texture to udpdate
  11352. * @param data defines the data to store
  11353. * @param format defines the data format
  11354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. * @param compression defines the compression used (null by default)
  11357. * @param level defines which level of the texture to update
  11358. */
  11359. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11360. /**
  11361. * Creates a new raw cube texture from a specified url
  11362. * @param url defines the url where the data is located
  11363. * @param scene defines the current scene
  11364. * @param size defines the size of the textures
  11365. * @param format defines the format of the data
  11366. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11367. * @param noMipmap defines if the engine should avoid generating the mip levels
  11368. * @param callback defines a callback used to extract texture data from loaded data
  11369. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11370. * @param onLoad defines a callback called when texture is loaded
  11371. * @param onError defines a callback called if there is an error
  11372. * @returns the cube texture as an InternalTexture
  11373. */
  11374. 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;
  11375. /**
  11376. * Creates a new raw cube texture from a specified url
  11377. * @param url defines the url where the data is located
  11378. * @param scene defines the current scene
  11379. * @param size defines the size of the textures
  11380. * @param format defines the format of the data
  11381. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11382. * @param noMipmap defines if the engine should avoid generating the mip levels
  11383. * @param callback defines a callback used to extract texture data from loaded data
  11384. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11385. * @param onLoad defines a callback called when texture is loaded
  11386. * @param onError defines a callback called if there is an error
  11387. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11388. * @param invertY defines if data must be stored with Y axis inverted
  11389. * @returns the cube texture as an InternalTexture
  11390. */
  11391. 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;
  11392. /**
  11393. * Creates a new raw 3D texture
  11394. * @param data defines the data used to create the texture
  11395. * @param width defines the width of the texture
  11396. * @param height defines the height of the texture
  11397. * @param depth defines the depth of the texture
  11398. * @param format defines the format of the texture
  11399. * @param generateMipMaps defines if the engine must generate mip levels
  11400. * @param invertY defines if data must be stored with Y axis inverted
  11401. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11402. * @param compression defines the compressed used (can be null)
  11403. * @param textureType defines the compressed used (can be null)
  11404. * @returns a new raw 3D texture (stored in an InternalTexture)
  11405. */
  11406. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11407. /**
  11408. * Update a raw 3D texture
  11409. * @param texture defines the texture to update
  11410. * @param data defines the data to store
  11411. * @param format defines the data format
  11412. * @param invertY defines if data must be stored with Y axis inverted
  11413. */
  11414. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11415. /**
  11416. * Update a raw 3D texture
  11417. * @param texture defines the texture to update
  11418. * @param data defines the data to store
  11419. * @param format defines the data format
  11420. * @param invertY defines if data must be stored with Y axis inverted
  11421. * @param compression defines the used compression (can be null)
  11422. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11423. */
  11424. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11425. /**
  11426. * Creates a new raw 2D array texture
  11427. * @param data defines the data used to create the texture
  11428. * @param width defines the width of the texture
  11429. * @param height defines the height of the texture
  11430. * @param depth defines the number of layers of the texture
  11431. * @param format defines the format of the texture
  11432. * @param generateMipMaps defines if the engine must generate mip levels
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11435. * @param compression defines the compressed used (can be null)
  11436. * @param textureType defines the compressed used (can be null)
  11437. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11438. */
  11439. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11440. /**
  11441. * Update a raw 2D array texture
  11442. * @param texture defines the texture to update
  11443. * @param data defines the data to store
  11444. * @param format defines the data format
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. */
  11447. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11448. /**
  11449. * Update a raw 2D array texture
  11450. * @param texture defines the texture to update
  11451. * @param data defines the data to store
  11452. * @param format defines the data format
  11453. * @param invertY defines if data must be stored with Y axis inverted
  11454. * @param compression defines the used compression (can be null)
  11455. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11456. */
  11457. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11458. }
  11459. }
  11460. declare module BABYLON {
  11461. /**
  11462. * Raw texture can help creating a texture directly from an array of data.
  11463. * This can be super useful if you either get the data from an uncompressed source or
  11464. * if you wish to create your texture pixel by pixel.
  11465. */
  11466. export class RawTexture extends Texture {
  11467. /**
  11468. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11469. */
  11470. format: number;
  11471. /**
  11472. * Instantiates a new RawTexture.
  11473. * Raw texture can help creating a texture directly from an array of data.
  11474. * This can be super useful if you either get the data from an uncompressed source or
  11475. * if you wish to create your texture pixel by pixel.
  11476. * @param data define the array of data to use to create the texture
  11477. * @param width define the width of the texture
  11478. * @param height define the height of the texture
  11479. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11480. * @param scene define the scene the texture belongs to
  11481. * @param generateMipMaps define whether mip maps should be generated or not
  11482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11485. */
  11486. constructor(data: ArrayBufferView, width: number, height: number,
  11487. /**
  11488. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11489. */
  11490. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11491. /**
  11492. * Updates the texture underlying data.
  11493. * @param data Define the new data of the texture
  11494. */
  11495. update(data: ArrayBufferView): void;
  11496. /**
  11497. * Creates a luminance texture from some data.
  11498. * @param data Define the texture data
  11499. * @param width Define the width of the texture
  11500. * @param height Define the height of the texture
  11501. * @param scene Define the scene the texture belongs to
  11502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11505. * @returns the luminance texture
  11506. */
  11507. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11508. /**
  11509. * Creates a luminance alpha texture from some data.
  11510. * @param data Define the texture data
  11511. * @param width Define the width of the texture
  11512. * @param height Define the height of the texture
  11513. * @param scene Define the scene the texture belongs to
  11514. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11515. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11516. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11517. * @returns the luminance alpha texture
  11518. */
  11519. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11520. /**
  11521. * Creates an alpha texture from some data.
  11522. * @param data Define the texture data
  11523. * @param width Define the width of the texture
  11524. * @param height Define the height of the texture
  11525. * @param scene Define the scene the texture belongs to
  11526. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11527. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11528. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11529. * @returns the alpha texture
  11530. */
  11531. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11532. /**
  11533. * Creates a RGB texture from some data.
  11534. * @param data Define the texture data
  11535. * @param width Define the width of the texture
  11536. * @param height Define the height of the texture
  11537. * @param scene Define the scene the texture belongs to
  11538. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11539. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11540. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11541. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11542. * @returns the RGB alpha texture
  11543. */
  11544. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11545. /**
  11546. * Creates a RGBA texture from some data.
  11547. * @param data Define the texture data
  11548. * @param width Define the width of the texture
  11549. * @param height Define the height of the texture
  11550. * @param scene Define the scene the texture belongs to
  11551. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11554. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11555. * @returns the RGBA texture
  11556. */
  11557. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11558. /**
  11559. * Creates a R texture from some data.
  11560. * @param data Define the texture data
  11561. * @param width Define the width of the texture
  11562. * @param height Define the height of the texture
  11563. * @param scene Define the scene the texture belongs to
  11564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11567. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11568. * @returns the R texture
  11569. */
  11570. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11571. }
  11572. }
  11573. declare module BABYLON {
  11574. interface AbstractScene {
  11575. /**
  11576. * The list of procedural textures added to the scene
  11577. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11578. */
  11579. proceduralTextures: Array<ProceduralTexture>;
  11580. }
  11581. /**
  11582. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11583. * in a given scene.
  11584. */
  11585. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11586. /**
  11587. * The component name helpfull to identify the component in the list of scene components.
  11588. */
  11589. readonly name: string;
  11590. /**
  11591. * The scene the component belongs to.
  11592. */
  11593. scene: Scene;
  11594. /**
  11595. * Creates a new instance of the component for the given scene
  11596. * @param scene Defines the scene to register the component in
  11597. */
  11598. constructor(scene: Scene);
  11599. /**
  11600. * Registers the component in a given scene
  11601. */
  11602. register(): void;
  11603. /**
  11604. * Rebuilds the elements related to this component in case of
  11605. * context lost for instance.
  11606. */
  11607. rebuild(): void;
  11608. /**
  11609. * Disposes the component and the associated ressources.
  11610. */
  11611. dispose(): void;
  11612. private _beforeClear;
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. interface ThinEngine {
  11617. /**
  11618. * Creates a new render target cube texture
  11619. * @param size defines the size of the texture
  11620. * @param options defines the options used to create the texture
  11621. * @returns a new render target cube texture stored in an InternalTexture
  11622. */
  11623. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /** @hidden */
  11628. export var proceduralVertexShader: {
  11629. name: string;
  11630. shader: string;
  11631. };
  11632. }
  11633. declare module BABYLON {
  11634. /**
  11635. * 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.
  11636. * This is the base class of any Procedural texture and contains most of the shareable code.
  11637. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11638. */
  11639. export class ProceduralTexture extends Texture {
  11640. isCube: boolean;
  11641. /**
  11642. * Define if the texture is enabled or not (disabled texture will not render)
  11643. */
  11644. isEnabled: boolean;
  11645. /**
  11646. * Define if the texture must be cleared before rendering (default is true)
  11647. */
  11648. autoClear: boolean;
  11649. /**
  11650. * Callback called when the texture is generated
  11651. */
  11652. onGenerated: () => void;
  11653. /**
  11654. * Event raised when the texture is generated
  11655. */
  11656. onGeneratedObservable: Observable<ProceduralTexture>;
  11657. /** @hidden */
  11658. _generateMipMaps: boolean;
  11659. /** @hidden **/
  11660. _effect: Effect;
  11661. /** @hidden */
  11662. _textures: {
  11663. [key: string]: Texture;
  11664. };
  11665. /** @hidden */
  11666. protected _fallbackTexture: Nullable<Texture>;
  11667. private _size;
  11668. private _currentRefreshId;
  11669. private _frameId;
  11670. private _refreshRate;
  11671. private _vertexBuffers;
  11672. private _indexBuffer;
  11673. private _uniforms;
  11674. private _samplers;
  11675. private _fragment;
  11676. private _floats;
  11677. private _ints;
  11678. private _floatsArrays;
  11679. private _colors3;
  11680. private _colors4;
  11681. private _vectors2;
  11682. private _vectors3;
  11683. private _matrices;
  11684. private _fallbackTextureUsed;
  11685. private _fullEngine;
  11686. private _cachedDefines;
  11687. private _contentUpdateId;
  11688. private _contentData;
  11689. /**
  11690. * Instantiates a new procedural texture.
  11691. * 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.
  11692. * This is the base class of any Procedural texture and contains most of the shareable code.
  11693. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11694. * @param name Define the name of the texture
  11695. * @param size Define the size of the texture to create
  11696. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11697. * @param scene Define the scene the texture belongs to
  11698. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11699. * @param generateMipMaps Define if the texture should creates mip maps or not
  11700. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11701. */
  11702. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11703. /**
  11704. * The effect that is created when initializing the post process.
  11705. * @returns The created effect corresponding the the postprocess.
  11706. */
  11707. getEffect(): Effect;
  11708. /**
  11709. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11710. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11711. */
  11712. getContent(): Nullable<ArrayBufferView>;
  11713. private _createIndexBuffer;
  11714. /** @hidden */
  11715. _rebuild(): void;
  11716. /**
  11717. * Resets the texture in order to recreate its associated resources.
  11718. * This can be called in case of context loss
  11719. */
  11720. reset(): void;
  11721. protected _getDefines(): string;
  11722. /**
  11723. * Is the texture ready to be used ? (rendered at least once)
  11724. * @returns true if ready, otherwise, false.
  11725. */
  11726. isReady(): boolean;
  11727. /**
  11728. * Resets the refresh counter of the texture and start bak from scratch.
  11729. * Could be useful to regenerate the texture if it is setup to render only once.
  11730. */
  11731. resetRefreshCounter(): void;
  11732. /**
  11733. * Set the fragment shader to use in order to render the texture.
  11734. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11735. */
  11736. setFragment(fragment: any): void;
  11737. /**
  11738. * Define the refresh rate of the texture or the rendering frequency.
  11739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11740. */
  11741. get refreshRate(): number;
  11742. set refreshRate(value: number);
  11743. /** @hidden */
  11744. _shouldRender(): boolean;
  11745. /**
  11746. * Get the size the texture is rendering at.
  11747. * @returns the size (texture is always squared)
  11748. */
  11749. getRenderSize(): number;
  11750. /**
  11751. * Resize the texture to new value.
  11752. * @param size Define the new size the texture should have
  11753. * @param generateMipMaps Define whether the new texture should create mip maps
  11754. */
  11755. resize(size: number, generateMipMaps: boolean): void;
  11756. private _checkUniform;
  11757. /**
  11758. * Set a texture in the shader program used to render.
  11759. * @param name Define the name of the uniform samplers as defined in the shader
  11760. * @param texture Define the texture to bind to this sampler
  11761. * @return the texture itself allowing "fluent" like uniform updates
  11762. */
  11763. setTexture(name: string, texture: Texture): ProceduralTexture;
  11764. /**
  11765. * Set a float in the shader.
  11766. * @param name Define the name of the uniform as defined in the shader
  11767. * @param value Define the value to give to the uniform
  11768. * @return the texture itself allowing "fluent" like uniform updates
  11769. */
  11770. setFloat(name: string, value: number): ProceduralTexture;
  11771. /**
  11772. * Set a int in the shader.
  11773. * @param name Define the name of the uniform as defined in the shader
  11774. * @param value Define the value to give to the uniform
  11775. * @return the texture itself allowing "fluent" like uniform updates
  11776. */
  11777. setInt(name: string, value: number): ProceduralTexture;
  11778. /**
  11779. * Set an array of floats in the shader.
  11780. * @param name Define the name of the uniform as defined in the shader
  11781. * @param value Define the value to give to the uniform
  11782. * @return the texture itself allowing "fluent" like uniform updates
  11783. */
  11784. setFloats(name: string, value: number[]): ProceduralTexture;
  11785. /**
  11786. * Set a vec3 in the shader from a Color3.
  11787. * @param name Define the name of the uniform as defined in the shader
  11788. * @param value Define the value to give to the uniform
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setColor3(name: string, value: Color3): ProceduralTexture;
  11792. /**
  11793. * Set a vec4 in the shader from a Color4.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setColor4(name: string, value: Color4): ProceduralTexture;
  11799. /**
  11800. * Set a vec2 in the shader from a Vector2.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setVector2(name: string, value: Vector2): ProceduralTexture;
  11806. /**
  11807. * Set a vec3 in the shader from a Vector3.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setVector3(name: string, value: Vector3): ProceduralTexture;
  11813. /**
  11814. * Set a mat4 in the shader from a MAtrix.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11820. /**
  11821. * Render the texture to its associated render target.
  11822. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11823. */
  11824. render(useCameraPostProcess?: boolean): void;
  11825. /**
  11826. * Clone the texture.
  11827. * @returns the cloned texture
  11828. */
  11829. clone(): ProceduralTexture;
  11830. /**
  11831. * Dispose the texture and release its asoociated resources.
  11832. */
  11833. dispose(): void;
  11834. }
  11835. }
  11836. declare module BABYLON {
  11837. /**
  11838. * This represents the base class for particle system in Babylon.
  11839. * 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.
  11840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11841. * @example https://doc.babylonjs.com/babylon101/particles
  11842. */
  11843. export class BaseParticleSystem {
  11844. /**
  11845. * Source color is added to the destination color without alpha affecting the result
  11846. */
  11847. static BLENDMODE_ONEONE: number;
  11848. /**
  11849. * Blend current color and particle color using particle’s alpha
  11850. */
  11851. static BLENDMODE_STANDARD: number;
  11852. /**
  11853. * Add current color and particle color multiplied by particle’s alpha
  11854. */
  11855. static BLENDMODE_ADD: number;
  11856. /**
  11857. * Multiply current color with particle color
  11858. */
  11859. static BLENDMODE_MULTIPLY: number;
  11860. /**
  11861. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11862. */
  11863. static BLENDMODE_MULTIPLYADD: number;
  11864. /**
  11865. * List of animations used by the particle system.
  11866. */
  11867. animations: Animation[];
  11868. /**
  11869. * Gets or sets the unique id of the particle system
  11870. */
  11871. uniqueId: number;
  11872. /**
  11873. * The id of the Particle system.
  11874. */
  11875. id: string;
  11876. /**
  11877. * The friendly name of the Particle system.
  11878. */
  11879. name: string;
  11880. /**
  11881. * Snippet ID if the particle system was created from the snippet server
  11882. */
  11883. snippetId: string;
  11884. /**
  11885. * The rendering group used by the Particle system to chose when to render.
  11886. */
  11887. renderingGroupId: number;
  11888. /**
  11889. * The emitter represents the Mesh or position we are attaching the particle system to.
  11890. */
  11891. emitter: Nullable<AbstractMesh | Vector3>;
  11892. /**
  11893. * The maximum number of particles to emit per frame
  11894. */
  11895. emitRate: number;
  11896. /**
  11897. * If you want to launch only a few particles at once, that can be done, as well.
  11898. */
  11899. manualEmitCount: number;
  11900. /**
  11901. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11902. */
  11903. updateSpeed: number;
  11904. /**
  11905. * The amount of time the particle system is running (depends of the overall update speed).
  11906. */
  11907. targetStopDuration: number;
  11908. /**
  11909. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11910. */
  11911. disposeOnStop: boolean;
  11912. /**
  11913. * Minimum power of emitting particles.
  11914. */
  11915. minEmitPower: number;
  11916. /**
  11917. * Maximum power of emitting particles.
  11918. */
  11919. maxEmitPower: number;
  11920. /**
  11921. * Minimum life time of emitting particles.
  11922. */
  11923. minLifeTime: number;
  11924. /**
  11925. * Maximum life time of emitting particles.
  11926. */
  11927. maxLifeTime: number;
  11928. /**
  11929. * Minimum Size of emitting particles.
  11930. */
  11931. minSize: number;
  11932. /**
  11933. * Maximum Size of emitting particles.
  11934. */
  11935. maxSize: number;
  11936. /**
  11937. * Minimum scale of emitting particles on X axis.
  11938. */
  11939. minScaleX: number;
  11940. /**
  11941. * Maximum scale of emitting particles on X axis.
  11942. */
  11943. maxScaleX: number;
  11944. /**
  11945. * Minimum scale of emitting particles on Y axis.
  11946. */
  11947. minScaleY: number;
  11948. /**
  11949. * Maximum scale of emitting particles on Y axis.
  11950. */
  11951. maxScaleY: number;
  11952. /**
  11953. * Gets or sets the minimal initial rotation in radians.
  11954. */
  11955. minInitialRotation: number;
  11956. /**
  11957. * Gets or sets the maximal initial rotation in radians.
  11958. */
  11959. maxInitialRotation: number;
  11960. /**
  11961. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11962. */
  11963. minAngularSpeed: number;
  11964. /**
  11965. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11966. */
  11967. maxAngularSpeed: number;
  11968. /**
  11969. * The texture used to render each particle. (this can be a spritesheet)
  11970. */
  11971. particleTexture: Nullable<Texture>;
  11972. /**
  11973. * The layer mask we are rendering the particles through.
  11974. */
  11975. layerMask: number;
  11976. /**
  11977. * This can help using your own shader to render the particle system.
  11978. * The according effect will be created
  11979. */
  11980. customShader: any;
  11981. /**
  11982. * By default particle system starts as soon as they are created. This prevents the
  11983. * automatic start to happen and let you decide when to start emitting particles.
  11984. */
  11985. preventAutoStart: boolean;
  11986. private _noiseTexture;
  11987. /**
  11988. * Gets or sets a texture used to add random noise to particle positions
  11989. */
  11990. get noiseTexture(): Nullable<ProceduralTexture>;
  11991. set noiseTexture(value: Nullable<ProceduralTexture>);
  11992. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11993. noiseStrength: Vector3;
  11994. /**
  11995. * Callback triggered when the particle animation is ending.
  11996. */
  11997. onAnimationEnd: Nullable<() => void>;
  11998. /**
  11999. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12000. */
  12001. blendMode: number;
  12002. /**
  12003. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12004. * to override the particles.
  12005. */
  12006. forceDepthWrite: boolean;
  12007. /** 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 */
  12008. preWarmCycles: number;
  12009. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12010. preWarmStepOffset: number;
  12011. /**
  12012. * 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)
  12013. */
  12014. spriteCellChangeSpeed: number;
  12015. /**
  12016. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12017. */
  12018. startSpriteCellID: number;
  12019. /**
  12020. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12021. */
  12022. endSpriteCellID: number;
  12023. /**
  12024. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12025. */
  12026. spriteCellWidth: number;
  12027. /**
  12028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12029. */
  12030. spriteCellHeight: number;
  12031. /**
  12032. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12033. */
  12034. spriteRandomStartCell: boolean;
  12035. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12036. translationPivot: Vector2;
  12037. /** @hidden */
  12038. protected _isAnimationSheetEnabled: boolean;
  12039. /**
  12040. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12041. */
  12042. beginAnimationOnStart: boolean;
  12043. /**
  12044. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12045. */
  12046. beginAnimationFrom: number;
  12047. /**
  12048. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12049. */
  12050. beginAnimationTo: number;
  12051. /**
  12052. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12053. */
  12054. beginAnimationLoop: boolean;
  12055. /**
  12056. * Gets or sets a world offset applied to all particles
  12057. */
  12058. worldOffset: Vector3;
  12059. /**
  12060. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12061. */
  12062. get isAnimationSheetEnabled(): boolean;
  12063. set isAnimationSheetEnabled(value: boolean);
  12064. /**
  12065. * Get hosting scene
  12066. * @returns the scene
  12067. */
  12068. getScene(): Scene;
  12069. /**
  12070. * You can use gravity if you want to give an orientation to your particles.
  12071. */
  12072. gravity: Vector3;
  12073. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12074. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12075. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12076. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12077. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12078. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12079. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12080. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12081. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12082. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12083. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12084. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12085. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12086. /**
  12087. * Defines the delay in milliseconds before starting the system (0 by default)
  12088. */
  12089. startDelay: number;
  12090. /**
  12091. * Gets the current list of drag gradients.
  12092. * You must use addDragGradient and removeDragGradient to udpate this list
  12093. * @returns the list of drag gradients
  12094. */
  12095. getDragGradients(): Nullable<Array<FactorGradient>>;
  12096. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12097. limitVelocityDamping: number;
  12098. /**
  12099. * Gets the current list of limit velocity gradients.
  12100. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12101. * @returns the list of limit velocity gradients
  12102. */
  12103. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12104. /**
  12105. * Gets the current list of color gradients.
  12106. * You must use addColorGradient and removeColorGradient to udpate this list
  12107. * @returns the list of color gradients
  12108. */
  12109. getColorGradients(): Nullable<Array<ColorGradient>>;
  12110. /**
  12111. * Gets the current list of size gradients.
  12112. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12113. * @returns the list of size gradients
  12114. */
  12115. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12116. /**
  12117. * Gets the current list of color remap gradients.
  12118. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12119. * @returns the list of color remap gradients
  12120. */
  12121. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12122. /**
  12123. * Gets the current list of alpha remap gradients.
  12124. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12125. * @returns the list of alpha remap gradients
  12126. */
  12127. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12128. /**
  12129. * Gets the current list of life time gradients.
  12130. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12131. * @returns the list of life time gradients
  12132. */
  12133. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of angular speed gradients.
  12136. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12137. * @returns the list of angular speed gradients
  12138. */
  12139. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12140. /**
  12141. * Gets the current list of velocity gradients.
  12142. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12143. * @returns the list of velocity gradients
  12144. */
  12145. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of start size gradients.
  12148. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12149. * @returns the list of start size gradients
  12150. */
  12151. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of emit rate gradients.
  12154. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12155. * @returns the list of emit rate gradients
  12156. */
  12157. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12160. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12161. */
  12162. get direction1(): Vector3;
  12163. set direction1(value: Vector3);
  12164. /**
  12165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12167. */
  12168. get direction2(): Vector3;
  12169. set direction2(value: Vector3);
  12170. /**
  12171. * 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.
  12172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12173. */
  12174. get minEmitBox(): Vector3;
  12175. set minEmitBox(value: Vector3);
  12176. /**
  12177. * 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.
  12178. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12179. */
  12180. get maxEmitBox(): Vector3;
  12181. set maxEmitBox(value: Vector3);
  12182. /**
  12183. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12184. */
  12185. color1: Color4;
  12186. /**
  12187. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12188. */
  12189. color2: Color4;
  12190. /**
  12191. * Color the particle will have at the end of its lifetime
  12192. */
  12193. colorDead: Color4;
  12194. /**
  12195. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12196. */
  12197. textureMask: Color4;
  12198. /**
  12199. * The particle emitter type defines the emitter used by the particle system.
  12200. * It can be for example box, sphere, or cone...
  12201. */
  12202. particleEmitterType: IParticleEmitterType;
  12203. /** @hidden */
  12204. _isSubEmitter: boolean;
  12205. /**
  12206. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12207. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12208. */
  12209. billboardMode: number;
  12210. protected _isBillboardBased: boolean;
  12211. /**
  12212. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12213. */
  12214. get isBillboardBased(): boolean;
  12215. set isBillboardBased(value: boolean);
  12216. /**
  12217. * The scene the particle system belongs to.
  12218. */
  12219. protected _scene: Scene;
  12220. /**
  12221. * Local cache of defines for image processing.
  12222. */
  12223. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12224. /**
  12225. * Default configuration related to image processing available in the standard Material.
  12226. */
  12227. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12228. /**
  12229. * Gets the image processing configuration used either in this material.
  12230. */
  12231. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12232. /**
  12233. * Sets the Default image processing configuration used either in the this material.
  12234. *
  12235. * If sets to null, the scene one is in use.
  12236. */
  12237. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12238. /**
  12239. * Attaches a new image processing configuration to the Standard Material.
  12240. * @param configuration
  12241. */
  12242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12243. /** @hidden */
  12244. protected _reset(): void;
  12245. /** @hidden */
  12246. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12247. /**
  12248. * Instantiates a particle system.
  12249. * 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.
  12250. * @param name The name of the particle system
  12251. */
  12252. constructor(name: string);
  12253. /**
  12254. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12257. * @returns the emitter
  12258. */
  12259. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12260. /**
  12261. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12262. * @param radius The radius of the hemisphere to emit from
  12263. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12264. * @returns the emitter
  12265. */
  12266. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12267. /**
  12268. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12269. * @param radius The radius of the sphere to emit from
  12270. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12271. * @returns the emitter
  12272. */
  12273. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12274. /**
  12275. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12276. * @param radius The radius of the sphere to emit from
  12277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12279. * @returns the emitter
  12280. */
  12281. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12282. /**
  12283. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12284. * @param radius The radius of the emission cylinder
  12285. * @param height The height of the emission cylinder
  12286. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12287. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12288. * @returns the emitter
  12289. */
  12290. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12291. /**
  12292. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12293. * @param radius The radius of the cylinder to emit from
  12294. * @param height The height of the emission cylinder
  12295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12298. * @returns the emitter
  12299. */
  12300. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12301. /**
  12302. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12303. * @param radius The radius of the cone to emit from
  12304. * @param angle The base angle of the cone
  12305. * @returns the emitter
  12306. */
  12307. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12308. /**
  12309. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12312. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12313. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12314. * @returns the emitter
  12315. */
  12316. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Type of sub emitter
  12322. */
  12323. export enum SubEmitterType {
  12324. /**
  12325. * Attached to the particle over it's lifetime
  12326. */
  12327. ATTACHED = 0,
  12328. /**
  12329. * Created when the particle dies
  12330. */
  12331. END = 1
  12332. }
  12333. /**
  12334. * Sub emitter class used to emit particles from an existing particle
  12335. */
  12336. export class SubEmitter {
  12337. /**
  12338. * the particle system to be used by the sub emitter
  12339. */
  12340. particleSystem: ParticleSystem;
  12341. /**
  12342. * Type of the submitter (Default: END)
  12343. */
  12344. type: SubEmitterType;
  12345. /**
  12346. * 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)
  12347. * Note: This only is supported when using an emitter of type Mesh
  12348. */
  12349. inheritDirection: boolean;
  12350. /**
  12351. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12352. */
  12353. inheritedVelocityAmount: number;
  12354. /**
  12355. * Creates a sub emitter
  12356. * @param particleSystem the particle system to be used by the sub emitter
  12357. */
  12358. constructor(
  12359. /**
  12360. * the particle system to be used by the sub emitter
  12361. */
  12362. particleSystem: ParticleSystem);
  12363. /**
  12364. * Clones the sub emitter
  12365. * @returns the cloned sub emitter
  12366. */
  12367. clone(): SubEmitter;
  12368. /**
  12369. * Serialize current object to a JSON object
  12370. * @returns the serialized object
  12371. */
  12372. serialize(): any;
  12373. /** @hidden */
  12374. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12375. /**
  12376. * Creates a new SubEmitter from a serialized JSON version
  12377. * @param serializationObject defines the JSON object to read from
  12378. * @param scene defines the hosting scene
  12379. * @param rootUrl defines the rootUrl for data loading
  12380. * @returns a new SubEmitter
  12381. */
  12382. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12383. /** Release associated resources */
  12384. dispose(): void;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /** @hidden */
  12389. export var imageProcessingDeclaration: {
  12390. name: string;
  12391. shader: string;
  12392. };
  12393. }
  12394. declare module BABYLON {
  12395. /** @hidden */
  12396. export var imageProcessingFunctions: {
  12397. name: string;
  12398. shader: string;
  12399. };
  12400. }
  12401. declare module BABYLON {
  12402. /** @hidden */
  12403. export var particlesPixelShader: {
  12404. name: string;
  12405. shader: string;
  12406. };
  12407. }
  12408. declare module BABYLON {
  12409. /** @hidden */
  12410. export var particlesVertexShader: {
  12411. name: string;
  12412. shader: string;
  12413. };
  12414. }
  12415. declare module BABYLON {
  12416. /**
  12417. * This represents a particle system in Babylon.
  12418. * 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.
  12419. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12420. * @example https://doc.babylonjs.com/babylon101/particles
  12421. */
  12422. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12423. /**
  12424. * Billboard mode will only apply to Y axis
  12425. */
  12426. static readonly BILLBOARDMODE_Y: number;
  12427. /**
  12428. * Billboard mode will apply to all axes
  12429. */
  12430. static readonly BILLBOARDMODE_ALL: number;
  12431. /**
  12432. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12433. */
  12434. static readonly BILLBOARDMODE_STRETCHED: number;
  12435. /**
  12436. * This function can be defined to provide custom update for active particles.
  12437. * This function will be called instead of regular update (age, position, color, etc.).
  12438. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12439. */
  12440. updateFunction: (particles: Particle[]) => void;
  12441. private _emitterWorldMatrix;
  12442. /**
  12443. * This function can be defined to specify initial direction for every new particle.
  12444. * It by default use the emitterType defined function
  12445. */
  12446. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12447. /**
  12448. * This function can be defined to specify initial position for every new particle.
  12449. * It by default use the emitterType defined function
  12450. */
  12451. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12452. /**
  12453. * @hidden
  12454. */
  12455. _inheritedVelocityOffset: Vector3;
  12456. /**
  12457. * An event triggered when the system is disposed
  12458. */
  12459. onDisposeObservable: Observable<IParticleSystem>;
  12460. private _onDisposeObserver;
  12461. /**
  12462. * Sets a callback that will be triggered when the system is disposed
  12463. */
  12464. set onDispose(callback: () => void);
  12465. private _particles;
  12466. private _epsilon;
  12467. private _capacity;
  12468. private _stockParticles;
  12469. private _newPartsExcess;
  12470. private _vertexData;
  12471. private _vertexBuffer;
  12472. private _vertexBuffers;
  12473. private _spriteBuffer;
  12474. private _indexBuffer;
  12475. private _effect;
  12476. private _customEffect;
  12477. private _cachedDefines;
  12478. private _scaledColorStep;
  12479. private _colorDiff;
  12480. private _scaledDirection;
  12481. private _scaledGravity;
  12482. private _currentRenderId;
  12483. private _alive;
  12484. private _useInstancing;
  12485. private _started;
  12486. private _stopped;
  12487. private _actualFrame;
  12488. private _scaledUpdateSpeed;
  12489. private _vertexBufferSize;
  12490. /** @hidden */
  12491. _currentEmitRateGradient: Nullable<FactorGradient>;
  12492. /** @hidden */
  12493. _currentEmitRate1: number;
  12494. /** @hidden */
  12495. _currentEmitRate2: number;
  12496. /** @hidden */
  12497. _currentStartSizeGradient: Nullable<FactorGradient>;
  12498. /** @hidden */
  12499. _currentStartSize1: number;
  12500. /** @hidden */
  12501. _currentStartSize2: number;
  12502. private readonly _rawTextureWidth;
  12503. private _rampGradientsTexture;
  12504. private _useRampGradients;
  12505. /** Gets or sets a boolean indicating that ramp gradients must be used
  12506. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12507. */
  12508. get useRampGradients(): boolean;
  12509. set useRampGradients(value: boolean);
  12510. /**
  12511. * 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.
  12512. * 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: [])
  12513. */
  12514. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12515. private _subEmitters;
  12516. /**
  12517. * @hidden
  12518. * If the particle systems emitter should be disposed when the particle system is disposed
  12519. */
  12520. _disposeEmitterOnDispose: boolean;
  12521. /**
  12522. * The current active Sub-systems, this property is used by the root particle system only.
  12523. */
  12524. activeSubSystems: Array<ParticleSystem>;
  12525. /**
  12526. * Specifies if the particles are updated in emitter local space or world space
  12527. */
  12528. isLocal: boolean;
  12529. private _rootParticleSystem;
  12530. /**
  12531. * Gets the current list of active particles
  12532. */
  12533. get particles(): Particle[];
  12534. /**
  12535. * Gets the number of particles active at the same time.
  12536. * @returns The number of active particles.
  12537. */
  12538. getActiveCount(): number;
  12539. /**
  12540. * Returns the string "ParticleSystem"
  12541. * @returns a string containing the class name
  12542. */
  12543. getClassName(): string;
  12544. /**
  12545. * Gets a boolean indicating that the system is stopping
  12546. * @returns true if the system is currently stopping
  12547. */
  12548. isStopping(): boolean;
  12549. /**
  12550. * Gets the custom effect used to render the particles
  12551. * @param blendMode Blend mode for which the effect should be retrieved
  12552. * @returns The effect
  12553. */
  12554. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12555. /**
  12556. * Sets the custom effect used to render the particles
  12557. * @param effect The effect to set
  12558. * @param blendMode Blend mode for which the effect should be set
  12559. */
  12560. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12561. /** @hidden */
  12562. private _onBeforeDrawParticlesObservable;
  12563. /**
  12564. * Observable that will be called just before the particles are drawn
  12565. */
  12566. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12567. /**
  12568. * Gets the name of the particle vertex shader
  12569. */
  12570. get vertexShaderName(): string;
  12571. /**
  12572. * Instantiates a particle system.
  12573. * 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.
  12574. * @param name The name of the particle system
  12575. * @param capacity The max number of particles alive at the same time
  12576. * @param scene The scene the particle system belongs to
  12577. * @param customEffect a custom effect used to change the way particles are rendered by default
  12578. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12579. * @param epsilon Offset used to render the particles
  12580. */
  12581. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12582. private _addFactorGradient;
  12583. private _removeFactorGradient;
  12584. /**
  12585. * Adds a new life time gradient
  12586. * @param gradient defines the gradient to use (between 0 and 1)
  12587. * @param factor defines the life time factor to affect to the specified gradient
  12588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12589. * @returns the current particle system
  12590. */
  12591. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12592. /**
  12593. * Remove a specific life time gradient
  12594. * @param gradient defines the gradient to remove
  12595. * @returns the current particle system
  12596. */
  12597. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12598. /**
  12599. * Adds a new size gradient
  12600. * @param gradient defines the gradient to use (between 0 and 1)
  12601. * @param factor defines the size factor to affect to the specified gradient
  12602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12603. * @returns the current particle system
  12604. */
  12605. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12606. /**
  12607. * Remove a specific size gradient
  12608. * @param gradient defines the gradient to remove
  12609. * @returns the current particle system
  12610. */
  12611. removeSizeGradient(gradient: number): IParticleSystem;
  12612. /**
  12613. * Adds a new color remap gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param min defines the color remap minimal range
  12616. * @param max defines the color remap maximal range
  12617. * @returns the current particle system
  12618. */
  12619. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific color remap gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeColorRemapGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new alpha remap gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param min defines the alpha remap minimal range
  12630. * @param max defines the alpha remap maximal range
  12631. * @returns the current particle system
  12632. */
  12633. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific alpha remap gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new angular speed gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param factor defines the angular speed to affect to the specified gradient
  12644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12645. * @returns the current particle system
  12646. */
  12647. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific angular speed gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new velocity gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param factor defines the velocity to affect to the specified gradient
  12658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12659. * @returns the current particle system
  12660. */
  12661. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific velocity gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeVelocityGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new limit velocity gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the limit velocity value to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific limit velocity gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new drag gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the drag value to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific drag gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeDragGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the emit rate value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific emit rate gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeEmitRateGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the start size value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific start size gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeStartSizeGradient(gradient: number): IParticleSystem;
  12724. private _createRampGradientTexture;
  12725. /**
  12726. * Gets the current list of ramp gradients.
  12727. * You must use addRampGradient and removeRampGradient to udpate this list
  12728. * @returns the list of ramp gradients
  12729. */
  12730. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12731. /** Force the system to rebuild all gradients that need to be resync */
  12732. forceRefreshGradients(): void;
  12733. private _syncRampGradientTexture;
  12734. /**
  12735. * Adds a new ramp gradient used to remap particle colors
  12736. * @param gradient defines the gradient to use (between 0 and 1)
  12737. * @param color defines the color to affect to the specified gradient
  12738. * @returns the current particle system
  12739. */
  12740. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12741. /**
  12742. * Remove a specific ramp gradient
  12743. * @param gradient defines the gradient to remove
  12744. * @returns the current particle system
  12745. */
  12746. removeRampGradient(gradient: number): ParticleSystem;
  12747. /**
  12748. * Adds a new color gradient
  12749. * @param gradient defines the gradient to use (between 0 and 1)
  12750. * @param color1 defines the color to affect to the specified gradient
  12751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12752. * @returns this particle system
  12753. */
  12754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12755. /**
  12756. * Remove a specific color gradient
  12757. * @param gradient defines the gradient to remove
  12758. * @returns this particle system
  12759. */
  12760. removeColorGradient(gradient: number): IParticleSystem;
  12761. private _fetchR;
  12762. protected _reset(): void;
  12763. private _resetEffect;
  12764. private _createVertexBuffers;
  12765. private _createIndexBuffer;
  12766. /**
  12767. * Gets the maximum number of particles active at the same time.
  12768. * @returns The max number of active particles.
  12769. */
  12770. getCapacity(): number;
  12771. /**
  12772. * Gets whether there are still active particles in the system.
  12773. * @returns True if it is alive, otherwise false.
  12774. */
  12775. isAlive(): boolean;
  12776. /**
  12777. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12778. * @returns True if it has been started, otherwise false.
  12779. */
  12780. isStarted(): boolean;
  12781. private _prepareSubEmitterInternalArray;
  12782. /**
  12783. * Starts the particle system and begins to emit
  12784. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12785. */
  12786. start(delay?: number): void;
  12787. /**
  12788. * Stops the particle system.
  12789. * @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.
  12790. */
  12791. stop(stopSubEmitters?: boolean): void;
  12792. /**
  12793. * Remove all active particles
  12794. */
  12795. reset(): void;
  12796. /**
  12797. * @hidden (for internal use only)
  12798. */
  12799. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12800. /**
  12801. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12802. * Its lifetime will start back at 0.
  12803. */
  12804. recycleParticle: (particle: Particle) => void;
  12805. private _stopSubEmitters;
  12806. private _createParticle;
  12807. private _removeFromRoot;
  12808. private _emitFromParticle;
  12809. private _update;
  12810. /** @hidden */
  12811. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12812. /** @hidden */
  12813. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12814. /**
  12815. * Fill the defines array according to the current settings of the particle system
  12816. * @param defines Array to be updated
  12817. * @param blendMode blend mode to take into account when updating the array
  12818. */
  12819. fillDefines(defines: Array<string>, blendMode: number): void;
  12820. /**
  12821. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12822. * @param uniforms Uniforms array to fill
  12823. * @param attributes Attributes array to fill
  12824. * @param samplers Samplers array to fill
  12825. */
  12826. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12827. /** @hidden */
  12828. private _getEffect;
  12829. /**
  12830. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12831. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12832. */
  12833. animate(preWarmOnly?: boolean): void;
  12834. private _appendParticleVertices;
  12835. /**
  12836. * Rebuilds the particle system.
  12837. */
  12838. rebuild(): void;
  12839. /**
  12840. * Is this system ready to be used/rendered
  12841. * @return true if the system is ready
  12842. */
  12843. isReady(): boolean;
  12844. private _render;
  12845. /**
  12846. * Renders the particle system in its current state.
  12847. * @returns the current number of particles
  12848. */
  12849. render(): number;
  12850. /**
  12851. * Disposes the particle system and free the associated resources
  12852. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12853. */
  12854. dispose(disposeTexture?: boolean): void;
  12855. /**
  12856. * Clones the particle system.
  12857. * @param name The name of the cloned object
  12858. * @param newEmitter The new emitter to use
  12859. * @returns the cloned particle system
  12860. */
  12861. clone(name: string, newEmitter: any): ParticleSystem;
  12862. /**
  12863. * Serializes the particle system to a JSON object
  12864. * @param serializeTexture defines if the texture must be serialized as well
  12865. * @returns the JSON object
  12866. */
  12867. serialize(serializeTexture?: boolean): any;
  12868. /** @hidden */
  12869. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12870. /** @hidden */
  12871. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12872. /**
  12873. * Parses a JSON object to create a particle system.
  12874. * @param parsedParticleSystem The JSON object to parse
  12875. * @param scene The scene to create the particle system in
  12876. * @param rootUrl The root url to use to load external dependencies like texture
  12877. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12878. * @returns the Parsed particle system
  12879. */
  12880. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12881. }
  12882. }
  12883. declare module BABYLON {
  12884. /**
  12885. * A particle represents one of the element emitted by a particle system.
  12886. * This is mainly define by its coordinates, direction, velocity and age.
  12887. */
  12888. export class Particle {
  12889. /**
  12890. * The particle system the particle belongs to.
  12891. */
  12892. particleSystem: ParticleSystem;
  12893. private static _Count;
  12894. /**
  12895. * Unique ID of the particle
  12896. */
  12897. id: number;
  12898. /**
  12899. * The world position of the particle in the scene.
  12900. */
  12901. position: Vector3;
  12902. /**
  12903. * The world direction of the particle in the scene.
  12904. */
  12905. direction: Vector3;
  12906. /**
  12907. * The color of the particle.
  12908. */
  12909. color: Color4;
  12910. /**
  12911. * The color change of the particle per step.
  12912. */
  12913. colorStep: Color4;
  12914. /**
  12915. * Defines how long will the life of the particle be.
  12916. */
  12917. lifeTime: number;
  12918. /**
  12919. * The current age of the particle.
  12920. */
  12921. age: number;
  12922. /**
  12923. * The current size of the particle.
  12924. */
  12925. size: number;
  12926. /**
  12927. * The current scale of the particle.
  12928. */
  12929. scale: Vector2;
  12930. /**
  12931. * The current angle of the particle.
  12932. */
  12933. angle: number;
  12934. /**
  12935. * Defines how fast is the angle changing.
  12936. */
  12937. angularSpeed: number;
  12938. /**
  12939. * Defines the cell index used by the particle to be rendered from a sprite.
  12940. */
  12941. cellIndex: number;
  12942. /**
  12943. * The information required to support color remapping
  12944. */
  12945. remapData: Vector4;
  12946. /** @hidden */
  12947. _randomCellOffset?: number;
  12948. /** @hidden */
  12949. _initialDirection: Nullable<Vector3>;
  12950. /** @hidden */
  12951. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12952. /** @hidden */
  12953. _initialStartSpriteCellID: number;
  12954. /** @hidden */
  12955. _initialEndSpriteCellID: number;
  12956. /** @hidden */
  12957. _currentColorGradient: Nullable<ColorGradient>;
  12958. /** @hidden */
  12959. _currentColor1: Color4;
  12960. /** @hidden */
  12961. _currentColor2: Color4;
  12962. /** @hidden */
  12963. _currentSizeGradient: Nullable<FactorGradient>;
  12964. /** @hidden */
  12965. _currentSize1: number;
  12966. /** @hidden */
  12967. _currentSize2: number;
  12968. /** @hidden */
  12969. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12970. /** @hidden */
  12971. _currentAngularSpeed1: number;
  12972. /** @hidden */
  12973. _currentAngularSpeed2: number;
  12974. /** @hidden */
  12975. _currentVelocityGradient: Nullable<FactorGradient>;
  12976. /** @hidden */
  12977. _currentVelocity1: number;
  12978. /** @hidden */
  12979. _currentVelocity2: number;
  12980. /** @hidden */
  12981. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12982. /** @hidden */
  12983. _currentLimitVelocity1: number;
  12984. /** @hidden */
  12985. _currentLimitVelocity2: number;
  12986. /** @hidden */
  12987. _currentDragGradient: Nullable<FactorGradient>;
  12988. /** @hidden */
  12989. _currentDrag1: number;
  12990. /** @hidden */
  12991. _currentDrag2: number;
  12992. /** @hidden */
  12993. _randomNoiseCoordinates1: Vector3;
  12994. /** @hidden */
  12995. _randomNoiseCoordinates2: Vector3;
  12996. /** @hidden */
  12997. _localPosition?: Vector3;
  12998. /**
  12999. * Creates a new instance Particle
  13000. * @param particleSystem the particle system the particle belongs to
  13001. */
  13002. constructor(
  13003. /**
  13004. * The particle system the particle belongs to.
  13005. */
  13006. particleSystem: ParticleSystem);
  13007. private updateCellInfoFromSystem;
  13008. /**
  13009. * Defines how the sprite cell index is updated for the particle
  13010. */
  13011. updateCellIndex(): void;
  13012. /** @hidden */
  13013. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13014. /** @hidden */
  13015. _inheritParticleInfoToSubEmitters(): void;
  13016. /** @hidden */
  13017. _reset(): void;
  13018. /**
  13019. * Copy the properties of particle to another one.
  13020. * @param other the particle to copy the information to.
  13021. */
  13022. copyTo(other: Particle): void;
  13023. }
  13024. }
  13025. declare module BABYLON {
  13026. /**
  13027. * Particle emitter represents a volume emitting particles.
  13028. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13029. */
  13030. export interface IParticleEmitterType {
  13031. /**
  13032. * Called by the particle System when the direction is computed for the created particle.
  13033. * @param worldMatrix is the world matrix of the particle system
  13034. * @param directionToUpdate is the direction vector to update with the result
  13035. * @param particle is the particle we are computed the direction for
  13036. * @param isLocal defines if the direction should be set in local space
  13037. */
  13038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13039. /**
  13040. * Called by the particle System when the position is computed for the created particle.
  13041. * @param worldMatrix is the world matrix of the particle system
  13042. * @param positionToUpdate is the position vector to update with the result
  13043. * @param particle is the particle we are computed the position for
  13044. * @param isLocal defines if the position should be set in local space
  13045. */
  13046. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13047. /**
  13048. * Clones the current emitter and returns a copy of it
  13049. * @returns the new emitter
  13050. */
  13051. clone(): IParticleEmitterType;
  13052. /**
  13053. * Called by the GPUParticleSystem to setup the update shader
  13054. * @param effect defines the update shader
  13055. */
  13056. applyToShader(effect: Effect): void;
  13057. /**
  13058. * Returns a string to use to update the GPU particles update shader
  13059. * @returns the effect defines string
  13060. */
  13061. getEffectDefines(): string;
  13062. /**
  13063. * Returns a string representing the class name
  13064. * @returns a string containing the class name
  13065. */
  13066. getClassName(): string;
  13067. /**
  13068. * Serializes the particle system to a JSON object.
  13069. * @returns the JSON object
  13070. */
  13071. serialize(): any;
  13072. /**
  13073. * Parse properties from a JSON object
  13074. * @param serializationObject defines the JSON object
  13075. * @param scene defines the hosting scene
  13076. */
  13077. parse(serializationObject: any, scene: Scene): void;
  13078. }
  13079. }
  13080. declare module BABYLON {
  13081. /**
  13082. * Particle emitter emitting particles from the inside of a box.
  13083. * It emits the particles randomly between 2 given directions.
  13084. */
  13085. export class BoxParticleEmitter implements IParticleEmitterType {
  13086. /**
  13087. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13088. */
  13089. direction1: Vector3;
  13090. /**
  13091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13092. */
  13093. direction2: Vector3;
  13094. /**
  13095. * 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.
  13096. */
  13097. minEmitBox: Vector3;
  13098. /**
  13099. * 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.
  13100. */
  13101. maxEmitBox: Vector3;
  13102. /**
  13103. * Creates a new instance BoxParticleEmitter
  13104. */
  13105. constructor();
  13106. /**
  13107. * Called by the particle System when the direction is computed for the created particle.
  13108. * @param worldMatrix is the world matrix of the particle system
  13109. * @param directionToUpdate is the direction vector to update with the result
  13110. * @param particle is the particle we are computed the direction for
  13111. * @param isLocal defines if the direction should be set in local space
  13112. */
  13113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13114. /**
  13115. * Called by the particle System when the position is computed for the created particle.
  13116. * @param worldMatrix is the world matrix of the particle system
  13117. * @param positionToUpdate is the position vector to update with the result
  13118. * @param particle is the particle we are computed the position for
  13119. * @param isLocal defines if the position should be set in local space
  13120. */
  13121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13122. /**
  13123. * Clones the current emitter and returns a copy of it
  13124. * @returns the new emitter
  13125. */
  13126. clone(): BoxParticleEmitter;
  13127. /**
  13128. * Called by the GPUParticleSystem to setup the update shader
  13129. * @param effect defines the update shader
  13130. */
  13131. applyToShader(effect: Effect): void;
  13132. /**
  13133. * Returns a string to use to update the GPU particles update shader
  13134. * @returns a string containng the defines string
  13135. */
  13136. getEffectDefines(): string;
  13137. /**
  13138. * Returns the string "BoxParticleEmitter"
  13139. * @returns a string containing the class name
  13140. */
  13141. getClassName(): string;
  13142. /**
  13143. * Serializes the particle system to a JSON object.
  13144. * @returns the JSON object
  13145. */
  13146. serialize(): any;
  13147. /**
  13148. * Parse properties from a JSON object
  13149. * @param serializationObject defines the JSON object
  13150. */
  13151. parse(serializationObject: any): void;
  13152. }
  13153. }
  13154. declare module BABYLON {
  13155. /**
  13156. * Particle emitter emitting particles from the inside of a cone.
  13157. * It emits the particles alongside the cone volume from the base to the particle.
  13158. * The emission direction might be randomized.
  13159. */
  13160. export class ConeParticleEmitter implements IParticleEmitterType {
  13161. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13162. directionRandomizer: number;
  13163. private _radius;
  13164. private _angle;
  13165. private _height;
  13166. /**
  13167. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13168. */
  13169. radiusRange: number;
  13170. /**
  13171. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13172. */
  13173. heightRange: number;
  13174. /**
  13175. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13176. */
  13177. emitFromSpawnPointOnly: boolean;
  13178. /**
  13179. * Gets or sets the radius of the emission cone
  13180. */
  13181. get radius(): number;
  13182. set radius(value: number);
  13183. /**
  13184. * Gets or sets the angle of the emission cone
  13185. */
  13186. get angle(): number;
  13187. set angle(value: number);
  13188. private _buildHeight;
  13189. /**
  13190. * Creates a new instance ConeParticleEmitter
  13191. * @param radius the radius of the emission cone (1 by default)
  13192. * @param angle the cone base angle (PI by default)
  13193. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13194. */
  13195. constructor(radius?: number, angle?: number,
  13196. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13197. directionRandomizer?: number);
  13198. /**
  13199. * Called by the particle System when the direction is computed for the created particle.
  13200. * @param worldMatrix is the world matrix of the particle system
  13201. * @param directionToUpdate is the direction vector to update with the result
  13202. * @param particle is the particle we are computed the direction for
  13203. * @param isLocal defines if the direction should be set in local space
  13204. */
  13205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13206. /**
  13207. * Called by the particle System when the position is computed for the created particle.
  13208. * @param worldMatrix is the world matrix of the particle system
  13209. * @param positionToUpdate is the position vector to update with the result
  13210. * @param particle is the particle we are computed the position for
  13211. * @param isLocal defines if the position should be set in local space
  13212. */
  13213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13214. /**
  13215. * Clones the current emitter and returns a copy of it
  13216. * @returns the new emitter
  13217. */
  13218. clone(): ConeParticleEmitter;
  13219. /**
  13220. * Called by the GPUParticleSystem to setup the update shader
  13221. * @param effect defines the update shader
  13222. */
  13223. applyToShader(effect: Effect): void;
  13224. /**
  13225. * Returns a string to use to update the GPU particles update shader
  13226. * @returns a string containng the defines string
  13227. */
  13228. getEffectDefines(): string;
  13229. /**
  13230. * Returns the string "ConeParticleEmitter"
  13231. * @returns a string containing the class name
  13232. */
  13233. getClassName(): string;
  13234. /**
  13235. * Serializes the particle system to a JSON object.
  13236. * @returns the JSON object
  13237. */
  13238. serialize(): any;
  13239. /**
  13240. * Parse properties from a JSON object
  13241. * @param serializationObject defines the JSON object
  13242. */
  13243. parse(serializationObject: any): void;
  13244. }
  13245. }
  13246. declare module BABYLON {
  13247. /**
  13248. * Particle emitter emitting particles from the inside of a cylinder.
  13249. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13250. */
  13251. export class CylinderParticleEmitter implements IParticleEmitterType {
  13252. /**
  13253. * The radius of the emission cylinder.
  13254. */
  13255. radius: number;
  13256. /**
  13257. * The height of the emission cylinder.
  13258. */
  13259. height: number;
  13260. /**
  13261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13262. */
  13263. radiusRange: number;
  13264. /**
  13265. * How much to randomize the particle direction [0-1].
  13266. */
  13267. directionRandomizer: number;
  13268. /**
  13269. * Creates a new instance CylinderParticleEmitter
  13270. * @param radius the radius of the emission cylinder (1 by default)
  13271. * @param height the height of the emission cylinder (1 by default)
  13272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13273. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13274. */
  13275. constructor(
  13276. /**
  13277. * The radius of the emission cylinder.
  13278. */
  13279. radius?: number,
  13280. /**
  13281. * The height of the emission cylinder.
  13282. */
  13283. height?: number,
  13284. /**
  13285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13286. */
  13287. radiusRange?: number,
  13288. /**
  13289. * How much to randomize the particle direction [0-1].
  13290. */
  13291. directionRandomizer?: number);
  13292. /**
  13293. * Called by the particle System when the direction is computed for the created particle.
  13294. * @param worldMatrix is the world matrix of the particle system
  13295. * @param directionToUpdate is the direction vector to update with the result
  13296. * @param particle is the particle we are computed the direction for
  13297. * @param isLocal defines if the direction should be set in local space
  13298. */
  13299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13300. /**
  13301. * Called by the particle System when the position is computed for the created particle.
  13302. * @param worldMatrix is the world matrix of the particle system
  13303. * @param positionToUpdate is the position vector to update with the result
  13304. * @param particle is the particle we are computed the position for
  13305. * @param isLocal defines if the position should be set in local space
  13306. */
  13307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13308. /**
  13309. * Clones the current emitter and returns a copy of it
  13310. * @returns the new emitter
  13311. */
  13312. clone(): CylinderParticleEmitter;
  13313. /**
  13314. * Called by the GPUParticleSystem to setup the update shader
  13315. * @param effect defines the update shader
  13316. */
  13317. applyToShader(effect: Effect): void;
  13318. /**
  13319. * Returns a string to use to update the GPU particles update shader
  13320. * @returns a string containng the defines string
  13321. */
  13322. getEffectDefines(): string;
  13323. /**
  13324. * Returns the string "CylinderParticleEmitter"
  13325. * @returns a string containing the class name
  13326. */
  13327. getClassName(): string;
  13328. /**
  13329. * Serializes the particle system to a JSON object.
  13330. * @returns the JSON object
  13331. */
  13332. serialize(): any;
  13333. /**
  13334. * Parse properties from a JSON object
  13335. * @param serializationObject defines the JSON object
  13336. */
  13337. parse(serializationObject: any): void;
  13338. }
  13339. /**
  13340. * Particle emitter emitting particles from the inside of a cylinder.
  13341. * It emits the particles randomly between two vectors.
  13342. */
  13343. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13344. /**
  13345. * The min limit of the emission direction.
  13346. */
  13347. direction1: Vector3;
  13348. /**
  13349. * The max limit of the emission direction.
  13350. */
  13351. direction2: Vector3;
  13352. /**
  13353. * Creates a new instance CylinderDirectedParticleEmitter
  13354. * @param radius the radius of the emission cylinder (1 by default)
  13355. * @param height the height of the emission cylinder (1 by default)
  13356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13357. * @param direction1 the min limit of the emission direction (up vector by default)
  13358. * @param direction2 the max limit of the emission direction (up vector by default)
  13359. */
  13360. constructor(radius?: number, height?: number, radiusRange?: number,
  13361. /**
  13362. * The min limit of the emission direction.
  13363. */
  13364. direction1?: Vector3,
  13365. /**
  13366. * The max limit of the emission direction.
  13367. */
  13368. direction2?: Vector3);
  13369. /**
  13370. * Called by the particle System when the direction is computed for the created particle.
  13371. * @param worldMatrix is the world matrix of the particle system
  13372. * @param directionToUpdate is the direction vector to update with the result
  13373. * @param particle is the particle we are computed the direction for
  13374. */
  13375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13376. /**
  13377. * Clones the current emitter and returns a copy of it
  13378. * @returns the new emitter
  13379. */
  13380. clone(): CylinderDirectedParticleEmitter;
  13381. /**
  13382. * Called by the GPUParticleSystem to setup the update shader
  13383. * @param effect defines the update shader
  13384. */
  13385. applyToShader(effect: Effect): void;
  13386. /**
  13387. * Returns a string to use to update the GPU particles update shader
  13388. * @returns a string containng the defines string
  13389. */
  13390. getEffectDefines(): string;
  13391. /**
  13392. * Returns the string "CylinderDirectedParticleEmitter"
  13393. * @returns a string containing the class name
  13394. */
  13395. getClassName(): string;
  13396. /**
  13397. * Serializes the particle system to a JSON object.
  13398. * @returns the JSON object
  13399. */
  13400. serialize(): any;
  13401. /**
  13402. * Parse properties from a JSON object
  13403. * @param serializationObject defines the JSON object
  13404. */
  13405. parse(serializationObject: any): void;
  13406. }
  13407. }
  13408. declare module BABYLON {
  13409. /**
  13410. * Particle emitter emitting particles from the inside of a hemisphere.
  13411. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13412. */
  13413. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13414. /**
  13415. * The radius of the emission hemisphere.
  13416. */
  13417. radius: number;
  13418. /**
  13419. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13420. */
  13421. radiusRange: number;
  13422. /**
  13423. * How much to randomize the particle direction [0-1].
  13424. */
  13425. directionRandomizer: number;
  13426. /**
  13427. * Creates a new instance HemisphericParticleEmitter
  13428. * @param radius the radius of the emission hemisphere (1 by default)
  13429. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13430. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13431. */
  13432. constructor(
  13433. /**
  13434. * The radius of the emission hemisphere.
  13435. */
  13436. radius?: number,
  13437. /**
  13438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13439. */
  13440. radiusRange?: number,
  13441. /**
  13442. * How much to randomize the particle direction [0-1].
  13443. */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): HemisphericParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "HemisphericParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from a point.
  13496. * It emits the particles randomly between 2 given directions.
  13497. */
  13498. export class PointParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13501. */
  13502. direction1: Vector3;
  13503. /**
  13504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13505. */
  13506. direction2: Vector3;
  13507. /**
  13508. * Creates a new instance PointParticleEmitter
  13509. */
  13510. constructor();
  13511. /**
  13512. * Called by the particle System when the direction is computed for the created particle.
  13513. * @param worldMatrix is the world matrix of the particle system
  13514. * @param directionToUpdate is the direction vector to update with the result
  13515. * @param particle is the particle we are computed the direction for
  13516. * @param isLocal defines if the direction should be set in local space
  13517. */
  13518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13519. /**
  13520. * Called by the particle System when the position is computed for the created particle.
  13521. * @param worldMatrix is the world matrix of the particle system
  13522. * @param positionToUpdate is the position vector to update with the result
  13523. * @param particle is the particle we are computed the position for
  13524. * @param isLocal defines if the position should be set in local space
  13525. */
  13526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13527. /**
  13528. * Clones the current emitter and returns a copy of it
  13529. * @returns the new emitter
  13530. */
  13531. clone(): PointParticleEmitter;
  13532. /**
  13533. * Called by the GPUParticleSystem to setup the update shader
  13534. * @param effect defines the update shader
  13535. */
  13536. applyToShader(effect: Effect): void;
  13537. /**
  13538. * Returns a string to use to update the GPU particles update shader
  13539. * @returns a string containng the defines string
  13540. */
  13541. getEffectDefines(): string;
  13542. /**
  13543. * Returns the string "PointParticleEmitter"
  13544. * @returns a string containing the class name
  13545. */
  13546. getClassName(): string;
  13547. /**
  13548. * Serializes the particle system to a JSON object.
  13549. * @returns the JSON object
  13550. */
  13551. serialize(): any;
  13552. /**
  13553. * Parse properties from a JSON object
  13554. * @param serializationObject defines the JSON object
  13555. */
  13556. parse(serializationObject: any): void;
  13557. }
  13558. }
  13559. declare module BABYLON {
  13560. /**
  13561. * Particle emitter emitting particles from the inside of a sphere.
  13562. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13563. */
  13564. export class SphereParticleEmitter implements IParticleEmitterType {
  13565. /**
  13566. * The radius of the emission sphere.
  13567. */
  13568. radius: number;
  13569. /**
  13570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13571. */
  13572. radiusRange: number;
  13573. /**
  13574. * How much to randomize the particle direction [0-1].
  13575. */
  13576. directionRandomizer: number;
  13577. /**
  13578. * Creates a new instance SphereParticleEmitter
  13579. * @param radius the radius of the emission sphere (1 by default)
  13580. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13582. */
  13583. constructor(
  13584. /**
  13585. * The radius of the emission sphere.
  13586. */
  13587. radius?: number,
  13588. /**
  13589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13590. */
  13591. radiusRange?: number,
  13592. /**
  13593. * How much to randomize the particle direction [0-1].
  13594. */
  13595. directionRandomizer?: number);
  13596. /**
  13597. * Called by the particle System when the direction is computed for the created particle.
  13598. * @param worldMatrix is the world matrix of the particle system
  13599. * @param directionToUpdate is the direction vector to update with the result
  13600. * @param particle is the particle we are computed the direction for
  13601. * @param isLocal defines if the direction should be set in local space
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13604. /**
  13605. * Called by the particle System when the position is computed for the created particle.
  13606. * @param worldMatrix is the world matrix of the particle system
  13607. * @param positionToUpdate is the position vector to update with the result
  13608. * @param particle is the particle we are computed the position for
  13609. * @param isLocal defines if the position should be set in local space
  13610. */
  13611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13612. /**
  13613. * Clones the current emitter and returns a copy of it
  13614. * @returns the new emitter
  13615. */
  13616. clone(): SphereParticleEmitter;
  13617. /**
  13618. * Called by the GPUParticleSystem to setup the update shader
  13619. * @param effect defines the update shader
  13620. */
  13621. applyToShader(effect: Effect): void;
  13622. /**
  13623. * Returns a string to use to update the GPU particles update shader
  13624. * @returns a string containng the defines string
  13625. */
  13626. getEffectDefines(): string;
  13627. /**
  13628. * Returns the string "SphereParticleEmitter"
  13629. * @returns a string containing the class name
  13630. */
  13631. getClassName(): string;
  13632. /**
  13633. * Serializes the particle system to a JSON object.
  13634. * @returns the JSON object
  13635. */
  13636. serialize(): any;
  13637. /**
  13638. * Parse properties from a JSON object
  13639. * @param serializationObject defines the JSON object
  13640. */
  13641. parse(serializationObject: any): void;
  13642. }
  13643. /**
  13644. * Particle emitter emitting particles from the inside of a sphere.
  13645. * It emits the particles randomly between two vectors.
  13646. */
  13647. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13648. /**
  13649. * The min limit of the emission direction.
  13650. */
  13651. direction1: Vector3;
  13652. /**
  13653. * The max limit of the emission direction.
  13654. */
  13655. direction2: Vector3;
  13656. /**
  13657. * Creates a new instance SphereDirectedParticleEmitter
  13658. * @param radius the radius of the emission sphere (1 by default)
  13659. * @param direction1 the min limit of the emission direction (up vector by default)
  13660. * @param direction2 the max limit of the emission direction (up vector by default)
  13661. */
  13662. constructor(radius?: number,
  13663. /**
  13664. * The min limit of the emission direction.
  13665. */
  13666. direction1?: Vector3,
  13667. /**
  13668. * The max limit of the emission direction.
  13669. */
  13670. direction2?: Vector3);
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. */
  13677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13678. /**
  13679. * Clones the current emitter and returns a copy of it
  13680. * @returns the new emitter
  13681. */
  13682. clone(): SphereDirectedParticleEmitter;
  13683. /**
  13684. * Called by the GPUParticleSystem to setup the update shader
  13685. * @param effect defines the update shader
  13686. */
  13687. applyToShader(effect: Effect): void;
  13688. /**
  13689. * Returns a string to use to update the GPU particles update shader
  13690. * @returns a string containng the defines string
  13691. */
  13692. getEffectDefines(): string;
  13693. /**
  13694. * Returns the string "SphereDirectedParticleEmitter"
  13695. * @returns a string containing the class name
  13696. */
  13697. getClassName(): string;
  13698. /**
  13699. * Serializes the particle system to a JSON object.
  13700. * @returns the JSON object
  13701. */
  13702. serialize(): any;
  13703. /**
  13704. * Parse properties from a JSON object
  13705. * @param serializationObject defines the JSON object
  13706. */
  13707. parse(serializationObject: any): void;
  13708. }
  13709. }
  13710. declare module BABYLON {
  13711. /**
  13712. * Particle emitter emitting particles from a custom list of positions.
  13713. */
  13714. export class CustomParticleEmitter implements IParticleEmitterType {
  13715. /**
  13716. * Gets or sets the position generator that will create the inital position of each particle.
  13717. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13718. */
  13719. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13720. /**
  13721. * Gets or sets the destination generator that will create the final destination of each particle.
  13722. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13723. */
  13724. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13725. /**
  13726. * Creates a new instance CustomParticleEmitter
  13727. */
  13728. constructor();
  13729. /**
  13730. * Called by the particle System when the direction is computed for the created particle.
  13731. * @param worldMatrix is the world matrix of the particle system
  13732. * @param directionToUpdate is the direction vector to update with the result
  13733. * @param particle is the particle we are computed the direction for
  13734. * @param isLocal defines if the direction should be set in local space
  13735. */
  13736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13737. /**
  13738. * Called by the particle System when the position is computed for the created particle.
  13739. * @param worldMatrix is the world matrix of the particle system
  13740. * @param positionToUpdate is the position vector to update with the result
  13741. * @param particle is the particle we are computed the position for
  13742. * @param isLocal defines if the position should be set in local space
  13743. */
  13744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13745. /**
  13746. * Clones the current emitter and returns a copy of it
  13747. * @returns the new emitter
  13748. */
  13749. clone(): CustomParticleEmitter;
  13750. /**
  13751. * Called by the GPUParticleSystem to setup the update shader
  13752. * @param effect defines the update shader
  13753. */
  13754. applyToShader(effect: Effect): void;
  13755. /**
  13756. * Returns a string to use to update the GPU particles update shader
  13757. * @returns a string containng the defines string
  13758. */
  13759. getEffectDefines(): string;
  13760. /**
  13761. * Returns the string "PointParticleEmitter"
  13762. * @returns a string containing the class name
  13763. */
  13764. getClassName(): string;
  13765. /**
  13766. * Serializes the particle system to a JSON object.
  13767. * @returns the JSON object
  13768. */
  13769. serialize(): any;
  13770. /**
  13771. * Parse properties from a JSON object
  13772. * @param serializationObject defines the JSON object
  13773. */
  13774. parse(serializationObject: any): void;
  13775. }
  13776. }
  13777. declare module BABYLON {
  13778. /**
  13779. * Particle emitter emitting particles from the inside of a box.
  13780. * It emits the particles randomly between 2 given directions.
  13781. */
  13782. export class MeshParticleEmitter implements IParticleEmitterType {
  13783. private _indices;
  13784. private _positions;
  13785. private _normals;
  13786. private _storedNormal;
  13787. private _mesh;
  13788. /**
  13789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13790. */
  13791. direction1: Vector3;
  13792. /**
  13793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13794. */
  13795. direction2: Vector3;
  13796. /**
  13797. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13798. */
  13799. useMeshNormalsForDirection: boolean;
  13800. /** Defines the mesh to use as source */
  13801. get mesh(): Nullable<AbstractMesh>;
  13802. set mesh(value: Nullable<AbstractMesh>);
  13803. /**
  13804. * Creates a new instance MeshParticleEmitter
  13805. * @param mesh defines the mesh to use as source
  13806. */
  13807. constructor(mesh?: Nullable<AbstractMesh>);
  13808. /**
  13809. * Called by the particle System when the direction is computed for the created particle.
  13810. * @param worldMatrix is the world matrix of the particle system
  13811. * @param directionToUpdate is the direction vector to update with the result
  13812. * @param particle is the particle we are computed the direction for
  13813. * @param isLocal defines if the direction should be set in local space
  13814. */
  13815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13816. /**
  13817. * Called by the particle System when the position is computed for the created particle.
  13818. * @param worldMatrix is the world matrix of the particle system
  13819. * @param positionToUpdate is the position vector to update with the result
  13820. * @param particle is the particle we are computed the position for
  13821. * @param isLocal defines if the position should be set in local space
  13822. */
  13823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): MeshParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "BoxParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. * @param scene defines the hosting scene
  13853. */
  13854. parse(serializationObject: any, scene: Scene): void;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. /**
  13859. * Interface representing a particle system in Babylon.js.
  13860. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13861. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13862. */
  13863. export interface IParticleSystem {
  13864. /**
  13865. * List of animations used by the particle system.
  13866. */
  13867. animations: Animation[];
  13868. /**
  13869. * The id of the Particle system.
  13870. */
  13871. id: string;
  13872. /**
  13873. * The name of the Particle system.
  13874. */
  13875. name: string;
  13876. /**
  13877. * The emitter represents the Mesh or position we are attaching the particle system to.
  13878. */
  13879. emitter: Nullable<AbstractMesh | Vector3>;
  13880. /**
  13881. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13882. */
  13883. isBillboardBased: boolean;
  13884. /**
  13885. * The rendering group used by the Particle system to chose when to render.
  13886. */
  13887. renderingGroupId: number;
  13888. /**
  13889. * The layer mask we are rendering the particles through.
  13890. */
  13891. layerMask: number;
  13892. /**
  13893. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13894. */
  13895. updateSpeed: number;
  13896. /**
  13897. * The amount of time the particle system is running (depends of the overall update speed).
  13898. */
  13899. targetStopDuration: number;
  13900. /**
  13901. * The texture used to render each particle. (this can be a spritesheet)
  13902. */
  13903. particleTexture: Nullable<Texture>;
  13904. /**
  13905. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13906. */
  13907. blendMode: number;
  13908. /**
  13909. * Minimum life time of emitting particles.
  13910. */
  13911. minLifeTime: number;
  13912. /**
  13913. * Maximum life time of emitting particles.
  13914. */
  13915. maxLifeTime: number;
  13916. /**
  13917. * Minimum Size of emitting particles.
  13918. */
  13919. minSize: number;
  13920. /**
  13921. * Maximum Size of emitting particles.
  13922. */
  13923. maxSize: number;
  13924. /**
  13925. * Minimum scale of emitting particles on X axis.
  13926. */
  13927. minScaleX: number;
  13928. /**
  13929. * Maximum scale of emitting particles on X axis.
  13930. */
  13931. maxScaleX: number;
  13932. /**
  13933. * Minimum scale of emitting particles on Y axis.
  13934. */
  13935. minScaleY: number;
  13936. /**
  13937. * Maximum scale of emitting particles on Y axis.
  13938. */
  13939. maxScaleY: number;
  13940. /**
  13941. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13942. */
  13943. color1: Color4;
  13944. /**
  13945. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13946. */
  13947. color2: Color4;
  13948. /**
  13949. * Color the particle will have at the end of its lifetime.
  13950. */
  13951. colorDead: Color4;
  13952. /**
  13953. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13954. */
  13955. emitRate: number;
  13956. /**
  13957. * You can use gravity if you want to give an orientation to your particles.
  13958. */
  13959. gravity: Vector3;
  13960. /**
  13961. * Minimum power of emitting particles.
  13962. */
  13963. minEmitPower: number;
  13964. /**
  13965. * Maximum power of emitting particles.
  13966. */
  13967. maxEmitPower: number;
  13968. /**
  13969. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13970. */
  13971. minAngularSpeed: number;
  13972. /**
  13973. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13974. */
  13975. maxAngularSpeed: number;
  13976. /**
  13977. * Gets or sets the minimal initial rotation in radians.
  13978. */
  13979. minInitialRotation: number;
  13980. /**
  13981. * Gets or sets the maximal initial rotation in radians.
  13982. */
  13983. maxInitialRotation: number;
  13984. /**
  13985. * The particle emitter type defines the emitter used by the particle system.
  13986. * It can be for example box, sphere, or cone...
  13987. */
  13988. particleEmitterType: Nullable<IParticleEmitterType>;
  13989. /**
  13990. * Defines the delay in milliseconds before starting the system (0 by default)
  13991. */
  13992. startDelay: number;
  13993. /**
  13994. * 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
  13995. */
  13996. preWarmCycles: number;
  13997. /**
  13998. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13999. */
  14000. preWarmStepOffset: number;
  14001. /**
  14002. * 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)
  14003. */
  14004. spriteCellChangeSpeed: number;
  14005. /**
  14006. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14007. */
  14008. startSpriteCellID: number;
  14009. /**
  14010. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14011. */
  14012. endSpriteCellID: number;
  14013. /**
  14014. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14015. */
  14016. spriteCellWidth: number;
  14017. /**
  14018. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14019. */
  14020. spriteCellHeight: number;
  14021. /**
  14022. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14023. */
  14024. spriteRandomStartCell: boolean;
  14025. /**
  14026. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14027. */
  14028. isAnimationSheetEnabled: boolean;
  14029. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14030. translationPivot: Vector2;
  14031. /**
  14032. * Gets or sets a texture used to add random noise to particle positions
  14033. */
  14034. noiseTexture: Nullable<BaseTexture>;
  14035. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14036. noiseStrength: Vector3;
  14037. /**
  14038. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14039. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14040. */
  14041. billboardMode: number;
  14042. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14043. limitVelocityDamping: number;
  14044. /**
  14045. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14046. */
  14047. beginAnimationOnStart: boolean;
  14048. /**
  14049. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14050. */
  14051. beginAnimationFrom: number;
  14052. /**
  14053. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14054. */
  14055. beginAnimationTo: number;
  14056. /**
  14057. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14058. */
  14059. beginAnimationLoop: boolean;
  14060. /**
  14061. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14062. */
  14063. disposeOnStop: boolean;
  14064. /**
  14065. * Specifies if the particles are updated in emitter local space or world space
  14066. */
  14067. isLocal: boolean;
  14068. /** Snippet ID if the particle system was created from the snippet server */
  14069. snippetId: string;
  14070. /**
  14071. * Gets the maximum number of particles active at the same time.
  14072. * @returns The max number of active particles.
  14073. */
  14074. getCapacity(): number;
  14075. /**
  14076. * Gets the number of particles active at the same time.
  14077. * @returns The number of active particles.
  14078. */
  14079. getActiveCount(): number;
  14080. /**
  14081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14082. * @returns True if it has been started, otherwise false.
  14083. */
  14084. isStarted(): boolean;
  14085. /**
  14086. * Animates the particle system for this frame.
  14087. */
  14088. animate(): void;
  14089. /**
  14090. * Renders the particle system in its current state.
  14091. * @returns the current number of particles
  14092. */
  14093. render(): number;
  14094. /**
  14095. * Dispose the particle system and frees its associated resources.
  14096. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14097. */
  14098. dispose(disposeTexture?: boolean): void;
  14099. /**
  14100. * An event triggered when the system is disposed
  14101. */
  14102. onDisposeObservable: Observable<IParticleSystem>;
  14103. /**
  14104. * Clones the particle system.
  14105. * @param name The name of the cloned object
  14106. * @param newEmitter The new emitter to use
  14107. * @returns the cloned particle system
  14108. */
  14109. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14110. /**
  14111. * Serializes the particle system to a JSON object
  14112. * @param serializeTexture defines if the texture must be serialized as well
  14113. * @returns the JSON object
  14114. */
  14115. serialize(serializeTexture: boolean): any;
  14116. /**
  14117. * Rebuild the particle system
  14118. */
  14119. rebuild(): void;
  14120. /** Force the system to rebuild all gradients that need to be resync */
  14121. forceRefreshGradients(): void;
  14122. /**
  14123. * Starts the particle system and begins to emit
  14124. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14125. */
  14126. start(delay?: number): void;
  14127. /**
  14128. * Stops the particle system.
  14129. */
  14130. stop(): void;
  14131. /**
  14132. * Remove all active particles
  14133. */
  14134. reset(): void;
  14135. /**
  14136. * Gets a boolean indicating that the system is stopping
  14137. * @returns true if the system is currently stopping
  14138. */
  14139. isStopping(): boolean;
  14140. /**
  14141. * Is this system ready to be used/rendered
  14142. * @return true if the system is ready
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Returns the string "ParticleSystem"
  14147. * @returns a string containing the class name
  14148. */
  14149. getClassName(): string;
  14150. /**
  14151. * Gets the custom effect used to render the particles
  14152. * @param blendMode Blend mode for which the effect should be retrieved
  14153. * @returns The effect
  14154. */
  14155. getCustomEffect(blendMode: number): Nullable<Effect>;
  14156. /**
  14157. * Sets the custom effect used to render the particles
  14158. * @param effect The effect to set
  14159. * @param blendMode Blend mode for which the effect should be set
  14160. */
  14161. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14162. /**
  14163. * Fill the defines array according to the current settings of the particle system
  14164. * @param defines Array to be updated
  14165. * @param blendMode blend mode to take into account when updating the array
  14166. */
  14167. fillDefines(defines: Array<string>, blendMode: number): void;
  14168. /**
  14169. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14170. * @param uniforms Uniforms array to fill
  14171. * @param attributes Attributes array to fill
  14172. * @param samplers Samplers array to fill
  14173. */
  14174. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14175. /**
  14176. * Observable that will be called just before the particles are drawn
  14177. */
  14178. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14179. /**
  14180. * Gets the name of the particle vertex shader
  14181. */
  14182. vertexShaderName: string;
  14183. /**
  14184. * Adds a new color gradient
  14185. * @param gradient defines the gradient to use (between 0 and 1)
  14186. * @param color1 defines the color to affect to the specified gradient
  14187. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14188. * @returns the current particle system
  14189. */
  14190. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14191. /**
  14192. * Remove a specific color gradient
  14193. * @param gradient defines the gradient to remove
  14194. * @returns the current particle system
  14195. */
  14196. removeColorGradient(gradient: number): IParticleSystem;
  14197. /**
  14198. * Adds a new size gradient
  14199. * @param gradient defines the gradient to use (between 0 and 1)
  14200. * @param factor defines the size factor to affect to the specified gradient
  14201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14202. * @returns the current particle system
  14203. */
  14204. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14205. /**
  14206. * Remove a specific size gradient
  14207. * @param gradient defines the gradient to remove
  14208. * @returns the current particle system
  14209. */
  14210. removeSizeGradient(gradient: number): IParticleSystem;
  14211. /**
  14212. * Gets the current list of color gradients.
  14213. * You must use addColorGradient and removeColorGradient to udpate this list
  14214. * @returns the list of color gradients
  14215. */
  14216. getColorGradients(): Nullable<Array<ColorGradient>>;
  14217. /**
  14218. * Gets the current list of size gradients.
  14219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14220. * @returns the list of size gradients
  14221. */
  14222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14223. /**
  14224. * Gets the current list of angular speed gradients.
  14225. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14226. * @returns the list of angular speed gradients
  14227. */
  14228. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14229. /**
  14230. * Adds a new angular speed gradient
  14231. * @param gradient defines the gradient to use (between 0 and 1)
  14232. * @param factor defines the angular speed to affect to the specified gradient
  14233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14234. * @returns the current particle system
  14235. */
  14236. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14237. /**
  14238. * Remove a specific angular speed gradient
  14239. * @param gradient defines the gradient to remove
  14240. * @returns the current particle system
  14241. */
  14242. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14243. /**
  14244. * Gets the current list of velocity gradients.
  14245. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14246. * @returns the list of velocity gradients
  14247. */
  14248. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14249. /**
  14250. * Adds a new velocity gradient
  14251. * @param gradient defines the gradient to use (between 0 and 1)
  14252. * @param factor defines the velocity to affect to the specified gradient
  14253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14254. * @returns the current particle system
  14255. */
  14256. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14257. /**
  14258. * Remove a specific velocity gradient
  14259. * @param gradient defines the gradient to remove
  14260. * @returns the current particle system
  14261. */
  14262. removeVelocityGradient(gradient: number): IParticleSystem;
  14263. /**
  14264. * Gets the current list of limit velocity gradients.
  14265. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14266. * @returns the list of limit velocity gradients
  14267. */
  14268. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14269. /**
  14270. * Adds a new limit velocity gradient
  14271. * @param gradient defines the gradient to use (between 0 and 1)
  14272. * @param factor defines the limit velocity to affect to the specified gradient
  14273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14274. * @returns the current particle system
  14275. */
  14276. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14277. /**
  14278. * Remove a specific limit velocity gradient
  14279. * @param gradient defines the gradient to remove
  14280. * @returns the current particle system
  14281. */
  14282. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14283. /**
  14284. * Adds a new drag gradient
  14285. * @param gradient defines the gradient to use (between 0 and 1)
  14286. * @param factor defines the drag to affect to the specified gradient
  14287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14288. * @returns the current particle system
  14289. */
  14290. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14291. /**
  14292. * Remove a specific drag gradient
  14293. * @param gradient defines the gradient to remove
  14294. * @returns the current particle system
  14295. */
  14296. removeDragGradient(gradient: number): IParticleSystem;
  14297. /**
  14298. * Gets the current list of drag gradients.
  14299. * You must use addDragGradient and removeDragGradient to udpate this list
  14300. * @returns the list of drag gradients
  14301. */
  14302. getDragGradients(): Nullable<Array<FactorGradient>>;
  14303. /**
  14304. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14305. * @param gradient defines the gradient to use (between 0 and 1)
  14306. * @param factor defines the emit rate to affect to the specified gradient
  14307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14308. * @returns the current particle system
  14309. */
  14310. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14311. /**
  14312. * Remove a specific emit rate gradient
  14313. * @param gradient defines the gradient to remove
  14314. * @returns the current particle system
  14315. */
  14316. removeEmitRateGradient(gradient: number): IParticleSystem;
  14317. /**
  14318. * Gets the current list of emit rate gradients.
  14319. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14320. * @returns the list of emit rate gradients
  14321. */
  14322. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14323. /**
  14324. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14325. * @param gradient defines the gradient to use (between 0 and 1)
  14326. * @param factor defines the start size to affect to the specified gradient
  14327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14328. * @returns the current particle system
  14329. */
  14330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14331. /**
  14332. * Remove a specific start size gradient
  14333. * @param gradient defines the gradient to remove
  14334. * @returns the current particle system
  14335. */
  14336. removeStartSizeGradient(gradient: number): IParticleSystem;
  14337. /**
  14338. * Gets the current list of start size gradients.
  14339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14340. * @returns the list of start size gradients
  14341. */
  14342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Adds a new life time gradient
  14345. * @param gradient defines the gradient to use (between 0 and 1)
  14346. * @param factor defines the life time factor to affect to the specified gradient
  14347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14348. * @returns the current particle system
  14349. */
  14350. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14351. /**
  14352. * Remove a specific life time gradient
  14353. * @param gradient defines the gradient to remove
  14354. * @returns the current particle system
  14355. */
  14356. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14357. /**
  14358. * Gets the current list of life time gradients.
  14359. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14360. * @returns the list of life time gradients
  14361. */
  14362. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14363. /**
  14364. * Gets the current list of color gradients.
  14365. * You must use addColorGradient and removeColorGradient to udpate this list
  14366. * @returns the list of color gradients
  14367. */
  14368. getColorGradients(): Nullable<Array<ColorGradient>>;
  14369. /**
  14370. * Adds a new ramp gradient used to remap particle colors
  14371. * @param gradient defines the gradient to use (between 0 and 1)
  14372. * @param color defines the color to affect to the specified gradient
  14373. * @returns the current particle system
  14374. */
  14375. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14376. /**
  14377. * Gets the current list of ramp gradients.
  14378. * You must use addRampGradient and removeRampGradient to udpate this list
  14379. * @returns the list of ramp gradients
  14380. */
  14381. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14382. /** Gets or sets a boolean indicating that ramp gradients must be used
  14383. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14384. */
  14385. useRampGradients: boolean;
  14386. /**
  14387. * Adds a new color remap gradient
  14388. * @param gradient defines the gradient to use (between 0 and 1)
  14389. * @param min defines the color remap minimal range
  14390. * @param max defines the color remap maximal range
  14391. * @returns the current particle system
  14392. */
  14393. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14394. /**
  14395. * Gets the current list of color remap gradients.
  14396. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14397. * @returns the list of color remap gradients
  14398. */
  14399. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Adds a new alpha remap gradient
  14402. * @param gradient defines the gradient to use (between 0 and 1)
  14403. * @param min defines the alpha remap minimal range
  14404. * @param max defines the alpha remap maximal range
  14405. * @returns the current particle system
  14406. */
  14407. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14408. /**
  14409. * Gets the current list of alpha remap gradients.
  14410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14411. * @returns the list of alpha remap gradients
  14412. */
  14413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14414. /**
  14415. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14416. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14417. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14418. * @returns the emitter
  14419. */
  14420. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14421. /**
  14422. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14423. * @param radius The radius of the hemisphere to emit from
  14424. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14425. * @returns the emitter
  14426. */
  14427. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14428. /**
  14429. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14430. * @param radius The radius of the sphere to emit from
  14431. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14432. * @returns the emitter
  14433. */
  14434. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14435. /**
  14436. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14437. * @param radius The radius of the sphere to emit from
  14438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14440. * @returns the emitter
  14441. */
  14442. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14443. /**
  14444. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14445. * @param radius The radius of the emission cylinder
  14446. * @param height The height of the emission cylinder
  14447. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14448. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14449. * @returns the emitter
  14450. */
  14451. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14452. /**
  14453. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14454. * @param radius The radius of the cylinder to emit from
  14455. * @param height The height of the emission cylinder
  14456. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14459. * @returns the emitter
  14460. */
  14461. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14462. /**
  14463. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14464. * @param radius The radius of the cone to emit from
  14465. * @param angle The base angle of the cone
  14466. * @returns the emitter
  14467. */
  14468. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14469. /**
  14470. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14473. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14474. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14475. * @returns the emitter
  14476. */
  14477. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14478. /**
  14479. * Get hosting scene
  14480. * @returns the scene
  14481. */
  14482. getScene(): Scene;
  14483. }
  14484. }
  14485. declare module BABYLON {
  14486. /**
  14487. * 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.
  14488. * @see https://doc.babylonjs.com/how_to/transformnode
  14489. */
  14490. export class TransformNode extends Node {
  14491. /**
  14492. * Object will not rotate to face the camera
  14493. */
  14494. static BILLBOARDMODE_NONE: number;
  14495. /**
  14496. * Object will rotate to face the camera but only on the x axis
  14497. */
  14498. static BILLBOARDMODE_X: number;
  14499. /**
  14500. * Object will rotate to face the camera but only on the y axis
  14501. */
  14502. static BILLBOARDMODE_Y: number;
  14503. /**
  14504. * Object will rotate to face the camera but only on the z axis
  14505. */
  14506. static BILLBOARDMODE_Z: number;
  14507. /**
  14508. * Object will rotate to face the camera
  14509. */
  14510. static BILLBOARDMODE_ALL: number;
  14511. /**
  14512. * Object will rotate to face the camera's position instead of orientation
  14513. */
  14514. static BILLBOARDMODE_USE_POSITION: number;
  14515. private static _TmpRotation;
  14516. private static _TmpScaling;
  14517. private static _TmpTranslation;
  14518. private _forward;
  14519. private _forwardInverted;
  14520. private _up;
  14521. private _right;
  14522. private _rightInverted;
  14523. private _position;
  14524. private _rotation;
  14525. private _rotationQuaternion;
  14526. protected _scaling: Vector3;
  14527. protected _isDirty: boolean;
  14528. private _transformToBoneReferal;
  14529. private _isAbsoluteSynced;
  14530. private _billboardMode;
  14531. /**
  14532. * Gets or sets the billboard mode. Default is 0.
  14533. *
  14534. * | Value | Type | Description |
  14535. * | --- | --- | --- |
  14536. * | 0 | BILLBOARDMODE_NONE | |
  14537. * | 1 | BILLBOARDMODE_X | |
  14538. * | 2 | BILLBOARDMODE_Y | |
  14539. * | 4 | BILLBOARDMODE_Z | |
  14540. * | 7 | BILLBOARDMODE_ALL | |
  14541. *
  14542. */
  14543. get billboardMode(): number;
  14544. set billboardMode(value: number);
  14545. private _preserveParentRotationForBillboard;
  14546. /**
  14547. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14548. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14549. */
  14550. get preserveParentRotationForBillboard(): boolean;
  14551. set preserveParentRotationForBillboard(value: boolean);
  14552. /**
  14553. * 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
  14554. */
  14555. scalingDeterminant: number;
  14556. private _infiniteDistance;
  14557. /**
  14558. * Gets or sets the distance of the object to max, often used by skybox
  14559. */
  14560. get infiniteDistance(): boolean;
  14561. set infiniteDistance(value: boolean);
  14562. /**
  14563. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14564. * By default the system will update normals to compensate
  14565. */
  14566. ignoreNonUniformScaling: boolean;
  14567. /**
  14568. * 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
  14569. */
  14570. reIntegrateRotationIntoRotationQuaternion: boolean;
  14571. /** @hidden */
  14572. _poseMatrix: Nullable<Matrix>;
  14573. /** @hidden */
  14574. _localMatrix: Matrix;
  14575. private _usePivotMatrix;
  14576. private _absolutePosition;
  14577. private _absoluteScaling;
  14578. private _absoluteRotationQuaternion;
  14579. private _pivotMatrix;
  14580. private _pivotMatrixInverse;
  14581. protected _postMultiplyPivotMatrix: boolean;
  14582. protected _isWorldMatrixFrozen: boolean;
  14583. /** @hidden */
  14584. _indexInSceneTransformNodesArray: number;
  14585. /**
  14586. * An event triggered after the world matrix is updated
  14587. */
  14588. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14589. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14590. /**
  14591. * Gets a string identifying the name of the class
  14592. * @returns "TransformNode" string
  14593. */
  14594. getClassName(): string;
  14595. /**
  14596. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14597. */
  14598. get position(): Vector3;
  14599. set position(newPosition: Vector3);
  14600. /**
  14601. * 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)).
  14602. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14603. */
  14604. get rotation(): Vector3;
  14605. set rotation(newRotation: Vector3);
  14606. /**
  14607. * 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)).
  14608. */
  14609. get scaling(): Vector3;
  14610. set scaling(newScaling: Vector3);
  14611. /**
  14612. * 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).
  14613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14614. */
  14615. get rotationQuaternion(): Nullable<Quaternion>;
  14616. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14617. /**
  14618. * The forward direction of that transform in world space.
  14619. */
  14620. get forward(): Vector3;
  14621. /**
  14622. * The up direction of that transform in world space.
  14623. */
  14624. get up(): Vector3;
  14625. /**
  14626. * The right direction of that transform in world space.
  14627. */
  14628. get right(): Vector3;
  14629. /**
  14630. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14631. * @param matrix the matrix to copy the pose from
  14632. * @returns this TransformNode.
  14633. */
  14634. updatePoseMatrix(matrix: Matrix): TransformNode;
  14635. /**
  14636. * Returns the mesh Pose matrix.
  14637. * @returns the pose matrix
  14638. */
  14639. getPoseMatrix(): Matrix;
  14640. /** @hidden */
  14641. _isSynchronized(): boolean;
  14642. /** @hidden */
  14643. _initCache(): void;
  14644. /**
  14645. * Flag the transform node as dirty (Forcing it to update everything)
  14646. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14647. * @returns this transform node
  14648. */
  14649. markAsDirty(property: string): TransformNode;
  14650. /**
  14651. * Returns the current mesh absolute position.
  14652. * Returns a Vector3.
  14653. */
  14654. get absolutePosition(): Vector3;
  14655. /**
  14656. * Returns the current mesh absolute scaling.
  14657. * Returns a Vector3.
  14658. */
  14659. get absoluteScaling(): Vector3;
  14660. /**
  14661. * Returns the current mesh absolute rotation.
  14662. * Returns a Quaternion.
  14663. */
  14664. get absoluteRotationQuaternion(): Quaternion;
  14665. /**
  14666. * Sets a new matrix to apply before all other transformation
  14667. * @param matrix defines the transform matrix
  14668. * @returns the current TransformNode
  14669. */
  14670. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14671. /**
  14672. * Sets a new pivot matrix to the current node
  14673. * @param matrix defines the new pivot matrix to use
  14674. * @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
  14675. * @returns the current TransformNode
  14676. */
  14677. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14678. /**
  14679. * Returns the mesh pivot matrix.
  14680. * Default : Identity.
  14681. * @returns the matrix
  14682. */
  14683. getPivotMatrix(): Matrix;
  14684. /**
  14685. * Instantiate (when possible) or clone that node with its hierarchy
  14686. * @param newParent defines the new parent to use for the instance (or clone)
  14687. * @param options defines options to configure how copy is done
  14688. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14689. * @returns an instance (or a clone) of the current node with its hiearchy
  14690. */
  14691. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14692. doNotInstantiate: boolean;
  14693. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14694. /**
  14695. * Prevents the World matrix to be computed any longer
  14696. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14697. * @returns the TransformNode.
  14698. */
  14699. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14700. /**
  14701. * Allows back the World matrix computation.
  14702. * @returns the TransformNode.
  14703. */
  14704. unfreezeWorldMatrix(): this;
  14705. /**
  14706. * True if the World matrix has been frozen.
  14707. */
  14708. get isWorldMatrixFrozen(): boolean;
  14709. /**
  14710. * Retuns the mesh absolute position in the World.
  14711. * @returns a Vector3.
  14712. */
  14713. getAbsolutePosition(): Vector3;
  14714. /**
  14715. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14716. * @param absolutePosition the absolute position to set
  14717. * @returns the TransformNode.
  14718. */
  14719. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14720. /**
  14721. * Sets the mesh position in its local space.
  14722. * @param vector3 the position to set in localspace
  14723. * @returns the TransformNode.
  14724. */
  14725. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14726. /**
  14727. * Returns the mesh position in the local space from the current World matrix values.
  14728. * @returns a new Vector3.
  14729. */
  14730. getPositionExpressedInLocalSpace(): Vector3;
  14731. /**
  14732. * Translates the mesh along the passed Vector3 in its local space.
  14733. * @param vector3 the distance to translate in localspace
  14734. * @returns the TransformNode.
  14735. */
  14736. locallyTranslate(vector3: Vector3): TransformNode;
  14737. private static _lookAtVectorCache;
  14738. /**
  14739. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14740. * @param targetPoint the position (must be in same space as current mesh) to look at
  14741. * @param yawCor optional yaw (y-axis) correction in radians
  14742. * @param pitchCor optional pitch (x-axis) correction in radians
  14743. * @param rollCor optional roll (z-axis) correction in radians
  14744. * @param space the choosen space of the target
  14745. * @returns the TransformNode.
  14746. */
  14747. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14748. /**
  14749. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14750. * This Vector3 is expressed in the World space.
  14751. * @param localAxis axis to rotate
  14752. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14753. */
  14754. getDirection(localAxis: Vector3): Vector3;
  14755. /**
  14756. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14757. * localAxis is expressed in the mesh local space.
  14758. * result is computed in the Wordl space from the mesh World matrix.
  14759. * @param localAxis axis to rotate
  14760. * @param result the resulting transformnode
  14761. * @returns this TransformNode.
  14762. */
  14763. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14764. /**
  14765. * Sets this transform node rotation to the given local axis.
  14766. * @param localAxis the axis in local space
  14767. * @param yawCor optional yaw (y-axis) correction in radians
  14768. * @param pitchCor optional pitch (x-axis) correction in radians
  14769. * @param rollCor optional roll (z-axis) correction in radians
  14770. * @returns this TransformNode
  14771. */
  14772. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14773. /**
  14774. * Sets a new pivot point to the current node
  14775. * @param point defines the new pivot point to use
  14776. * @param space defines if the point is in world or local space (local by default)
  14777. * @returns the current TransformNode
  14778. */
  14779. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14780. /**
  14781. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14782. * @returns the pivot point
  14783. */
  14784. getPivotPoint(): Vector3;
  14785. /**
  14786. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14787. * @param result the vector3 to store the result
  14788. * @returns this TransformNode.
  14789. */
  14790. getPivotPointToRef(result: Vector3): TransformNode;
  14791. /**
  14792. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14793. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14794. */
  14795. getAbsolutePivotPoint(): Vector3;
  14796. /**
  14797. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14798. * @param result vector3 to store the result
  14799. * @returns this TransformNode.
  14800. */
  14801. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14802. /**
  14803. * Defines the passed node as the parent of the current node.
  14804. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14805. * @see https://doc.babylonjs.com/how_to/parenting
  14806. * @param node the node ot set as the parent
  14807. * @returns this TransformNode.
  14808. */
  14809. setParent(node: Nullable<Node>): TransformNode;
  14810. private _nonUniformScaling;
  14811. /**
  14812. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14813. */
  14814. get nonUniformScaling(): boolean;
  14815. /** @hidden */
  14816. _updateNonUniformScalingState(value: boolean): boolean;
  14817. /**
  14818. * Attach the current TransformNode to another TransformNode associated with a bone
  14819. * @param bone Bone affecting the TransformNode
  14820. * @param affectedTransformNode TransformNode associated with the bone
  14821. * @returns this object
  14822. */
  14823. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14824. /**
  14825. * Detach the transform node if its associated with a bone
  14826. * @returns this object
  14827. */
  14828. detachFromBone(): TransformNode;
  14829. private static _rotationAxisCache;
  14830. /**
  14831. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14832. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14833. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14834. * The passed axis is also normalized.
  14835. * @param axis the axis to rotate around
  14836. * @param amount the amount to rotate in radians
  14837. * @param space Space to rotate in (Default: local)
  14838. * @returns the TransformNode.
  14839. */
  14840. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14841. /**
  14842. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14843. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14844. * The passed axis is also normalized. .
  14845. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14846. * @param point the point to rotate around
  14847. * @param axis the axis to rotate around
  14848. * @param amount the amount to rotate in radians
  14849. * @returns the TransformNode
  14850. */
  14851. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14852. /**
  14853. * Translates the mesh along the axis vector for the passed distance in the given space.
  14854. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14855. * @param axis the axis to translate in
  14856. * @param distance the distance to translate
  14857. * @param space Space to rotate in (Default: local)
  14858. * @returns the TransformNode.
  14859. */
  14860. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14861. /**
  14862. * Adds a rotation step to the mesh current rotation.
  14863. * x, y, z are Euler angles expressed in radians.
  14864. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14865. * This means this rotation is made in the mesh local space only.
  14866. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14867. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14868. * ```javascript
  14869. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14870. * ```
  14871. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14872. * 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.
  14873. * @param x Rotation to add
  14874. * @param y Rotation to add
  14875. * @param z Rotation to add
  14876. * @returns the TransformNode.
  14877. */
  14878. addRotation(x: number, y: number, z: number): TransformNode;
  14879. /**
  14880. * @hidden
  14881. */
  14882. protected _getEffectiveParent(): Nullable<Node>;
  14883. /**
  14884. * Computes the world matrix of the node
  14885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14886. * @returns the world matrix
  14887. */
  14888. computeWorldMatrix(force?: boolean): Matrix;
  14889. /**
  14890. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14891. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14892. */
  14893. resetLocalMatrix(independentOfChildren?: boolean): void;
  14894. protected _afterComputeWorldMatrix(): void;
  14895. /**
  14896. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14897. * @param func callback function to add
  14898. *
  14899. * @returns the TransformNode.
  14900. */
  14901. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14902. /**
  14903. * Removes a registered callback function.
  14904. * @param func callback function to remove
  14905. * @returns the TransformNode.
  14906. */
  14907. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14908. /**
  14909. * Gets the position of the current mesh in camera space
  14910. * @param camera defines the camera to use
  14911. * @returns a position
  14912. */
  14913. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14914. /**
  14915. * Returns the distance from the mesh to the active camera
  14916. * @param camera defines the camera to use
  14917. * @returns the distance
  14918. */
  14919. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14920. /**
  14921. * Clone the current transform node
  14922. * @param name Name of the new clone
  14923. * @param newParent New parent for the clone
  14924. * @param doNotCloneChildren Do not clone children hierarchy
  14925. * @returns the new transform node
  14926. */
  14927. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14928. /**
  14929. * Serializes the objects information.
  14930. * @param currentSerializationObject defines the object to serialize in
  14931. * @returns the serialized object
  14932. */
  14933. serialize(currentSerializationObject?: any): any;
  14934. /**
  14935. * Returns a new TransformNode object parsed from the source provided.
  14936. * @param parsedTransformNode is the source.
  14937. * @param scene the scne the object belongs to
  14938. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14939. * @returns a new TransformNode object parsed from the source provided.
  14940. */
  14941. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14942. /**
  14943. * Get all child-transformNodes of this node
  14944. * @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
  14945. * @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
  14946. * @returns an array of TransformNode
  14947. */
  14948. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14949. /**
  14950. * Releases resources associated with this transform node.
  14951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14953. */
  14954. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14955. /**
  14956. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14957. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14958. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14959. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14960. * @returns the current mesh
  14961. */
  14962. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14963. private _syncAbsoluteScalingAndRotation;
  14964. }
  14965. }
  14966. declare module BABYLON {
  14967. /**
  14968. * Class used to override all child animations of a given target
  14969. */
  14970. export class AnimationPropertiesOverride {
  14971. /**
  14972. * Gets or sets a value indicating if animation blending must be used
  14973. */
  14974. enableBlending: boolean;
  14975. /**
  14976. * Gets or sets the blending speed to use when enableBlending is true
  14977. */
  14978. blendingSpeed: number;
  14979. /**
  14980. * Gets or sets the default loop mode to use
  14981. */
  14982. loopMode: number;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. /**
  14987. * Class used to store bone information
  14988. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14989. */
  14990. export class Bone extends Node {
  14991. /**
  14992. * defines the bone name
  14993. */
  14994. name: string;
  14995. private static _tmpVecs;
  14996. private static _tmpQuat;
  14997. private static _tmpMats;
  14998. /**
  14999. * Gets the list of child bones
  15000. */
  15001. children: Bone[];
  15002. /** Gets the animations associated with this bone */
  15003. animations: Animation[];
  15004. /**
  15005. * Gets or sets bone length
  15006. */
  15007. length: number;
  15008. /**
  15009. * @hidden Internal only
  15010. * Set this value to map this bone to a different index in the transform matrices
  15011. * Set this value to -1 to exclude the bone from the transform matrices
  15012. */
  15013. _index: Nullable<number>;
  15014. private _skeleton;
  15015. private _localMatrix;
  15016. private _restPose;
  15017. private _baseMatrix;
  15018. private _absoluteTransform;
  15019. private _invertedAbsoluteTransform;
  15020. private _parent;
  15021. private _scalingDeterminant;
  15022. private _worldTransform;
  15023. private _localScaling;
  15024. private _localRotation;
  15025. private _localPosition;
  15026. private _needToDecompose;
  15027. private _needToCompose;
  15028. /** @hidden */
  15029. _linkedTransformNode: Nullable<TransformNode>;
  15030. /** @hidden */
  15031. _waitingTransformNodeId: Nullable<string>;
  15032. /** @hidden */
  15033. get _matrix(): Matrix;
  15034. /** @hidden */
  15035. set _matrix(value: Matrix);
  15036. /**
  15037. * Create a new bone
  15038. * @param name defines the bone name
  15039. * @param skeleton defines the parent skeleton
  15040. * @param parentBone defines the parent (can be null if the bone is the root)
  15041. * @param localMatrix defines the local matrix
  15042. * @param restPose defines the rest pose matrix
  15043. * @param baseMatrix defines the base matrix
  15044. * @param index defines index of the bone in the hiearchy
  15045. */
  15046. constructor(
  15047. /**
  15048. * defines the bone name
  15049. */
  15050. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15051. /**
  15052. * Gets the current object class name.
  15053. * @return the class name
  15054. */
  15055. getClassName(): string;
  15056. /**
  15057. * Gets the parent skeleton
  15058. * @returns a skeleton
  15059. */
  15060. getSkeleton(): Skeleton;
  15061. /**
  15062. * Gets parent bone
  15063. * @returns a bone or null if the bone is the root of the bone hierarchy
  15064. */
  15065. getParent(): Nullable<Bone>;
  15066. /**
  15067. * Returns an array containing the root bones
  15068. * @returns an array containing the root bones
  15069. */
  15070. getChildren(): Array<Bone>;
  15071. /**
  15072. * Gets the node index in matrix array generated for rendering
  15073. * @returns the node index
  15074. */
  15075. getIndex(): number;
  15076. /**
  15077. * Sets the parent bone
  15078. * @param parent defines the parent (can be null if the bone is the root)
  15079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15080. */
  15081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15082. /**
  15083. * Gets the local matrix
  15084. * @returns a matrix
  15085. */
  15086. getLocalMatrix(): Matrix;
  15087. /**
  15088. * Gets the base matrix (initial matrix which remains unchanged)
  15089. * @returns a matrix
  15090. */
  15091. getBaseMatrix(): Matrix;
  15092. /**
  15093. * Gets the rest pose matrix
  15094. * @returns a matrix
  15095. */
  15096. getRestPose(): Matrix;
  15097. /**
  15098. * Sets the rest pose matrix
  15099. * @param matrix the local-space rest pose to set for this bone
  15100. */
  15101. setRestPose(matrix: Matrix): void;
  15102. /**
  15103. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15104. */
  15105. getWorldMatrix(): Matrix;
  15106. /**
  15107. * Sets the local matrix to rest pose matrix
  15108. */
  15109. returnToRest(): void;
  15110. /**
  15111. * Gets the inverse of the absolute transform matrix.
  15112. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15113. * @returns a matrix
  15114. */
  15115. getInvertedAbsoluteTransform(): Matrix;
  15116. /**
  15117. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15118. * @returns a matrix
  15119. */
  15120. getAbsoluteTransform(): Matrix;
  15121. /**
  15122. * Links with the given transform node.
  15123. * The local matrix of this bone is copied from the transform node every frame.
  15124. * @param transformNode defines the transform node to link to
  15125. */
  15126. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15127. /**
  15128. * Gets the node used to drive the bone's transformation
  15129. * @returns a transform node or null
  15130. */
  15131. getTransformNode(): Nullable<TransformNode>;
  15132. /** Gets or sets current position (in local space) */
  15133. get position(): Vector3;
  15134. set position(newPosition: Vector3);
  15135. /** Gets or sets current rotation (in local space) */
  15136. get rotation(): Vector3;
  15137. set rotation(newRotation: Vector3);
  15138. /** Gets or sets current rotation quaternion (in local space) */
  15139. get rotationQuaternion(): Quaternion;
  15140. set rotationQuaternion(newRotation: Quaternion);
  15141. /** Gets or sets current scaling (in local space) */
  15142. get scaling(): Vector3;
  15143. set scaling(newScaling: Vector3);
  15144. /**
  15145. * Gets the animation properties override
  15146. */
  15147. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15148. private _decompose;
  15149. private _compose;
  15150. /**
  15151. * Update the base and local matrices
  15152. * @param matrix defines the new base or local matrix
  15153. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15154. * @param updateLocalMatrix defines if the local matrix should be updated
  15155. */
  15156. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15157. /** @hidden */
  15158. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15159. /**
  15160. * Flag the bone as dirty (Forcing it to update everything)
  15161. */
  15162. markAsDirty(): void;
  15163. /** @hidden */
  15164. _markAsDirtyAndCompose(): void;
  15165. private _markAsDirtyAndDecompose;
  15166. /**
  15167. * Translate the bone in local or world space
  15168. * @param vec The amount to translate the bone
  15169. * @param space The space that the translation is in
  15170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15171. */
  15172. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15173. /**
  15174. * Set the postion of the bone in local or world space
  15175. * @param position The position to set the bone
  15176. * @param space The space that the position is in
  15177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15178. */
  15179. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15180. /**
  15181. * Set the absolute position of the bone (world space)
  15182. * @param position The position to set the bone
  15183. * @param mesh The mesh that this bone is attached to
  15184. */
  15185. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15186. /**
  15187. * Scale the bone on the x, y and z axes (in local space)
  15188. * @param x The amount to scale the bone on the x axis
  15189. * @param y The amount to scale the bone on the y axis
  15190. * @param z The amount to scale the bone on the z axis
  15191. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15192. */
  15193. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15194. /**
  15195. * Set the bone scaling in local space
  15196. * @param scale defines the scaling vector
  15197. */
  15198. setScale(scale: Vector3): void;
  15199. /**
  15200. * Gets the current scaling in local space
  15201. * @returns the current scaling vector
  15202. */
  15203. getScale(): Vector3;
  15204. /**
  15205. * Gets the current scaling in local space and stores it in a target vector
  15206. * @param result defines the target vector
  15207. */
  15208. getScaleToRef(result: Vector3): void;
  15209. /**
  15210. * Set the yaw, pitch, and roll of the bone in local or world space
  15211. * @param yaw The rotation of the bone on the y axis
  15212. * @param pitch The rotation of the bone on the x axis
  15213. * @param roll The rotation of the bone on the z axis
  15214. * @param space The space that the axes of rotation are in
  15215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15216. */
  15217. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15218. /**
  15219. * Add a rotation to the bone on an axis in local or world space
  15220. * @param axis The axis to rotate the bone on
  15221. * @param amount The amount to rotate the bone
  15222. * @param space The space that the axis is in
  15223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15224. */
  15225. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15226. /**
  15227. * Set the rotation of the bone to a particular axis angle in local or world space
  15228. * @param axis The axis to rotate the bone on
  15229. * @param angle The angle that the bone should be rotated to
  15230. * @param space The space that the axis is in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. */
  15233. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15234. /**
  15235. * Set the euler rotation of the bone in local of world space
  15236. * @param rotation The euler rotation that the bone should be set to
  15237. * @param space The space that the rotation is in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. */
  15240. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15241. /**
  15242. * Set the quaternion rotation of the bone in local of world space
  15243. * @param quat The quaternion rotation that the bone should be set to
  15244. * @param space The space that the rotation is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation matrix of the bone in local of world space
  15250. * @param rotMat The rotation matrix that the bone should be set to
  15251. * @param space The space that the rotation is in
  15252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15253. */
  15254. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15255. private _rotateWithMatrix;
  15256. private _getNegativeRotationToRef;
  15257. /**
  15258. * Get the position of the bone in local or world space
  15259. * @param space The space that the returned position is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. * @returns The position of the bone
  15262. */
  15263. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15264. /**
  15265. * Copy the position of the bone to a vector3 in local or world space
  15266. * @param space The space that the returned position is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. * @param result The vector3 to copy the position to
  15269. */
  15270. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15271. /**
  15272. * Get the absolute position of the bone (world space)
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @returns The absolute position of the bone
  15275. */
  15276. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15277. /**
  15278. * Copy the absolute position of the bone (world space) to the result param
  15279. * @param mesh The mesh that this bone is attached to
  15280. * @param result The vector3 to copy the absolute position to
  15281. */
  15282. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15283. /**
  15284. * Compute the absolute transforms of this bone and its children
  15285. */
  15286. computeAbsoluteTransforms(): void;
  15287. /**
  15288. * Get the world direction from an axis that is in the local space of the bone
  15289. * @param localAxis The local direction that is used to compute the world direction
  15290. * @param mesh The mesh that this bone is attached to
  15291. * @returns The world direction
  15292. */
  15293. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15294. /**
  15295. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15296. * @param localAxis The local direction that is used to compute the world direction
  15297. * @param mesh The mesh that this bone is attached to
  15298. * @param result The vector3 that the world direction will be copied to
  15299. */
  15300. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15301. /**
  15302. * Get the euler rotation of the bone in local or world space
  15303. * @param space The space that the rotation should be in
  15304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15305. * @returns The euler rotation
  15306. */
  15307. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15308. /**
  15309. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15310. * @param space The space that the rotation should be in
  15311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15312. * @param result The vector3 that the rotation should be copied to
  15313. */
  15314. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15315. /**
  15316. * Get the quaternion rotation of the bone in either local or world space
  15317. * @param space The space that the rotation should be in
  15318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15319. * @returns The quaternion rotation
  15320. */
  15321. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15322. /**
  15323. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15324. * @param space The space that the rotation should be in
  15325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15326. * @param result The quaternion that the rotation should be copied to
  15327. */
  15328. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15329. /**
  15330. * Get the rotation matrix of the bone in local or world space
  15331. * @param space The space that the rotation should be in
  15332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15333. * @returns The rotation matrix
  15334. */
  15335. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15336. /**
  15337. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15338. * @param space The space that the rotation should be in
  15339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15340. * @param result The quaternion that the rotation should be copied to
  15341. */
  15342. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15343. /**
  15344. * Get the world position of a point that is in the local space of the bone
  15345. * @param position The local position
  15346. * @param mesh The mesh that this bone is attached to
  15347. * @returns The world position
  15348. */
  15349. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15350. /**
  15351. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15352. * @param position The local position
  15353. * @param mesh The mesh that this bone is attached to
  15354. * @param result The vector3 that the world position should be copied to
  15355. */
  15356. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15357. /**
  15358. * Get the local position of a point that is in world space
  15359. * @param position The world position
  15360. * @param mesh The mesh that this bone is attached to
  15361. * @returns The local position
  15362. */
  15363. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15364. /**
  15365. * Get the local position of a point that is in world space and copy it to the result param
  15366. * @param position The world position
  15367. * @param mesh The mesh that this bone is attached to
  15368. * @param result The vector3 that the local position should be copied to
  15369. */
  15370. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15371. }
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * Defines a runtime animation
  15376. */
  15377. export class RuntimeAnimation {
  15378. private _events;
  15379. /**
  15380. * The current frame of the runtime animation
  15381. */
  15382. private _currentFrame;
  15383. /**
  15384. * The animation used by the runtime animation
  15385. */
  15386. private _animation;
  15387. /**
  15388. * The target of the runtime animation
  15389. */
  15390. private _target;
  15391. /**
  15392. * The initiating animatable
  15393. */
  15394. private _host;
  15395. /**
  15396. * The original value of the runtime animation
  15397. */
  15398. private _originalValue;
  15399. /**
  15400. * The original blend value of the runtime animation
  15401. */
  15402. private _originalBlendValue;
  15403. /**
  15404. * The offsets cache of the runtime animation
  15405. */
  15406. private _offsetsCache;
  15407. /**
  15408. * The high limits cache of the runtime animation
  15409. */
  15410. private _highLimitsCache;
  15411. /**
  15412. * Specifies if the runtime animation has been stopped
  15413. */
  15414. private _stopped;
  15415. /**
  15416. * The blending factor of the runtime animation
  15417. */
  15418. private _blendingFactor;
  15419. /**
  15420. * The BabylonJS scene
  15421. */
  15422. private _scene;
  15423. /**
  15424. * The current value of the runtime animation
  15425. */
  15426. private _currentValue;
  15427. /** @hidden */
  15428. _animationState: _IAnimationState;
  15429. /**
  15430. * The active target of the runtime animation
  15431. */
  15432. private _activeTargets;
  15433. private _currentActiveTarget;
  15434. private _directTarget;
  15435. /**
  15436. * The target path of the runtime animation
  15437. */
  15438. private _targetPath;
  15439. /**
  15440. * The weight of the runtime animation
  15441. */
  15442. private _weight;
  15443. /**
  15444. * The ratio offset of the runtime animation
  15445. */
  15446. private _ratioOffset;
  15447. /**
  15448. * The previous delay of the runtime animation
  15449. */
  15450. private _previousDelay;
  15451. /**
  15452. * The previous ratio of the runtime animation
  15453. */
  15454. private _previousRatio;
  15455. private _enableBlending;
  15456. private _keys;
  15457. private _minFrame;
  15458. private _maxFrame;
  15459. private _minValue;
  15460. private _maxValue;
  15461. private _targetIsArray;
  15462. /**
  15463. * Gets the current frame of the runtime animation
  15464. */
  15465. get currentFrame(): number;
  15466. /**
  15467. * Gets the weight of the runtime animation
  15468. */
  15469. get weight(): number;
  15470. /**
  15471. * Gets the current value of the runtime animation
  15472. */
  15473. get currentValue(): any;
  15474. /**
  15475. * Gets the target path of the runtime animation
  15476. */
  15477. get targetPath(): string;
  15478. /**
  15479. * Gets the actual target of the runtime animation
  15480. */
  15481. get target(): any;
  15482. /**
  15483. * Gets the additive state of the runtime animation
  15484. */
  15485. get isAdditive(): boolean;
  15486. /** @hidden */
  15487. _onLoop: () => void;
  15488. /**
  15489. * Create a new RuntimeAnimation object
  15490. * @param target defines the target of the animation
  15491. * @param animation defines the source animation object
  15492. * @param scene defines the hosting scene
  15493. * @param host defines the initiating Animatable
  15494. */
  15495. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15496. private _preparePath;
  15497. /**
  15498. * Gets the animation from the runtime animation
  15499. */
  15500. get animation(): Animation;
  15501. /**
  15502. * Resets the runtime animation to the beginning
  15503. * @param restoreOriginal defines whether to restore the target property to the original value
  15504. */
  15505. reset(restoreOriginal?: boolean): void;
  15506. /**
  15507. * Specifies if the runtime animation is stopped
  15508. * @returns Boolean specifying if the runtime animation is stopped
  15509. */
  15510. isStopped(): boolean;
  15511. /**
  15512. * Disposes of the runtime animation
  15513. */
  15514. dispose(): void;
  15515. /**
  15516. * Apply the interpolated value to the target
  15517. * @param currentValue defines the value computed by the animation
  15518. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15519. */
  15520. setValue(currentValue: any, weight: number): void;
  15521. private _getOriginalValues;
  15522. private _setValue;
  15523. /**
  15524. * Gets the loop pmode of the runtime animation
  15525. * @returns Loop Mode
  15526. */
  15527. private _getCorrectLoopMode;
  15528. /**
  15529. * Move the current animation to a given frame
  15530. * @param frame defines the frame to move to
  15531. */
  15532. goToFrame(frame: number): void;
  15533. /**
  15534. * @hidden Internal use only
  15535. */
  15536. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15537. /**
  15538. * Execute the current animation
  15539. * @param delay defines the delay to add to the current frame
  15540. * @param from defines the lower bound of the animation range
  15541. * @param to defines the upper bound of the animation range
  15542. * @param loop defines if the current animation must loop
  15543. * @param speedRatio defines the current speed ratio
  15544. * @param weight defines the weight of the animation (default is -1 so no weight)
  15545. * @param onLoop optional callback called when animation loops
  15546. * @returns a boolean indicating if the animation is running
  15547. */
  15548. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15549. }
  15550. }
  15551. declare module BABYLON {
  15552. /**
  15553. * Class used to store an actual running animation
  15554. */
  15555. export class Animatable {
  15556. /** defines the target object */
  15557. target: any;
  15558. /** defines the starting frame number (default is 0) */
  15559. fromFrame: number;
  15560. /** defines the ending frame number (default is 100) */
  15561. toFrame: number;
  15562. /** defines if the animation must loop (default is false) */
  15563. loopAnimation: boolean;
  15564. /** defines a callback to call when animation ends if it is not looping */
  15565. onAnimationEnd?: (() => void) | null | undefined;
  15566. /** defines a callback to call when animation loops */
  15567. onAnimationLoop?: (() => void) | null | undefined;
  15568. /** defines whether the animation should be evaluated additively */
  15569. isAdditive: boolean;
  15570. private _localDelayOffset;
  15571. private _pausedDelay;
  15572. private _runtimeAnimations;
  15573. private _paused;
  15574. private _scene;
  15575. private _speedRatio;
  15576. private _weight;
  15577. private _syncRoot;
  15578. /**
  15579. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15580. * This will only apply for non looping animation (default is true)
  15581. */
  15582. disposeOnEnd: boolean;
  15583. /**
  15584. * Gets a boolean indicating if the animation has started
  15585. */
  15586. animationStarted: boolean;
  15587. /**
  15588. * Observer raised when the animation ends
  15589. */
  15590. onAnimationEndObservable: Observable<Animatable>;
  15591. /**
  15592. * Observer raised when the animation loops
  15593. */
  15594. onAnimationLoopObservable: Observable<Animatable>;
  15595. /**
  15596. * Gets the root Animatable used to synchronize and normalize animations
  15597. */
  15598. get syncRoot(): Nullable<Animatable>;
  15599. /**
  15600. * Gets the current frame of the first RuntimeAnimation
  15601. * Used to synchronize Animatables
  15602. */
  15603. get masterFrame(): number;
  15604. /**
  15605. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15606. */
  15607. get weight(): number;
  15608. set weight(value: number);
  15609. /**
  15610. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15611. */
  15612. get speedRatio(): number;
  15613. set speedRatio(value: number);
  15614. /**
  15615. * Creates a new Animatable
  15616. * @param scene defines the hosting scene
  15617. * @param target defines the target object
  15618. * @param fromFrame defines the starting frame number (default is 0)
  15619. * @param toFrame defines the ending frame number (default is 100)
  15620. * @param loopAnimation defines if the animation must loop (default is false)
  15621. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15622. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15623. * @param animations defines a group of animation to add to the new Animatable
  15624. * @param onAnimationLoop defines a callback to call when animation loops
  15625. * @param isAdditive defines whether the animation should be evaluated additively
  15626. */
  15627. constructor(scene: Scene,
  15628. /** defines the target object */
  15629. target: any,
  15630. /** defines the starting frame number (default is 0) */
  15631. fromFrame?: number,
  15632. /** defines the ending frame number (default is 100) */
  15633. toFrame?: number,
  15634. /** defines if the animation must loop (default is false) */
  15635. loopAnimation?: boolean, speedRatio?: number,
  15636. /** defines a callback to call when animation ends if it is not looping */
  15637. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15638. /** defines a callback to call when animation loops */
  15639. onAnimationLoop?: (() => void) | null | undefined,
  15640. /** defines whether the animation should be evaluated additively */
  15641. isAdditive?: boolean);
  15642. /**
  15643. * Synchronize and normalize current Animatable with a source Animatable
  15644. * This is useful when using animation weights and when animations are not of the same length
  15645. * @param root defines the root Animatable to synchronize with
  15646. * @returns the current Animatable
  15647. */
  15648. syncWith(root: Animatable): Animatable;
  15649. /**
  15650. * Gets the list of runtime animations
  15651. * @returns an array of RuntimeAnimation
  15652. */
  15653. getAnimations(): RuntimeAnimation[];
  15654. /**
  15655. * Adds more animations to the current animatable
  15656. * @param target defines the target of the animations
  15657. * @param animations defines the new animations to add
  15658. */
  15659. appendAnimations(target: any, animations: Animation[]): void;
  15660. /**
  15661. * Gets the source animation for a specific property
  15662. * @param property defines the propertyu to look for
  15663. * @returns null or the source animation for the given property
  15664. */
  15665. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15666. /**
  15667. * Gets the runtime animation for a specific property
  15668. * @param property defines the propertyu to look for
  15669. * @returns null or the runtime animation for the given property
  15670. */
  15671. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15672. /**
  15673. * Resets the animatable to its original state
  15674. */
  15675. reset(): void;
  15676. /**
  15677. * Allows the animatable to blend with current running animations
  15678. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15679. * @param blendingSpeed defines the blending speed to use
  15680. */
  15681. enableBlending(blendingSpeed: number): void;
  15682. /**
  15683. * Disable animation blending
  15684. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15685. */
  15686. disableBlending(): void;
  15687. /**
  15688. * Jump directly to a given frame
  15689. * @param frame defines the frame to jump to
  15690. */
  15691. goToFrame(frame: number): void;
  15692. /**
  15693. * Pause the animation
  15694. */
  15695. pause(): void;
  15696. /**
  15697. * Restart the animation
  15698. */
  15699. restart(): void;
  15700. private _raiseOnAnimationEnd;
  15701. /**
  15702. * Stop and delete the current animation
  15703. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15704. * @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)
  15705. */
  15706. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15707. /**
  15708. * Wait asynchronously for the animation to end
  15709. * @returns a promise which will be fullfilled when the animation ends
  15710. */
  15711. waitAsync(): Promise<Animatable>;
  15712. /** @hidden */
  15713. _animate(delay: number): boolean;
  15714. }
  15715. interface Scene {
  15716. /** @hidden */
  15717. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15718. /** @hidden */
  15719. _processLateAnimationBindingsForMatrices(holder: {
  15720. totalWeight: number;
  15721. totalAdditiveWeight: number;
  15722. animations: RuntimeAnimation[];
  15723. additiveAnimations: RuntimeAnimation[];
  15724. originalValue: Matrix;
  15725. }): any;
  15726. /** @hidden */
  15727. _processLateAnimationBindingsForQuaternions(holder: {
  15728. totalWeight: number;
  15729. totalAdditiveWeight: number;
  15730. animations: RuntimeAnimation[];
  15731. additiveAnimations: RuntimeAnimation[];
  15732. originalValue: Quaternion;
  15733. }, refQuaternion: Quaternion): Quaternion;
  15734. /** @hidden */
  15735. _processLateAnimationBindings(): void;
  15736. /**
  15737. * Will start the animation sequence of a given target
  15738. * @param target defines the target
  15739. * @param from defines from which frame should animation start
  15740. * @param to defines until which frame should animation run.
  15741. * @param weight defines the weight to apply to the animation (1.0 by default)
  15742. * @param loop defines if the animation loops
  15743. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15744. * @param onAnimationEnd defines the function to be executed when the animation ends
  15745. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15746. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15747. * @param onAnimationLoop defines the callback to call when an animation loops
  15748. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15749. * @returns the animatable object created for this animation
  15750. */
  15751. 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;
  15752. /**
  15753. * Will start the animation sequence of a given target
  15754. * @param target defines the target
  15755. * @param from defines from which frame should animation start
  15756. * @param to defines until which frame should animation run.
  15757. * @param loop defines if the animation loops
  15758. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15759. * @param onAnimationEnd defines the function to be executed when the animation ends
  15760. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15761. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15762. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15763. * @param onAnimationLoop defines the callback to call when an animation loops
  15764. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15765. * @returns the animatable object created for this animation
  15766. */
  15767. 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;
  15768. /**
  15769. * Will start the animation sequence of a given target and its hierarchy
  15770. * @param target defines the target
  15771. * @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.
  15772. * @param from defines from which frame should animation start
  15773. * @param to defines until which frame should animation run.
  15774. * @param loop defines if the animation loops
  15775. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15776. * @param onAnimationEnd defines the function to be executed when the animation ends
  15777. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15778. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15779. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15780. * @param onAnimationLoop defines the callback to call when an animation loops
  15781. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15782. * @returns the list of created animatables
  15783. */
  15784. 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[];
  15785. /**
  15786. * Begin a new animation on a given node
  15787. * @param target defines the target where the animation will take place
  15788. * @param animations defines the list of animations to start
  15789. * @param from defines the initial value
  15790. * @param to defines the final value
  15791. * @param loop defines if you want animation to loop (off by default)
  15792. * @param speedRatio defines the speed ratio to apply to all animations
  15793. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15794. * @param onAnimationLoop defines the callback to call when an animation loops
  15795. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15796. * @returns the list of created animatables
  15797. */
  15798. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15799. /**
  15800. * Begin a new animation on a given node and its hierarchy
  15801. * @param target defines the root node where the animation will take place
  15802. * @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.
  15803. * @param animations defines the list of animations to start
  15804. * @param from defines the initial value
  15805. * @param to defines the final value
  15806. * @param loop defines if you want animation to loop (off by default)
  15807. * @param speedRatio defines the speed ratio to apply to all animations
  15808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15809. * @param onAnimationLoop defines the callback to call when an animation loops
  15810. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15811. * @returns the list of animatables created for all nodes
  15812. */
  15813. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15814. /**
  15815. * Gets the animatable associated with a specific target
  15816. * @param target defines the target of the animatable
  15817. * @returns the required animatable if found
  15818. */
  15819. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15820. /**
  15821. * Gets all animatables associated with a given target
  15822. * @param target defines the target to look animatables for
  15823. * @returns an array of Animatables
  15824. */
  15825. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15826. /**
  15827. * Stops and removes all animations that have been applied to the scene
  15828. */
  15829. stopAllAnimations(): void;
  15830. /**
  15831. * Gets the current delta time used by animation engine
  15832. */
  15833. deltaTime: number;
  15834. }
  15835. interface Bone {
  15836. /**
  15837. * Copy an animation range from another bone
  15838. * @param source defines the source bone
  15839. * @param rangeName defines the range name to copy
  15840. * @param frameOffset defines the frame offset
  15841. * @param rescaleAsRequired defines if rescaling must be applied if required
  15842. * @param skelDimensionsRatio defines the scaling ratio
  15843. * @returns true if operation was successful
  15844. */
  15845. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Class used to handle skinning animations
  15851. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15852. */
  15853. export class Skeleton implements IAnimatable {
  15854. /** defines the skeleton name */
  15855. name: string;
  15856. /** defines the skeleton Id */
  15857. id: string;
  15858. /**
  15859. * Defines the list of child bones
  15860. */
  15861. bones: Bone[];
  15862. /**
  15863. * Defines an estimate of the dimension of the skeleton at rest
  15864. */
  15865. dimensionsAtRest: Vector3;
  15866. /**
  15867. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15868. */
  15869. needInitialSkinMatrix: boolean;
  15870. /**
  15871. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15872. */
  15873. overrideMesh: Nullable<AbstractMesh>;
  15874. /**
  15875. * Gets the list of animations attached to this skeleton
  15876. */
  15877. animations: Array<Animation>;
  15878. private _scene;
  15879. private _isDirty;
  15880. private _transformMatrices;
  15881. private _transformMatrixTexture;
  15882. private _meshesWithPoseMatrix;
  15883. private _animatables;
  15884. private _identity;
  15885. private _synchronizedWithMesh;
  15886. private _ranges;
  15887. private _lastAbsoluteTransformsUpdateId;
  15888. private _canUseTextureForBones;
  15889. private _uniqueId;
  15890. /** @hidden */
  15891. _numBonesWithLinkedTransformNode: number;
  15892. /** @hidden */
  15893. _hasWaitingData: Nullable<boolean>;
  15894. /**
  15895. * Specifies if the skeleton should be serialized
  15896. */
  15897. doNotSerialize: boolean;
  15898. private _useTextureToStoreBoneMatrices;
  15899. /**
  15900. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15901. * Please note that this option is not available if the hardware does not support it
  15902. */
  15903. get useTextureToStoreBoneMatrices(): boolean;
  15904. set useTextureToStoreBoneMatrices(value: boolean);
  15905. private _animationPropertiesOverride;
  15906. /**
  15907. * Gets or sets the animation properties override
  15908. */
  15909. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15910. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15911. /**
  15912. * List of inspectable custom properties (used by the Inspector)
  15913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15914. */
  15915. inspectableCustomProperties: IInspectable[];
  15916. /**
  15917. * An observable triggered before computing the skeleton's matrices
  15918. */
  15919. onBeforeComputeObservable: Observable<Skeleton>;
  15920. /**
  15921. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15922. */
  15923. get isUsingTextureForMatrices(): boolean;
  15924. /**
  15925. * Gets the unique ID of this skeleton
  15926. */
  15927. get uniqueId(): number;
  15928. /**
  15929. * Creates a new skeleton
  15930. * @param name defines the skeleton name
  15931. * @param id defines the skeleton Id
  15932. * @param scene defines the hosting scene
  15933. */
  15934. constructor(
  15935. /** defines the skeleton name */
  15936. name: string,
  15937. /** defines the skeleton Id */
  15938. id: string, scene: Scene);
  15939. /**
  15940. * Gets the current object class name.
  15941. * @return the class name
  15942. */
  15943. getClassName(): string;
  15944. /**
  15945. * Returns an array containing the root bones
  15946. * @returns an array containing the root bones
  15947. */
  15948. getChildren(): Array<Bone>;
  15949. /**
  15950. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15951. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15952. * @returns a Float32Array containing matrices data
  15953. */
  15954. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15955. /**
  15956. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15957. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15958. * @returns a raw texture containing the data
  15959. */
  15960. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15961. /**
  15962. * Gets the current hosting scene
  15963. * @returns a scene object
  15964. */
  15965. getScene(): Scene;
  15966. /**
  15967. * Gets a string representing the current skeleton data
  15968. * @param fullDetails defines a boolean indicating if we want a verbose version
  15969. * @returns a string representing the current skeleton data
  15970. */
  15971. toString(fullDetails?: boolean): string;
  15972. /**
  15973. * Get bone's index searching by name
  15974. * @param name defines bone's name to search for
  15975. * @return the indice of the bone. Returns -1 if not found
  15976. */
  15977. getBoneIndexByName(name: string): number;
  15978. /**
  15979. * Creater a new animation range
  15980. * @param name defines the name of the range
  15981. * @param from defines the start key
  15982. * @param to defines the end key
  15983. */
  15984. createAnimationRange(name: string, from: number, to: number): void;
  15985. /**
  15986. * Delete a specific animation range
  15987. * @param name defines the name of the range
  15988. * @param deleteFrames defines if frames must be removed as well
  15989. */
  15990. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15991. /**
  15992. * Gets a specific animation range
  15993. * @param name defines the name of the range to look for
  15994. * @returns the requested animation range or null if not found
  15995. */
  15996. getAnimationRange(name: string): Nullable<AnimationRange>;
  15997. /**
  15998. * Gets the list of all animation ranges defined on this skeleton
  15999. * @returns an array
  16000. */
  16001. getAnimationRanges(): Nullable<AnimationRange>[];
  16002. /**
  16003. * Copy animation range from a source skeleton.
  16004. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16005. * @param source defines the source skeleton
  16006. * @param name defines the name of the range to copy
  16007. * @param rescaleAsRequired defines if rescaling must be applied if required
  16008. * @returns true if operation was successful
  16009. */
  16010. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16011. /**
  16012. * Forces the skeleton to go to rest pose
  16013. */
  16014. returnToRest(): void;
  16015. private _getHighestAnimationFrame;
  16016. /**
  16017. * Begin a specific animation range
  16018. * @param name defines the name of the range to start
  16019. * @param loop defines if looping must be turned on (false by default)
  16020. * @param speedRatio defines the speed ratio to apply (1 by default)
  16021. * @param onAnimationEnd defines a callback which will be called when animation will end
  16022. * @returns a new animatable
  16023. */
  16024. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16025. /**
  16026. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16027. * @param skeleton defines the Skeleton containing the animation range to convert
  16028. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16029. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16030. * @returns the original skeleton
  16031. */
  16032. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16033. /** @hidden */
  16034. _markAsDirty(): void;
  16035. /** @hidden */
  16036. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16037. /** @hidden */
  16038. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16039. private _computeTransformMatrices;
  16040. /**
  16041. * Build all resources required to render a skeleton
  16042. */
  16043. prepare(): void;
  16044. /**
  16045. * Gets the list of animatables currently running for this skeleton
  16046. * @returns an array of animatables
  16047. */
  16048. getAnimatables(): IAnimatable[];
  16049. /**
  16050. * Clone the current skeleton
  16051. * @param name defines the name of the new skeleton
  16052. * @param id defines the id of the new skeleton
  16053. * @returns the new skeleton
  16054. */
  16055. clone(name: string, id?: string): Skeleton;
  16056. /**
  16057. * Enable animation blending for this skeleton
  16058. * @param blendingSpeed defines the blending speed to apply
  16059. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16060. */
  16061. enableBlending(blendingSpeed?: number): void;
  16062. /**
  16063. * Releases all resources associated with the current skeleton
  16064. */
  16065. dispose(): void;
  16066. /**
  16067. * Serialize the skeleton in a JSON object
  16068. * @returns a JSON object
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Creates a new skeleton from serialized data
  16073. * @param parsedSkeleton defines the serialized data
  16074. * @param scene defines the hosting scene
  16075. * @returns a new skeleton
  16076. */
  16077. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16078. /**
  16079. * Compute all node absolute transforms
  16080. * @param forceUpdate defines if computation must be done even if cache is up to date
  16081. */
  16082. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16083. /**
  16084. * Gets the root pose matrix
  16085. * @returns a matrix
  16086. */
  16087. getPoseMatrix(): Nullable<Matrix>;
  16088. /**
  16089. * Sorts bones per internal index
  16090. */
  16091. sortBones(): void;
  16092. private _sortBones;
  16093. }
  16094. }
  16095. declare module BABYLON {
  16096. /**
  16097. * Creates an instance based on a source mesh.
  16098. */
  16099. export class InstancedMesh extends AbstractMesh {
  16100. private _sourceMesh;
  16101. private _currentLOD;
  16102. /** @hidden */
  16103. _indexInSourceMeshInstanceArray: number;
  16104. constructor(name: string, source: Mesh);
  16105. /**
  16106. * Returns the string "InstancedMesh".
  16107. */
  16108. getClassName(): string;
  16109. /** Gets the list of lights affecting that mesh */
  16110. get lightSources(): Light[];
  16111. _resyncLightSources(): void;
  16112. _resyncLightSource(light: Light): void;
  16113. _removeLightSource(light: Light, dispose: boolean): void;
  16114. /**
  16115. * If the source mesh receives shadows
  16116. */
  16117. get receiveShadows(): boolean;
  16118. /**
  16119. * The material of the source mesh
  16120. */
  16121. get material(): Nullable<Material>;
  16122. /**
  16123. * Visibility of the source mesh
  16124. */
  16125. get visibility(): number;
  16126. /**
  16127. * Skeleton of the source mesh
  16128. */
  16129. get skeleton(): Nullable<Skeleton>;
  16130. /**
  16131. * Rendering ground id of the source mesh
  16132. */
  16133. get renderingGroupId(): number;
  16134. set renderingGroupId(value: number);
  16135. /**
  16136. * Returns the total number of vertices (integer).
  16137. */
  16138. getTotalVertices(): number;
  16139. /**
  16140. * Returns a positive integer : the total number of indices in this mesh geometry.
  16141. * @returns the numner of indices or zero if the mesh has no geometry.
  16142. */
  16143. getTotalIndices(): number;
  16144. /**
  16145. * The source mesh of the instance
  16146. */
  16147. get sourceMesh(): Mesh;
  16148. /**
  16149. * Creates a new InstancedMesh object from the mesh model.
  16150. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16151. * @param name defines the name of the new instance
  16152. * @returns a new InstancedMesh
  16153. */
  16154. createInstance(name: string): InstancedMesh;
  16155. /**
  16156. * Is this node ready to be used/rendered
  16157. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16158. * @return {boolean} is it ready
  16159. */
  16160. isReady(completeCheck?: boolean): boolean;
  16161. /**
  16162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16163. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16164. * @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.
  16165. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16166. */
  16167. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16168. /**
  16169. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16170. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16171. * The `data` are either a numeric array either a Float32Array.
  16172. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16173. * 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).
  16174. * Note that a new underlying VertexBuffer object is created each call.
  16175. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16176. *
  16177. * Possible `kind` values :
  16178. * - VertexBuffer.PositionKind
  16179. * - VertexBuffer.UVKind
  16180. * - VertexBuffer.UV2Kind
  16181. * - VertexBuffer.UV3Kind
  16182. * - VertexBuffer.UV4Kind
  16183. * - VertexBuffer.UV5Kind
  16184. * - VertexBuffer.UV6Kind
  16185. * - VertexBuffer.ColorKind
  16186. * - VertexBuffer.MatricesIndicesKind
  16187. * - VertexBuffer.MatricesIndicesExtraKind
  16188. * - VertexBuffer.MatricesWeightsKind
  16189. * - VertexBuffer.MatricesWeightsExtraKind
  16190. *
  16191. * Returns the Mesh.
  16192. */
  16193. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16194. /**
  16195. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16196. * If the mesh has no geometry, it is simply returned as it is.
  16197. * The `data` are either a numeric array either a Float32Array.
  16198. * No new underlying VertexBuffer object is created.
  16199. * 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.
  16200. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16201. *
  16202. * Possible `kind` values :
  16203. * - VertexBuffer.PositionKind
  16204. * - VertexBuffer.UVKind
  16205. * - VertexBuffer.UV2Kind
  16206. * - VertexBuffer.UV3Kind
  16207. * - VertexBuffer.UV4Kind
  16208. * - VertexBuffer.UV5Kind
  16209. * - VertexBuffer.UV6Kind
  16210. * - VertexBuffer.ColorKind
  16211. * - VertexBuffer.MatricesIndicesKind
  16212. * - VertexBuffer.MatricesIndicesExtraKind
  16213. * - VertexBuffer.MatricesWeightsKind
  16214. * - VertexBuffer.MatricesWeightsExtraKind
  16215. *
  16216. * Returns the Mesh.
  16217. */
  16218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16219. /**
  16220. * Sets the mesh indices.
  16221. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16222. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16223. * This method creates a new index buffer each call.
  16224. * Returns the Mesh.
  16225. */
  16226. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16227. /**
  16228. * Boolean : True if the mesh owns the requested kind of data.
  16229. */
  16230. isVerticesDataPresent(kind: string): boolean;
  16231. /**
  16232. * Returns an array of indices (IndicesArray).
  16233. */
  16234. getIndices(): Nullable<IndicesArray>;
  16235. get _positions(): Nullable<Vector3[]>;
  16236. /**
  16237. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16238. * This means the mesh underlying bounding box and sphere are recomputed.
  16239. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16240. * @returns the current mesh
  16241. */
  16242. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16243. /** @hidden */
  16244. _preActivate(): InstancedMesh;
  16245. /** @hidden */
  16246. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16247. /** @hidden */
  16248. _postActivate(): void;
  16249. getWorldMatrix(): Matrix;
  16250. get isAnInstance(): boolean;
  16251. /**
  16252. * Returns the current associated LOD AbstractMesh.
  16253. */
  16254. getLOD(camera: Camera): AbstractMesh;
  16255. /** @hidden */
  16256. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16257. /** @hidden */
  16258. _syncSubMeshes(): InstancedMesh;
  16259. /** @hidden */
  16260. _generatePointsArray(): boolean;
  16261. /**
  16262. * Creates a new InstancedMesh from the current mesh.
  16263. * - name (string) : the cloned mesh name
  16264. * - newParent (optional Node) : the optional Node to parent the clone to.
  16265. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16266. *
  16267. * Returns the clone.
  16268. */
  16269. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16270. /**
  16271. * Disposes the InstancedMesh.
  16272. * Returns nothing.
  16273. */
  16274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16275. }
  16276. interface Mesh {
  16277. /**
  16278. * Register a custom buffer that will be instanced
  16279. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16280. * @param kind defines the buffer kind
  16281. * @param stride defines the stride in floats
  16282. */
  16283. registerInstancedBuffer(kind: string, stride: number): void;
  16284. /**
  16285. * true to use the edge renderer for all instances of this mesh
  16286. */
  16287. edgesShareWithInstances: boolean;
  16288. /** @hidden */
  16289. _userInstancedBuffersStorage: {
  16290. data: {
  16291. [key: string]: Float32Array;
  16292. };
  16293. sizes: {
  16294. [key: string]: number;
  16295. };
  16296. vertexBuffers: {
  16297. [key: string]: Nullable<VertexBuffer>;
  16298. };
  16299. strides: {
  16300. [key: string]: number;
  16301. };
  16302. };
  16303. }
  16304. interface AbstractMesh {
  16305. /**
  16306. * Object used to store instanced buffers defined by user
  16307. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16308. */
  16309. instancedBuffers: {
  16310. [key: string]: any;
  16311. };
  16312. }
  16313. }
  16314. declare module BABYLON {
  16315. /**
  16316. * Defines the options associated with the creation of a shader material.
  16317. */
  16318. export interface IShaderMaterialOptions {
  16319. /**
  16320. * Does the material work in alpha blend mode
  16321. */
  16322. needAlphaBlending: boolean;
  16323. /**
  16324. * Does the material work in alpha test mode
  16325. */
  16326. needAlphaTesting: boolean;
  16327. /**
  16328. * The list of attribute names used in the shader
  16329. */
  16330. attributes: string[];
  16331. /**
  16332. * The list of unifrom names used in the shader
  16333. */
  16334. uniforms: string[];
  16335. /**
  16336. * The list of UBO names used in the shader
  16337. */
  16338. uniformBuffers: string[];
  16339. /**
  16340. * The list of sampler names used in the shader
  16341. */
  16342. samplers: string[];
  16343. /**
  16344. * The list of defines used in the shader
  16345. */
  16346. defines: string[];
  16347. }
  16348. /**
  16349. * 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.
  16350. *
  16351. * This returned material effects how the mesh will look based on the code in the shaders.
  16352. *
  16353. * @see https://doc.babylonjs.com/how_to/shader_material
  16354. */
  16355. export class ShaderMaterial extends Material {
  16356. private _shaderPath;
  16357. private _options;
  16358. private _textures;
  16359. private _textureArrays;
  16360. private _floats;
  16361. private _ints;
  16362. private _floatsArrays;
  16363. private _colors3;
  16364. private _colors3Arrays;
  16365. private _colors4;
  16366. private _colors4Arrays;
  16367. private _vectors2;
  16368. private _vectors3;
  16369. private _vectors4;
  16370. private _matrices;
  16371. private _matrixArrays;
  16372. private _matrices3x3;
  16373. private _matrices2x2;
  16374. private _vectors2Arrays;
  16375. private _vectors3Arrays;
  16376. private _vectors4Arrays;
  16377. private _cachedWorldViewMatrix;
  16378. private _cachedWorldViewProjectionMatrix;
  16379. private _renderId;
  16380. private _multiview;
  16381. private _cachedDefines;
  16382. /** Define the Url to load snippets */
  16383. static SnippetUrl: string;
  16384. /** Snippet ID if the material was created from the snippet server */
  16385. snippetId: string;
  16386. /**
  16387. * Instantiate a new shader material.
  16388. * 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.
  16389. * This returned material effects how the mesh will look based on the code in the shaders.
  16390. * @see https://doc.babylonjs.com/how_to/shader_material
  16391. * @param name Define the name of the material in the scene
  16392. * @param scene Define the scene the material belongs to
  16393. * @param shaderPath Defines the route to the shader code in one of three ways:
  16394. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16395. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16396. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16397. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16398. * @param options Define the options used to create the shader
  16399. */
  16400. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16401. /**
  16402. * Gets the shader path used to define the shader code
  16403. * It can be modified to trigger a new compilation
  16404. */
  16405. get shaderPath(): any;
  16406. /**
  16407. * Sets the shader path used to define the shader code
  16408. * It can be modified to trigger a new compilation
  16409. */
  16410. set shaderPath(shaderPath: any);
  16411. /**
  16412. * Gets the options used to compile the shader.
  16413. * They can be modified to trigger a new compilation
  16414. */
  16415. get options(): IShaderMaterialOptions;
  16416. /**
  16417. * Gets the current class name of the material e.g. "ShaderMaterial"
  16418. * Mainly use in serialization.
  16419. * @returns the class name
  16420. */
  16421. getClassName(): string;
  16422. /**
  16423. * Specifies if the material will require alpha blending
  16424. * @returns a boolean specifying if alpha blending is needed
  16425. */
  16426. needAlphaBlending(): boolean;
  16427. /**
  16428. * Specifies if this material should be rendered in alpha test mode
  16429. * @returns a boolean specifying if an alpha test is needed.
  16430. */
  16431. needAlphaTesting(): boolean;
  16432. private _checkUniform;
  16433. /**
  16434. * Set a texture in the shader.
  16435. * @param name Define the name of the uniform samplers as defined in the shader
  16436. * @param texture Define the texture to bind to this sampler
  16437. * @return the material itself allowing "fluent" like uniform updates
  16438. */
  16439. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16440. /**
  16441. * Set a texture array in the shader.
  16442. * @param name Define the name of the uniform sampler array as defined in the shader
  16443. * @param textures Define the list of textures to bind to this sampler
  16444. * @return the material itself allowing "fluent" like uniform updates
  16445. */
  16446. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16447. /**
  16448. * Set a float in the shader.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the material itself allowing "fluent" like uniform updates
  16452. */
  16453. setFloat(name: string, value: number): ShaderMaterial;
  16454. /**
  16455. * Set a int in the shader.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the material itself allowing "fluent" like uniform updates
  16459. */
  16460. setInt(name: string, value: number): ShaderMaterial;
  16461. /**
  16462. * Set an array of floats in the shader.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the material itself allowing "fluent" like uniform updates
  16466. */
  16467. setFloats(name: string, value: number[]): ShaderMaterial;
  16468. /**
  16469. * Set a vec3 in the shader from a Color3.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the material itself allowing "fluent" like uniform updates
  16473. */
  16474. setColor3(name: string, value: Color3): ShaderMaterial;
  16475. /**
  16476. * Set a vec3 array in the shader from a Color3 array.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the material itself allowing "fluent" like uniform updates
  16480. */
  16481. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16482. /**
  16483. * Set a vec4 in the shader from a Color4.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setColor4(name: string, value: Color4): ShaderMaterial;
  16489. /**
  16490. * Set a vec4 array in the shader from a Color4 array.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16496. /**
  16497. * Set a vec2 in the shader from a Vector2.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setVector2(name: string, value: Vector2): ShaderMaterial;
  16503. /**
  16504. * Set a vec3 in the shader from a Vector3.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setVector3(name: string, value: Vector3): ShaderMaterial;
  16510. /**
  16511. * Set a vec4 in the shader from a Vector4.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setVector4(name: string, value: Vector4): ShaderMaterial;
  16517. /**
  16518. * Set a mat4 in the shader from a Matrix.
  16519. * @param name Define the name of the uniform as defined in the shader
  16520. * @param value Define the value to give to the uniform
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16524. /**
  16525. * Set a float32Array in the shader from a matrix array.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16531. /**
  16532. * Set a mat3 in the shader from a Float32Array.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16538. /**
  16539. * Set a mat2 in the shader from a Float32Array.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16545. /**
  16546. * Set a vec2 array in the shader from a number array.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setArray2(name: string, value: number[]): ShaderMaterial;
  16552. /**
  16553. * Set a vec3 array in the shader from a number array.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setArray3(name: string, value: number[]): ShaderMaterial;
  16559. /**
  16560. * Set a vec4 array in the shader from a number array.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setArray4(name: string, value: number[]): ShaderMaterial;
  16566. private _checkCache;
  16567. /**
  16568. * Specifies that the submesh is ready to be used
  16569. * @param mesh defines the mesh to check
  16570. * @param subMesh defines which submesh to check
  16571. * @param useInstances specifies that instances should be used
  16572. * @returns a boolean indicating that the submesh is ready or not
  16573. */
  16574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16575. /**
  16576. * Checks if the material is ready to render the requested mesh
  16577. * @param mesh Define the mesh to render
  16578. * @param useInstances Define whether or not the material is used with instances
  16579. * @returns true if ready, otherwise false
  16580. */
  16581. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16582. /**
  16583. * Binds the world matrix to the material
  16584. * @param world defines the world transformation matrix
  16585. * @param effectOverride - If provided, use this effect instead of internal effect
  16586. */
  16587. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16588. /**
  16589. * Binds the submesh to this material by preparing the effect and shader to draw
  16590. * @param world defines the world transformation matrix
  16591. * @param mesh defines the mesh containing the submesh
  16592. * @param subMesh defines the submesh to bind the material to
  16593. */
  16594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16595. /**
  16596. * Binds the material to the mesh
  16597. * @param world defines the world transformation matrix
  16598. * @param mesh defines the mesh to bind the material to
  16599. * @param effectOverride - If provided, use this effect instead of internal effect
  16600. */
  16601. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16602. protected _afterBind(mesh?: Mesh): void;
  16603. /**
  16604. * Gets the active textures from the material
  16605. * @returns an array of textures
  16606. */
  16607. getActiveTextures(): BaseTexture[];
  16608. /**
  16609. * Specifies if the material uses a texture
  16610. * @param texture defines the texture to check against the material
  16611. * @returns a boolean specifying if the material uses the texture
  16612. */
  16613. hasTexture(texture: BaseTexture): boolean;
  16614. /**
  16615. * Makes a duplicate of the material, and gives it a new name
  16616. * @param name defines the new name for the duplicated material
  16617. * @returns the cloned material
  16618. */
  16619. clone(name: string): ShaderMaterial;
  16620. /**
  16621. * Disposes the material
  16622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16624. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16625. */
  16626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16627. /**
  16628. * Serializes this material in a JSON representation
  16629. * @returns the serialized material object
  16630. */
  16631. serialize(): any;
  16632. /**
  16633. * Creates a shader material from parsed shader material data
  16634. * @param source defines the JSON represnetation of the material
  16635. * @param scene defines the hosting scene
  16636. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16637. * @returns a new material
  16638. */
  16639. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16640. /**
  16641. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16642. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16643. * @param url defines the url to load from
  16644. * @param scene defines the hosting scene
  16645. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16646. * @returns a promise that will resolve to the new ShaderMaterial
  16647. */
  16648. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16649. /**
  16650. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16651. * @param snippetId defines the snippet to load
  16652. * @param scene defines the hosting scene
  16653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16654. * @returns a promise that will resolve to the new ShaderMaterial
  16655. */
  16656. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /** @hidden */
  16661. export var colorPixelShader: {
  16662. name: string;
  16663. shader: string;
  16664. };
  16665. }
  16666. declare module BABYLON {
  16667. /** @hidden */
  16668. export var colorVertexShader: {
  16669. name: string;
  16670. shader: string;
  16671. };
  16672. }
  16673. declare module BABYLON {
  16674. /**
  16675. * Line mesh
  16676. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16677. */
  16678. export class LinesMesh extends Mesh {
  16679. /**
  16680. * If vertex color should be applied to the mesh
  16681. */
  16682. readonly useVertexColor?: boolean | undefined;
  16683. /**
  16684. * If vertex alpha should be applied to the mesh
  16685. */
  16686. readonly useVertexAlpha?: boolean | undefined;
  16687. /**
  16688. * Color of the line (Default: White)
  16689. */
  16690. color: Color3;
  16691. /**
  16692. * Alpha of the line (Default: 1)
  16693. */
  16694. alpha: number;
  16695. /**
  16696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16697. * This margin is expressed in world space coordinates, so its value may vary.
  16698. * Default value is 0.1
  16699. */
  16700. intersectionThreshold: number;
  16701. private _colorShader;
  16702. private color4;
  16703. /**
  16704. * Creates a new LinesMesh
  16705. * @param name defines the name
  16706. * @param scene defines the hosting scene
  16707. * @param parent defines the parent mesh if any
  16708. * @param source defines the optional source LinesMesh used to clone data from
  16709. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16710. * When false, achieved by calling a clone(), also passing False.
  16711. * This will make creation of children, recursive.
  16712. * @param useVertexColor defines if this LinesMesh supports vertex color
  16713. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16714. */
  16715. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16716. /**
  16717. * If vertex color should be applied to the mesh
  16718. */
  16719. useVertexColor?: boolean | undefined,
  16720. /**
  16721. * If vertex alpha should be applied to the mesh
  16722. */
  16723. useVertexAlpha?: boolean | undefined);
  16724. private _addClipPlaneDefine;
  16725. private _removeClipPlaneDefine;
  16726. isReady(): boolean;
  16727. /**
  16728. * Returns the string "LineMesh"
  16729. */
  16730. getClassName(): string;
  16731. /**
  16732. * @hidden
  16733. */
  16734. get material(): Material;
  16735. /**
  16736. * @hidden
  16737. */
  16738. set material(value: Material);
  16739. /**
  16740. * @hidden
  16741. */
  16742. get checkCollisions(): boolean;
  16743. /** @hidden */
  16744. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16745. /** @hidden */
  16746. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16747. /**
  16748. * Disposes of the line mesh
  16749. * @param doNotRecurse If children should be disposed
  16750. */
  16751. dispose(doNotRecurse?: boolean): void;
  16752. /**
  16753. * Returns a new LineMesh object cloned from the current one.
  16754. */
  16755. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16756. /**
  16757. * Creates a new InstancedLinesMesh object from the mesh model.
  16758. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16759. * @param name defines the name of the new instance
  16760. * @returns a new InstancedLinesMesh
  16761. */
  16762. createInstance(name: string): InstancedLinesMesh;
  16763. }
  16764. /**
  16765. * Creates an instance based on a source LinesMesh
  16766. */
  16767. export class InstancedLinesMesh extends InstancedMesh {
  16768. /**
  16769. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16770. * This margin is expressed in world space coordinates, so its value may vary.
  16771. * Initilized with the intersectionThreshold value of the source LinesMesh
  16772. */
  16773. intersectionThreshold: number;
  16774. constructor(name: string, source: LinesMesh);
  16775. /**
  16776. * Returns the string "InstancedLinesMesh".
  16777. */
  16778. getClassName(): string;
  16779. }
  16780. }
  16781. declare module BABYLON {
  16782. /** @hidden */
  16783. export var linePixelShader: {
  16784. name: string;
  16785. shader: string;
  16786. };
  16787. }
  16788. declare module BABYLON {
  16789. /** @hidden */
  16790. export var lineVertexShader: {
  16791. name: string;
  16792. shader: string;
  16793. };
  16794. }
  16795. declare module BABYLON {
  16796. interface Scene {
  16797. /** @hidden */
  16798. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16799. }
  16800. interface AbstractMesh {
  16801. /**
  16802. * Gets the edgesRenderer associated with the mesh
  16803. */
  16804. edgesRenderer: Nullable<EdgesRenderer>;
  16805. }
  16806. interface LinesMesh {
  16807. /**
  16808. * Enables the edge rendering mode on the mesh.
  16809. * This mode makes the mesh edges visible
  16810. * @param epsilon defines the maximal distance between two angles to detect a face
  16811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16812. * @returns the currentAbstractMesh
  16813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16814. */
  16815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16816. }
  16817. interface InstancedLinesMesh {
  16818. /**
  16819. * Enables the edge rendering mode on the mesh.
  16820. * This mode makes the mesh edges visible
  16821. * @param epsilon defines the maximal distance between two angles to detect a face
  16822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16823. * @returns the current InstancedLinesMesh
  16824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16825. */
  16826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16827. }
  16828. /**
  16829. * Defines the minimum contract an Edges renderer should follow.
  16830. */
  16831. export interface IEdgesRenderer extends IDisposable {
  16832. /**
  16833. * Gets or sets a boolean indicating if the edgesRenderer is active
  16834. */
  16835. isEnabled: boolean;
  16836. /**
  16837. * Renders the edges of the attached mesh,
  16838. */
  16839. render(): void;
  16840. /**
  16841. * Checks wether or not the edges renderer is ready to render.
  16842. * @return true if ready, otherwise false.
  16843. */
  16844. isReady(): boolean;
  16845. /**
  16846. * List of instances to render in case the source mesh has instances
  16847. */
  16848. customInstances: SmartArray<Matrix>;
  16849. }
  16850. /**
  16851. * Defines the additional options of the edges renderer
  16852. */
  16853. export interface IEdgesRendererOptions {
  16854. /**
  16855. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16856. * If not defined, the default value is true
  16857. */
  16858. useAlternateEdgeFinder?: boolean;
  16859. /**
  16860. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16861. * If not defined, the default value is true.
  16862. * 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)
  16863. * This option is used only if useAlternateEdgeFinder = true
  16864. */
  16865. useFastVertexMerger?: boolean;
  16866. /**
  16867. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16868. * The default value is 1e-6
  16869. * This option is used only if useAlternateEdgeFinder = true
  16870. */
  16871. epsilonVertexMerge?: number;
  16872. /**
  16873. * 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
  16874. * 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.
  16875. * This option is used only if useAlternateEdgeFinder = true
  16876. */
  16877. applyTessellation?: boolean;
  16878. /**
  16879. * 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
  16880. * The default value is 1e-6
  16881. * This option is used only if useAlternateEdgeFinder = true
  16882. */
  16883. epsilonVertexAligned?: number;
  16884. }
  16885. /**
  16886. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16887. */
  16888. export class EdgesRenderer implements IEdgesRenderer {
  16889. /**
  16890. * Define the size of the edges with an orthographic camera
  16891. */
  16892. edgesWidthScalerForOrthographic: number;
  16893. /**
  16894. * Define the size of the edges with a perspective camera
  16895. */
  16896. edgesWidthScalerForPerspective: number;
  16897. protected _source: AbstractMesh;
  16898. protected _linesPositions: number[];
  16899. protected _linesNormals: number[];
  16900. protected _linesIndices: number[];
  16901. protected _epsilon: number;
  16902. protected _indicesCount: number;
  16903. protected _lineShader: ShaderMaterial;
  16904. protected _ib: DataBuffer;
  16905. protected _buffers: {
  16906. [key: string]: Nullable<VertexBuffer>;
  16907. };
  16908. protected _buffersForInstances: {
  16909. [key: string]: Nullable<VertexBuffer>;
  16910. };
  16911. protected _checkVerticesInsteadOfIndices: boolean;
  16912. protected _options: Nullable<IEdgesRendererOptions>;
  16913. private _meshRebuildObserver;
  16914. private _meshDisposeObserver;
  16915. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16916. isEnabled: boolean;
  16917. /**
  16918. * List of instances to render in case the source mesh has instances
  16919. */
  16920. customInstances: SmartArray<Matrix>;
  16921. private static GetShader;
  16922. /**
  16923. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16924. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16925. * @param source Mesh used to create edges
  16926. * @param epsilon sum of angles in adjacency to check for edge
  16927. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16928. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16929. * @param options The options to apply when generating the edges
  16930. */
  16931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16932. protected _prepareRessources(): void;
  16933. /** @hidden */
  16934. _rebuild(): void;
  16935. /**
  16936. * Releases the required resources for the edges renderer
  16937. */
  16938. dispose(): void;
  16939. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16940. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16941. /**
  16942. * Checks if the pair of p0 and p1 is en edge
  16943. * @param faceIndex
  16944. * @param edge
  16945. * @param faceNormals
  16946. * @param p0
  16947. * @param p1
  16948. * @private
  16949. */
  16950. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16951. /**
  16952. * push line into the position, normal and index buffer
  16953. * @protected
  16954. */
  16955. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16956. /**
  16957. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16958. */
  16959. private _tessellateTriangle;
  16960. private _generateEdgesLinesAlternate;
  16961. /**
  16962. * Generates lines edges from adjacencjes
  16963. * @private
  16964. */
  16965. _generateEdgesLines(): void;
  16966. /**
  16967. * Checks wether or not the edges renderer is ready to render.
  16968. * @return true if ready, otherwise false.
  16969. */
  16970. isReady(): boolean;
  16971. /**
  16972. * Renders the edges of the attached mesh,
  16973. */
  16974. render(): void;
  16975. }
  16976. /**
  16977. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16978. */
  16979. export class LineEdgesRenderer extends EdgesRenderer {
  16980. /**
  16981. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16982. * @param source LineMesh used to generate edges
  16983. * @param epsilon not important (specified angle for edge detection)
  16984. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16985. */
  16986. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16987. /**
  16988. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16989. */
  16990. _generateEdgesLines(): void;
  16991. }
  16992. }
  16993. declare module BABYLON {
  16994. /**
  16995. * This represents the object necessary to create a rendering group.
  16996. * This is exclusively used and created by the rendering manager.
  16997. * To modify the behavior, you use the available helpers in your scene or meshes.
  16998. * @hidden
  16999. */
  17000. export class RenderingGroup {
  17001. index: number;
  17002. private static _zeroVector;
  17003. private _scene;
  17004. private _opaqueSubMeshes;
  17005. private _transparentSubMeshes;
  17006. private _alphaTestSubMeshes;
  17007. private _depthOnlySubMeshes;
  17008. private _particleSystems;
  17009. private _spriteManagers;
  17010. private _opaqueSortCompareFn;
  17011. private _alphaTestSortCompareFn;
  17012. private _transparentSortCompareFn;
  17013. private _renderOpaque;
  17014. private _renderAlphaTest;
  17015. private _renderTransparent;
  17016. /** @hidden */
  17017. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17018. onBeforeTransparentRendering: () => void;
  17019. /**
  17020. * Set the opaque sort comparison function.
  17021. * If null the sub meshes will be render in the order they were created
  17022. */
  17023. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17024. /**
  17025. * Set the alpha test sort comparison function.
  17026. * If null the sub meshes will be render in the order they were created
  17027. */
  17028. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17029. /**
  17030. * Set the transparent sort comparison function.
  17031. * If null the sub meshes will be render in the order they were created
  17032. */
  17033. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17034. /**
  17035. * Creates a new rendering group.
  17036. * @param index The rendering group index
  17037. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17038. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17039. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17040. */
  17041. 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>);
  17042. /**
  17043. * Render all the sub meshes contained in the group.
  17044. * @param customRenderFunction Used to override the default render behaviour of the group.
  17045. * @returns true if rendered some submeshes.
  17046. */
  17047. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17048. /**
  17049. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17050. * @param subMeshes The submeshes to render
  17051. */
  17052. private renderOpaqueSorted;
  17053. /**
  17054. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17055. * @param subMeshes The submeshes to render
  17056. */
  17057. private renderAlphaTestSorted;
  17058. /**
  17059. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17060. * @param subMeshes The submeshes to render
  17061. */
  17062. private renderTransparentSorted;
  17063. /**
  17064. * Renders the submeshes in a specified order.
  17065. * @param subMeshes The submeshes to sort before render
  17066. * @param sortCompareFn The comparison function use to sort
  17067. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17068. * @param transparent Specifies to activate blending if true
  17069. */
  17070. private static renderSorted;
  17071. /**
  17072. * Renders the submeshes in the order they were dispatched (no sort applied).
  17073. * @param subMeshes The submeshes to render
  17074. */
  17075. private static renderUnsorted;
  17076. /**
  17077. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17078. * are rendered back to front if in the same alpha index.
  17079. *
  17080. * @param a The first submesh
  17081. * @param b The second submesh
  17082. * @returns The result of the comparison
  17083. */
  17084. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17085. /**
  17086. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17087. * are rendered back to front.
  17088. *
  17089. * @param a The first submesh
  17090. * @param b The second submesh
  17091. * @returns The result of the comparison
  17092. */
  17093. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17094. /**
  17095. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17096. * are rendered front to back (prevent overdraw).
  17097. *
  17098. * @param a The first submesh
  17099. * @param b The second submesh
  17100. * @returns The result of the comparison
  17101. */
  17102. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17103. /**
  17104. * Resets the different lists of submeshes to prepare a new frame.
  17105. */
  17106. prepare(): void;
  17107. dispose(): void;
  17108. /**
  17109. * Inserts the submesh in its correct queue depending on its material.
  17110. * @param subMesh The submesh to dispatch
  17111. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17112. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17113. */
  17114. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17115. dispatchSprites(spriteManager: ISpriteManager): void;
  17116. dispatchParticles(particleSystem: IParticleSystem): void;
  17117. private _renderParticles;
  17118. private _renderSprites;
  17119. }
  17120. }
  17121. declare module BABYLON {
  17122. /**
  17123. * Interface describing the different options available in the rendering manager
  17124. * regarding Auto Clear between groups.
  17125. */
  17126. export interface IRenderingManagerAutoClearSetup {
  17127. /**
  17128. * Defines whether or not autoclear is enable.
  17129. */
  17130. autoClear: boolean;
  17131. /**
  17132. * Defines whether or not to autoclear the depth buffer.
  17133. */
  17134. depth: boolean;
  17135. /**
  17136. * Defines whether or not to autoclear the stencil buffer.
  17137. */
  17138. stencil: boolean;
  17139. }
  17140. /**
  17141. * This class is used by the onRenderingGroupObservable
  17142. */
  17143. export class RenderingGroupInfo {
  17144. /**
  17145. * The Scene that being rendered
  17146. */
  17147. scene: Scene;
  17148. /**
  17149. * The camera currently used for the rendering pass
  17150. */
  17151. camera: Nullable<Camera>;
  17152. /**
  17153. * The ID of the renderingGroup being processed
  17154. */
  17155. renderingGroupId: number;
  17156. }
  17157. /**
  17158. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17159. * It is enable to manage the different groups as well as the different necessary sort functions.
  17160. * This should not be used directly aside of the few static configurations
  17161. */
  17162. export class RenderingManager {
  17163. /**
  17164. * The max id used for rendering groups (not included)
  17165. */
  17166. static MAX_RENDERINGGROUPS: number;
  17167. /**
  17168. * The min id used for rendering groups (included)
  17169. */
  17170. static MIN_RENDERINGGROUPS: number;
  17171. /**
  17172. * Used to globally prevent autoclearing scenes.
  17173. */
  17174. static AUTOCLEAR: boolean;
  17175. /**
  17176. * @hidden
  17177. */
  17178. _useSceneAutoClearSetup: boolean;
  17179. private _scene;
  17180. private _renderingGroups;
  17181. private _depthStencilBufferAlreadyCleaned;
  17182. private _autoClearDepthStencil;
  17183. private _customOpaqueSortCompareFn;
  17184. private _customAlphaTestSortCompareFn;
  17185. private _customTransparentSortCompareFn;
  17186. private _renderingGroupInfo;
  17187. /**
  17188. * Instantiates a new rendering group for a particular scene
  17189. * @param scene Defines the scene the groups belongs to
  17190. */
  17191. constructor(scene: Scene);
  17192. private _clearDepthStencilBuffer;
  17193. /**
  17194. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17195. * @hidden
  17196. */
  17197. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17198. /**
  17199. * Resets the different information of the group to prepare a new frame
  17200. * @hidden
  17201. */
  17202. reset(): void;
  17203. /**
  17204. * Dispose and release the group and its associated resources.
  17205. * @hidden
  17206. */
  17207. dispose(): void;
  17208. /**
  17209. * Clear the info related to rendering groups preventing retention points during dispose.
  17210. */
  17211. freeRenderingGroups(): void;
  17212. private _prepareRenderingGroup;
  17213. /**
  17214. * Add a sprite manager to the rendering manager in order to render it this frame.
  17215. * @param spriteManager Define the sprite manager to render
  17216. */
  17217. dispatchSprites(spriteManager: ISpriteManager): void;
  17218. /**
  17219. * Add a particle system to the rendering manager in order to render it this frame.
  17220. * @param particleSystem Define the particle system to render
  17221. */
  17222. dispatchParticles(particleSystem: IParticleSystem): void;
  17223. /**
  17224. * Add a submesh to the manager in order to render it this frame
  17225. * @param subMesh The submesh to dispatch
  17226. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17227. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17228. */
  17229. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17230. /**
  17231. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17232. * This allowed control for front to back rendering or reversly depending of the special needs.
  17233. *
  17234. * @param renderingGroupId The rendering group id corresponding to its index
  17235. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17236. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17237. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17238. */
  17239. 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;
  17240. /**
  17241. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17242. *
  17243. * @param renderingGroupId The rendering group id corresponding to its index
  17244. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17245. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17246. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17247. */
  17248. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17249. /**
  17250. * Gets the current auto clear configuration for one rendering group of the rendering
  17251. * manager.
  17252. * @param index the rendering group index to get the information for
  17253. * @returns The auto clear setup for the requested rendering group
  17254. */
  17255. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17256. }
  17257. }
  17258. declare module BABYLON {
  17259. /**
  17260. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17261. */
  17262. export interface ICustomShaderOptions {
  17263. /**
  17264. * Gets or sets the custom shader name to use
  17265. */
  17266. shaderName: string;
  17267. /**
  17268. * The list of attribute names used in the shader
  17269. */
  17270. attributes?: string[];
  17271. /**
  17272. * The list of unifrom names used in the shader
  17273. */
  17274. uniforms?: string[];
  17275. /**
  17276. * The list of sampler names used in the shader
  17277. */
  17278. samplers?: string[];
  17279. /**
  17280. * The list of defines used in the shader
  17281. */
  17282. defines?: string[];
  17283. }
  17284. /**
  17285. * Interface to implement to create a shadow generator compatible with BJS.
  17286. */
  17287. export interface IShadowGenerator {
  17288. /**
  17289. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17290. * @returns The render target texture if present otherwise, null
  17291. */
  17292. getShadowMap(): Nullable<RenderTargetTexture>;
  17293. /**
  17294. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17295. * @param subMesh The submesh we want to render in the shadow map
  17296. * @param useInstances Defines wether will draw in the map using instances
  17297. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17298. * @returns true if ready otherwise, false
  17299. */
  17300. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17301. /**
  17302. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17303. * @param defines Defines of the material we want to update
  17304. * @param lightIndex Index of the light in the enabled light list of the material
  17305. */
  17306. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17307. /**
  17308. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17309. * defined in the generator but impacting the effect).
  17310. * It implies the unifroms available on the materials are the standard BJS ones.
  17311. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17312. * @param effect The effect we are binfing the information for
  17313. */
  17314. bindShadowLight(lightIndex: string, effect: Effect): void;
  17315. /**
  17316. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17317. * (eq to shadow prjection matrix * light transform matrix)
  17318. * @returns The transform matrix used to create the shadow map
  17319. */
  17320. getTransformMatrix(): Matrix;
  17321. /**
  17322. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17323. * Cube and 2D textures for instance.
  17324. */
  17325. recreateShadowMap(): void;
  17326. /**
  17327. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17328. * @param onCompiled Callback triggered at the and of the effects compilation
  17329. * @param options Sets of optional options forcing the compilation with different modes
  17330. */
  17331. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17332. useInstances: boolean;
  17333. }>): void;
  17334. /**
  17335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17336. * @param options Sets of optional options forcing the compilation with different modes
  17337. * @returns A promise that resolves when the compilation completes
  17338. */
  17339. forceCompilationAsync(options?: Partial<{
  17340. useInstances: boolean;
  17341. }>): Promise<void>;
  17342. /**
  17343. * Serializes the shadow generator setup to a json object.
  17344. * @returns The serialized JSON object
  17345. */
  17346. serialize(): any;
  17347. /**
  17348. * Disposes the Shadow map and related Textures and effects.
  17349. */
  17350. dispose(): void;
  17351. }
  17352. /**
  17353. * Default implementation IShadowGenerator.
  17354. * This is the main object responsible of generating shadows in the framework.
  17355. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17356. */
  17357. export class ShadowGenerator implements IShadowGenerator {
  17358. /**
  17359. * Name of the shadow generator class
  17360. */
  17361. static CLASSNAME: string;
  17362. /**
  17363. * Shadow generator mode None: no filtering applied.
  17364. */
  17365. static readonly FILTER_NONE: number;
  17366. /**
  17367. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17368. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17369. */
  17370. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17371. /**
  17372. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17373. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17374. */
  17375. static readonly FILTER_POISSONSAMPLING: number;
  17376. /**
  17377. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17379. */
  17380. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17381. /**
  17382. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17383. * edge artifacts on steep falloff.
  17384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17385. */
  17386. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17387. /**
  17388. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17389. * edge artifacts on steep falloff.
  17390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17391. */
  17392. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17393. /**
  17394. * Shadow generator mode PCF: Percentage Closer Filtering
  17395. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17396. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17397. */
  17398. static readonly FILTER_PCF: number;
  17399. /**
  17400. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17401. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17402. * Contact Hardening
  17403. */
  17404. static readonly FILTER_PCSS: number;
  17405. /**
  17406. * Reserved for PCF and PCSS
  17407. * Highest Quality.
  17408. *
  17409. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17410. *
  17411. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17412. */
  17413. static readonly QUALITY_HIGH: number;
  17414. /**
  17415. * Reserved for PCF and PCSS
  17416. * Good tradeoff for quality/perf cross devices
  17417. *
  17418. * Execute PCF on a 3*3 kernel.
  17419. *
  17420. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17421. */
  17422. static readonly QUALITY_MEDIUM: number;
  17423. /**
  17424. * Reserved for PCF and PCSS
  17425. * The lowest quality but the fastest.
  17426. *
  17427. * Execute PCF on a 1*1 kernel.
  17428. *
  17429. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17430. */
  17431. static readonly QUALITY_LOW: number;
  17432. /** Gets or sets the custom shader name to use */
  17433. customShaderOptions: ICustomShaderOptions;
  17434. /**
  17435. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17436. */
  17437. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17438. /**
  17439. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17440. */
  17441. onAfterShadowMapRenderObservable: Observable<Effect>;
  17442. /**
  17443. * Observable triggered before a mesh is rendered in the shadow map.
  17444. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17445. */
  17446. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17447. /**
  17448. * Observable triggered after a mesh is rendered in the shadow map.
  17449. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17450. */
  17451. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17452. protected _bias: number;
  17453. /**
  17454. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17455. */
  17456. get bias(): number;
  17457. /**
  17458. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17459. */
  17460. set bias(bias: number);
  17461. protected _normalBias: number;
  17462. /**
  17463. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17464. */
  17465. get normalBias(): number;
  17466. /**
  17467. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17468. */
  17469. set normalBias(normalBias: number);
  17470. protected _blurBoxOffset: number;
  17471. /**
  17472. * Gets the blur box offset: offset applied during the blur pass.
  17473. * Only useful if useKernelBlur = false
  17474. */
  17475. get blurBoxOffset(): number;
  17476. /**
  17477. * Sets the blur box offset: offset applied during the blur pass.
  17478. * Only useful if useKernelBlur = false
  17479. */
  17480. set blurBoxOffset(value: number);
  17481. protected _blurScale: number;
  17482. /**
  17483. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17484. * 2 means half of the size.
  17485. */
  17486. get blurScale(): number;
  17487. /**
  17488. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17489. * 2 means half of the size.
  17490. */
  17491. set blurScale(value: number);
  17492. protected _blurKernel: number;
  17493. /**
  17494. * Gets the blur kernel: kernel size of the blur pass.
  17495. * Only useful if useKernelBlur = true
  17496. */
  17497. get blurKernel(): number;
  17498. /**
  17499. * Sets the blur kernel: kernel size of the blur pass.
  17500. * Only useful if useKernelBlur = true
  17501. */
  17502. set blurKernel(value: number);
  17503. protected _useKernelBlur: boolean;
  17504. /**
  17505. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17506. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17507. */
  17508. get useKernelBlur(): boolean;
  17509. /**
  17510. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17512. */
  17513. set useKernelBlur(value: boolean);
  17514. protected _depthScale: number;
  17515. /**
  17516. * Gets the depth scale used in ESM mode.
  17517. */
  17518. get depthScale(): number;
  17519. /**
  17520. * Sets the depth scale used in ESM mode.
  17521. * This can override the scale stored on the light.
  17522. */
  17523. set depthScale(value: number);
  17524. protected _validateFilter(filter: number): number;
  17525. protected _filter: number;
  17526. /**
  17527. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17529. */
  17530. get filter(): number;
  17531. /**
  17532. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17533. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17534. */
  17535. set filter(value: number);
  17536. /**
  17537. * Gets if the current filter is set to Poisson Sampling.
  17538. */
  17539. get usePoissonSampling(): boolean;
  17540. /**
  17541. * Sets the current filter to Poisson Sampling.
  17542. */
  17543. set usePoissonSampling(value: boolean);
  17544. /**
  17545. * Gets if the current filter is set to ESM.
  17546. */
  17547. get useExponentialShadowMap(): boolean;
  17548. /**
  17549. * Sets the current filter is to ESM.
  17550. */
  17551. set useExponentialShadowMap(value: boolean);
  17552. /**
  17553. * Gets if the current filter is set to filtered ESM.
  17554. */
  17555. get useBlurExponentialShadowMap(): boolean;
  17556. /**
  17557. * Gets if the current filter is set to filtered ESM.
  17558. */
  17559. set useBlurExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17562. * exponential to prevent steep falloff artifacts).
  17563. */
  17564. get useCloseExponentialShadowMap(): boolean;
  17565. /**
  17566. * Sets the current filter to "close ESM" (using the inverse of the
  17567. * exponential to prevent steep falloff artifacts).
  17568. */
  17569. set useCloseExponentialShadowMap(value: boolean);
  17570. /**
  17571. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17572. * exponential to prevent steep falloff artifacts).
  17573. */
  17574. get useBlurCloseExponentialShadowMap(): boolean;
  17575. /**
  17576. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17577. * exponential to prevent steep falloff artifacts).
  17578. */
  17579. set useBlurCloseExponentialShadowMap(value: boolean);
  17580. /**
  17581. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17582. */
  17583. get usePercentageCloserFiltering(): boolean;
  17584. /**
  17585. * Sets the current filter to "PCF" (percentage closer filtering).
  17586. */
  17587. set usePercentageCloserFiltering(value: boolean);
  17588. protected _filteringQuality: number;
  17589. /**
  17590. * Gets the PCF or PCSS Quality.
  17591. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17592. */
  17593. get filteringQuality(): number;
  17594. /**
  17595. * Sets the PCF or PCSS Quality.
  17596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17597. */
  17598. set filteringQuality(filteringQuality: number);
  17599. /**
  17600. * Gets if the current filter is set to "PCSS" (contact hardening).
  17601. */
  17602. get useContactHardeningShadow(): boolean;
  17603. /**
  17604. * Sets the current filter to "PCSS" (contact hardening).
  17605. */
  17606. set useContactHardeningShadow(value: boolean);
  17607. protected _contactHardeningLightSizeUVRatio: number;
  17608. /**
  17609. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17610. * Using a ratio helps keeping shape stability independently of the map size.
  17611. *
  17612. * It does not account for the light projection as it was having too much
  17613. * instability during the light setup or during light position changes.
  17614. *
  17615. * Only valid if useContactHardeningShadow is true.
  17616. */
  17617. get contactHardeningLightSizeUVRatio(): number;
  17618. /**
  17619. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17620. * Using a ratio helps keeping shape stability independently of the map size.
  17621. *
  17622. * It does not account for the light projection as it was having too much
  17623. * instability during the light setup or during light position changes.
  17624. *
  17625. * Only valid if useContactHardeningShadow is true.
  17626. */
  17627. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17628. protected _darkness: number;
  17629. /** Gets or sets the actual darkness of a shadow */
  17630. get darkness(): number;
  17631. set darkness(value: number);
  17632. /**
  17633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17634. * 0 means strongest and 1 would means no shadow.
  17635. * @returns the darkness.
  17636. */
  17637. getDarkness(): number;
  17638. /**
  17639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17641. * @returns the shadow generator allowing fluent coding.
  17642. */
  17643. setDarkness(darkness: number): ShadowGenerator;
  17644. protected _transparencyShadow: boolean;
  17645. /** Gets or sets the ability to have transparent shadow */
  17646. get transparencyShadow(): boolean;
  17647. set transparencyShadow(value: boolean);
  17648. /**
  17649. * Sets the ability to have transparent shadow (boolean).
  17650. * @param transparent True if transparent else False
  17651. * @returns the shadow generator allowing fluent coding
  17652. */
  17653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17654. /**
  17655. * Enables or disables shadows with varying strength based on the transparency
  17656. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17657. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17658. * mesh.visibility * alphaTexture.a
  17659. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17660. */
  17661. enableSoftTransparentShadow: boolean;
  17662. protected _shadowMap: Nullable<RenderTargetTexture>;
  17663. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17664. /**
  17665. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17666. * @returns The render target texture if present otherwise, null
  17667. */
  17668. getShadowMap(): Nullable<RenderTargetTexture>;
  17669. /**
  17670. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17671. * @returns The render target texture if the shadow map is present otherwise, null
  17672. */
  17673. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17674. /**
  17675. * Gets the class name of that object
  17676. * @returns "ShadowGenerator"
  17677. */
  17678. getClassName(): string;
  17679. /**
  17680. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17681. * @param mesh Mesh to add
  17682. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17683. * @returns the Shadow Generator itself
  17684. */
  17685. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17686. /**
  17687. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17688. * @param mesh Mesh to remove
  17689. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17690. * @returns the Shadow Generator itself
  17691. */
  17692. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17693. /**
  17694. * Controls the extent to which the shadows fade out at the edge of the frustum
  17695. */
  17696. frustumEdgeFalloff: number;
  17697. protected _light: IShadowLight;
  17698. /**
  17699. * Returns the associated light object.
  17700. * @returns the light generating the shadow
  17701. */
  17702. getLight(): IShadowLight;
  17703. /**
  17704. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17705. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17706. * It might on the other hand introduce peter panning.
  17707. */
  17708. forceBackFacesOnly: boolean;
  17709. protected _scene: Scene;
  17710. protected _lightDirection: Vector3;
  17711. protected _effect: Effect;
  17712. protected _viewMatrix: Matrix;
  17713. protected _projectionMatrix: Matrix;
  17714. protected _transformMatrix: Matrix;
  17715. protected _cachedPosition: Vector3;
  17716. protected _cachedDirection: Vector3;
  17717. protected _cachedDefines: string;
  17718. protected _currentRenderID: number;
  17719. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17720. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17721. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17722. protected _blurPostProcesses: PostProcess[];
  17723. protected _mapSize: number;
  17724. protected _currentFaceIndex: number;
  17725. protected _currentFaceIndexCache: number;
  17726. protected _textureType: number;
  17727. protected _defaultTextureMatrix: Matrix;
  17728. protected _storedUniqueId: Nullable<number>;
  17729. /** @hidden */
  17730. static _SceneComponentInitialization: (scene: Scene) => void;
  17731. /**
  17732. * Creates a ShadowGenerator object.
  17733. * A ShadowGenerator is the required tool to use the shadows.
  17734. * Each light casting shadows needs to use its own ShadowGenerator.
  17735. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17736. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17737. * @param light The light object generating the shadows.
  17738. * @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.
  17739. */
  17740. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17741. protected _initializeGenerator(): void;
  17742. protected _createTargetRenderTexture(): void;
  17743. protected _initializeShadowMap(): void;
  17744. protected _initializeBlurRTTAndPostProcesses(): void;
  17745. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17746. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17747. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17748. protected _applyFilterValues(): void;
  17749. /**
  17750. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17751. * @param onCompiled Callback triggered at the and of the effects compilation
  17752. * @param options Sets of optional options forcing the compilation with different modes
  17753. */
  17754. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17755. useInstances: boolean;
  17756. }>): void;
  17757. /**
  17758. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17759. * @param options Sets of optional options forcing the compilation with different modes
  17760. * @returns A promise that resolves when the compilation completes
  17761. */
  17762. forceCompilationAsync(options?: Partial<{
  17763. useInstances: boolean;
  17764. }>): Promise<void>;
  17765. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17766. private _prepareShadowDefines;
  17767. /**
  17768. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17769. * @param subMesh The submesh we want to render in the shadow map
  17770. * @param useInstances Defines wether will draw in the map using instances
  17771. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17772. * @returns true if ready otherwise, false
  17773. */
  17774. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17775. /**
  17776. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17777. * @param defines Defines of the material we want to update
  17778. * @param lightIndex Index of the light in the enabled light list of the material
  17779. */
  17780. prepareDefines(defines: any, lightIndex: number): void;
  17781. /**
  17782. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17783. * defined in the generator but impacting the effect).
  17784. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17785. * @param effect The effect we are binfing the information for
  17786. */
  17787. bindShadowLight(lightIndex: string, effect: Effect): void;
  17788. /**
  17789. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17790. * (eq to shadow prjection matrix * light transform matrix)
  17791. * @returns The transform matrix used to create the shadow map
  17792. */
  17793. getTransformMatrix(): Matrix;
  17794. /**
  17795. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17796. * Cube and 2D textures for instance.
  17797. */
  17798. recreateShadowMap(): void;
  17799. protected _disposeBlurPostProcesses(): void;
  17800. protected _disposeRTTandPostProcesses(): void;
  17801. /**
  17802. * Disposes the ShadowGenerator.
  17803. * Returns nothing.
  17804. */
  17805. dispose(): void;
  17806. /**
  17807. * Serializes the shadow generator setup to a json object.
  17808. * @returns The serialized JSON object
  17809. */
  17810. serialize(): any;
  17811. /**
  17812. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17813. * @param parsedShadowGenerator The JSON object to parse
  17814. * @param scene The scene to create the shadow map for
  17815. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17816. * @returns The parsed shadow generator
  17817. */
  17818. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17819. }
  17820. }
  17821. declare module BABYLON {
  17822. /**
  17823. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17824. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17825. * 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.
  17826. */
  17827. export abstract class Light extends Node {
  17828. /**
  17829. * Falloff Default: light is falling off following the material specification:
  17830. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17831. */
  17832. static readonly FALLOFF_DEFAULT: number;
  17833. /**
  17834. * Falloff Physical: light is falling off following the inverse squared distance law.
  17835. */
  17836. static readonly FALLOFF_PHYSICAL: number;
  17837. /**
  17838. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17839. * to enhance interoperability with other engines.
  17840. */
  17841. static readonly FALLOFF_GLTF: number;
  17842. /**
  17843. * Falloff Standard: light is falling off like in the standard material
  17844. * to enhance interoperability with other materials.
  17845. */
  17846. static readonly FALLOFF_STANDARD: number;
  17847. /**
  17848. * If every light affecting the material is in this lightmapMode,
  17849. * material.lightmapTexture adds or multiplies
  17850. * (depends on material.useLightmapAsShadowmap)
  17851. * after every other light calculations.
  17852. */
  17853. static readonly LIGHTMAP_DEFAULT: number;
  17854. /**
  17855. * material.lightmapTexture as only diffuse lighting from this light
  17856. * adds only specular lighting from this light
  17857. * adds dynamic shadows
  17858. */
  17859. static readonly LIGHTMAP_SPECULAR: number;
  17860. /**
  17861. * material.lightmapTexture as only lighting
  17862. * no light calculation from this light
  17863. * only adds dynamic shadows from this light
  17864. */
  17865. static readonly LIGHTMAP_SHADOWSONLY: number;
  17866. /**
  17867. * Each light type uses the default quantity according to its type:
  17868. * point/spot lights use luminous intensity
  17869. * directional lights use illuminance
  17870. */
  17871. static readonly INTENSITYMODE_AUTOMATIC: number;
  17872. /**
  17873. * lumen (lm)
  17874. */
  17875. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17876. /**
  17877. * candela (lm/sr)
  17878. */
  17879. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17880. /**
  17881. * lux (lm/m^2)
  17882. */
  17883. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17884. /**
  17885. * nit (cd/m^2)
  17886. */
  17887. static readonly INTENSITYMODE_LUMINANCE: number;
  17888. /**
  17889. * Light type const id of the point light.
  17890. */
  17891. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17892. /**
  17893. * Light type const id of the directional light.
  17894. */
  17895. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17896. /**
  17897. * Light type const id of the spot light.
  17898. */
  17899. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17900. /**
  17901. * Light type const id of the hemispheric light.
  17902. */
  17903. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17904. /**
  17905. * Diffuse gives the basic color to an object.
  17906. */
  17907. diffuse: Color3;
  17908. /**
  17909. * Specular produces a highlight color on an object.
  17910. * Note: This is note affecting PBR materials.
  17911. */
  17912. specular: Color3;
  17913. /**
  17914. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17915. * falling off base on range or angle.
  17916. * This can be set to any values in Light.FALLOFF_x.
  17917. *
  17918. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17919. * other types of materials.
  17920. */
  17921. falloffType: number;
  17922. /**
  17923. * Strength of the light.
  17924. * Note: By default it is define in the framework own unit.
  17925. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17926. */
  17927. intensity: number;
  17928. private _range;
  17929. protected _inverseSquaredRange: number;
  17930. /**
  17931. * Defines how far from the source the light is impacting in scene units.
  17932. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17933. */
  17934. get range(): number;
  17935. /**
  17936. * Defines how far from the source the light is impacting in scene units.
  17937. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17938. */
  17939. set range(value: number);
  17940. /**
  17941. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17942. * of light.
  17943. */
  17944. private _photometricScale;
  17945. private _intensityMode;
  17946. /**
  17947. * Gets the photometric scale used to interpret the intensity.
  17948. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17949. */
  17950. get intensityMode(): number;
  17951. /**
  17952. * Sets the photometric scale used to interpret the intensity.
  17953. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17954. */
  17955. set intensityMode(value: number);
  17956. private _radius;
  17957. /**
  17958. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17959. */
  17960. get radius(): number;
  17961. /**
  17962. * sets the light radius used by PBR Materials to simulate soft area lights.
  17963. */
  17964. set radius(value: number);
  17965. private _renderPriority;
  17966. /**
  17967. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17968. * exceeding the number allowed of the materials.
  17969. */
  17970. renderPriority: number;
  17971. private _shadowEnabled;
  17972. /**
  17973. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17974. * the current shadow generator.
  17975. */
  17976. get shadowEnabled(): boolean;
  17977. /**
  17978. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17979. * the current shadow generator.
  17980. */
  17981. set shadowEnabled(value: boolean);
  17982. private _includedOnlyMeshes;
  17983. /**
  17984. * Gets the only meshes impacted by this light.
  17985. */
  17986. get includedOnlyMeshes(): AbstractMesh[];
  17987. /**
  17988. * Sets the only meshes impacted by this light.
  17989. */
  17990. set includedOnlyMeshes(value: AbstractMesh[]);
  17991. private _excludedMeshes;
  17992. /**
  17993. * Gets the meshes not impacted by this light.
  17994. */
  17995. get excludedMeshes(): AbstractMesh[];
  17996. /**
  17997. * Sets the meshes not impacted by this light.
  17998. */
  17999. set excludedMeshes(value: AbstractMesh[]);
  18000. private _excludeWithLayerMask;
  18001. /**
  18002. * Gets the layer id use to find what meshes are not impacted by the light.
  18003. * Inactive if 0
  18004. */
  18005. get excludeWithLayerMask(): number;
  18006. /**
  18007. * Sets the layer id use to find what meshes are not impacted by the light.
  18008. * Inactive if 0
  18009. */
  18010. set excludeWithLayerMask(value: number);
  18011. private _includeOnlyWithLayerMask;
  18012. /**
  18013. * Gets the layer id use to find what meshes are impacted by the light.
  18014. * Inactive if 0
  18015. */
  18016. get includeOnlyWithLayerMask(): number;
  18017. /**
  18018. * Sets the layer id use to find what meshes are impacted by the light.
  18019. * Inactive if 0
  18020. */
  18021. set includeOnlyWithLayerMask(value: number);
  18022. private _lightmapMode;
  18023. /**
  18024. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18025. */
  18026. get lightmapMode(): number;
  18027. /**
  18028. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18029. */
  18030. set lightmapMode(value: number);
  18031. /**
  18032. * Shadow generator associted to the light.
  18033. * @hidden Internal use only.
  18034. */
  18035. _shadowGenerator: Nullable<IShadowGenerator>;
  18036. /**
  18037. * @hidden Internal use only.
  18038. */
  18039. _excludedMeshesIds: string[];
  18040. /**
  18041. * @hidden Internal use only.
  18042. */
  18043. _includedOnlyMeshesIds: string[];
  18044. /**
  18045. * The current light unifom buffer.
  18046. * @hidden Internal use only.
  18047. */
  18048. _uniformBuffer: UniformBuffer;
  18049. /** @hidden */
  18050. _renderId: number;
  18051. /**
  18052. * Creates a Light object in the scene.
  18053. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18054. * @param name The firendly name of the light
  18055. * @param scene The scene the light belongs too
  18056. */
  18057. constructor(name: string, scene: Scene);
  18058. protected abstract _buildUniformLayout(): void;
  18059. /**
  18060. * Sets the passed Effect "effect" with the Light information.
  18061. * @param effect The effect to update
  18062. * @param lightIndex The index of the light in the effect to update
  18063. * @returns The light
  18064. */
  18065. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18066. /**
  18067. * Sets the passed Effect "effect" with the Light textures.
  18068. * @param effect The effect to update
  18069. * @param lightIndex The index of the light in the effect to update
  18070. * @returns The light
  18071. */
  18072. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18073. /**
  18074. * Binds the lights information from the scene to the effect for the given mesh.
  18075. * @param lightIndex Light index
  18076. * @param scene The scene where the light belongs to
  18077. * @param effect The effect we are binding the data to
  18078. * @param useSpecular Defines if specular is supported
  18079. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18080. */
  18081. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18082. /**
  18083. * Sets the passed Effect "effect" with the Light information.
  18084. * @param effect The effect to update
  18085. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18086. * @returns The light
  18087. */
  18088. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18089. /**
  18090. * Returns the string "Light".
  18091. * @returns the class name
  18092. */
  18093. getClassName(): string;
  18094. /** @hidden */
  18095. readonly _isLight: boolean;
  18096. /**
  18097. * Converts the light information to a readable string for debug purpose.
  18098. * @param fullDetails Supports for multiple levels of logging within scene loading
  18099. * @returns the human readable light info
  18100. */
  18101. toString(fullDetails?: boolean): string;
  18102. /** @hidden */
  18103. protected _syncParentEnabledState(): void;
  18104. /**
  18105. * Set the enabled state of this node.
  18106. * @param value - the new enabled state
  18107. */
  18108. setEnabled(value: boolean): void;
  18109. /**
  18110. * Returns the Light associated shadow generator if any.
  18111. * @return the associated shadow generator.
  18112. */
  18113. getShadowGenerator(): Nullable<IShadowGenerator>;
  18114. /**
  18115. * Returns a Vector3, the absolute light position in the World.
  18116. * @returns the world space position of the light
  18117. */
  18118. getAbsolutePosition(): Vector3;
  18119. /**
  18120. * Specifies if the light will affect the passed mesh.
  18121. * @param mesh The mesh to test against the light
  18122. * @return true the mesh is affected otherwise, false.
  18123. */
  18124. canAffectMesh(mesh: AbstractMesh): boolean;
  18125. /**
  18126. * Sort function to order lights for rendering.
  18127. * @param a First Light object to compare to second.
  18128. * @param b Second Light object to compare first.
  18129. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18130. */
  18131. static CompareLightsPriority(a: Light, b: Light): number;
  18132. /**
  18133. * Releases resources associated with this node.
  18134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18136. */
  18137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18138. /**
  18139. * Returns the light type ID (integer).
  18140. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18141. */
  18142. getTypeID(): number;
  18143. /**
  18144. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18145. * @returns the scaled intensity in intensity mode unit
  18146. */
  18147. getScaledIntensity(): number;
  18148. /**
  18149. * Returns a new Light object, named "name", from the current one.
  18150. * @param name The name of the cloned light
  18151. * @param newParent The parent of this light, if it has one
  18152. * @returns the new created light
  18153. */
  18154. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18155. /**
  18156. * Serializes the current light into a Serialization object.
  18157. * @returns the serialized object.
  18158. */
  18159. serialize(): any;
  18160. /**
  18161. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18162. * This new light is named "name" and added to the passed scene.
  18163. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18164. * @param name The friendly name of the light
  18165. * @param scene The scene the new light will belong to
  18166. * @returns the constructor function
  18167. */
  18168. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18169. /**
  18170. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18171. * @param parsedLight The JSON representation of the light
  18172. * @param scene The scene to create the parsed light in
  18173. * @returns the created light after parsing
  18174. */
  18175. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18176. private _hookArrayForExcluded;
  18177. private _hookArrayForIncludedOnly;
  18178. private _resyncMeshes;
  18179. /**
  18180. * Forces the meshes to update their light related information in their rendering used effects
  18181. * @hidden Internal Use Only
  18182. */
  18183. _markMeshesAsLightDirty(): void;
  18184. /**
  18185. * Recomputes the cached photometric scale if needed.
  18186. */
  18187. private _computePhotometricScale;
  18188. /**
  18189. * Returns the Photometric Scale according to the light type and intensity mode.
  18190. */
  18191. private _getPhotometricScale;
  18192. /**
  18193. * Reorder the light in the scene according to their defined priority.
  18194. * @hidden Internal Use Only
  18195. */
  18196. _reorderLightsInScene(): void;
  18197. /**
  18198. * Prepares the list of defines specific to the light type.
  18199. * @param defines the list of defines
  18200. * @param lightIndex defines the index of the light for the effect
  18201. */
  18202. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18203. }
  18204. }
  18205. declare module BABYLON {
  18206. /**
  18207. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18208. * This is the base of the follow, arc rotate cameras and Free camera
  18209. * @see https://doc.babylonjs.com/features/cameras
  18210. */
  18211. export class TargetCamera extends Camera {
  18212. private static _RigCamTransformMatrix;
  18213. private static _TargetTransformMatrix;
  18214. private static _TargetFocalPoint;
  18215. private _tmpUpVector;
  18216. private _tmpTargetVector;
  18217. /**
  18218. * Define the current direction the camera is moving to
  18219. */
  18220. cameraDirection: Vector3;
  18221. /**
  18222. * Define the current rotation the camera is rotating to
  18223. */
  18224. cameraRotation: Vector2;
  18225. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18226. ignoreParentScaling: boolean;
  18227. /**
  18228. * When set, the up vector of the camera will be updated by the rotation of the camera
  18229. */
  18230. updateUpVectorFromRotation: boolean;
  18231. private _tmpQuaternion;
  18232. /**
  18233. * Define the current rotation of the camera
  18234. */
  18235. rotation: Vector3;
  18236. /**
  18237. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18238. */
  18239. rotationQuaternion: Quaternion;
  18240. /**
  18241. * Define the current speed of the camera
  18242. */
  18243. speed: number;
  18244. /**
  18245. * Add constraint to the camera to prevent it to move freely in all directions and
  18246. * around all axis.
  18247. */
  18248. noRotationConstraint: boolean;
  18249. /**
  18250. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18251. * panning
  18252. */
  18253. invertRotation: boolean;
  18254. /**
  18255. * Speed multiplier for inverse camera panning
  18256. */
  18257. inverseRotationSpeed: number;
  18258. /**
  18259. * Define the current target of the camera as an object or a position.
  18260. */
  18261. lockedTarget: any;
  18262. /** @hidden */
  18263. _currentTarget: Vector3;
  18264. /** @hidden */
  18265. _initialFocalDistance: number;
  18266. /** @hidden */
  18267. _viewMatrix: Matrix;
  18268. /** @hidden */
  18269. _camMatrix: Matrix;
  18270. /** @hidden */
  18271. _cameraTransformMatrix: Matrix;
  18272. /** @hidden */
  18273. _cameraRotationMatrix: Matrix;
  18274. /** @hidden */
  18275. _referencePoint: Vector3;
  18276. /** @hidden */
  18277. _transformedReferencePoint: Vector3;
  18278. /** @hidden */
  18279. _reset: () => void;
  18280. private _defaultUp;
  18281. /**
  18282. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18283. * This is the base of the follow, arc rotate cameras and Free camera
  18284. * @see https://doc.babylonjs.com/features/cameras
  18285. * @param name Defines the name of the camera in the scene
  18286. * @param position Defines the start position of the camera in the scene
  18287. * @param scene Defines the scene the camera belongs to
  18288. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18289. */
  18290. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18291. /**
  18292. * Gets the position in front of the camera at a given distance.
  18293. * @param distance The distance from the camera we want the position to be
  18294. * @returns the position
  18295. */
  18296. getFrontPosition(distance: number): Vector3;
  18297. /** @hidden */
  18298. _getLockedTargetPosition(): Nullable<Vector3>;
  18299. private _storedPosition;
  18300. private _storedRotation;
  18301. private _storedRotationQuaternion;
  18302. /**
  18303. * Store current camera state of the camera (fov, position, rotation, etc..)
  18304. * @returns the camera
  18305. */
  18306. storeState(): Camera;
  18307. /**
  18308. * Restored camera state. You must call storeState() first
  18309. * @returns whether it was successful or not
  18310. * @hidden
  18311. */
  18312. _restoreStateValues(): boolean;
  18313. /** @hidden */
  18314. _initCache(): void;
  18315. /** @hidden */
  18316. _updateCache(ignoreParentClass?: boolean): void;
  18317. /** @hidden */
  18318. _isSynchronizedViewMatrix(): boolean;
  18319. /** @hidden */
  18320. _computeLocalCameraSpeed(): number;
  18321. /**
  18322. * Defines the target the camera should look at.
  18323. * @param target Defines the new target as a Vector or a mesh
  18324. */
  18325. setTarget(target: Vector3): void;
  18326. /**
  18327. * Return the current target position of the camera. This value is expressed in local space.
  18328. * @returns the target position
  18329. */
  18330. getTarget(): Vector3;
  18331. /** @hidden */
  18332. _decideIfNeedsToMove(): boolean;
  18333. /** @hidden */
  18334. _updatePosition(): void;
  18335. /** @hidden */
  18336. _checkInputs(): void;
  18337. protected _updateCameraRotationMatrix(): void;
  18338. /**
  18339. * 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)
  18340. * @returns the current camera
  18341. */
  18342. private _rotateUpVectorWithCameraRotationMatrix;
  18343. private _cachedRotationZ;
  18344. private _cachedQuaternionRotationZ;
  18345. /** @hidden */
  18346. _getViewMatrix(): Matrix;
  18347. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18348. /**
  18349. * @hidden
  18350. */
  18351. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18352. /**
  18353. * @hidden
  18354. */
  18355. _updateRigCameras(): void;
  18356. private _getRigCamPositionAndTarget;
  18357. /**
  18358. * Gets the current object class name.
  18359. * @return the class name
  18360. */
  18361. getClassName(): string;
  18362. }
  18363. }
  18364. declare module BABYLON {
  18365. /**
  18366. * Gather the list of keyboard event types as constants.
  18367. */
  18368. export class KeyboardEventTypes {
  18369. /**
  18370. * The keydown event is fired when a key becomes active (pressed).
  18371. */
  18372. static readonly KEYDOWN: number;
  18373. /**
  18374. * The keyup event is fired when a key has been released.
  18375. */
  18376. static readonly KEYUP: number;
  18377. }
  18378. /**
  18379. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18380. */
  18381. export class KeyboardInfo {
  18382. /**
  18383. * Defines the type of event (KeyboardEventTypes)
  18384. */
  18385. type: number;
  18386. /**
  18387. * Defines the related dom event
  18388. */
  18389. event: KeyboardEvent;
  18390. /**
  18391. * Instantiates a new keyboard info.
  18392. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18393. * @param type Defines the type of event (KeyboardEventTypes)
  18394. * @param event Defines the related dom event
  18395. */
  18396. constructor(
  18397. /**
  18398. * Defines the type of event (KeyboardEventTypes)
  18399. */
  18400. type: number,
  18401. /**
  18402. * Defines the related dom event
  18403. */
  18404. event: KeyboardEvent);
  18405. }
  18406. /**
  18407. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18408. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18409. */
  18410. export class KeyboardInfoPre extends KeyboardInfo {
  18411. /**
  18412. * Defines the type of event (KeyboardEventTypes)
  18413. */
  18414. type: number;
  18415. /**
  18416. * Defines the related dom event
  18417. */
  18418. event: KeyboardEvent;
  18419. /**
  18420. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18421. */
  18422. skipOnPointerObservable: boolean;
  18423. /**
  18424. * Instantiates a new keyboard pre info.
  18425. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18426. * @param type Defines the type of event (KeyboardEventTypes)
  18427. * @param event Defines the related dom event
  18428. */
  18429. constructor(
  18430. /**
  18431. * Defines the type of event (KeyboardEventTypes)
  18432. */
  18433. type: number,
  18434. /**
  18435. * Defines the related dom event
  18436. */
  18437. event: KeyboardEvent);
  18438. }
  18439. }
  18440. declare module BABYLON {
  18441. /**
  18442. * Manage the keyboard inputs to control the movement of a free camera.
  18443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18444. */
  18445. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18446. /**
  18447. * Defines the camera the input is attached to.
  18448. */
  18449. camera: FreeCamera;
  18450. /**
  18451. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18452. */
  18453. keysUp: number[];
  18454. /**
  18455. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18456. */
  18457. keysUpward: number[];
  18458. /**
  18459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18460. */
  18461. keysDown: number[];
  18462. /**
  18463. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18464. */
  18465. keysDownward: number[];
  18466. /**
  18467. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18468. */
  18469. keysLeft: number[];
  18470. /**
  18471. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18472. */
  18473. keysRight: number[];
  18474. private _keys;
  18475. private _onCanvasBlurObserver;
  18476. private _onKeyboardObserver;
  18477. private _engine;
  18478. private _scene;
  18479. /**
  18480. * Attach the input controls to a specific dom element to get the input from.
  18481. * @param element Defines the element the controls should be listened from
  18482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18483. */
  18484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18485. /**
  18486. * Detach the current controls from the specified dom element.
  18487. * @param element Defines the element to stop listening the inputs from
  18488. */
  18489. detachControl(element: Nullable<HTMLElement>): void;
  18490. /**
  18491. * Update the current camera state depending on the inputs that have been used this frame.
  18492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18493. */
  18494. checkInputs(): void;
  18495. /**
  18496. * Gets the class name of the current intput.
  18497. * @returns the class name
  18498. */
  18499. getClassName(): string;
  18500. /** @hidden */
  18501. _onLostFocus(): void;
  18502. /**
  18503. * Get the friendly name associated with the input class.
  18504. * @returns the input friendly name
  18505. */
  18506. getSimpleName(): string;
  18507. }
  18508. }
  18509. declare module BABYLON {
  18510. /**
  18511. * Gather the list of pointer event types as constants.
  18512. */
  18513. export class PointerEventTypes {
  18514. /**
  18515. * 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.
  18516. */
  18517. static readonly POINTERDOWN: number;
  18518. /**
  18519. * The pointerup event is fired when a pointer is no longer active.
  18520. */
  18521. static readonly POINTERUP: number;
  18522. /**
  18523. * The pointermove event is fired when a pointer changes coordinates.
  18524. */
  18525. static readonly POINTERMOVE: number;
  18526. /**
  18527. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18528. */
  18529. static readonly POINTERWHEEL: number;
  18530. /**
  18531. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18532. */
  18533. static readonly POINTERPICK: number;
  18534. /**
  18535. * The pointertap event is fired when a the object has been touched and released without drag.
  18536. */
  18537. static readonly POINTERTAP: number;
  18538. /**
  18539. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18540. */
  18541. static readonly POINTERDOUBLETAP: number;
  18542. }
  18543. /**
  18544. * Base class of pointer info types.
  18545. */
  18546. export class PointerInfoBase {
  18547. /**
  18548. * Defines the type of event (PointerEventTypes)
  18549. */
  18550. type: number;
  18551. /**
  18552. * Defines the related dom event
  18553. */
  18554. event: PointerEvent | MouseWheelEvent;
  18555. /**
  18556. * Instantiates the base class of pointers info.
  18557. * @param type Defines the type of event (PointerEventTypes)
  18558. * @param event Defines the related dom event
  18559. */
  18560. constructor(
  18561. /**
  18562. * Defines the type of event (PointerEventTypes)
  18563. */
  18564. type: number,
  18565. /**
  18566. * Defines the related dom event
  18567. */
  18568. event: PointerEvent | MouseWheelEvent);
  18569. }
  18570. /**
  18571. * This class is used to store pointer related info for the onPrePointerObservable event.
  18572. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18573. */
  18574. export class PointerInfoPre extends PointerInfoBase {
  18575. /**
  18576. * Ray from a pointer if availible (eg. 6dof controller)
  18577. */
  18578. ray: Nullable<Ray>;
  18579. /**
  18580. * Defines the local position of the pointer on the canvas.
  18581. */
  18582. localPosition: Vector2;
  18583. /**
  18584. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18585. */
  18586. skipOnPointerObservable: boolean;
  18587. /**
  18588. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18589. * @param type Defines the type of event (PointerEventTypes)
  18590. * @param event Defines the related dom event
  18591. * @param localX Defines the local x coordinates of the pointer when the event occured
  18592. * @param localY Defines the local y coordinates of the pointer when the event occured
  18593. */
  18594. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18595. }
  18596. /**
  18597. * This type contains all the data related to a pointer event in Babylon.js.
  18598. * 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.
  18599. */
  18600. export class PointerInfo extends PointerInfoBase {
  18601. /**
  18602. * Defines the picking info associated to the info (if any)\
  18603. */
  18604. pickInfo: Nullable<PickingInfo>;
  18605. /**
  18606. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18607. * @param type Defines the type of event (PointerEventTypes)
  18608. * @param event Defines the related dom event
  18609. * @param pickInfo Defines the picking info associated to the info (if any)\
  18610. */
  18611. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18612. /**
  18613. * Defines the picking info associated to the info (if any)\
  18614. */
  18615. pickInfo: Nullable<PickingInfo>);
  18616. }
  18617. /**
  18618. * Data relating to a touch event on the screen.
  18619. */
  18620. export interface PointerTouch {
  18621. /**
  18622. * X coordinate of touch.
  18623. */
  18624. x: number;
  18625. /**
  18626. * Y coordinate of touch.
  18627. */
  18628. y: number;
  18629. /**
  18630. * Id of touch. Unique for each finger.
  18631. */
  18632. pointerId: number;
  18633. /**
  18634. * Event type passed from DOM.
  18635. */
  18636. type: any;
  18637. }
  18638. }
  18639. declare module BABYLON {
  18640. /**
  18641. * Manage the mouse inputs to control the movement of a free camera.
  18642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18643. */
  18644. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18645. /**
  18646. * Define if touch is enabled in the mouse input
  18647. */
  18648. touchEnabled: boolean;
  18649. /**
  18650. * Defines the camera the input is attached to.
  18651. */
  18652. camera: FreeCamera;
  18653. /**
  18654. * Defines the buttons associated with the input to handle camera move.
  18655. */
  18656. buttons: number[];
  18657. /**
  18658. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18659. */
  18660. angularSensibility: number;
  18661. private _pointerInput;
  18662. private _onMouseMove;
  18663. private _observer;
  18664. private previousPosition;
  18665. /**
  18666. * Observable for when a pointer move event occurs containing the move offset
  18667. */
  18668. onPointerMovedObservable: Observable<{
  18669. offsetX: number;
  18670. offsetY: number;
  18671. }>;
  18672. /**
  18673. * @hidden
  18674. * If the camera should be rotated automatically based on pointer movement
  18675. */
  18676. _allowCameraRotation: boolean;
  18677. /**
  18678. * Manage the mouse inputs to control the movement of a free camera.
  18679. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18680. * @param touchEnabled Defines if touch is enabled or not
  18681. */
  18682. constructor(
  18683. /**
  18684. * Define if touch is enabled in the mouse input
  18685. */
  18686. touchEnabled?: boolean);
  18687. /**
  18688. * Attach the input controls to a specific dom element to get the input from.
  18689. * @param element Defines the element the controls should be listened from
  18690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18691. */
  18692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18693. /**
  18694. * Called on JS contextmenu event.
  18695. * Override this method to provide functionality.
  18696. */
  18697. protected onContextMenu(evt: PointerEvent): void;
  18698. /**
  18699. * Detach the current controls from the specified dom element.
  18700. * @param element Defines the element to stop listening the inputs from
  18701. */
  18702. detachControl(element: Nullable<HTMLElement>): void;
  18703. /**
  18704. * Gets the class name of the current intput.
  18705. * @returns the class name
  18706. */
  18707. getClassName(): string;
  18708. /**
  18709. * Get the friendly name associated with the input class.
  18710. * @returns the input friendly name
  18711. */
  18712. getSimpleName(): string;
  18713. }
  18714. }
  18715. declare module BABYLON {
  18716. /**
  18717. * Manage the touch inputs to control the movement of a free camera.
  18718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18719. */
  18720. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18721. /**
  18722. * Defines the camera the input is attached to.
  18723. */
  18724. camera: FreeCamera;
  18725. /**
  18726. * Defines the touch sensibility for rotation.
  18727. * The higher the faster.
  18728. */
  18729. touchAngularSensibility: number;
  18730. /**
  18731. * Defines the touch sensibility for move.
  18732. * The higher the faster.
  18733. */
  18734. touchMoveSensibility: number;
  18735. private _offsetX;
  18736. private _offsetY;
  18737. private _pointerPressed;
  18738. private _pointerInput;
  18739. private _observer;
  18740. private _onLostFocus;
  18741. /**
  18742. * Attach the input controls to a specific dom element to get the input from.
  18743. * @param element Defines the element the controls should be listened from
  18744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18745. */
  18746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18747. /**
  18748. * Detach the current controls from the specified dom element.
  18749. * @param element Defines the element to stop listening the inputs from
  18750. */
  18751. detachControl(element: Nullable<HTMLElement>): void;
  18752. /**
  18753. * Update the current camera state depending on the inputs that have been used this frame.
  18754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18755. */
  18756. checkInputs(): void;
  18757. /**
  18758. * Gets the class name of the current intput.
  18759. * @returns the class name
  18760. */
  18761. getClassName(): string;
  18762. /**
  18763. * Get the friendly name associated with the input class.
  18764. * @returns the input friendly name
  18765. */
  18766. getSimpleName(): string;
  18767. }
  18768. }
  18769. declare module BABYLON {
  18770. /**
  18771. * Default Inputs manager for the FreeCamera.
  18772. * It groups all the default supported inputs for ease of use.
  18773. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18774. */
  18775. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18776. /**
  18777. * @hidden
  18778. */
  18779. _mouseInput: Nullable<FreeCameraMouseInput>;
  18780. /**
  18781. * Instantiates a new FreeCameraInputsManager.
  18782. * @param camera Defines the camera the inputs belong to
  18783. */
  18784. constructor(camera: FreeCamera);
  18785. /**
  18786. * Add keyboard input support to the input manager.
  18787. * @returns the current input manager
  18788. */
  18789. addKeyboard(): FreeCameraInputsManager;
  18790. /**
  18791. * Add mouse input support to the input manager.
  18792. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18793. * @returns the current input manager
  18794. */
  18795. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18796. /**
  18797. * Removes the mouse input support from the manager
  18798. * @returns the current input manager
  18799. */
  18800. removeMouse(): FreeCameraInputsManager;
  18801. /**
  18802. * Add touch input support to the input manager.
  18803. * @returns the current input manager
  18804. */
  18805. addTouch(): FreeCameraInputsManager;
  18806. /**
  18807. * Remove all attached input methods from a camera
  18808. */
  18809. clear(): void;
  18810. }
  18811. }
  18812. declare module BABYLON {
  18813. /**
  18814. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18815. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18816. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18817. */
  18818. export class FreeCamera extends TargetCamera {
  18819. /**
  18820. * Define the collision ellipsoid of the camera.
  18821. * This is helpful to simulate a camera body like the player body around the camera
  18822. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18823. */
  18824. ellipsoid: Vector3;
  18825. /**
  18826. * Define an offset for the position of the ellipsoid around the camera.
  18827. * This can be helpful to determine the center of the body near the gravity center of the body
  18828. * instead of its head.
  18829. */
  18830. ellipsoidOffset: Vector3;
  18831. /**
  18832. * Enable or disable collisions of the camera with the rest of the scene objects.
  18833. */
  18834. checkCollisions: boolean;
  18835. /**
  18836. * Enable or disable gravity on the camera.
  18837. */
  18838. applyGravity: boolean;
  18839. /**
  18840. * Define the input manager associated to the camera.
  18841. */
  18842. inputs: FreeCameraInputsManager;
  18843. /**
  18844. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. get angularSensibility(): number;
  18848. /**
  18849. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18850. * Higher values reduce sensitivity.
  18851. */
  18852. set angularSensibility(value: number);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18855. */
  18856. get keysUp(): number[];
  18857. set keysUp(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18860. */
  18861. get keysUpward(): number[];
  18862. set keysUpward(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18865. */
  18866. get keysDown(): number[];
  18867. set keysDown(value: number[]);
  18868. /**
  18869. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18870. */
  18871. get keysDownward(): number[];
  18872. set keysDownward(value: number[]);
  18873. /**
  18874. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18875. */
  18876. get keysLeft(): number[];
  18877. set keysLeft(value: number[]);
  18878. /**
  18879. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18880. */
  18881. get keysRight(): number[];
  18882. set keysRight(value: number[]);
  18883. /**
  18884. * Event raised when the camera collide with a mesh in the scene.
  18885. */
  18886. onCollide: (collidedMesh: AbstractMesh) => void;
  18887. private _collider;
  18888. private _needMoveForGravity;
  18889. private _oldPosition;
  18890. private _diffPosition;
  18891. private _newPosition;
  18892. /** @hidden */
  18893. _localDirection: Vector3;
  18894. /** @hidden */
  18895. _transformedDirection: Vector3;
  18896. /**
  18897. * Instantiates a Free Camera.
  18898. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18899. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18900. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18901. * @param name Define the name of the camera in the scene
  18902. * @param position Define the start position of the camera in the scene
  18903. * @param scene Define the scene the camera belongs to
  18904. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18905. */
  18906. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18907. /**
  18908. * Attached controls to the current camera.
  18909. * @param element Defines the element the controls should be listened from
  18910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18911. */
  18912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18913. /**
  18914. * Detach the current controls from the camera.
  18915. * The camera will stop reacting to inputs.
  18916. * @param element Defines the element to stop listening the inputs from
  18917. */
  18918. detachControl(element: HTMLElement): void;
  18919. private _collisionMask;
  18920. /**
  18921. * Define a collision mask to limit the list of object the camera can collide with
  18922. */
  18923. get collisionMask(): number;
  18924. set collisionMask(mask: number);
  18925. /** @hidden */
  18926. _collideWithWorld(displacement: Vector3): void;
  18927. private _onCollisionPositionChange;
  18928. /** @hidden */
  18929. _checkInputs(): void;
  18930. /** @hidden */
  18931. _decideIfNeedsToMove(): boolean;
  18932. /** @hidden */
  18933. _updatePosition(): void;
  18934. /**
  18935. * Destroy the camera and release the current resources hold by it.
  18936. */
  18937. dispose(): void;
  18938. /**
  18939. * Gets the current object class name.
  18940. * @return the class name
  18941. */
  18942. getClassName(): string;
  18943. }
  18944. }
  18945. declare module BABYLON {
  18946. /**
  18947. * Represents a gamepad control stick position
  18948. */
  18949. export class StickValues {
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number;
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number;
  18958. /**
  18959. * Initializes the gamepad x and y control stick values
  18960. * @param x The x component of the gamepad control stick value
  18961. * @param y The y component of the gamepad control stick value
  18962. */
  18963. constructor(
  18964. /**
  18965. * The x component of the control stick
  18966. */
  18967. x: number,
  18968. /**
  18969. * The y component of the control stick
  18970. */
  18971. y: number);
  18972. }
  18973. /**
  18974. * An interface which manages callbacks for gamepad button changes
  18975. */
  18976. export interface GamepadButtonChanges {
  18977. /**
  18978. * Called when a gamepad has been changed
  18979. */
  18980. changed: boolean;
  18981. /**
  18982. * Called when a gamepad press event has been triggered
  18983. */
  18984. pressChanged: boolean;
  18985. /**
  18986. * Called when a touch event has been triggered
  18987. */
  18988. touchChanged: boolean;
  18989. /**
  18990. * Called when a value has changed
  18991. */
  18992. valueChanged: boolean;
  18993. }
  18994. /**
  18995. * Represents a gamepad
  18996. */
  18997. export class Gamepad {
  18998. /**
  18999. * The id of the gamepad
  19000. */
  19001. id: string;
  19002. /**
  19003. * The index of the gamepad
  19004. */
  19005. index: number;
  19006. /**
  19007. * The browser gamepad
  19008. */
  19009. browserGamepad: any;
  19010. /**
  19011. * Specifies what type of gamepad this represents
  19012. */
  19013. type: number;
  19014. private _leftStick;
  19015. private _rightStick;
  19016. /** @hidden */
  19017. _isConnected: boolean;
  19018. private _leftStickAxisX;
  19019. private _leftStickAxisY;
  19020. private _rightStickAxisX;
  19021. private _rightStickAxisY;
  19022. /**
  19023. * Triggered when the left control stick has been changed
  19024. */
  19025. private _onleftstickchanged;
  19026. /**
  19027. * Triggered when the right control stick has been changed
  19028. */
  19029. private _onrightstickchanged;
  19030. /**
  19031. * Represents a gamepad controller
  19032. */
  19033. static GAMEPAD: number;
  19034. /**
  19035. * Represents a generic controller
  19036. */
  19037. static GENERIC: number;
  19038. /**
  19039. * Represents an XBox controller
  19040. */
  19041. static XBOX: number;
  19042. /**
  19043. * Represents a pose-enabled controller
  19044. */
  19045. static POSE_ENABLED: number;
  19046. /**
  19047. * Represents an Dual Shock controller
  19048. */
  19049. static DUALSHOCK: number;
  19050. /**
  19051. * Specifies whether the left control stick should be Y-inverted
  19052. */
  19053. protected _invertLeftStickY: boolean;
  19054. /**
  19055. * Specifies if the gamepad has been connected
  19056. */
  19057. get isConnected(): boolean;
  19058. /**
  19059. * Initializes the gamepad
  19060. * @param id The id of the gamepad
  19061. * @param index The index of the gamepad
  19062. * @param browserGamepad The browser gamepad
  19063. * @param leftStickX The x component of the left joystick
  19064. * @param leftStickY The y component of the left joystick
  19065. * @param rightStickX The x component of the right joystick
  19066. * @param rightStickY The y component of the right joystick
  19067. */
  19068. constructor(
  19069. /**
  19070. * The id of the gamepad
  19071. */
  19072. id: string,
  19073. /**
  19074. * The index of the gamepad
  19075. */
  19076. index: number,
  19077. /**
  19078. * The browser gamepad
  19079. */
  19080. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19081. /**
  19082. * Callback triggered when the left joystick has changed
  19083. * @param callback
  19084. */
  19085. onleftstickchanged(callback: (values: StickValues) => void): void;
  19086. /**
  19087. * Callback triggered when the right joystick has changed
  19088. * @param callback
  19089. */
  19090. onrightstickchanged(callback: (values: StickValues) => void): void;
  19091. /**
  19092. * Gets the left joystick
  19093. */
  19094. get leftStick(): StickValues;
  19095. /**
  19096. * Sets the left joystick values
  19097. */
  19098. set leftStick(newValues: StickValues);
  19099. /**
  19100. * Gets the right joystick
  19101. */
  19102. get rightStick(): StickValues;
  19103. /**
  19104. * Sets the right joystick value
  19105. */
  19106. set rightStick(newValues: StickValues);
  19107. /**
  19108. * Updates the gamepad joystick positions
  19109. */
  19110. update(): void;
  19111. /**
  19112. * Disposes the gamepad
  19113. */
  19114. dispose(): void;
  19115. }
  19116. /**
  19117. * Represents a generic gamepad
  19118. */
  19119. export class GenericPad extends Gamepad {
  19120. private _buttons;
  19121. private _onbuttondown;
  19122. private _onbuttonup;
  19123. /**
  19124. * Observable triggered when a button has been pressed
  19125. */
  19126. onButtonDownObservable: Observable<number>;
  19127. /**
  19128. * Observable triggered when a button has been released
  19129. */
  19130. onButtonUpObservable: Observable<number>;
  19131. /**
  19132. * Callback triggered when a button has been pressed
  19133. * @param callback Called when a button has been pressed
  19134. */
  19135. onbuttondown(callback: (buttonPressed: number) => void): void;
  19136. /**
  19137. * Callback triggered when a button has been released
  19138. * @param callback Called when a button has been released
  19139. */
  19140. onbuttonup(callback: (buttonReleased: number) => void): void;
  19141. /**
  19142. * Initializes the generic gamepad
  19143. * @param id The id of the generic gamepad
  19144. * @param index The index of the generic gamepad
  19145. * @param browserGamepad The browser gamepad
  19146. */
  19147. constructor(id: string, index: number, browserGamepad: any);
  19148. private _setButtonValue;
  19149. /**
  19150. * Updates the generic gamepad
  19151. */
  19152. update(): void;
  19153. /**
  19154. * Disposes the generic gamepad
  19155. */
  19156. dispose(): void;
  19157. }
  19158. }
  19159. declare module BABYLON {
  19160. /**
  19161. * Defines the types of pose enabled controllers that are supported
  19162. */
  19163. export enum PoseEnabledControllerType {
  19164. /**
  19165. * HTC Vive
  19166. */
  19167. VIVE = 0,
  19168. /**
  19169. * Oculus Rift
  19170. */
  19171. OCULUS = 1,
  19172. /**
  19173. * Windows mixed reality
  19174. */
  19175. WINDOWS = 2,
  19176. /**
  19177. * Samsung gear VR
  19178. */
  19179. GEAR_VR = 3,
  19180. /**
  19181. * Google Daydream
  19182. */
  19183. DAYDREAM = 4,
  19184. /**
  19185. * Generic
  19186. */
  19187. GENERIC = 5
  19188. }
  19189. /**
  19190. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19191. */
  19192. export interface MutableGamepadButton {
  19193. /**
  19194. * Value of the button/trigger
  19195. */
  19196. value: number;
  19197. /**
  19198. * If the button/trigger is currently touched
  19199. */
  19200. touched: boolean;
  19201. /**
  19202. * If the button/trigger is currently pressed
  19203. */
  19204. pressed: boolean;
  19205. }
  19206. /**
  19207. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19208. * @hidden
  19209. */
  19210. export interface ExtendedGamepadButton extends GamepadButton {
  19211. /**
  19212. * If the button/trigger is currently pressed
  19213. */
  19214. readonly pressed: boolean;
  19215. /**
  19216. * If the button/trigger is currently touched
  19217. */
  19218. readonly touched: boolean;
  19219. /**
  19220. * Value of the button/trigger
  19221. */
  19222. readonly value: number;
  19223. }
  19224. /** @hidden */
  19225. export interface _GamePadFactory {
  19226. /**
  19227. * Returns whether or not the current gamepad can be created for this type of controller.
  19228. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19229. * @returns true if it can be created, otherwise false
  19230. */
  19231. canCreate(gamepadInfo: any): boolean;
  19232. /**
  19233. * Creates a new instance of the Gamepad.
  19234. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19235. * @returns the new gamepad instance
  19236. */
  19237. create(gamepadInfo: any): Gamepad;
  19238. }
  19239. /**
  19240. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19241. */
  19242. export class PoseEnabledControllerHelper {
  19243. /** @hidden */
  19244. static _ControllerFactories: _GamePadFactory[];
  19245. /** @hidden */
  19246. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19247. /**
  19248. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19249. * @param vrGamepad the gamepad to initialized
  19250. * @returns a vr controller of the type the gamepad identified as
  19251. */
  19252. static InitiateController(vrGamepad: any): Gamepad;
  19253. }
  19254. /**
  19255. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19256. */
  19257. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19258. /**
  19259. * If the controller is used in a webXR session
  19260. */
  19261. isXR: boolean;
  19262. private _deviceRoomPosition;
  19263. private _deviceRoomRotationQuaternion;
  19264. /**
  19265. * The device position in babylon space
  19266. */
  19267. devicePosition: Vector3;
  19268. /**
  19269. * The device rotation in babylon space
  19270. */
  19271. deviceRotationQuaternion: Quaternion;
  19272. /**
  19273. * The scale factor of the device in babylon space
  19274. */
  19275. deviceScaleFactor: number;
  19276. /**
  19277. * (Likely devicePosition should be used instead) The device position in its room space
  19278. */
  19279. position: Vector3;
  19280. /**
  19281. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19282. */
  19283. rotationQuaternion: Quaternion;
  19284. /**
  19285. * The type of controller (Eg. Windows mixed reality)
  19286. */
  19287. controllerType: PoseEnabledControllerType;
  19288. protected _calculatedPosition: Vector3;
  19289. private _calculatedRotation;
  19290. /**
  19291. * The raw pose from the device
  19292. */
  19293. rawPose: DevicePose;
  19294. private _trackPosition;
  19295. private _maxRotationDistFromHeadset;
  19296. private _draggedRoomRotation;
  19297. /**
  19298. * @hidden
  19299. */
  19300. _disableTrackPosition(fixedPosition: Vector3): void;
  19301. /**
  19302. * Internal, the mesh attached to the controller
  19303. * @hidden
  19304. */
  19305. _mesh: Nullable<AbstractMesh>;
  19306. private _poseControlledCamera;
  19307. private _leftHandSystemQuaternion;
  19308. /**
  19309. * Internal, matrix used to convert room space to babylon space
  19310. * @hidden
  19311. */
  19312. _deviceToWorld: Matrix;
  19313. /**
  19314. * Node to be used when casting a ray from the controller
  19315. * @hidden
  19316. */
  19317. _pointingPoseNode: Nullable<TransformNode>;
  19318. /**
  19319. * Name of the child mesh that can be used to cast a ray from the controller
  19320. */
  19321. static readonly POINTING_POSE: string;
  19322. /**
  19323. * Creates a new PoseEnabledController from a gamepad
  19324. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19325. */
  19326. constructor(browserGamepad: any);
  19327. private _workingMatrix;
  19328. /**
  19329. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19330. */
  19331. update(): void;
  19332. /**
  19333. * Updates only the pose device and mesh without doing any button event checking
  19334. */
  19335. protected _updatePoseAndMesh(): void;
  19336. /**
  19337. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19338. * @param poseData raw pose fromthe device
  19339. */
  19340. updateFromDevice(poseData: DevicePose): void;
  19341. /**
  19342. * @hidden
  19343. */
  19344. _meshAttachedObservable: Observable<AbstractMesh>;
  19345. /**
  19346. * Attaches a mesh to the controller
  19347. * @param mesh the mesh to be attached
  19348. */
  19349. attachToMesh(mesh: AbstractMesh): void;
  19350. /**
  19351. * Attaches the controllers mesh to a camera
  19352. * @param camera the camera the mesh should be attached to
  19353. */
  19354. attachToPoseControlledCamera(camera: TargetCamera): void;
  19355. /**
  19356. * Disposes of the controller
  19357. */
  19358. dispose(): void;
  19359. /**
  19360. * The mesh that is attached to the controller
  19361. */
  19362. get mesh(): Nullable<AbstractMesh>;
  19363. /**
  19364. * Gets the ray of the controller in the direction the controller is pointing
  19365. * @param length the length the resulting ray should be
  19366. * @returns a ray in the direction the controller is pointing
  19367. */
  19368. getForwardRay(length?: number): Ray;
  19369. }
  19370. }
  19371. declare module BABYLON {
  19372. /**
  19373. * Defines the WebVRController object that represents controllers tracked in 3D space
  19374. */
  19375. export abstract class WebVRController extends PoseEnabledController {
  19376. /**
  19377. * Internal, the default controller model for the controller
  19378. */
  19379. protected _defaultModel: Nullable<AbstractMesh>;
  19380. /**
  19381. * Fired when the trigger state has changed
  19382. */
  19383. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19384. /**
  19385. * Fired when the main button state has changed
  19386. */
  19387. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19388. /**
  19389. * Fired when the secondary button state has changed
  19390. */
  19391. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when the pad state has changed
  19394. */
  19395. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19396. /**
  19397. * Fired when controllers stick values have changed
  19398. */
  19399. onPadValuesChangedObservable: Observable<StickValues>;
  19400. /**
  19401. * Array of button availible on the controller
  19402. */
  19403. protected _buttons: Array<MutableGamepadButton>;
  19404. private _onButtonStateChange;
  19405. /**
  19406. * Fired when a controller button's state has changed
  19407. * @param callback the callback containing the button that was modified
  19408. */
  19409. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19410. /**
  19411. * X and Y axis corresponding to the controllers joystick
  19412. */
  19413. pad: StickValues;
  19414. /**
  19415. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19416. */
  19417. hand: string;
  19418. /**
  19419. * The default controller model for the controller
  19420. */
  19421. get defaultModel(): Nullable<AbstractMesh>;
  19422. /**
  19423. * Creates a new WebVRController from a gamepad
  19424. * @param vrGamepad the gamepad that the WebVRController should be created from
  19425. */
  19426. constructor(vrGamepad: any);
  19427. /**
  19428. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19429. */
  19430. update(): void;
  19431. /**
  19432. * Function to be called when a button is modified
  19433. */
  19434. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19435. /**
  19436. * Loads a mesh and attaches it to the controller
  19437. * @param scene the scene the mesh should be added to
  19438. * @param meshLoaded callback for when the mesh has been loaded
  19439. */
  19440. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19441. private _setButtonValue;
  19442. private _changes;
  19443. private _checkChanges;
  19444. /**
  19445. * Disposes of th webVRCOntroller
  19446. */
  19447. dispose(): void;
  19448. }
  19449. }
  19450. declare module BABYLON {
  19451. /**
  19452. * The HemisphericLight simulates the ambient environment light,
  19453. * so the passed direction is the light reflection direction, not the incoming direction.
  19454. */
  19455. export class HemisphericLight extends Light {
  19456. /**
  19457. * The groundColor is the light in the opposite direction to the one specified during creation.
  19458. * 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.
  19459. */
  19460. groundColor: Color3;
  19461. /**
  19462. * The light reflection direction, not the incoming direction.
  19463. */
  19464. direction: Vector3;
  19465. /**
  19466. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19467. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19468. * The HemisphericLight can't cast shadows.
  19469. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19470. * @param name The friendly name of the light
  19471. * @param direction The direction of the light reflection
  19472. * @param scene The scene the light belongs to
  19473. */
  19474. constructor(name: string, direction: Vector3, scene: Scene);
  19475. protected _buildUniformLayout(): void;
  19476. /**
  19477. * Returns the string "HemisphericLight".
  19478. * @return The class name
  19479. */
  19480. getClassName(): string;
  19481. /**
  19482. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19483. * Returns the updated direction.
  19484. * @param target The target the direction should point to
  19485. * @return The computed direction
  19486. */
  19487. setDirectionToTarget(target: Vector3): Vector3;
  19488. /**
  19489. * Returns the shadow generator associated to the light.
  19490. * @returns Always null for hemispheric lights because it does not support shadows.
  19491. */
  19492. getShadowGenerator(): Nullable<IShadowGenerator>;
  19493. /**
  19494. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19495. * @param effect The effect to update
  19496. * @param lightIndex The index of the light in the effect to update
  19497. * @returns The hemispheric light
  19498. */
  19499. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19500. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19501. /**
  19502. * Computes the world matrix of the node
  19503. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19504. * @param useWasUpdatedFlag defines a reserved property
  19505. * @returns the world matrix
  19506. */
  19507. computeWorldMatrix(): Matrix;
  19508. /**
  19509. * Returns the integer 3.
  19510. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19511. */
  19512. getTypeID(): number;
  19513. /**
  19514. * Prepares the list of defines specific to the light type.
  19515. * @param defines the list of defines
  19516. * @param lightIndex defines the index of the light for the effect
  19517. */
  19518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19519. }
  19520. }
  19521. declare module BABYLON {
  19522. /** @hidden */
  19523. export var vrMultiviewToSingleviewPixelShader: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Renders to multiple views with a single draw call
  19531. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19532. */
  19533. export class MultiviewRenderTarget extends RenderTargetTexture {
  19534. /**
  19535. * Creates a multiview render target
  19536. * @param scene scene used with the render target
  19537. * @param size the size of the render target (used for each view)
  19538. */
  19539. constructor(scene: Scene, size?: number | {
  19540. width: number;
  19541. height: number;
  19542. } | {
  19543. ratio: number;
  19544. });
  19545. /**
  19546. * @hidden
  19547. * @param faceIndex the face index, if its a cube texture
  19548. */
  19549. _bindFrameBuffer(faceIndex?: number): void;
  19550. /**
  19551. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19552. * @returns the view count
  19553. */
  19554. getViewCount(): number;
  19555. }
  19556. }
  19557. declare module BABYLON {
  19558. interface Engine {
  19559. /**
  19560. * Creates a new multiview render target
  19561. * @param width defines the width of the texture
  19562. * @param height defines the height of the texture
  19563. * @returns the created multiview texture
  19564. */
  19565. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19566. /**
  19567. * Binds a multiview framebuffer to be drawn to
  19568. * @param multiviewTexture texture to bind
  19569. */
  19570. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19571. }
  19572. interface Camera {
  19573. /**
  19574. * @hidden
  19575. * 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)
  19576. */
  19577. _useMultiviewToSingleView: boolean;
  19578. /**
  19579. * @hidden
  19580. * 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)
  19581. */
  19582. _multiviewTexture: Nullable<RenderTargetTexture>;
  19583. /**
  19584. * @hidden
  19585. * ensures the multiview texture of the camera exists and has the specified width/height
  19586. * @param width height to set on the multiview texture
  19587. * @param height width to set on the multiview texture
  19588. */
  19589. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19590. }
  19591. interface Scene {
  19592. /** @hidden */
  19593. _transformMatrixR: Matrix;
  19594. /** @hidden */
  19595. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19596. /** @hidden */
  19597. _createMultiviewUbo(): void;
  19598. /** @hidden */
  19599. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19600. /** @hidden */
  19601. _renderMultiviewToSingleView(camera: Camera): void;
  19602. }
  19603. }
  19604. declare module BABYLON {
  19605. /**
  19606. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19607. * This will not be used for webXR as it supports displaying texture arrays directly
  19608. */
  19609. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19610. /**
  19611. * Initializes a VRMultiviewToSingleview
  19612. * @param name name of the post process
  19613. * @param camera camera to be applied to
  19614. * @param scaleFactor scaling factor to the size of the output texture
  19615. */
  19616. constructor(name: string, camera: Camera, scaleFactor: number);
  19617. }
  19618. }
  19619. declare module BABYLON {
  19620. /**
  19621. * Interface used to define additional presentation attributes
  19622. */
  19623. export interface IVRPresentationAttributes {
  19624. /**
  19625. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19626. */
  19627. highRefreshRate: boolean;
  19628. /**
  19629. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19630. */
  19631. foveationLevel: number;
  19632. }
  19633. interface Engine {
  19634. /** @hidden */
  19635. _vrDisplay: any;
  19636. /** @hidden */
  19637. _vrSupported: boolean;
  19638. /** @hidden */
  19639. _oldSize: Size;
  19640. /** @hidden */
  19641. _oldHardwareScaleFactor: number;
  19642. /** @hidden */
  19643. _vrExclusivePointerMode: boolean;
  19644. /** @hidden */
  19645. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19646. /** @hidden */
  19647. _onVRDisplayPointerRestricted: () => void;
  19648. /** @hidden */
  19649. _onVRDisplayPointerUnrestricted: () => void;
  19650. /** @hidden */
  19651. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19652. /** @hidden */
  19653. _onVrDisplayDisconnect: Nullable<() => void>;
  19654. /** @hidden */
  19655. _onVrDisplayPresentChange: Nullable<() => void>;
  19656. /**
  19657. * Observable signaled when VR display mode changes
  19658. */
  19659. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19660. /**
  19661. * Observable signaled when VR request present is complete
  19662. */
  19663. onVRRequestPresentComplete: Observable<boolean>;
  19664. /**
  19665. * Observable signaled when VR request present starts
  19666. */
  19667. onVRRequestPresentStart: Observable<Engine>;
  19668. /**
  19669. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19670. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19671. */
  19672. isInVRExclusivePointerMode: boolean;
  19673. /**
  19674. * Gets a boolean indicating if a webVR device was detected
  19675. * @returns true if a webVR device was detected
  19676. */
  19677. isVRDevicePresent(): boolean;
  19678. /**
  19679. * Gets the current webVR device
  19680. * @returns the current webVR device (or null)
  19681. */
  19682. getVRDevice(): any;
  19683. /**
  19684. * Initializes a webVR display and starts listening to display change events
  19685. * The onVRDisplayChangedObservable will be notified upon these changes
  19686. * @returns A promise containing a VRDisplay and if vr is supported
  19687. */
  19688. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19689. /** @hidden */
  19690. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19691. /**
  19692. * Gets or sets the presentation attributes used to configure VR rendering
  19693. */
  19694. vrPresentationAttributes?: IVRPresentationAttributes;
  19695. /**
  19696. * Call this function to switch to webVR mode
  19697. * Will do nothing if webVR is not supported or if there is no webVR device
  19698. * @param options the webvr options provided to the camera. mainly used for multiview
  19699. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19700. */
  19701. enableVR(options: WebVROptions): void;
  19702. /** @hidden */
  19703. _onVRFullScreenTriggered(): void;
  19704. }
  19705. }
  19706. declare module BABYLON {
  19707. /**
  19708. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19709. * IMPORTANT!! The data is right-hand data.
  19710. * @export
  19711. * @interface DevicePose
  19712. */
  19713. export interface DevicePose {
  19714. /**
  19715. * The position of the device, values in array are [x,y,z].
  19716. */
  19717. readonly position: Nullable<Float32Array>;
  19718. /**
  19719. * The linearVelocity of the device, values in array are [x,y,z].
  19720. */
  19721. readonly linearVelocity: Nullable<Float32Array>;
  19722. /**
  19723. * The linearAcceleration of the device, values in array are [x,y,z].
  19724. */
  19725. readonly linearAcceleration: Nullable<Float32Array>;
  19726. /**
  19727. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19728. */
  19729. readonly orientation: Nullable<Float32Array>;
  19730. /**
  19731. * The angularVelocity of the device, values in array are [x,y,z].
  19732. */
  19733. readonly angularVelocity: Nullable<Float32Array>;
  19734. /**
  19735. * The angularAcceleration of the device, values in array are [x,y,z].
  19736. */
  19737. readonly angularAcceleration: Nullable<Float32Array>;
  19738. }
  19739. /**
  19740. * Interface representing a pose controlled object in Babylon.
  19741. * A pose controlled object has both regular pose values as well as pose values
  19742. * from an external device such as a VR head mounted display
  19743. */
  19744. export interface PoseControlled {
  19745. /**
  19746. * The position of the object in babylon space.
  19747. */
  19748. position: Vector3;
  19749. /**
  19750. * The rotation quaternion of the object in babylon space.
  19751. */
  19752. rotationQuaternion: Quaternion;
  19753. /**
  19754. * The position of the device in babylon space.
  19755. */
  19756. devicePosition?: Vector3;
  19757. /**
  19758. * The rotation quaternion of the device in babylon space.
  19759. */
  19760. deviceRotationQuaternion: Quaternion;
  19761. /**
  19762. * The raw pose coming from the device.
  19763. */
  19764. rawPose: Nullable<DevicePose>;
  19765. /**
  19766. * The scale of the device to be used when translating from device space to babylon space.
  19767. */
  19768. deviceScaleFactor: number;
  19769. /**
  19770. * Updates the poseControlled values based on the input device pose.
  19771. * @param poseData the pose data to update the object with
  19772. */
  19773. updateFromDevice(poseData: DevicePose): void;
  19774. }
  19775. /**
  19776. * Set of options to customize the webVRCamera
  19777. */
  19778. export interface WebVROptions {
  19779. /**
  19780. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19781. */
  19782. trackPosition?: boolean;
  19783. /**
  19784. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19785. */
  19786. positionScale?: number;
  19787. /**
  19788. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19789. */
  19790. displayName?: string;
  19791. /**
  19792. * Should the native controller meshes be initialized. (default: true)
  19793. */
  19794. controllerMeshes?: boolean;
  19795. /**
  19796. * Creating a default HemiLight only on controllers. (default: true)
  19797. */
  19798. defaultLightingOnControllers?: boolean;
  19799. /**
  19800. * If you don't want to use the default VR button of the helper. (default: false)
  19801. */
  19802. useCustomVRButton?: boolean;
  19803. /**
  19804. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19805. */
  19806. customVRButton?: HTMLButtonElement;
  19807. /**
  19808. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19809. */
  19810. rayLength?: number;
  19811. /**
  19812. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19813. */
  19814. defaultHeight?: number;
  19815. /**
  19816. * If multiview should be used if availible (default: false)
  19817. */
  19818. useMultiview?: boolean;
  19819. }
  19820. /**
  19821. * This represents a WebVR camera.
  19822. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19823. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19824. */
  19825. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19826. private webVROptions;
  19827. /**
  19828. * @hidden
  19829. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19830. */
  19831. _vrDevice: any;
  19832. /**
  19833. * The rawPose of the vrDevice.
  19834. */
  19835. rawPose: Nullable<DevicePose>;
  19836. private _onVREnabled;
  19837. private _specsVersion;
  19838. private _attached;
  19839. private _frameData;
  19840. protected _descendants: Array<Node>;
  19841. private _deviceRoomPosition;
  19842. /** @hidden */
  19843. _deviceRoomRotationQuaternion: Quaternion;
  19844. private _standingMatrix;
  19845. /**
  19846. * Represents device position in babylon space.
  19847. */
  19848. devicePosition: Vector3;
  19849. /**
  19850. * Represents device rotation in babylon space.
  19851. */
  19852. deviceRotationQuaternion: Quaternion;
  19853. /**
  19854. * The scale of the device to be used when translating from device space to babylon space.
  19855. */
  19856. deviceScaleFactor: number;
  19857. private _deviceToWorld;
  19858. private _worldToDevice;
  19859. /**
  19860. * References to the webVR controllers for the vrDevice.
  19861. */
  19862. controllers: Array<WebVRController>;
  19863. /**
  19864. * Emits an event when a controller is attached.
  19865. */
  19866. onControllersAttachedObservable: Observable<WebVRController[]>;
  19867. /**
  19868. * Emits an event when a controller's mesh has been loaded;
  19869. */
  19870. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19871. /**
  19872. * Emits an event when the HMD's pose has been updated.
  19873. */
  19874. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19875. private _poseSet;
  19876. /**
  19877. * If the rig cameras be used as parent instead of this camera.
  19878. */
  19879. rigParenting: boolean;
  19880. private _lightOnControllers;
  19881. private _defaultHeight?;
  19882. /**
  19883. * Instantiates a WebVRFreeCamera.
  19884. * @param name The name of the WebVRFreeCamera
  19885. * @param position The starting anchor position for the camera
  19886. * @param scene The scene the camera belongs to
  19887. * @param webVROptions a set of customizable options for the webVRCamera
  19888. */
  19889. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19890. /**
  19891. * Gets the device distance from the ground in meters.
  19892. * @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.
  19893. */
  19894. deviceDistanceToRoomGround(): number;
  19895. /**
  19896. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19897. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19898. */
  19899. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19900. /**
  19901. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19902. * @returns A promise with a boolean set to if the standing matrix is supported.
  19903. */
  19904. useStandingMatrixAsync(): Promise<boolean>;
  19905. /**
  19906. * Disposes the camera
  19907. */
  19908. dispose(): void;
  19909. /**
  19910. * Gets a vrController by name.
  19911. * @param name The name of the controller to retreive
  19912. * @returns the controller matching the name specified or null if not found
  19913. */
  19914. getControllerByName(name: string): Nullable<WebVRController>;
  19915. private _leftController;
  19916. /**
  19917. * The controller corresponding to the users left hand.
  19918. */
  19919. get leftController(): Nullable<WebVRController>;
  19920. private _rightController;
  19921. /**
  19922. * The controller corresponding to the users right hand.
  19923. */
  19924. get rightController(): Nullable<WebVRController>;
  19925. /**
  19926. * Casts a ray forward from the vrCamera's gaze.
  19927. * @param length Length of the ray (default: 100)
  19928. * @returns the ray corresponding to the gaze
  19929. */
  19930. getForwardRay(length?: number): Ray;
  19931. /**
  19932. * @hidden
  19933. * Updates the camera based on device's frame data
  19934. */
  19935. _checkInputs(): void;
  19936. /**
  19937. * Updates the poseControlled values based on the input device pose.
  19938. * @param poseData Pose coming from the device
  19939. */
  19940. updateFromDevice(poseData: DevicePose): void;
  19941. private _htmlElementAttached;
  19942. private _detachIfAttached;
  19943. /**
  19944. * WebVR's attach control will start broadcasting frames to the device.
  19945. * Note that in certain browsers (chrome for example) this function must be called
  19946. * within a user-interaction callback. Example:
  19947. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19948. *
  19949. * @param element html element to attach the vrDevice to
  19950. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19951. */
  19952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19953. /**
  19954. * Detaches the camera from the html element and disables VR
  19955. *
  19956. * @param element html element to detach from
  19957. */
  19958. detachControl(element: HTMLElement): void;
  19959. /**
  19960. * @returns the name of this class
  19961. */
  19962. getClassName(): string;
  19963. /**
  19964. * Calls resetPose on the vrDisplay
  19965. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19966. */
  19967. resetToCurrentRotation(): void;
  19968. /**
  19969. * @hidden
  19970. * Updates the rig cameras (left and right eye)
  19971. */
  19972. _updateRigCameras(): void;
  19973. private _workingVector;
  19974. private _oneVector;
  19975. private _workingMatrix;
  19976. private updateCacheCalled;
  19977. private _correctPositionIfNotTrackPosition;
  19978. /**
  19979. * @hidden
  19980. * Updates the cached values of the camera
  19981. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19982. */
  19983. _updateCache(ignoreParentClass?: boolean): void;
  19984. /**
  19985. * @hidden
  19986. * Get current device position in babylon world
  19987. */
  19988. _computeDevicePosition(): void;
  19989. /**
  19990. * Updates the current device position and rotation in the babylon world
  19991. */
  19992. update(): void;
  19993. /**
  19994. * @hidden
  19995. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19996. * @returns an identity matrix
  19997. */
  19998. _getViewMatrix(): Matrix;
  19999. private _tmpMatrix;
  20000. /**
  20001. * This function is called by the two RIG cameras.
  20002. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20003. * @hidden
  20004. */
  20005. _getWebVRViewMatrix(): Matrix;
  20006. /** @hidden */
  20007. _getWebVRProjectionMatrix(): Matrix;
  20008. private _onGamepadConnectedObserver;
  20009. private _onGamepadDisconnectedObserver;
  20010. private _updateCacheWhenTrackingDisabledObserver;
  20011. /**
  20012. * Initializes the controllers and their meshes
  20013. */
  20014. initControllers(): void;
  20015. }
  20016. }
  20017. declare module BABYLON {
  20018. /**
  20019. * "Static Class" containing the most commonly used helper while dealing with material for
  20020. * rendering purpose.
  20021. *
  20022. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20023. *
  20024. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20025. */
  20026. export class MaterialHelper {
  20027. /**
  20028. * Bind the current view position to an effect.
  20029. * @param effect The effect to be bound
  20030. * @param scene The scene the eyes position is used from
  20031. * @param variableName name of the shader variable that will hold the eye position
  20032. */
  20033. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20034. /**
  20035. * Helps preparing the defines values about the UVs in used in the effect.
  20036. * UVs are shared as much as we can accross channels in the shaders.
  20037. * @param texture The texture we are preparing the UVs for
  20038. * @param defines The defines to update
  20039. * @param key The channel key "diffuse", "specular"... used in the shader
  20040. */
  20041. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20042. /**
  20043. * Binds a texture matrix value to its corrsponding uniform
  20044. * @param texture The texture to bind the matrix for
  20045. * @param uniformBuffer The uniform buffer receivin the data
  20046. * @param key The channel key "diffuse", "specular"... used in the shader
  20047. */
  20048. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20049. /**
  20050. * Gets the current status of the fog (should it be enabled?)
  20051. * @param mesh defines the mesh to evaluate for fog support
  20052. * @param scene defines the hosting scene
  20053. * @returns true if fog must be enabled
  20054. */
  20055. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20056. /**
  20057. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20058. * @param mesh defines the current mesh
  20059. * @param scene defines the current scene
  20060. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20061. * @param pointsCloud defines if point cloud rendering has to be turned on
  20062. * @param fogEnabled defines if fog has to be turned on
  20063. * @param alphaTest defines if alpha testing has to be turned on
  20064. * @param defines defines the current list of defines
  20065. */
  20066. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20067. /**
  20068. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20069. * @param scene defines the current scene
  20070. * @param engine defines the current engine
  20071. * @param defines specifies the list of active defines
  20072. * @param useInstances defines if instances have to be turned on
  20073. * @param useClipPlane defines if clip plane have to be turned on
  20074. * @param useInstances defines if instances have to be turned on
  20075. * @param useThinInstances defines if thin instances have to be turned on
  20076. */
  20077. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20078. /**
  20079. * Prepares the defines for bones
  20080. * @param mesh The mesh containing the geometry data we will draw
  20081. * @param defines The defines to update
  20082. */
  20083. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20084. /**
  20085. * Prepares the defines for morph targets
  20086. * @param mesh The mesh containing the geometry data we will draw
  20087. * @param defines The defines to update
  20088. */
  20089. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20090. /**
  20091. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20092. * @param mesh The mesh containing the geometry data we will draw
  20093. * @param defines The defines to update
  20094. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20095. * @param useBones Precise whether bones should be used or not (override mesh info)
  20096. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20097. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20098. * @returns false if defines are considered not dirty and have not been checked
  20099. */
  20100. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20101. /**
  20102. * Prepares the defines related to multiview
  20103. * @param scene The scene we are intending to draw
  20104. * @param defines The defines to update
  20105. */
  20106. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20107. /**
  20108. * Prepares the defines related to the prepass
  20109. * @param scene The scene we are intending to draw
  20110. * @param defines The defines to update
  20111. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20112. */
  20113. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20114. /**
  20115. * Prepares the defines related to the light information passed in parameter
  20116. * @param scene The scene we are intending to draw
  20117. * @param mesh The mesh the effect is compiling for
  20118. * @param light The light the effect is compiling for
  20119. * @param lightIndex The index of the light
  20120. * @param defines The defines to update
  20121. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20122. * @param state Defines the current state regarding what is needed (normals, etc...)
  20123. */
  20124. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20125. needNormals: boolean;
  20126. needRebuild: boolean;
  20127. shadowEnabled: boolean;
  20128. specularEnabled: boolean;
  20129. lightmapMode: boolean;
  20130. }): void;
  20131. /**
  20132. * Prepares the defines related to the light information passed in parameter
  20133. * @param scene The scene we are intending to draw
  20134. * @param mesh The mesh the effect is compiling for
  20135. * @param defines The defines to update
  20136. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20137. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20138. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20139. * @returns true if normals will be required for the rest of the effect
  20140. */
  20141. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20142. /**
  20143. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20144. * @param lightIndex defines the light index
  20145. * @param uniformsList The uniform list
  20146. * @param samplersList The sampler list
  20147. * @param projectedLightTexture defines if projected texture must be used
  20148. * @param uniformBuffersList defines an optional list of uniform buffers
  20149. */
  20150. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20151. /**
  20152. * Prepares the uniforms and samplers list to be used in the effect
  20153. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20154. * @param samplersList The sampler list
  20155. * @param defines The defines helping in the list generation
  20156. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20157. */
  20158. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20159. /**
  20160. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20161. * @param defines The defines to update while falling back
  20162. * @param fallbacks The authorized effect fallbacks
  20163. * @param maxSimultaneousLights The maximum number of lights allowed
  20164. * @param rank the current rank of the Effect
  20165. * @returns The newly affected rank
  20166. */
  20167. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20168. private static _TmpMorphInfluencers;
  20169. /**
  20170. * Prepares the list of attributes required for morph targets according to the effect defines.
  20171. * @param attribs The current list of supported attribs
  20172. * @param mesh The mesh to prepare the morph targets attributes for
  20173. * @param influencers The number of influencers
  20174. */
  20175. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20176. /**
  20177. * Prepares the list of attributes required for morph targets according to the effect defines.
  20178. * @param attribs The current list of supported attribs
  20179. * @param mesh The mesh to prepare the morph targets attributes for
  20180. * @param defines The current Defines of the effect
  20181. */
  20182. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20183. /**
  20184. * Prepares the list of attributes required for bones according to the effect defines.
  20185. * @param attribs The current list of supported attribs
  20186. * @param mesh The mesh to prepare the bones attributes for
  20187. * @param defines The current Defines of the effect
  20188. * @param fallbacks The current efffect fallback strategy
  20189. */
  20190. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20191. /**
  20192. * Check and prepare the list of attributes required for instances according to the effect defines.
  20193. * @param attribs The current list of supported attribs
  20194. * @param defines The current MaterialDefines of the effect
  20195. */
  20196. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20197. /**
  20198. * Add the list of attributes required for instances to the attribs array.
  20199. * @param attribs The current list of supported attribs
  20200. */
  20201. static PushAttributesForInstances(attribs: string[]): void;
  20202. /**
  20203. * Binds the light information to the effect.
  20204. * @param light The light containing the generator
  20205. * @param effect The effect we are binding the data to
  20206. * @param lightIndex The light index in the effect used to render
  20207. */
  20208. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20209. /**
  20210. * Binds the lights information from the scene to the effect for the given mesh.
  20211. * @param light Light to bind
  20212. * @param lightIndex Light index
  20213. * @param scene The scene where the light belongs to
  20214. * @param effect The effect we are binding the data to
  20215. * @param useSpecular Defines if specular is supported
  20216. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20217. */
  20218. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20219. /**
  20220. * Binds the lights information from the scene to the effect for the given mesh.
  20221. * @param scene The scene the lights belongs to
  20222. * @param mesh The mesh we are binding the information to render
  20223. * @param effect The effect we are binding the data to
  20224. * @param defines The generated defines for the effect
  20225. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20226. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20227. */
  20228. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20229. private static _tempFogColor;
  20230. /**
  20231. * Binds the fog information from the scene to the effect for the given mesh.
  20232. * @param scene The scene the lights belongs to
  20233. * @param mesh The mesh we are binding the information to render
  20234. * @param effect The effect we are binding the data to
  20235. * @param linearSpace Defines if the fog effect is applied in linear space
  20236. */
  20237. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20238. /**
  20239. * Binds the bones information from the mesh to the effect.
  20240. * @param mesh The mesh we are binding the information to render
  20241. * @param effect The effect we are binding the data to
  20242. */
  20243. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20244. /**
  20245. * Binds the morph targets information from the mesh to the effect.
  20246. * @param abstractMesh The mesh we are binding the information to render
  20247. * @param effect The effect we are binding the data to
  20248. */
  20249. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20250. /**
  20251. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20252. * @param defines The generated defines used in the effect
  20253. * @param effect The effect we are binding the data to
  20254. * @param scene The scene we are willing to render with logarithmic scale for
  20255. */
  20256. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20257. /**
  20258. * Binds the clip plane information from the scene to the effect.
  20259. * @param scene The scene the clip plane information are extracted from
  20260. * @param effect The effect we are binding the data to
  20261. */
  20262. static BindClipPlane(effect: Effect, scene: Scene): void;
  20263. }
  20264. }
  20265. declare module BABYLON {
  20266. /**
  20267. * Block used to expose an input value
  20268. */
  20269. export class InputBlock extends NodeMaterialBlock {
  20270. private _mode;
  20271. private _associatedVariableName;
  20272. private _storedValue;
  20273. private _valueCallback;
  20274. private _type;
  20275. private _animationType;
  20276. /** Gets or set a value used to limit the range of float values */
  20277. min: number;
  20278. /** Gets or set a value used to limit the range of float values */
  20279. max: number;
  20280. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20281. isBoolean: boolean;
  20282. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20283. matrixMode: number;
  20284. /** @hidden */
  20285. _systemValue: Nullable<NodeMaterialSystemValues>;
  20286. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20287. visibleInInspector: boolean;
  20288. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20289. isConstant: boolean;
  20290. /** Gets or sets the group to use to display this block in the Inspector */
  20291. groupInInspector: string;
  20292. /** Gets an observable raised when the value is changed */
  20293. onValueChangedObservable: Observable<InputBlock>;
  20294. /**
  20295. * Gets or sets the connection point type (default is float)
  20296. */
  20297. get type(): NodeMaterialBlockConnectionPointTypes;
  20298. /**
  20299. * Creates a new InputBlock
  20300. * @param name defines the block name
  20301. * @param target defines the target of that block (Vertex by default)
  20302. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20303. */
  20304. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20305. /**
  20306. * Validates if a name is a reserve word.
  20307. * @param newName the new name to be given to the node.
  20308. * @returns false if the name is a reserve word, else true.
  20309. */
  20310. validateBlockName(newName: string): boolean;
  20311. /**
  20312. * Gets the output component
  20313. */
  20314. get output(): NodeMaterialConnectionPoint;
  20315. /**
  20316. * Set the source of this connection point to a vertex attribute
  20317. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20318. * @returns the current connection point
  20319. */
  20320. setAsAttribute(attributeName?: string): InputBlock;
  20321. /**
  20322. * Set the source of this connection point to a system value
  20323. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20324. * @returns the current connection point
  20325. */
  20326. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20327. /**
  20328. * Gets or sets the value of that point.
  20329. * Please note that this value will be ignored if valueCallback is defined
  20330. */
  20331. get value(): any;
  20332. set value(value: any);
  20333. /**
  20334. * Gets or sets a callback used to get the value of that point.
  20335. * Please note that setting this value will force the connection point to ignore the value property
  20336. */
  20337. get valueCallback(): () => any;
  20338. set valueCallback(value: () => any);
  20339. /**
  20340. * Gets or sets the associated variable name in the shader
  20341. */
  20342. get associatedVariableName(): string;
  20343. set associatedVariableName(value: string);
  20344. /** Gets or sets the type of animation applied to the input */
  20345. get animationType(): AnimatedInputBlockTypes;
  20346. set animationType(value: AnimatedInputBlockTypes);
  20347. /**
  20348. * Gets a boolean indicating that this connection point not defined yet
  20349. */
  20350. get isUndefined(): boolean;
  20351. /**
  20352. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20353. * In this case the connection point name must be the name of the uniform to use.
  20354. * Can only be set on inputs
  20355. */
  20356. get isUniform(): boolean;
  20357. set isUniform(value: boolean);
  20358. /**
  20359. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20360. * In this case the connection point name must be the name of the attribute to use
  20361. * Can only be set on inputs
  20362. */
  20363. get isAttribute(): boolean;
  20364. set isAttribute(value: boolean);
  20365. /**
  20366. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20367. * Can only be set on exit points
  20368. */
  20369. get isVarying(): boolean;
  20370. set isVarying(value: boolean);
  20371. /**
  20372. * Gets a boolean indicating that the current connection point is a system value
  20373. */
  20374. get isSystemValue(): boolean;
  20375. /**
  20376. * Gets or sets the current well known value or null if not defined as a system value
  20377. */
  20378. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20379. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20380. /**
  20381. * Gets the current class name
  20382. * @returns the class name
  20383. */
  20384. getClassName(): string;
  20385. /**
  20386. * Animate the input if animationType !== None
  20387. * @param scene defines the rendering scene
  20388. */
  20389. animate(scene: Scene): void;
  20390. private _emitDefine;
  20391. initialize(state: NodeMaterialBuildState): void;
  20392. /**
  20393. * Set the input block to its default value (based on its type)
  20394. */
  20395. setDefaultValue(): void;
  20396. private _emitConstant;
  20397. /** @hidden */
  20398. get _noContextSwitch(): boolean;
  20399. private _emit;
  20400. /** @hidden */
  20401. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20402. /** @hidden */
  20403. _transmit(effect: Effect, scene: Scene): void;
  20404. protected _buildBlock(state: NodeMaterialBuildState): void;
  20405. protected _dumpPropertiesCode(): string;
  20406. dispose(): void;
  20407. serialize(): any;
  20408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * Enum used to define the compatibility state between two connection points
  20414. */
  20415. export enum NodeMaterialConnectionPointCompatibilityStates {
  20416. /** Points are compatibles */
  20417. Compatible = 0,
  20418. /** Points are incompatible because of their types */
  20419. TypeIncompatible = 1,
  20420. /** Points are incompatible because of their targets (vertex vs fragment) */
  20421. TargetIncompatible = 2
  20422. }
  20423. /**
  20424. * Defines the direction of a connection point
  20425. */
  20426. export enum NodeMaterialConnectionPointDirection {
  20427. /** Input */
  20428. Input = 0,
  20429. /** Output */
  20430. Output = 1
  20431. }
  20432. /**
  20433. * Defines a connection point for a block
  20434. */
  20435. export class NodeMaterialConnectionPoint {
  20436. /** @hidden */
  20437. _ownerBlock: NodeMaterialBlock;
  20438. /** @hidden */
  20439. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20440. private _endpoints;
  20441. private _associatedVariableName;
  20442. private _direction;
  20443. /** @hidden */
  20444. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20445. /** @hidden */
  20446. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20447. private _type;
  20448. /** @hidden */
  20449. _enforceAssociatedVariableName: boolean;
  20450. /** Gets the direction of the point */
  20451. get direction(): NodeMaterialConnectionPointDirection;
  20452. /** Indicates that this connection point needs dual validation before being connected to another point */
  20453. needDualDirectionValidation: boolean;
  20454. /**
  20455. * Gets or sets the additional types supported by this connection point
  20456. */
  20457. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20458. /**
  20459. * Gets or sets the additional types excluded by this connection point
  20460. */
  20461. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20462. /**
  20463. * Observable triggered when this point is connected
  20464. */
  20465. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20466. /**
  20467. * Gets or sets the associated variable name in the shader
  20468. */
  20469. get associatedVariableName(): string;
  20470. set associatedVariableName(value: string);
  20471. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20472. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20473. /**
  20474. * Gets or sets the connection point type (default is float)
  20475. */
  20476. get type(): NodeMaterialBlockConnectionPointTypes;
  20477. set type(value: NodeMaterialBlockConnectionPointTypes);
  20478. /**
  20479. * Gets or sets the connection point name
  20480. */
  20481. name: string;
  20482. /**
  20483. * Gets or sets the connection point name
  20484. */
  20485. displayName: string;
  20486. /**
  20487. * Gets or sets a boolean indicating that this connection point can be omitted
  20488. */
  20489. isOptional: boolean;
  20490. /**
  20491. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20492. */
  20493. isExposedOnFrame: boolean;
  20494. /**
  20495. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20496. */
  20497. define: string;
  20498. /** @hidden */
  20499. _prioritizeVertex: boolean;
  20500. private _target;
  20501. /** Gets or sets the target of that connection point */
  20502. get target(): NodeMaterialBlockTargets;
  20503. set target(value: NodeMaterialBlockTargets);
  20504. /**
  20505. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20506. */
  20507. get isConnected(): boolean;
  20508. /**
  20509. * Gets a boolean indicating that the current point is connected to an input block
  20510. */
  20511. get isConnectedToInputBlock(): boolean;
  20512. /**
  20513. * Gets a the connected input block (if any)
  20514. */
  20515. get connectInputBlock(): Nullable<InputBlock>;
  20516. /** Get the other side of the connection (if any) */
  20517. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20518. /** Get the block that owns this connection point */
  20519. get ownerBlock(): NodeMaterialBlock;
  20520. /** Get the block connected on the other side of this connection (if any) */
  20521. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20522. /** Get the block connected on the endpoints of this connection (if any) */
  20523. get connectedBlocks(): Array<NodeMaterialBlock>;
  20524. /** Gets the list of connected endpoints */
  20525. get endpoints(): NodeMaterialConnectionPoint[];
  20526. /** Gets a boolean indicating if that output point is connected to at least one input */
  20527. get hasEndpoints(): boolean;
  20528. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20529. get isConnectedInVertexShader(): boolean;
  20530. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20531. get isConnectedInFragmentShader(): boolean;
  20532. /**
  20533. * Creates a block suitable to be used as an input for this input point.
  20534. * If null is returned, a block based on the point type will be created.
  20535. * @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
  20536. */
  20537. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20538. /**
  20539. * Creates a new connection point
  20540. * @param name defines the connection point name
  20541. * @param ownerBlock defines the block hosting this connection point
  20542. * @param direction defines the direction of the connection point
  20543. */
  20544. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20545. /**
  20546. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20547. * @returns the class name
  20548. */
  20549. getClassName(): string;
  20550. /**
  20551. * Gets a boolean indicating if the current point can be connected to another point
  20552. * @param connectionPoint defines the other connection point
  20553. * @returns a boolean
  20554. */
  20555. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20556. /**
  20557. * Gets a number indicating if the current point can be connected to another point
  20558. * @param connectionPoint defines the other connection point
  20559. * @returns a number defining the compatibility state
  20560. */
  20561. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20562. /**
  20563. * Connect this point to another connection point
  20564. * @param connectionPoint defines the other connection point
  20565. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20566. * @returns the current connection point
  20567. */
  20568. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20569. /**
  20570. * Disconnect this point from one of his endpoint
  20571. * @param endpoint defines the other connection point
  20572. * @returns the current connection point
  20573. */
  20574. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20575. /**
  20576. * Serializes this point in a JSON representation
  20577. * @param isInput defines if the connection point is an input (default is true)
  20578. * @returns the serialized point object
  20579. */
  20580. serialize(isInput?: boolean): any;
  20581. /**
  20582. * Release resources
  20583. */
  20584. dispose(): void;
  20585. }
  20586. }
  20587. declare module BABYLON {
  20588. /**
  20589. * Enum used to define the material modes
  20590. */
  20591. export enum NodeMaterialModes {
  20592. /** Regular material */
  20593. Material = 0,
  20594. /** For post process */
  20595. PostProcess = 1,
  20596. /** For particle system */
  20597. Particle = 2
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /**
  20602. * Block used to read a texture from a sampler
  20603. */
  20604. export class TextureBlock extends NodeMaterialBlock {
  20605. private _defineName;
  20606. private _linearDefineName;
  20607. private _gammaDefineName;
  20608. private _tempTextureRead;
  20609. private _samplerName;
  20610. private _transformedUVName;
  20611. private _textureTransformName;
  20612. private _textureInfoName;
  20613. private _mainUVName;
  20614. private _mainUVDefineName;
  20615. private _fragmentOnly;
  20616. /**
  20617. * Gets or sets the texture associated with the node
  20618. */
  20619. texture: Nullable<Texture>;
  20620. /**
  20621. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20622. */
  20623. convertToGammaSpace: boolean;
  20624. /**
  20625. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20626. */
  20627. convertToLinearSpace: boolean;
  20628. /**
  20629. * Create a new TextureBlock
  20630. * @param name defines the block name
  20631. */
  20632. constructor(name: string, fragmentOnly?: boolean);
  20633. /**
  20634. * Gets the current class name
  20635. * @returns the class name
  20636. */
  20637. getClassName(): string;
  20638. /**
  20639. * Gets the uv input component
  20640. */
  20641. get uv(): NodeMaterialConnectionPoint;
  20642. /**
  20643. * Gets the rgba output component
  20644. */
  20645. get rgba(): NodeMaterialConnectionPoint;
  20646. /**
  20647. * Gets the rgb output component
  20648. */
  20649. get rgb(): NodeMaterialConnectionPoint;
  20650. /**
  20651. * Gets the r output component
  20652. */
  20653. get r(): NodeMaterialConnectionPoint;
  20654. /**
  20655. * Gets the g output component
  20656. */
  20657. get g(): NodeMaterialConnectionPoint;
  20658. /**
  20659. * Gets the b output component
  20660. */
  20661. get b(): NodeMaterialConnectionPoint;
  20662. /**
  20663. * Gets the a output component
  20664. */
  20665. get a(): NodeMaterialConnectionPoint;
  20666. get target(): NodeMaterialBlockTargets;
  20667. autoConfigure(material: NodeMaterial): void;
  20668. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20670. isReady(): boolean;
  20671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20672. private get _isMixed();
  20673. private _injectVertexCode;
  20674. private _writeTextureRead;
  20675. private _writeOutput;
  20676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20677. protected _dumpPropertiesCode(): string;
  20678. serialize(): any;
  20679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20680. }
  20681. }
  20682. declare module BABYLON {
  20683. /** @hidden */
  20684. export var reflectionFunction: {
  20685. name: string;
  20686. shader: string;
  20687. };
  20688. }
  20689. declare module BABYLON {
  20690. /**
  20691. * Base block used to read a reflection texture from a sampler
  20692. */
  20693. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20694. /** @hidden */
  20695. _define3DName: string;
  20696. /** @hidden */
  20697. _defineCubicName: string;
  20698. /** @hidden */
  20699. _defineExplicitName: string;
  20700. /** @hidden */
  20701. _defineProjectionName: string;
  20702. /** @hidden */
  20703. _defineLocalCubicName: string;
  20704. /** @hidden */
  20705. _defineSphericalName: string;
  20706. /** @hidden */
  20707. _definePlanarName: string;
  20708. /** @hidden */
  20709. _defineEquirectangularName: string;
  20710. /** @hidden */
  20711. _defineMirroredEquirectangularFixedName: string;
  20712. /** @hidden */
  20713. _defineEquirectangularFixedName: string;
  20714. /** @hidden */
  20715. _defineSkyboxName: string;
  20716. /** @hidden */
  20717. _defineOppositeZ: string;
  20718. /** @hidden */
  20719. _cubeSamplerName: string;
  20720. /** @hidden */
  20721. _2DSamplerName: string;
  20722. protected _positionUVWName: string;
  20723. protected _directionWName: string;
  20724. protected _reflectionVectorName: string;
  20725. /** @hidden */
  20726. _reflectionCoordsName: string;
  20727. /** @hidden */
  20728. _reflectionMatrixName: string;
  20729. protected _reflectionColorName: string;
  20730. /**
  20731. * Gets or sets the texture associated with the node
  20732. */
  20733. texture: Nullable<BaseTexture>;
  20734. /**
  20735. * Create a new ReflectionTextureBaseBlock
  20736. * @param name defines the block name
  20737. */
  20738. constructor(name: string);
  20739. /**
  20740. * Gets the current class name
  20741. * @returns the class name
  20742. */
  20743. getClassName(): string;
  20744. /**
  20745. * Gets the world position input component
  20746. */
  20747. abstract get position(): NodeMaterialConnectionPoint;
  20748. /**
  20749. * Gets the world position input component
  20750. */
  20751. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20752. /**
  20753. * Gets the world normal input component
  20754. */
  20755. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20756. /**
  20757. * Gets the world input component
  20758. */
  20759. abstract get world(): NodeMaterialConnectionPoint;
  20760. /**
  20761. * Gets the camera (or eye) position component
  20762. */
  20763. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20764. /**
  20765. * Gets the view input component
  20766. */
  20767. abstract get view(): NodeMaterialConnectionPoint;
  20768. protected _getTexture(): Nullable<BaseTexture>;
  20769. autoConfigure(material: NodeMaterial): void;
  20770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20771. isReady(): boolean;
  20772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20773. /**
  20774. * Gets the code to inject in the vertex shader
  20775. * @param state current state of the node material building
  20776. * @returns the shader code
  20777. */
  20778. handleVertexSide(state: NodeMaterialBuildState): string;
  20779. /**
  20780. * Handles the inits for the fragment code path
  20781. * @param state node material build state
  20782. */
  20783. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20784. /**
  20785. * Generates the reflection coords code for the fragment code path
  20786. * @param worldNormalVarName name of the world normal variable
  20787. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20788. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20789. * @returns the shader code
  20790. */
  20791. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20792. /**
  20793. * Generates the reflection color code for the fragment code path
  20794. * @param lodVarName name of the lod variable
  20795. * @param swizzleLookupTexture swizzle to use for the final color variable
  20796. * @returns the shader code
  20797. */
  20798. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20799. /**
  20800. * Generates the code corresponding to the connected output points
  20801. * @param state node material build state
  20802. * @param varName name of the variable to output
  20803. * @returns the shader code
  20804. */
  20805. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20806. protected _buildBlock(state: NodeMaterialBuildState): this;
  20807. protected _dumpPropertiesCode(): string;
  20808. serialize(): any;
  20809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20810. }
  20811. }
  20812. declare module BABYLON {
  20813. /**
  20814. * Defines a connection point to be used for points with a custom object type
  20815. */
  20816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20817. private _blockType;
  20818. private _blockName;
  20819. private _nameForCheking?;
  20820. /**
  20821. * Creates a new connection point
  20822. * @param name defines the connection point name
  20823. * @param ownerBlock defines the block hosting this connection point
  20824. * @param direction defines the direction of the connection point
  20825. */
  20826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20827. /**
  20828. * Gets a number indicating if the current point can be connected to another point
  20829. * @param connectionPoint defines the other connection point
  20830. * @returns a number defining the compatibility state
  20831. */
  20832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20833. /**
  20834. * Creates a block suitable to be used as an input for this input point.
  20835. * If null is returned, a block based on the point type will be created.
  20836. * @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
  20837. */
  20838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /**
  20843. * Enum defining the type of properties that can be edited in the property pages in the NME
  20844. */
  20845. export enum PropertyTypeForEdition {
  20846. /** property is a boolean */
  20847. Boolean = 0,
  20848. /** property is a float */
  20849. Float = 1,
  20850. /** property is a Vector2 */
  20851. Vector2 = 2,
  20852. /** property is a list of values */
  20853. List = 3
  20854. }
  20855. /**
  20856. * Interface that defines an option in a variable of type list
  20857. */
  20858. export interface IEditablePropertyListOption {
  20859. /** label of the option */
  20860. "label": string;
  20861. /** value of the option */
  20862. "value": number;
  20863. }
  20864. /**
  20865. * Interface that defines the options available for an editable property
  20866. */
  20867. export interface IEditablePropertyOption {
  20868. /** min value */
  20869. "min"?: number;
  20870. /** max value */
  20871. "max"?: number;
  20872. /** notifiers: indicates which actions to take when the property is changed */
  20873. "notifiers"?: {
  20874. /** the material should be rebuilt */
  20875. "rebuild"?: boolean;
  20876. /** the preview should be updated */
  20877. "update"?: boolean;
  20878. };
  20879. /** list of the options for a variable of type list */
  20880. "options"?: IEditablePropertyListOption[];
  20881. }
  20882. /**
  20883. * Interface that describes an editable property
  20884. */
  20885. export interface IPropertyDescriptionForEdition {
  20886. /** name of the property */
  20887. "propertyName": string;
  20888. /** display name of the property */
  20889. "displayName": string;
  20890. /** type of the property */
  20891. "type": PropertyTypeForEdition;
  20892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20893. "groupName": string;
  20894. /** options for the property */
  20895. "options": IEditablePropertyOption;
  20896. }
  20897. /**
  20898. * Decorator that flags a property in a node material block as being editable
  20899. */
  20900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20901. }
  20902. declare module BABYLON {
  20903. /**
  20904. * Block used to implement the refraction part of the sub surface module of the PBR material
  20905. */
  20906. export class RefractionBlock extends NodeMaterialBlock {
  20907. /** @hidden */
  20908. _define3DName: string;
  20909. /** @hidden */
  20910. _refractionMatrixName: string;
  20911. /** @hidden */
  20912. _defineLODRefractionAlpha: string;
  20913. /** @hidden */
  20914. _defineLinearSpecularRefraction: string;
  20915. /** @hidden */
  20916. _defineOppositeZ: string;
  20917. /** @hidden */
  20918. _cubeSamplerName: string;
  20919. /** @hidden */
  20920. _2DSamplerName: string;
  20921. /** @hidden */
  20922. _vRefractionMicrosurfaceInfosName: string;
  20923. /** @hidden */
  20924. _vRefractionInfosName: string;
  20925. private _scene;
  20926. /**
  20927. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20928. * Materials half opaque for instance using refraction could benefit from this control.
  20929. */
  20930. linkRefractionWithTransparency: boolean;
  20931. /**
  20932. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20933. */
  20934. invertRefractionY: boolean;
  20935. /**
  20936. * Gets or sets the texture associated with the node
  20937. */
  20938. texture: Nullable<BaseTexture>;
  20939. /**
  20940. * Create a new RefractionBlock
  20941. * @param name defines the block name
  20942. */
  20943. constructor(name: string);
  20944. /**
  20945. * Gets the current class name
  20946. * @returns the class name
  20947. */
  20948. getClassName(): string;
  20949. /**
  20950. * Gets the intensity input component
  20951. */
  20952. get intensity(): NodeMaterialConnectionPoint;
  20953. /**
  20954. * Gets the index of refraction input component
  20955. */
  20956. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20957. /**
  20958. * Gets the tint at distance input component
  20959. */
  20960. get tintAtDistance(): NodeMaterialConnectionPoint;
  20961. /**
  20962. * Gets the view input component
  20963. */
  20964. get view(): NodeMaterialConnectionPoint;
  20965. /**
  20966. * Gets the refraction object output component
  20967. */
  20968. get refraction(): NodeMaterialConnectionPoint;
  20969. /**
  20970. * Returns true if the block has a texture
  20971. */
  20972. get hasTexture(): boolean;
  20973. protected _getTexture(): Nullable<BaseTexture>;
  20974. autoConfigure(material: NodeMaterial): void;
  20975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20976. isReady(): boolean;
  20977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20978. /**
  20979. * Gets the main code of the block (fragment side)
  20980. * @param state current state of the node material building
  20981. * @returns the shader code
  20982. */
  20983. getCode(state: NodeMaterialBuildState): string;
  20984. protected _buildBlock(state: NodeMaterialBuildState): this;
  20985. protected _dumpPropertiesCode(): string;
  20986. serialize(): any;
  20987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20988. }
  20989. }
  20990. declare module BABYLON {
  20991. /**
  20992. * Base block used as input for post process
  20993. */
  20994. export class CurrentScreenBlock extends NodeMaterialBlock {
  20995. private _samplerName;
  20996. private _linearDefineName;
  20997. private _gammaDefineName;
  20998. private _mainUVName;
  20999. private _tempTextureRead;
  21000. /**
  21001. * Gets or sets the texture associated with the node
  21002. */
  21003. texture: Nullable<BaseTexture>;
  21004. /**
  21005. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21006. */
  21007. convertToGammaSpace: boolean;
  21008. /**
  21009. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21010. */
  21011. convertToLinearSpace: boolean;
  21012. /**
  21013. * Create a new CurrentScreenBlock
  21014. * @param name defines the block name
  21015. */
  21016. constructor(name: string);
  21017. /**
  21018. * Gets the current class name
  21019. * @returns the class name
  21020. */
  21021. getClassName(): string;
  21022. /**
  21023. * Gets the uv input component
  21024. */
  21025. get uv(): NodeMaterialConnectionPoint;
  21026. /**
  21027. * Gets the rgba output component
  21028. */
  21029. get rgba(): NodeMaterialConnectionPoint;
  21030. /**
  21031. * Gets the rgb output component
  21032. */
  21033. get rgb(): NodeMaterialConnectionPoint;
  21034. /**
  21035. * Gets the r output component
  21036. */
  21037. get r(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Gets the g output component
  21040. */
  21041. get g(): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Gets the b output component
  21044. */
  21045. get b(): NodeMaterialConnectionPoint;
  21046. /**
  21047. * Gets the a output component
  21048. */
  21049. get a(): NodeMaterialConnectionPoint;
  21050. /**
  21051. * Initialize the block and prepare the context for build
  21052. * @param state defines the state that will be used for the build
  21053. */
  21054. initialize(state: NodeMaterialBuildState): void;
  21055. get target(): NodeMaterialBlockTargets;
  21056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21057. isReady(): boolean;
  21058. private _injectVertexCode;
  21059. private _writeTextureRead;
  21060. private _writeOutput;
  21061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21062. serialize(): any;
  21063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21064. }
  21065. }
  21066. declare module BABYLON {
  21067. /**
  21068. * Base block used for the particle texture
  21069. */
  21070. export class ParticleTextureBlock extends NodeMaterialBlock {
  21071. private _samplerName;
  21072. private _linearDefineName;
  21073. private _gammaDefineName;
  21074. private _tempTextureRead;
  21075. /**
  21076. * Gets or sets the texture associated with the node
  21077. */
  21078. texture: Nullable<BaseTexture>;
  21079. /**
  21080. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21081. */
  21082. convertToGammaSpace: boolean;
  21083. /**
  21084. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21085. */
  21086. convertToLinearSpace: boolean;
  21087. /**
  21088. * Create a new ParticleTextureBlock
  21089. * @param name defines the block name
  21090. */
  21091. constructor(name: string);
  21092. /**
  21093. * Gets the current class name
  21094. * @returns the class name
  21095. */
  21096. getClassName(): string;
  21097. /**
  21098. * Gets the uv input component
  21099. */
  21100. get uv(): NodeMaterialConnectionPoint;
  21101. /**
  21102. * Gets the rgba output component
  21103. */
  21104. get rgba(): NodeMaterialConnectionPoint;
  21105. /**
  21106. * Gets the rgb output component
  21107. */
  21108. get rgb(): NodeMaterialConnectionPoint;
  21109. /**
  21110. * Gets the r output component
  21111. */
  21112. get r(): NodeMaterialConnectionPoint;
  21113. /**
  21114. * Gets the g output component
  21115. */
  21116. get g(): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Gets the b output component
  21119. */
  21120. get b(): NodeMaterialConnectionPoint;
  21121. /**
  21122. * Gets the a output component
  21123. */
  21124. get a(): NodeMaterialConnectionPoint;
  21125. /**
  21126. * Initialize the block and prepare the context for build
  21127. * @param state defines the state that will be used for the build
  21128. */
  21129. initialize(state: NodeMaterialBuildState): void;
  21130. autoConfigure(material: NodeMaterial): void;
  21131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21132. isReady(): boolean;
  21133. private _writeOutput;
  21134. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21135. serialize(): any;
  21136. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21137. }
  21138. }
  21139. declare module BABYLON {
  21140. /**
  21141. * Class used to store shared data between 2 NodeMaterialBuildState
  21142. */
  21143. export class NodeMaterialBuildStateSharedData {
  21144. /**
  21145. * Gets the list of emitted varyings
  21146. */
  21147. temps: string[];
  21148. /**
  21149. * Gets the list of emitted varyings
  21150. */
  21151. varyings: string[];
  21152. /**
  21153. * Gets the varying declaration string
  21154. */
  21155. varyingDeclaration: string;
  21156. /**
  21157. * Input blocks
  21158. */
  21159. inputBlocks: InputBlock[];
  21160. /**
  21161. * Input blocks
  21162. */
  21163. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21164. /**
  21165. * Bindable blocks (Blocks that need to set data to the effect)
  21166. */
  21167. bindableBlocks: NodeMaterialBlock[];
  21168. /**
  21169. * List of blocks that can provide a compilation fallback
  21170. */
  21171. blocksWithFallbacks: NodeMaterialBlock[];
  21172. /**
  21173. * List of blocks that can provide a define update
  21174. */
  21175. blocksWithDefines: NodeMaterialBlock[];
  21176. /**
  21177. * List of blocks that can provide a repeatable content
  21178. */
  21179. repeatableContentBlocks: NodeMaterialBlock[];
  21180. /**
  21181. * List of blocks that can provide a dynamic list of uniforms
  21182. */
  21183. dynamicUniformBlocks: NodeMaterialBlock[];
  21184. /**
  21185. * List of blocks that can block the isReady function for the material
  21186. */
  21187. blockingBlocks: NodeMaterialBlock[];
  21188. /**
  21189. * Gets the list of animated inputs
  21190. */
  21191. animatedInputs: InputBlock[];
  21192. /**
  21193. * Build Id used to avoid multiple recompilations
  21194. */
  21195. buildId: number;
  21196. /** List of emitted variables */
  21197. variableNames: {
  21198. [key: string]: number;
  21199. };
  21200. /** List of emitted defines */
  21201. defineNames: {
  21202. [key: string]: number;
  21203. };
  21204. /** Should emit comments? */
  21205. emitComments: boolean;
  21206. /** Emit build activity */
  21207. verbose: boolean;
  21208. /** Gets or sets the hosting scene */
  21209. scene: Scene;
  21210. /**
  21211. * Gets the compilation hints emitted at compilation time
  21212. */
  21213. hints: {
  21214. needWorldViewMatrix: boolean;
  21215. needWorldViewProjectionMatrix: boolean;
  21216. needAlphaBlending: boolean;
  21217. needAlphaTesting: boolean;
  21218. };
  21219. /**
  21220. * List of compilation checks
  21221. */
  21222. checks: {
  21223. emitVertex: boolean;
  21224. emitFragment: boolean;
  21225. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21226. };
  21227. /**
  21228. * Is vertex program allowed to be empty?
  21229. */
  21230. allowEmptyVertexProgram: boolean;
  21231. /** Creates a new shared data */
  21232. constructor();
  21233. /**
  21234. * Emits console errors and exceptions if there is a failing check
  21235. */
  21236. emitErrors(): void;
  21237. }
  21238. }
  21239. declare module BABYLON {
  21240. /**
  21241. * Class used to store node based material build state
  21242. */
  21243. export class NodeMaterialBuildState {
  21244. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21245. supportUniformBuffers: boolean;
  21246. /**
  21247. * Gets the list of emitted attributes
  21248. */
  21249. attributes: string[];
  21250. /**
  21251. * Gets the list of emitted uniforms
  21252. */
  21253. uniforms: string[];
  21254. /**
  21255. * Gets the list of emitted constants
  21256. */
  21257. constants: string[];
  21258. /**
  21259. * Gets the list of emitted samplers
  21260. */
  21261. samplers: string[];
  21262. /**
  21263. * Gets the list of emitted functions
  21264. */
  21265. functions: {
  21266. [key: string]: string;
  21267. };
  21268. /**
  21269. * Gets the list of emitted extensions
  21270. */
  21271. extensions: {
  21272. [key: string]: string;
  21273. };
  21274. /**
  21275. * Gets the target of the compilation state
  21276. */
  21277. target: NodeMaterialBlockTargets;
  21278. /**
  21279. * Gets the list of emitted counters
  21280. */
  21281. counters: {
  21282. [key: string]: number;
  21283. };
  21284. /**
  21285. * Shared data between multiple NodeMaterialBuildState instances
  21286. */
  21287. sharedData: NodeMaterialBuildStateSharedData;
  21288. /** @hidden */
  21289. _vertexState: NodeMaterialBuildState;
  21290. /** @hidden */
  21291. _attributeDeclaration: string;
  21292. /** @hidden */
  21293. _uniformDeclaration: string;
  21294. /** @hidden */
  21295. _constantDeclaration: string;
  21296. /** @hidden */
  21297. _samplerDeclaration: string;
  21298. /** @hidden */
  21299. _varyingTransfer: string;
  21300. /** @hidden */
  21301. _injectAtEnd: string;
  21302. private _repeatableContentAnchorIndex;
  21303. /** @hidden */
  21304. _builtCompilationString: string;
  21305. /**
  21306. * Gets the emitted compilation strings
  21307. */
  21308. compilationString: string;
  21309. /**
  21310. * Finalize the compilation strings
  21311. * @param state defines the current compilation state
  21312. */
  21313. finalize(state: NodeMaterialBuildState): void;
  21314. /** @hidden */
  21315. get _repeatableContentAnchor(): string;
  21316. /** @hidden */
  21317. _getFreeVariableName(prefix: string): string;
  21318. /** @hidden */
  21319. _getFreeDefineName(prefix: string): string;
  21320. /** @hidden */
  21321. _excludeVariableName(name: string): void;
  21322. /** @hidden */
  21323. _emit2DSampler(name: string): void;
  21324. /** @hidden */
  21325. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21326. /** @hidden */
  21327. _emitExtension(name: string, extension: string, define?: string): void;
  21328. /** @hidden */
  21329. _emitFunction(name: string, code: string, comments: string): void;
  21330. /** @hidden */
  21331. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21332. replaceStrings?: {
  21333. search: RegExp;
  21334. replace: string;
  21335. }[];
  21336. repeatKey?: string;
  21337. }): string;
  21338. /** @hidden */
  21339. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21340. repeatKey?: string;
  21341. removeAttributes?: boolean;
  21342. removeUniforms?: boolean;
  21343. removeVaryings?: boolean;
  21344. removeIfDef?: boolean;
  21345. replaceStrings?: {
  21346. search: RegExp;
  21347. replace: string;
  21348. }[];
  21349. }, storeKey?: string): void;
  21350. /** @hidden */
  21351. _registerTempVariable(name: string): boolean;
  21352. /** @hidden */
  21353. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21354. /** @hidden */
  21355. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21356. /** @hidden */
  21357. _emitFloat(value: number): string;
  21358. }
  21359. }
  21360. declare module BABYLON {
  21361. /**
  21362. * Helper class used to generate session unique ID
  21363. */
  21364. export class UniqueIdGenerator {
  21365. private static _UniqueIdCounter;
  21366. /**
  21367. * Gets an unique (relatively to the current scene) Id
  21368. */
  21369. static get UniqueId(): number;
  21370. }
  21371. }
  21372. declare module BABYLON {
  21373. /**
  21374. * Defines a block that can be used inside a node based material
  21375. */
  21376. export class NodeMaterialBlock {
  21377. private _buildId;
  21378. private _buildTarget;
  21379. private _target;
  21380. private _isFinalMerger;
  21381. private _isInput;
  21382. private _name;
  21383. protected _isUnique: boolean;
  21384. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21385. inputsAreExclusive: boolean;
  21386. /** @hidden */
  21387. _codeVariableName: string;
  21388. /** @hidden */
  21389. _inputs: NodeMaterialConnectionPoint[];
  21390. /** @hidden */
  21391. _outputs: NodeMaterialConnectionPoint[];
  21392. /** @hidden */
  21393. _preparationId: number;
  21394. /**
  21395. * Gets the name of the block
  21396. */
  21397. get name(): string;
  21398. /**
  21399. * Sets the name of the block. Will check if the name is valid.
  21400. */
  21401. set name(newName: string);
  21402. /**
  21403. * Gets or sets the unique id of the node
  21404. */
  21405. uniqueId: number;
  21406. /**
  21407. * Gets or sets the comments associated with this block
  21408. */
  21409. comments: string;
  21410. /**
  21411. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21412. */
  21413. get isUnique(): boolean;
  21414. /**
  21415. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21416. */
  21417. get isFinalMerger(): boolean;
  21418. /**
  21419. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21420. */
  21421. get isInput(): boolean;
  21422. /**
  21423. * Gets or sets the build Id
  21424. */
  21425. get buildId(): number;
  21426. set buildId(value: number);
  21427. /**
  21428. * Gets or sets the target of the block
  21429. */
  21430. get target(): NodeMaterialBlockTargets;
  21431. set target(value: NodeMaterialBlockTargets);
  21432. /**
  21433. * Gets the list of input points
  21434. */
  21435. get inputs(): NodeMaterialConnectionPoint[];
  21436. /** Gets the list of output points */
  21437. get outputs(): NodeMaterialConnectionPoint[];
  21438. /**
  21439. * Find an input by its name
  21440. * @param name defines the name of the input to look for
  21441. * @returns the input or null if not found
  21442. */
  21443. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21444. /**
  21445. * Find an output by its name
  21446. * @param name defines the name of the outputto look for
  21447. * @returns the output or null if not found
  21448. */
  21449. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21450. /**
  21451. * Creates a new NodeMaterialBlock
  21452. * @param name defines the block name
  21453. * @param target defines the target of that block (Vertex by default)
  21454. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21455. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21456. */
  21457. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21458. /**
  21459. * Initialize the block and prepare the context for build
  21460. * @param state defines the state that will be used for the build
  21461. */
  21462. initialize(state: NodeMaterialBuildState): void;
  21463. /**
  21464. * Bind data to effect. Will only be called for blocks with isBindable === true
  21465. * @param effect defines the effect to bind data to
  21466. * @param nodeMaterial defines the hosting NodeMaterial
  21467. * @param mesh defines the mesh that will be rendered
  21468. * @param subMesh defines the submesh that will be rendered
  21469. */
  21470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21471. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21472. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21473. protected _writeFloat(value: number): string;
  21474. /**
  21475. * Gets the current class name e.g. "NodeMaterialBlock"
  21476. * @returns the class name
  21477. */
  21478. getClassName(): string;
  21479. /**
  21480. * Register a new input. Must be called inside a block constructor
  21481. * @param name defines the connection point name
  21482. * @param type defines the connection point type
  21483. * @param isOptional defines a boolean indicating that this input can be omitted
  21484. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21485. * @param point an already created connection point. If not provided, create a new one
  21486. * @returns the current block
  21487. */
  21488. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21489. /**
  21490. * Register a new output. Must be called inside a block constructor
  21491. * @param name defines the connection point name
  21492. * @param type defines the connection point type
  21493. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21494. * @param point an already created connection point. If not provided, create a new one
  21495. * @returns the current block
  21496. */
  21497. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21498. /**
  21499. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21500. * @param forOutput defines an optional connection point to check compatibility with
  21501. * @returns the first available input or null
  21502. */
  21503. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21504. /**
  21505. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21506. * @param forBlock defines an optional block to check compatibility with
  21507. * @returns the first available input or null
  21508. */
  21509. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21510. /**
  21511. * Gets the sibling of the given output
  21512. * @param current defines the current output
  21513. * @returns the next output in the list or null
  21514. */
  21515. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21516. /**
  21517. * Connect current block with another block
  21518. * @param other defines the block to connect with
  21519. * @param options define the various options to help pick the right connections
  21520. * @returns the current block
  21521. */
  21522. connectTo(other: NodeMaterialBlock, options?: {
  21523. input?: string;
  21524. output?: string;
  21525. outputSwizzle?: string;
  21526. }): this | undefined;
  21527. protected _buildBlock(state: NodeMaterialBuildState): void;
  21528. /**
  21529. * Add uniforms, samplers and uniform buffers at compilation time
  21530. * @param state defines the state to update
  21531. * @param nodeMaterial defines the node material requesting the update
  21532. * @param defines defines the material defines to update
  21533. * @param uniformBuffers defines the list of uniform buffer names
  21534. */
  21535. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21536. /**
  21537. * Add potential fallbacks if shader compilation fails
  21538. * @param mesh defines the mesh to be rendered
  21539. * @param fallbacks defines the current prioritized list of fallbacks
  21540. */
  21541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21542. /**
  21543. * Initialize defines for shader compilation
  21544. * @param mesh defines the mesh to be rendered
  21545. * @param nodeMaterial defines the node material requesting the update
  21546. * @param defines defines the material defines to update
  21547. * @param useInstances specifies that instances should be used
  21548. */
  21549. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21550. /**
  21551. * Update defines for shader compilation
  21552. * @param mesh defines the mesh to be rendered
  21553. * @param nodeMaterial defines the node material requesting the update
  21554. * @param defines defines the material defines to update
  21555. * @param useInstances specifies that instances should be used
  21556. * @param subMesh defines which submesh to render
  21557. */
  21558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21559. /**
  21560. * Lets the block try to connect some inputs automatically
  21561. * @param material defines the hosting NodeMaterial
  21562. */
  21563. autoConfigure(material: NodeMaterial): void;
  21564. /**
  21565. * Function called when a block is declared as repeatable content generator
  21566. * @param vertexShaderState defines the current compilation state for the vertex shader
  21567. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21568. * @param mesh defines the mesh to be rendered
  21569. * @param defines defines the material defines to update
  21570. */
  21571. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21572. /**
  21573. * Checks if the block is ready
  21574. * @param mesh defines the mesh to be rendered
  21575. * @param nodeMaterial defines the node material requesting the update
  21576. * @param defines defines the material defines to update
  21577. * @param useInstances specifies that instances should be used
  21578. * @returns true if the block is ready
  21579. */
  21580. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21581. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21582. private _processBuild;
  21583. /**
  21584. * Validates the new name for the block node.
  21585. * @param newName the new name to be given to the node.
  21586. * @returns false if the name is a reserve word, else true.
  21587. */
  21588. validateBlockName(newName: string): boolean;
  21589. /**
  21590. * Compile the current node and generate the shader code
  21591. * @param state defines the current compilation state (uniforms, samplers, current string)
  21592. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21593. * @returns true if already built
  21594. */
  21595. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21596. protected _inputRename(name: string): string;
  21597. protected _outputRename(name: string): string;
  21598. protected _dumpPropertiesCode(): string;
  21599. /** @hidden */
  21600. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21601. /** @hidden */
  21602. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21603. /**
  21604. * Clone the current block to a new identical block
  21605. * @param scene defines the hosting scene
  21606. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21607. * @returns a copy of the current block
  21608. */
  21609. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21610. /**
  21611. * Serializes this block in a JSON representation
  21612. * @returns the serialized block object
  21613. */
  21614. serialize(): any;
  21615. /** @hidden */
  21616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21617. private _deserializePortDisplayNamesAndExposedOnFrame;
  21618. /**
  21619. * Release resources
  21620. */
  21621. dispose(): void;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Base class of materials working in push mode in babylon JS
  21627. * @hidden
  21628. */
  21629. export class PushMaterial extends Material {
  21630. protected _activeEffect: Effect;
  21631. protected _normalMatrix: Matrix;
  21632. constructor(name: string, scene: Scene);
  21633. getEffect(): Effect;
  21634. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21635. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21636. /**
  21637. * Binds the given world matrix to the active effect
  21638. *
  21639. * @param world the matrix to bind
  21640. */
  21641. bindOnlyWorldMatrix(world: Matrix): void;
  21642. /**
  21643. * Binds the given normal matrix to the active effect
  21644. *
  21645. * @param normalMatrix the matrix to bind
  21646. */
  21647. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21648. bind(world: Matrix, mesh?: Mesh): void;
  21649. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21650. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Root class for all node material optimizers
  21656. */
  21657. export class NodeMaterialOptimizer {
  21658. /**
  21659. * Function used to optimize a NodeMaterial graph
  21660. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21661. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21662. */
  21663. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21664. }
  21665. }
  21666. declare module BABYLON {
  21667. /**
  21668. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21669. */
  21670. export class TransformBlock extends NodeMaterialBlock {
  21671. /**
  21672. * Defines the value to use to complement W value to transform it to a Vector4
  21673. */
  21674. complementW: number;
  21675. /**
  21676. * Defines the value to use to complement z value to transform it to a Vector4
  21677. */
  21678. complementZ: number;
  21679. /**
  21680. * Creates a new TransformBlock
  21681. * @param name defines the block name
  21682. */
  21683. constructor(name: string);
  21684. /**
  21685. * Gets the current class name
  21686. * @returns the class name
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Gets the vector input
  21691. */
  21692. get vector(): NodeMaterialConnectionPoint;
  21693. /**
  21694. * Gets the output component
  21695. */
  21696. get output(): NodeMaterialConnectionPoint;
  21697. /**
  21698. * Gets the xyz output component
  21699. */
  21700. get xyz(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the matrix transform input
  21703. */
  21704. get transform(): NodeMaterialConnectionPoint;
  21705. protected _buildBlock(state: NodeMaterialBuildState): this;
  21706. /**
  21707. * Update defines for shader compilation
  21708. * @param mesh defines the mesh to be rendered
  21709. * @param nodeMaterial defines the node material requesting the update
  21710. * @param defines defines the material defines to update
  21711. * @param useInstances specifies that instances should be used
  21712. * @param subMesh defines which submesh to render
  21713. */
  21714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21715. serialize(): any;
  21716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21717. protected _dumpPropertiesCode(): string;
  21718. }
  21719. }
  21720. declare module BABYLON {
  21721. /**
  21722. * Block used to output the vertex position
  21723. */
  21724. export class VertexOutputBlock extends NodeMaterialBlock {
  21725. /**
  21726. * Creates a new VertexOutputBlock
  21727. * @param name defines the block name
  21728. */
  21729. constructor(name: string);
  21730. /**
  21731. * Gets the current class name
  21732. * @returns the class name
  21733. */
  21734. getClassName(): string;
  21735. /**
  21736. * Gets the vector input component
  21737. */
  21738. get vector(): NodeMaterialConnectionPoint;
  21739. protected _buildBlock(state: NodeMaterialBuildState): this;
  21740. }
  21741. }
  21742. declare module BABYLON {
  21743. /**
  21744. * Block used to output the final color
  21745. */
  21746. export class FragmentOutputBlock extends NodeMaterialBlock {
  21747. /**
  21748. * Create a new FragmentOutputBlock
  21749. * @param name defines the block name
  21750. */
  21751. constructor(name: string);
  21752. /**
  21753. * Gets the current class name
  21754. * @returns the class name
  21755. */
  21756. getClassName(): string;
  21757. /**
  21758. * Gets the rgba input component
  21759. */
  21760. get rgba(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the rgb input component
  21763. */
  21764. get rgb(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the a input component
  21767. */
  21768. get a(): NodeMaterialConnectionPoint;
  21769. protected _buildBlock(state: NodeMaterialBuildState): this;
  21770. }
  21771. }
  21772. declare module BABYLON {
  21773. /**
  21774. * Block used for the particle ramp gradient section
  21775. */
  21776. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21777. /**
  21778. * Create a new ParticleRampGradientBlock
  21779. * @param name defines the block name
  21780. */
  21781. constructor(name: string);
  21782. /**
  21783. * Gets the current class name
  21784. * @returns the class name
  21785. */
  21786. getClassName(): string;
  21787. /**
  21788. * Gets the color input component
  21789. */
  21790. get color(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the rampColor output component
  21793. */
  21794. get rampColor(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Initialize the block and prepare the context for build
  21797. * @param state defines the state that will be used for the build
  21798. */
  21799. initialize(state: NodeMaterialBuildState): void;
  21800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21801. }
  21802. }
  21803. declare module BABYLON {
  21804. /**
  21805. * Block used for the particle blend multiply section
  21806. */
  21807. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21808. /**
  21809. * Create a new ParticleBlendMultiplyBlock
  21810. * @param name defines the block name
  21811. */
  21812. constructor(name: string);
  21813. /**
  21814. * Gets the current class name
  21815. * @returns the class name
  21816. */
  21817. getClassName(): string;
  21818. /**
  21819. * Gets the color input component
  21820. */
  21821. get color(): NodeMaterialConnectionPoint;
  21822. /**
  21823. * Gets the alphaTexture input component
  21824. */
  21825. get alphaTexture(): NodeMaterialConnectionPoint;
  21826. /**
  21827. * Gets the alphaColor input component
  21828. */
  21829. get alphaColor(): NodeMaterialConnectionPoint;
  21830. /**
  21831. * Gets the blendColor output component
  21832. */
  21833. get blendColor(): NodeMaterialConnectionPoint;
  21834. /**
  21835. * Initialize the block and prepare the context for build
  21836. * @param state defines the state that will be used for the build
  21837. */
  21838. initialize(state: NodeMaterialBuildState): void;
  21839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21840. }
  21841. }
  21842. declare module BABYLON {
  21843. /**
  21844. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21845. */
  21846. export class VectorMergerBlock extends NodeMaterialBlock {
  21847. /**
  21848. * Create a new VectorMergerBlock
  21849. * @param name defines the block name
  21850. */
  21851. constructor(name: string);
  21852. /**
  21853. * Gets the current class name
  21854. * @returns the class name
  21855. */
  21856. getClassName(): string;
  21857. /**
  21858. * Gets the xyz component (input)
  21859. */
  21860. get xyzIn(): NodeMaterialConnectionPoint;
  21861. /**
  21862. * Gets the xy component (input)
  21863. */
  21864. get xyIn(): NodeMaterialConnectionPoint;
  21865. /**
  21866. * Gets the x component (input)
  21867. */
  21868. get x(): NodeMaterialConnectionPoint;
  21869. /**
  21870. * Gets the y component (input)
  21871. */
  21872. get y(): NodeMaterialConnectionPoint;
  21873. /**
  21874. * Gets the z component (input)
  21875. */
  21876. get z(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the w component (input)
  21879. */
  21880. get w(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the xyzw component (output)
  21883. */
  21884. get xyzw(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the xyz component (output)
  21887. */
  21888. get xyzOut(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the xy component (output)
  21891. */
  21892. get xyOut(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the xy component (output)
  21895. * @deprecated Please use xyOut instead.
  21896. */
  21897. get xy(): NodeMaterialConnectionPoint;
  21898. /**
  21899. * Gets the xyz component (output)
  21900. * @deprecated Please use xyzOut instead.
  21901. */
  21902. get xyz(): NodeMaterialConnectionPoint;
  21903. protected _buildBlock(state: NodeMaterialBuildState): this;
  21904. }
  21905. }
  21906. declare module BABYLON {
  21907. /**
  21908. * Block used to remap a float from a range to a new one
  21909. */
  21910. export class RemapBlock extends NodeMaterialBlock {
  21911. /**
  21912. * Gets or sets the source range
  21913. */
  21914. sourceRange: Vector2;
  21915. /**
  21916. * Gets or sets the target range
  21917. */
  21918. targetRange: Vector2;
  21919. /**
  21920. * Creates a new RemapBlock
  21921. * @param name defines the block name
  21922. */
  21923. constructor(name: string);
  21924. /**
  21925. * Gets the current class name
  21926. * @returns the class name
  21927. */
  21928. getClassName(): string;
  21929. /**
  21930. * Gets the input component
  21931. */
  21932. get input(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the source min input component
  21935. */
  21936. get sourceMin(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the source max input component
  21939. */
  21940. get sourceMax(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the target min input component
  21943. */
  21944. get targetMin(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the target max input component
  21947. */
  21948. get targetMax(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the output component
  21951. */
  21952. get output(): NodeMaterialConnectionPoint;
  21953. protected _buildBlock(state: NodeMaterialBuildState): this;
  21954. protected _dumpPropertiesCode(): string;
  21955. serialize(): any;
  21956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Block used to multiply 2 values
  21962. */
  21963. export class MultiplyBlock extends NodeMaterialBlock {
  21964. /**
  21965. * Creates a new MultiplyBlock
  21966. * @param name defines the block name
  21967. */
  21968. constructor(name: string);
  21969. /**
  21970. * Gets the current class name
  21971. * @returns the class name
  21972. */
  21973. getClassName(): string;
  21974. /**
  21975. * Gets the left operand input component
  21976. */
  21977. get left(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the right operand input component
  21980. */
  21981. get right(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the output component
  21984. */
  21985. get output(): NodeMaterialConnectionPoint;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21992. */
  21993. export class ColorSplitterBlock extends NodeMaterialBlock {
  21994. /**
  21995. * Create a new ColorSplitterBlock
  21996. * @param name defines the block name
  21997. */
  21998. constructor(name: string);
  21999. /**
  22000. * Gets the current class name
  22001. * @returns the class name
  22002. */
  22003. getClassName(): string;
  22004. /**
  22005. * Gets the rgba component (input)
  22006. */
  22007. get rgba(): NodeMaterialConnectionPoint;
  22008. /**
  22009. * Gets the rgb component (input)
  22010. */
  22011. get rgbIn(): NodeMaterialConnectionPoint;
  22012. /**
  22013. * Gets the rgb component (output)
  22014. */
  22015. get rgbOut(): NodeMaterialConnectionPoint;
  22016. /**
  22017. * Gets the r component (output)
  22018. */
  22019. get r(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the g component (output)
  22022. */
  22023. get g(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the b component (output)
  22026. */
  22027. get b(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the a component (output)
  22030. */
  22031. get a(): NodeMaterialConnectionPoint;
  22032. protected _inputRename(name: string): string;
  22033. protected _outputRename(name: string): string;
  22034. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22035. }
  22036. }
  22037. declare module BABYLON {
  22038. /**
  22039. * Interface used to configure the node material editor
  22040. */
  22041. export interface INodeMaterialEditorOptions {
  22042. /** Define the URl to load node editor script */
  22043. editorURL?: string;
  22044. }
  22045. /** @hidden */
  22046. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22047. NORMAL: boolean;
  22048. TANGENT: boolean;
  22049. UV1: boolean;
  22050. /** BONES */
  22051. NUM_BONE_INFLUENCERS: number;
  22052. BonesPerMesh: number;
  22053. BONETEXTURE: boolean;
  22054. /** MORPH TARGETS */
  22055. MORPHTARGETS: boolean;
  22056. MORPHTARGETS_NORMAL: boolean;
  22057. MORPHTARGETS_TANGENT: boolean;
  22058. MORPHTARGETS_UV: boolean;
  22059. NUM_MORPH_INFLUENCERS: number;
  22060. /** IMAGE PROCESSING */
  22061. IMAGEPROCESSING: boolean;
  22062. VIGNETTE: boolean;
  22063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22064. VIGNETTEBLENDMODEOPAQUE: boolean;
  22065. TONEMAPPING: boolean;
  22066. TONEMAPPING_ACES: boolean;
  22067. CONTRAST: boolean;
  22068. EXPOSURE: boolean;
  22069. COLORCURVES: boolean;
  22070. COLORGRADING: boolean;
  22071. COLORGRADING3D: boolean;
  22072. SAMPLER3DGREENDEPTH: boolean;
  22073. SAMPLER3DBGRMAP: boolean;
  22074. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22075. /** MISC. */
  22076. BUMPDIRECTUV: number;
  22077. constructor();
  22078. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22079. }
  22080. /**
  22081. * Class used to configure NodeMaterial
  22082. */
  22083. export interface INodeMaterialOptions {
  22084. /**
  22085. * Defines if blocks should emit comments
  22086. */
  22087. emitComments: boolean;
  22088. }
  22089. /**
  22090. * Class used to create a node based material built by assembling shader blocks
  22091. */
  22092. export class NodeMaterial extends PushMaterial {
  22093. private static _BuildIdGenerator;
  22094. private _options;
  22095. private _vertexCompilationState;
  22096. private _fragmentCompilationState;
  22097. private _sharedData;
  22098. private _buildId;
  22099. private _buildWasSuccessful;
  22100. private _cachedWorldViewMatrix;
  22101. private _cachedWorldViewProjectionMatrix;
  22102. private _optimizers;
  22103. private _animationFrame;
  22104. /** Define the Url to load node editor script */
  22105. static EditorURL: string;
  22106. /** Define the Url to load snippets */
  22107. static SnippetUrl: string;
  22108. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22109. static IgnoreTexturesAtLoadTime: boolean;
  22110. private BJSNODEMATERIALEDITOR;
  22111. /** Get the inspector from bundle or global */
  22112. private _getGlobalNodeMaterialEditor;
  22113. /**
  22114. * Snippet ID if the material was created from the snippet server
  22115. */
  22116. snippetId: string;
  22117. /**
  22118. * Gets or sets data used by visual editor
  22119. * @see https://nme.babylonjs.com
  22120. */
  22121. editorData: any;
  22122. /**
  22123. * 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)
  22124. */
  22125. ignoreAlpha: boolean;
  22126. /**
  22127. * Defines the maximum number of lights that can be used in the material
  22128. */
  22129. maxSimultaneousLights: number;
  22130. /**
  22131. * Observable raised when the material is built
  22132. */
  22133. onBuildObservable: Observable<NodeMaterial>;
  22134. /**
  22135. * Gets or sets the root nodes of the material vertex shader
  22136. */
  22137. _vertexOutputNodes: NodeMaterialBlock[];
  22138. /**
  22139. * Gets or sets the root nodes of the material fragment (pixel) shader
  22140. */
  22141. _fragmentOutputNodes: NodeMaterialBlock[];
  22142. /** Gets or sets options to control the node material overall behavior */
  22143. get options(): INodeMaterialOptions;
  22144. set options(options: INodeMaterialOptions);
  22145. /**
  22146. * Default configuration related to image processing available in the standard Material.
  22147. */
  22148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22149. /**
  22150. * Gets the image processing configuration used either in this material.
  22151. */
  22152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22153. /**
  22154. * Sets the Default image processing configuration used either in the this material.
  22155. *
  22156. * If sets to null, the scene one is in use.
  22157. */
  22158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22159. /**
  22160. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22161. */
  22162. attachedBlocks: NodeMaterialBlock[];
  22163. /**
  22164. * Specifies the mode of the node material
  22165. * @hidden
  22166. */
  22167. _mode: NodeMaterialModes;
  22168. /**
  22169. * Gets the mode property
  22170. */
  22171. get mode(): NodeMaterialModes;
  22172. /**
  22173. * Create a new node based material
  22174. * @param name defines the material name
  22175. * @param scene defines the hosting scene
  22176. * @param options defines creation option
  22177. */
  22178. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22179. /**
  22180. * Gets the current class name of the material e.g. "NodeMaterial"
  22181. * @returns the class name
  22182. */
  22183. getClassName(): string;
  22184. /**
  22185. * Keep track of the image processing observer to allow dispose and replace.
  22186. */
  22187. private _imageProcessingObserver;
  22188. /**
  22189. * Attaches a new image processing configuration to the Standard Material.
  22190. * @param configuration
  22191. */
  22192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22193. /**
  22194. * Get a block by its name
  22195. * @param name defines the name of the block to retrieve
  22196. * @returns the required block or null if not found
  22197. */
  22198. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22199. /**
  22200. * Get a block by its name
  22201. * @param predicate defines the predicate used to find the good candidate
  22202. * @returns the required block or null if not found
  22203. */
  22204. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22205. /**
  22206. * Get an input block by its name
  22207. * @param predicate defines the predicate used to find the good candidate
  22208. * @returns the required input block or null if not found
  22209. */
  22210. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22211. /**
  22212. * Gets the list of input blocks attached to this material
  22213. * @returns an array of InputBlocks
  22214. */
  22215. getInputBlocks(): InputBlock[];
  22216. /**
  22217. * Adds a new optimizer to the list of optimizers
  22218. * @param optimizer defines the optimizers to add
  22219. * @returns the current material
  22220. */
  22221. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22222. /**
  22223. * Remove an optimizer from the list of optimizers
  22224. * @param optimizer defines the optimizers to remove
  22225. * @returns the current material
  22226. */
  22227. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22228. /**
  22229. * Add a new block to the list of output nodes
  22230. * @param node defines the node to add
  22231. * @returns the current material
  22232. */
  22233. addOutputNode(node: NodeMaterialBlock): this;
  22234. /**
  22235. * Remove a block from the list of root nodes
  22236. * @param node defines the node to remove
  22237. * @returns the current material
  22238. */
  22239. removeOutputNode(node: NodeMaterialBlock): this;
  22240. private _addVertexOutputNode;
  22241. private _removeVertexOutputNode;
  22242. private _addFragmentOutputNode;
  22243. private _removeFragmentOutputNode;
  22244. /**
  22245. * Specifies if the material will require alpha blending
  22246. * @returns a boolean specifying if alpha blending is needed
  22247. */
  22248. needAlphaBlending(): boolean;
  22249. /**
  22250. * Specifies if this material should be rendered in alpha test mode
  22251. * @returns a boolean specifying if an alpha test is needed.
  22252. */
  22253. needAlphaTesting(): boolean;
  22254. private _initializeBlock;
  22255. private _resetDualBlocks;
  22256. /**
  22257. * Remove a block from the current node material
  22258. * @param block defines the block to remove
  22259. */
  22260. removeBlock(block: NodeMaterialBlock): void;
  22261. /**
  22262. * Build the material and generates the inner effect
  22263. * @param verbose defines if the build should log activity
  22264. */
  22265. build(verbose?: boolean): void;
  22266. /**
  22267. * Runs an otpimization phase to try to improve the shader code
  22268. */
  22269. optimize(): void;
  22270. private _prepareDefinesForAttributes;
  22271. /**
  22272. * Create a post process from the material
  22273. * @param camera The camera to apply the render pass to.
  22274. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22276. * @param engine The engine which the post process will be applied. (default: current engine)
  22277. * @param reusable If the post process can be reused on the same frame. (default: false)
  22278. * @param textureType Type of textures used when performing the post process. (default: 0)
  22279. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22280. * @returns the post process created
  22281. */
  22282. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22283. /**
  22284. * Create the post process effect from the material
  22285. * @param postProcess The post process to create the effect for
  22286. */
  22287. createEffectForPostProcess(postProcess: PostProcess): void;
  22288. private _createEffectOrPostProcess;
  22289. private _createEffectForParticles;
  22290. /**
  22291. * Create the effect to be used as the custom effect for a particle system
  22292. * @param particleSystem Particle system to create the effect for
  22293. * @param onCompiled defines a function to call when the effect creation is successful
  22294. * @param onError defines a function to call when the effect creation has failed
  22295. */
  22296. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22297. private _processDefines;
  22298. /**
  22299. * Get if the submesh is ready to be used and all its information available.
  22300. * Child classes can use it to update shaders
  22301. * @param mesh defines the mesh to check
  22302. * @param subMesh defines which submesh to check
  22303. * @param useInstances specifies that instances should be used
  22304. * @returns a boolean indicating that the submesh is ready or not
  22305. */
  22306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22307. /**
  22308. * Get a string representing the shaders built by the current node graph
  22309. */
  22310. get compiledShaders(): string;
  22311. /**
  22312. * Binds the world matrix to the material
  22313. * @param world defines the world transformation matrix
  22314. */
  22315. bindOnlyWorldMatrix(world: Matrix): void;
  22316. /**
  22317. * Binds the submesh to this material by preparing the effect and shader to draw
  22318. * @param world defines the world transformation matrix
  22319. * @param mesh defines the mesh containing the submesh
  22320. * @param subMesh defines the submesh to bind the material to
  22321. */
  22322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22323. /**
  22324. * Gets the active textures from the material
  22325. * @returns an array of textures
  22326. */
  22327. getActiveTextures(): BaseTexture[];
  22328. /**
  22329. * Gets the list of texture blocks
  22330. * @returns an array of texture blocks
  22331. */
  22332. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22333. /**
  22334. * Specifies if the material uses a texture
  22335. * @param texture defines the texture to check against the material
  22336. * @returns a boolean specifying if the material uses the texture
  22337. */
  22338. hasTexture(texture: BaseTexture): boolean;
  22339. /**
  22340. * Disposes the material
  22341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22343. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22344. */
  22345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22346. /** Creates the node editor window. */
  22347. private _createNodeEditor;
  22348. /**
  22349. * Launch the node material editor
  22350. * @param config Define the configuration of the editor
  22351. * @return a promise fulfilled when the node editor is visible
  22352. */
  22353. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22354. /**
  22355. * Clear the current material
  22356. */
  22357. clear(): void;
  22358. /**
  22359. * Clear the current material and set it to a default state
  22360. */
  22361. setToDefault(): void;
  22362. /**
  22363. * Clear the current material and set it to a default state for post process
  22364. */
  22365. setToDefaultPostProcess(): void;
  22366. /**
  22367. * Clear the current material and set it to a default state for particle
  22368. */
  22369. setToDefaultParticle(): void;
  22370. /**
  22371. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22372. * @param url defines the url to load from
  22373. * @returns a promise that will fullfil when the material is fully loaded
  22374. */
  22375. loadAsync(url: string): Promise<void>;
  22376. private _gatherBlocks;
  22377. /**
  22378. * Generate a string containing the code declaration required to create an equivalent of this material
  22379. * @returns a string
  22380. */
  22381. generateCode(): string;
  22382. /**
  22383. * Serializes this material in a JSON representation
  22384. * @returns the serialized material object
  22385. */
  22386. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22387. private _restoreConnections;
  22388. /**
  22389. * Clear the current graph and load a new one from a serialization object
  22390. * @param source defines the JSON representation of the material
  22391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22392. * @param merge defines whether or not the source must be merged or replace the current content
  22393. */
  22394. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22395. /**
  22396. * Makes a duplicate of the current material.
  22397. * @param name - name to use for the new material.
  22398. */
  22399. clone(name: string): NodeMaterial;
  22400. /**
  22401. * Creates a node material from parsed material data
  22402. * @param source defines the JSON representation of the material
  22403. * @param scene defines the hosting scene
  22404. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22405. * @returns a new node material
  22406. */
  22407. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22408. /**
  22409. * Creates a node material from a snippet saved in a remote file
  22410. * @param name defines the name of the material to create
  22411. * @param url defines the url to load from
  22412. * @param scene defines the hosting scene
  22413. * @returns a promise that will resolve to the new node material
  22414. */
  22415. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22416. /**
  22417. * Creates a node material from a snippet saved by the node material editor
  22418. * @param snippetId defines the snippet to load
  22419. * @param scene defines the hosting scene
  22420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22421. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22422. * @returns a promise that will resolve to the new node material
  22423. */
  22424. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22425. /**
  22426. * Creates a new node material set to default basic configuration
  22427. * @param name defines the name of the material
  22428. * @param scene defines the hosting scene
  22429. * @returns a new NodeMaterial
  22430. */
  22431. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Size options for a post process
  22437. */
  22438. export type PostProcessOptions = {
  22439. width: number;
  22440. height: number;
  22441. };
  22442. /**
  22443. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22444. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22445. */
  22446. export class PostProcess {
  22447. /** Name of the PostProcess. */
  22448. name: string;
  22449. /**
  22450. * Gets or sets the unique id of the post process
  22451. */
  22452. uniqueId: number;
  22453. /**
  22454. * Width of the texture to apply the post process on
  22455. */
  22456. width: number;
  22457. /**
  22458. * Height of the texture to apply the post process on
  22459. */
  22460. height: number;
  22461. /**
  22462. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22463. */
  22464. nodeMaterialSource: Nullable<NodeMaterial>;
  22465. /**
  22466. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22467. * @hidden
  22468. */
  22469. _outputTexture: Nullable<InternalTexture>;
  22470. /**
  22471. * Sampling mode used by the shader
  22472. * See https://doc.babylonjs.com/classes/3.1/texture
  22473. */
  22474. renderTargetSamplingMode: number;
  22475. /**
  22476. * Clear color to use when screen clearing
  22477. */
  22478. clearColor: Color4;
  22479. /**
  22480. * If the buffer needs to be cleared before applying the post process. (default: true)
  22481. * Should be set to false if shader will overwrite all previous pixels.
  22482. */
  22483. autoClear: boolean;
  22484. /**
  22485. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22486. */
  22487. alphaMode: number;
  22488. /**
  22489. * Sets the setAlphaBlendConstants of the babylon engine
  22490. */
  22491. alphaConstants: Color4;
  22492. /**
  22493. * Animations to be used for the post processing
  22494. */
  22495. animations: Animation[];
  22496. /**
  22497. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22498. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22499. */
  22500. enablePixelPerfectMode: boolean;
  22501. /**
  22502. * Force the postprocess to be applied without taking in account viewport
  22503. */
  22504. forceFullscreenViewport: boolean;
  22505. /**
  22506. * List of inspectable custom properties (used by the Inspector)
  22507. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22508. */
  22509. inspectableCustomProperties: IInspectable[];
  22510. /**
  22511. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22512. *
  22513. * | Value | Type | Description |
  22514. * | ----- | ----------------------------------- | ----------- |
  22515. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22516. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22517. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22518. *
  22519. */
  22520. scaleMode: number;
  22521. /**
  22522. * Force textures to be a power of two (default: false)
  22523. */
  22524. alwaysForcePOT: boolean;
  22525. private _samples;
  22526. /**
  22527. * Number of sample textures (default: 1)
  22528. */
  22529. get samples(): number;
  22530. set samples(n: number);
  22531. /**
  22532. * Modify the scale of the post process to be the same as the viewport (default: false)
  22533. */
  22534. adaptScaleToCurrentViewport: boolean;
  22535. private _camera;
  22536. protected _scene: Scene;
  22537. private _engine;
  22538. private _options;
  22539. private _reusable;
  22540. private _textureType;
  22541. private _textureFormat;
  22542. /**
  22543. * Smart array of input and output textures for the post process.
  22544. * @hidden
  22545. */
  22546. _textures: SmartArray<InternalTexture>;
  22547. /**
  22548. * The index in _textures that corresponds to the output texture.
  22549. * @hidden
  22550. */
  22551. _currentRenderTextureInd: number;
  22552. private _effect;
  22553. private _samplers;
  22554. private _fragmentUrl;
  22555. private _vertexUrl;
  22556. private _parameters;
  22557. private _scaleRatio;
  22558. protected _indexParameters: any;
  22559. private _shareOutputWithPostProcess;
  22560. private _texelSize;
  22561. private _forcedOutputTexture;
  22562. /**
  22563. * Returns the fragment url or shader name used in the post process.
  22564. * @returns the fragment url or name in the shader store.
  22565. */
  22566. getEffectName(): string;
  22567. /**
  22568. * An event triggered when the postprocess is activated.
  22569. */
  22570. onActivateObservable: Observable<Camera>;
  22571. private _onActivateObserver;
  22572. /**
  22573. * A function that is added to the onActivateObservable
  22574. */
  22575. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22576. /**
  22577. * An event triggered when the postprocess changes its size.
  22578. */
  22579. onSizeChangedObservable: Observable<PostProcess>;
  22580. private _onSizeChangedObserver;
  22581. /**
  22582. * A function that is added to the onSizeChangedObservable
  22583. */
  22584. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22585. /**
  22586. * An event triggered when the postprocess applies its effect.
  22587. */
  22588. onApplyObservable: Observable<Effect>;
  22589. private _onApplyObserver;
  22590. /**
  22591. * A function that is added to the onApplyObservable
  22592. */
  22593. set onApply(callback: (effect: Effect) => void);
  22594. /**
  22595. * An event triggered before rendering the postprocess
  22596. */
  22597. onBeforeRenderObservable: Observable<Effect>;
  22598. private _onBeforeRenderObserver;
  22599. /**
  22600. * A function that is added to the onBeforeRenderObservable
  22601. */
  22602. set onBeforeRender(callback: (effect: Effect) => void);
  22603. /**
  22604. * An event triggered after rendering the postprocess
  22605. */
  22606. onAfterRenderObservable: Observable<Effect>;
  22607. private _onAfterRenderObserver;
  22608. /**
  22609. * A function that is added to the onAfterRenderObservable
  22610. */
  22611. set onAfterRender(callback: (efect: Effect) => void);
  22612. /**
  22613. * 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
  22614. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22615. */
  22616. get inputTexture(): InternalTexture;
  22617. set inputTexture(value: InternalTexture);
  22618. /**
  22619. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22620. * the only way to unset it is to use this function to restore its internal state
  22621. */
  22622. restoreDefaultInputTexture(): void;
  22623. /**
  22624. * Gets the camera which post process is applied to.
  22625. * @returns The camera the post process is applied to.
  22626. */
  22627. getCamera(): Camera;
  22628. /**
  22629. * Gets the texel size of the postprocess.
  22630. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22631. */
  22632. get texelSize(): Vector2;
  22633. /**
  22634. * Creates a new instance PostProcess
  22635. * @param name The name of the PostProcess.
  22636. * @param fragmentUrl The url of the fragment shader to be used.
  22637. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22638. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22639. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22640. * @param camera The camera to apply the render pass to.
  22641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22642. * @param engine The engine which the post process will be applied. (default: current engine)
  22643. * @param reusable If the post process can be reused on the same frame. (default: false)
  22644. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22645. * @param textureType Type of textures used when performing the post process. (default: 0)
  22646. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22647. * @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
  22648. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22649. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22650. */
  22651. constructor(
  22652. /** Name of the PostProcess. */
  22653. 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);
  22654. /**
  22655. * Gets a string idenfifying the name of the class
  22656. * @returns "PostProcess" string
  22657. */
  22658. getClassName(): string;
  22659. /**
  22660. * Gets the engine which this post process belongs to.
  22661. * @returns The engine the post process was enabled with.
  22662. */
  22663. getEngine(): Engine;
  22664. /**
  22665. * The effect that is created when initializing the post process.
  22666. * @returns The created effect corresponding the the postprocess.
  22667. */
  22668. getEffect(): Effect;
  22669. /**
  22670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22671. * @param postProcess The post process to share the output with.
  22672. * @returns This post process.
  22673. */
  22674. shareOutputWith(postProcess: PostProcess): PostProcess;
  22675. /**
  22676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22678. */
  22679. useOwnOutput(): void;
  22680. /**
  22681. * Updates the effect with the current post process compile time values and recompiles the shader.
  22682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22685. * @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
  22686. * @param onCompiled Called when the shader has been compiled.
  22687. * @param onError Called if there is an error when compiling a shader.
  22688. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22689. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22690. */
  22691. 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;
  22692. /**
  22693. * The post process is reusable if it can be used multiple times within one frame.
  22694. * @returns If the post process is reusable
  22695. */
  22696. isReusable(): boolean;
  22697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22698. markTextureDirty(): void;
  22699. /**
  22700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22701. * 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.
  22702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22705. * @returns The target texture that was bound to be written to.
  22706. */
  22707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22708. /**
  22709. * If the post process is supported.
  22710. */
  22711. get isSupported(): boolean;
  22712. /**
  22713. * The aspect ratio of the output texture.
  22714. */
  22715. get aspectRatio(): number;
  22716. /**
  22717. * Get a value indicating if the post-process is ready to be used
  22718. * @returns true if the post-process is ready (shader is compiled)
  22719. */
  22720. isReady(): boolean;
  22721. /**
  22722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22724. */
  22725. apply(): Nullable<Effect>;
  22726. private _disposeTextures;
  22727. /**
  22728. * Disposes the post process.
  22729. * @param camera The camera to dispose the post process on.
  22730. */
  22731. dispose(camera?: Camera): void;
  22732. }
  22733. }
  22734. declare module BABYLON {
  22735. /** @hidden */
  22736. export var kernelBlurVaryingDeclaration: {
  22737. name: string;
  22738. shader: string;
  22739. };
  22740. }
  22741. declare module BABYLON {
  22742. /** @hidden */
  22743. export var kernelBlurFragment: {
  22744. name: string;
  22745. shader: string;
  22746. };
  22747. }
  22748. declare module BABYLON {
  22749. /** @hidden */
  22750. export var kernelBlurFragment2: {
  22751. name: string;
  22752. shader: string;
  22753. };
  22754. }
  22755. declare module BABYLON {
  22756. /** @hidden */
  22757. export var kernelBlurPixelShader: {
  22758. name: string;
  22759. shader: string;
  22760. };
  22761. }
  22762. declare module BABYLON {
  22763. /** @hidden */
  22764. export var kernelBlurVertex: {
  22765. name: string;
  22766. shader: string;
  22767. };
  22768. }
  22769. declare module BABYLON {
  22770. /** @hidden */
  22771. export var kernelBlurVertexShader: {
  22772. name: string;
  22773. shader: string;
  22774. };
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * The Blur Post Process which blurs an image based on a kernel and direction.
  22779. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22780. */
  22781. export class BlurPostProcess extends PostProcess {
  22782. /** The direction in which to blur the image. */
  22783. direction: Vector2;
  22784. private blockCompilation;
  22785. protected _kernel: number;
  22786. protected _idealKernel: number;
  22787. protected _packedFloat: boolean;
  22788. private _staticDefines;
  22789. /**
  22790. * Sets the length in pixels of the blur sample region
  22791. */
  22792. set kernel(v: number);
  22793. /**
  22794. * Gets the length in pixels of the blur sample region
  22795. */
  22796. get kernel(): number;
  22797. /**
  22798. * Sets wether or not the blur needs to unpack/repack floats
  22799. */
  22800. set packedFloat(v: boolean);
  22801. /**
  22802. * Gets wether or not the blur is unpacking/repacking floats
  22803. */
  22804. get packedFloat(): boolean;
  22805. /**
  22806. * Creates a new instance BlurPostProcess
  22807. * @param name The name of the effect.
  22808. * @param direction The direction in which to blur the image.
  22809. * @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.
  22810. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22811. * @param camera The camera to apply the render pass to.
  22812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22813. * @param engine The engine which the post process will be applied. (default: current engine)
  22814. * @param reusable If the post process can be reused on the same frame. (default: false)
  22815. * @param textureType Type of textures used when performing the post process. (default: 0)
  22816. * @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)
  22817. */
  22818. constructor(name: string,
  22819. /** The direction in which to blur the image. */
  22820. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22821. /**
  22822. * Updates the effect with the current post process compile time values and recompiles the shader.
  22823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22826. * @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
  22827. * @param onCompiled Called when the shader has been compiled.
  22828. * @param onError Called if there is an error when compiling a shader.
  22829. */
  22830. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22831. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22832. /**
  22833. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22834. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22835. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22836. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22837. * The gaps between physical kernels are compensated for in the weighting of the samples
  22838. * @param idealKernel Ideal blur kernel.
  22839. * @return Nearest best kernel.
  22840. */
  22841. protected _nearestBestKernel(idealKernel: number): number;
  22842. /**
  22843. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22844. * @param x The point on the Gaussian distribution to sample.
  22845. * @return the value of the Gaussian function at x.
  22846. */
  22847. protected _gaussianWeight(x: number): number;
  22848. /**
  22849. * Generates a string that can be used as a floating point number in GLSL.
  22850. * @param x Value to print.
  22851. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22852. * @return GLSL float string.
  22853. */
  22854. protected _glslFloat(x: number, decimalFigures?: number): string;
  22855. }
  22856. }
  22857. declare module BABYLON {
  22858. /**
  22859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22861. * You can then easily use it as a reflectionTexture on a flat surface.
  22862. * In case the surface is not a plane, please consider relying on reflection probes.
  22863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22864. */
  22865. export class MirrorTexture extends RenderTargetTexture {
  22866. private scene;
  22867. /**
  22868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22869. * 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.
  22870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22871. */
  22872. mirrorPlane: Plane;
  22873. /**
  22874. * Define the blur ratio used to blur the reflection if needed.
  22875. */
  22876. set blurRatio(value: number);
  22877. get blurRatio(): number;
  22878. /**
  22879. * Define the adaptive blur kernel used to blur the reflection if needed.
  22880. * This will autocompute the closest best match for the `blurKernel`
  22881. */
  22882. set adaptiveBlurKernel(value: number);
  22883. /**
  22884. * Define the blur kernel used to blur the reflection if needed.
  22885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22886. */
  22887. set blurKernel(value: number);
  22888. /**
  22889. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22890. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22891. */
  22892. set blurKernelX(value: number);
  22893. get blurKernelX(): number;
  22894. /**
  22895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22897. */
  22898. set blurKernelY(value: number);
  22899. get blurKernelY(): number;
  22900. private _autoComputeBlurKernel;
  22901. protected _onRatioRescale(): void;
  22902. private _updateGammaSpace;
  22903. private _imageProcessingConfigChangeObserver;
  22904. private _transformMatrix;
  22905. private _mirrorMatrix;
  22906. private _savedViewMatrix;
  22907. private _blurX;
  22908. private _blurY;
  22909. private _adaptiveBlurKernel;
  22910. private _blurKernelX;
  22911. private _blurKernelY;
  22912. private _blurRatio;
  22913. /**
  22914. * Instantiates a Mirror Texture.
  22915. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22916. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22917. * You can then easily use it as a reflectionTexture on a flat surface.
  22918. * In case the surface is not a plane, please consider relying on reflection probes.
  22919. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22920. * @param name
  22921. * @param size
  22922. * @param scene
  22923. * @param generateMipMaps
  22924. * @param type
  22925. * @param samplingMode
  22926. * @param generateDepthBuffer
  22927. */
  22928. constructor(name: string, size: number | {
  22929. width: number;
  22930. height: number;
  22931. } | {
  22932. ratio: number;
  22933. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22934. private _preparePostProcesses;
  22935. /**
  22936. * Clone the mirror texture.
  22937. * @returns the cloned texture
  22938. */
  22939. clone(): MirrorTexture;
  22940. /**
  22941. * Serialize the texture to a JSON representation you could use in Parse later on
  22942. * @returns the serialized JSON representation
  22943. */
  22944. serialize(): any;
  22945. /**
  22946. * Dispose the texture and release its associated resources.
  22947. */
  22948. dispose(): void;
  22949. }
  22950. }
  22951. declare module BABYLON {
  22952. /**
  22953. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22954. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22955. */
  22956. export class Texture extends BaseTexture {
  22957. /**
  22958. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22959. */
  22960. static SerializeBuffers: boolean;
  22961. /** @hidden */
  22962. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22963. /** @hidden */
  22964. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22965. /** @hidden */
  22966. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22967. /** nearest is mag = nearest and min = nearest and mip = linear */
  22968. static readonly NEAREST_SAMPLINGMODE: number;
  22969. /** nearest is mag = nearest and min = nearest and mip = linear */
  22970. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22972. static readonly BILINEAR_SAMPLINGMODE: number;
  22973. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22974. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22975. /** Trilinear is mag = linear and min = linear and mip = linear */
  22976. static readonly TRILINEAR_SAMPLINGMODE: number;
  22977. /** Trilinear is mag = linear and min = linear and mip = linear */
  22978. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22979. /** mag = nearest and min = nearest and mip = nearest */
  22980. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22981. /** mag = nearest and min = linear and mip = nearest */
  22982. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22983. /** mag = nearest and min = linear and mip = linear */
  22984. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22985. /** mag = nearest and min = linear and mip = none */
  22986. static readonly NEAREST_LINEAR: number;
  22987. /** mag = nearest and min = nearest and mip = none */
  22988. static readonly NEAREST_NEAREST: number;
  22989. /** mag = linear and min = nearest and mip = nearest */
  22990. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22991. /** mag = linear and min = nearest and mip = linear */
  22992. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22993. /** mag = linear and min = linear and mip = none */
  22994. static readonly LINEAR_LINEAR: number;
  22995. /** mag = linear and min = nearest and mip = none */
  22996. static readonly LINEAR_NEAREST: number;
  22997. /** Explicit coordinates mode */
  22998. static readonly EXPLICIT_MODE: number;
  22999. /** Spherical coordinates mode */
  23000. static readonly SPHERICAL_MODE: number;
  23001. /** Planar coordinates mode */
  23002. static readonly PLANAR_MODE: number;
  23003. /** Cubic coordinates mode */
  23004. static readonly CUBIC_MODE: number;
  23005. /** Projection coordinates mode */
  23006. static readonly PROJECTION_MODE: number;
  23007. /** Inverse Cubic coordinates mode */
  23008. static readonly SKYBOX_MODE: number;
  23009. /** Inverse Cubic coordinates mode */
  23010. static readonly INVCUBIC_MODE: number;
  23011. /** Equirectangular coordinates mode */
  23012. static readonly EQUIRECTANGULAR_MODE: number;
  23013. /** Equirectangular Fixed coordinates mode */
  23014. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23015. /** Equirectangular Fixed Mirrored coordinates mode */
  23016. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23017. /** Texture is not repeating outside of 0..1 UVs */
  23018. static readonly CLAMP_ADDRESSMODE: number;
  23019. /** Texture is repeating outside of 0..1 UVs */
  23020. static readonly WRAP_ADDRESSMODE: number;
  23021. /** Texture is repeating and mirrored */
  23022. static readonly MIRROR_ADDRESSMODE: number;
  23023. /**
  23024. * 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
  23025. */
  23026. static UseSerializedUrlIfAny: boolean;
  23027. /**
  23028. * Define the url of the texture.
  23029. */
  23030. url: Nullable<string>;
  23031. /**
  23032. * Define an offset on the texture to offset the u coordinates of the UVs
  23033. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23034. */
  23035. uOffset: number;
  23036. /**
  23037. * Define an offset on the texture to offset the v coordinates of the UVs
  23038. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23039. */
  23040. vOffset: number;
  23041. /**
  23042. * Define an offset on the texture to scale the u coordinates of the UVs
  23043. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23044. */
  23045. uScale: number;
  23046. /**
  23047. * Define an offset on the texture to scale the v coordinates of the UVs
  23048. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23049. */
  23050. vScale: number;
  23051. /**
  23052. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23053. * @see https://doc.babylonjs.com/how_to/more_materials
  23054. */
  23055. uAng: number;
  23056. /**
  23057. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23058. * @see https://doc.babylonjs.com/how_to/more_materials
  23059. */
  23060. vAng: number;
  23061. /**
  23062. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23063. * @see https://doc.babylonjs.com/how_to/more_materials
  23064. */
  23065. wAng: number;
  23066. /**
  23067. * Defines the center of rotation (U)
  23068. */
  23069. uRotationCenter: number;
  23070. /**
  23071. * Defines the center of rotation (V)
  23072. */
  23073. vRotationCenter: number;
  23074. /**
  23075. * Defines the center of rotation (W)
  23076. */
  23077. wRotationCenter: number;
  23078. /**
  23079. * Are mip maps generated for this texture or not.
  23080. */
  23081. get noMipmap(): boolean;
  23082. /**
  23083. * List of inspectable custom properties (used by the Inspector)
  23084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23085. */
  23086. inspectableCustomProperties: Nullable<IInspectable[]>;
  23087. private _noMipmap;
  23088. /** @hidden */
  23089. _invertY: boolean;
  23090. private _rowGenerationMatrix;
  23091. private _cachedTextureMatrix;
  23092. private _projectionModeMatrix;
  23093. private _t0;
  23094. private _t1;
  23095. private _t2;
  23096. private _cachedUOffset;
  23097. private _cachedVOffset;
  23098. private _cachedUScale;
  23099. private _cachedVScale;
  23100. private _cachedUAng;
  23101. private _cachedVAng;
  23102. private _cachedWAng;
  23103. private _cachedProjectionMatrixId;
  23104. private _cachedCoordinatesMode;
  23105. /** @hidden */
  23106. protected _initialSamplingMode: number;
  23107. /** @hidden */
  23108. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23109. private _deleteBuffer;
  23110. protected _format: Nullable<number>;
  23111. private _delayedOnLoad;
  23112. private _delayedOnError;
  23113. private _mimeType?;
  23114. /**
  23115. * Observable triggered once the texture has been loaded.
  23116. */
  23117. onLoadObservable: Observable<Texture>;
  23118. protected _isBlocking: boolean;
  23119. /**
  23120. * Is the texture preventing material to render while loading.
  23121. * If false, a default texture will be used instead of the loading one during the preparation step.
  23122. */
  23123. set isBlocking(value: boolean);
  23124. get isBlocking(): boolean;
  23125. /**
  23126. * Get the current sampling mode associated with the texture.
  23127. */
  23128. get samplingMode(): number;
  23129. /**
  23130. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23131. */
  23132. get invertY(): boolean;
  23133. /**
  23134. * Instantiates a new texture.
  23135. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23136. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23137. * @param url defines the url of the picture to load as a texture
  23138. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23139. * @param noMipmap defines if the texture will require mip maps or not
  23140. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23141. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23142. * @param onLoad defines a callback triggered when the texture has been loaded
  23143. * @param onError defines a callback triggered when an error occurred during the loading session
  23144. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23145. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23146. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23147. * @param mimeType defines an optional mime type information
  23148. */
  23149. 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);
  23150. /**
  23151. * Update the url (and optional buffer) of this texture if url was null during construction.
  23152. * @param url the url of the texture
  23153. * @param buffer the buffer of the texture (defaults to null)
  23154. * @param onLoad callback called when the texture is loaded (defaults to null)
  23155. */
  23156. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23157. /**
  23158. * Finish the loading sequence of a texture flagged as delayed load.
  23159. * @hidden
  23160. */
  23161. delayLoad(): void;
  23162. private _prepareRowForTextureGeneration;
  23163. /**
  23164. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23165. * @returns the transform matrix of the texture.
  23166. */
  23167. getTextureMatrix(uBase?: number): Matrix;
  23168. /**
  23169. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23170. * @returns The reflection texture transform
  23171. */
  23172. getReflectionTextureMatrix(): Matrix;
  23173. /**
  23174. * Clones the texture.
  23175. * @returns the cloned texture
  23176. */
  23177. clone(): Texture;
  23178. /**
  23179. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23180. * @returns The JSON representation of the texture
  23181. */
  23182. serialize(): any;
  23183. /**
  23184. * Get the current class name of the texture useful for serialization or dynamic coding.
  23185. * @returns "Texture"
  23186. */
  23187. getClassName(): string;
  23188. /**
  23189. * Dispose the texture and release its associated resources.
  23190. */
  23191. dispose(): void;
  23192. /**
  23193. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23194. * @param parsedTexture Define the JSON representation of the texture
  23195. * @param scene Define the scene the parsed texture should be instantiated in
  23196. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23197. * @returns The parsed texture if successful
  23198. */
  23199. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23200. /**
  23201. * Creates a texture from its base 64 representation.
  23202. * @param data Define the base64 payload without the data: prefix
  23203. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23204. * @param scene Define the scene the texture should belong to
  23205. * @param noMipmap Forces the texture to not create mip map information if true
  23206. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23207. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23208. * @param onLoad define a callback triggered when the texture has been loaded
  23209. * @param onError define a callback triggered when an error occurred during the loading session
  23210. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23211. * @returns the created texture
  23212. */
  23213. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23214. /**
  23215. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23216. * @param data Define the base64 payload without the data: prefix
  23217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23218. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23219. * @param scene Define the scene the texture should belong to
  23220. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23221. * @param noMipmap Forces the texture to not create mip map information if true
  23222. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23223. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23224. * @param onLoad define a callback triggered when the texture has been loaded
  23225. * @param onError define a callback triggered when an error occurred during the loading session
  23226. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23227. * @returns the created texture
  23228. */
  23229. 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;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /**
  23234. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23235. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23236. */
  23237. export class PostProcessManager {
  23238. private _scene;
  23239. private _indexBuffer;
  23240. private _vertexBuffers;
  23241. /**
  23242. * Creates a new instance PostProcess
  23243. * @param scene The scene that the post process is associated with.
  23244. */
  23245. constructor(scene: Scene);
  23246. private _prepareBuffers;
  23247. private _buildIndexBuffer;
  23248. /**
  23249. * Rebuilds the vertex buffers of the manager.
  23250. * @hidden
  23251. */
  23252. _rebuild(): void;
  23253. /**
  23254. * Prepares a frame to be run through a post process.
  23255. * @param sourceTexture The input texture to the post procesess. (default: null)
  23256. * @param postProcesses An array of post processes to be run. (default: null)
  23257. * @returns True if the post processes were able to be run.
  23258. * @hidden
  23259. */
  23260. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23261. /**
  23262. * Manually render a set of post processes to a texture.
  23263. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23264. * @param postProcesses An array of post processes to be run.
  23265. * @param targetTexture The target texture to render to.
  23266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23267. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23268. * @param lodLevel defines which lod of the texture to render to
  23269. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23270. */
  23271. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23272. /**
  23273. * Finalize the result of the output of the postprocesses.
  23274. * @param doNotPresent If true the result will not be displayed to the screen.
  23275. * @param targetTexture The target texture to render to.
  23276. * @param faceIndex The index of the face to bind the target texture to.
  23277. * @param postProcesses The array of post processes to render.
  23278. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23279. * @hidden
  23280. */
  23281. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23282. /**
  23283. * Disposes of the post process manager.
  23284. */
  23285. dispose(): void;
  23286. }
  23287. }
  23288. declare module BABYLON {
  23289. /**
  23290. * This Helps creating a texture that will be created from a camera in your scene.
  23291. * It is basically a dynamic texture that could be used to create special effects for instance.
  23292. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23293. */
  23294. export class RenderTargetTexture extends Texture {
  23295. isCube: boolean;
  23296. /**
  23297. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23298. */
  23299. static readonly REFRESHRATE_RENDER_ONCE: number;
  23300. /**
  23301. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23302. */
  23303. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23304. /**
  23305. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23306. * the central point of your effect and can save a lot of performances.
  23307. */
  23308. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23309. /**
  23310. * Use this predicate to dynamically define the list of mesh you want to render.
  23311. * If set, the renderList property will be overwritten.
  23312. */
  23313. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23314. private _renderList;
  23315. /**
  23316. * Use this list to define the list of mesh you want to render.
  23317. */
  23318. get renderList(): Nullable<Array<AbstractMesh>>;
  23319. set renderList(value: Nullable<Array<AbstractMesh>>);
  23320. /**
  23321. * Use this function to overload the renderList array at rendering time.
  23322. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23323. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23324. * the cube (if the RTT is a cube, else layerOrFace=0).
  23325. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23326. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23327. * hold dummy elements!
  23328. */
  23329. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23330. private _hookArray;
  23331. /**
  23332. * Define if particles should be rendered in your texture.
  23333. */
  23334. renderParticles: boolean;
  23335. /**
  23336. * Define if sprites should be rendered in your texture.
  23337. */
  23338. renderSprites: boolean;
  23339. /**
  23340. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23341. */
  23342. coordinatesMode: number;
  23343. /**
  23344. * Define the camera used to render the texture.
  23345. */
  23346. activeCamera: Nullable<Camera>;
  23347. /**
  23348. * Override the mesh isReady function with your own one.
  23349. */
  23350. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23351. /**
  23352. * Override the render function of the texture with your own one.
  23353. */
  23354. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23355. /**
  23356. * Define if camera post processes should be use while rendering the texture.
  23357. */
  23358. useCameraPostProcesses: boolean;
  23359. /**
  23360. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23361. */
  23362. ignoreCameraViewport: boolean;
  23363. private _postProcessManager;
  23364. private _postProcesses;
  23365. private _resizeObserver;
  23366. /**
  23367. * An event triggered when the texture is unbind.
  23368. */
  23369. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23370. /**
  23371. * An event triggered when the texture is unbind.
  23372. */
  23373. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23374. private _onAfterUnbindObserver;
  23375. /**
  23376. * Set a after unbind callback in the texture.
  23377. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23378. */
  23379. set onAfterUnbind(callback: () => void);
  23380. /**
  23381. * An event triggered before rendering the texture
  23382. */
  23383. onBeforeRenderObservable: Observable<number>;
  23384. private _onBeforeRenderObserver;
  23385. /**
  23386. * Set a before render callback in the texture.
  23387. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23388. */
  23389. set onBeforeRender(callback: (faceIndex: number) => void);
  23390. /**
  23391. * An event triggered after rendering the texture
  23392. */
  23393. onAfterRenderObservable: Observable<number>;
  23394. private _onAfterRenderObserver;
  23395. /**
  23396. * Set a after render callback in the texture.
  23397. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23398. */
  23399. set onAfterRender(callback: (faceIndex: number) => void);
  23400. /**
  23401. * An event triggered after the texture clear
  23402. */
  23403. onClearObservable: Observable<Engine>;
  23404. private _onClearObserver;
  23405. /**
  23406. * Set a clear callback in the texture.
  23407. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23408. */
  23409. set onClear(callback: (Engine: Engine) => void);
  23410. /**
  23411. * An event triggered when the texture is resized.
  23412. */
  23413. onResizeObservable: Observable<RenderTargetTexture>;
  23414. /**
  23415. * Define the clear color of the Render Target if it should be different from the scene.
  23416. */
  23417. clearColor: Color4;
  23418. protected _size: number | {
  23419. width: number;
  23420. height: number;
  23421. layers?: number;
  23422. };
  23423. protected _initialSizeParameter: number | {
  23424. width: number;
  23425. height: number;
  23426. } | {
  23427. ratio: number;
  23428. };
  23429. protected _sizeRatio: Nullable<number>;
  23430. /** @hidden */
  23431. _generateMipMaps: boolean;
  23432. protected _renderingManager: RenderingManager;
  23433. /** @hidden */
  23434. _waitingRenderList: string[];
  23435. protected _doNotChangeAspectRatio: boolean;
  23436. protected _currentRefreshId: number;
  23437. protected _refreshRate: number;
  23438. protected _textureMatrix: Matrix;
  23439. protected _samples: number;
  23440. protected _renderTargetOptions: RenderTargetCreationOptions;
  23441. /**
  23442. * Gets render target creation options that were used.
  23443. */
  23444. get renderTargetOptions(): RenderTargetCreationOptions;
  23445. protected _onRatioRescale(): void;
  23446. /**
  23447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23448. * It must define where the camera used to render the texture is set
  23449. */
  23450. boundingBoxPosition: Vector3;
  23451. private _boundingBoxSize;
  23452. /**
  23453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23454. * When defined, the cubemap will switch to local mode
  23455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23456. * @example https://www.babylonjs-playground.com/#RNASML
  23457. */
  23458. set boundingBoxSize(value: Vector3);
  23459. get boundingBoxSize(): Vector3;
  23460. /**
  23461. * In case the RTT has been created with a depth texture, get the associated
  23462. * depth texture.
  23463. * Otherwise, return null.
  23464. */
  23465. get depthStencilTexture(): Nullable<InternalTexture>;
  23466. /**
  23467. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23468. * or used a shadow, depth texture...
  23469. * @param name The friendly name of the texture
  23470. * @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)
  23471. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23472. * @param generateMipMaps True if mip maps need to be generated after render.
  23473. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23474. * @param type The type of the buffer in the RTT (int, half float, float...)
  23475. * @param isCube True if a cube texture needs to be created
  23476. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23477. * @param generateDepthBuffer True to generate a depth buffer
  23478. * @param generateStencilBuffer True to generate a stencil buffer
  23479. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23480. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23481. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23482. */
  23483. constructor(name: string, size: number | {
  23484. width: number;
  23485. height: number;
  23486. layers?: number;
  23487. } | {
  23488. ratio: number;
  23489. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23490. /**
  23491. * Creates a depth stencil texture.
  23492. * This is only available in WebGL 2 or with the depth texture extension available.
  23493. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23494. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23495. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23496. */
  23497. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23498. private _processSizeParameter;
  23499. /**
  23500. * Define the number of samples to use in case of MSAA.
  23501. * It defaults to one meaning no MSAA has been enabled.
  23502. */
  23503. get samples(): number;
  23504. set samples(value: number);
  23505. /**
  23506. * Resets the refresh counter of the texture and start bak from scratch.
  23507. * Could be useful to regenerate the texture if it is setup to render only once.
  23508. */
  23509. resetRefreshCounter(): void;
  23510. /**
  23511. * Define the refresh rate of the texture or the rendering frequency.
  23512. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23513. */
  23514. get refreshRate(): number;
  23515. set refreshRate(value: number);
  23516. /**
  23517. * Adds a post process to the render target rendering passes.
  23518. * @param postProcess define the post process to add
  23519. */
  23520. addPostProcess(postProcess: PostProcess): void;
  23521. /**
  23522. * Clear all the post processes attached to the render target
  23523. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23524. */
  23525. clearPostProcesses(dispose?: boolean): void;
  23526. /**
  23527. * Remove one of the post process from the list of attached post processes to the texture
  23528. * @param postProcess define the post process to remove from the list
  23529. */
  23530. removePostProcess(postProcess: PostProcess): void;
  23531. /** @hidden */
  23532. _shouldRender(): boolean;
  23533. /**
  23534. * Gets the actual render size of the texture.
  23535. * @returns the width of the render size
  23536. */
  23537. getRenderSize(): number;
  23538. /**
  23539. * Gets the actual render width of the texture.
  23540. * @returns the width of the render size
  23541. */
  23542. getRenderWidth(): number;
  23543. /**
  23544. * Gets the actual render height of the texture.
  23545. * @returns the height of the render size
  23546. */
  23547. getRenderHeight(): number;
  23548. /**
  23549. * Gets the actual number of layers of the texture.
  23550. * @returns the number of layers
  23551. */
  23552. getRenderLayers(): number;
  23553. /**
  23554. * Get if the texture can be rescaled or not.
  23555. */
  23556. get canRescale(): boolean;
  23557. /**
  23558. * Resize the texture using a ratio.
  23559. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23560. */
  23561. scale(ratio: number): void;
  23562. /**
  23563. * Get the texture reflection matrix used to rotate/transform the reflection.
  23564. * @returns the reflection matrix
  23565. */
  23566. getReflectionTextureMatrix(): Matrix;
  23567. /**
  23568. * Resize the texture to a new desired size.
  23569. * Be carrefull as it will recreate all the data in the new texture.
  23570. * @param size Define the new size. It can be:
  23571. * - a number for squared texture,
  23572. * - an object containing { width: number, height: number }
  23573. * - or an object containing a ratio { ratio: number }
  23574. */
  23575. resize(size: number | {
  23576. width: number;
  23577. height: number;
  23578. } | {
  23579. ratio: number;
  23580. }): void;
  23581. private _defaultRenderListPrepared;
  23582. /**
  23583. * Renders all the objects from the render list into the texture.
  23584. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23585. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23586. */
  23587. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23588. private _bestReflectionRenderTargetDimension;
  23589. private _prepareRenderingManager;
  23590. /**
  23591. * @hidden
  23592. * @param faceIndex face index to bind to if this is a cubetexture
  23593. * @param layer defines the index of the texture to bind in the array
  23594. */
  23595. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23596. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23597. private renderToTarget;
  23598. /**
  23599. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23600. * This allowed control for front to back rendering or reversly depending of the special needs.
  23601. *
  23602. * @param renderingGroupId The rendering group id corresponding to its index
  23603. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23604. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23605. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23606. */
  23607. 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;
  23608. /**
  23609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23610. *
  23611. * @param renderingGroupId The rendering group id corresponding to its index
  23612. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23613. */
  23614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23615. /**
  23616. * Clones the texture.
  23617. * @returns the cloned texture
  23618. */
  23619. clone(): RenderTargetTexture;
  23620. /**
  23621. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23622. * @returns The JSON representation of the texture
  23623. */
  23624. serialize(): any;
  23625. /**
  23626. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23627. */
  23628. disposeFramebufferObjects(): void;
  23629. /**
  23630. * Dispose the texture and release its associated resources.
  23631. */
  23632. dispose(): void;
  23633. /** @hidden */
  23634. _rebuild(): void;
  23635. /**
  23636. * Clear the info related to rendering groups preventing retention point in material dispose.
  23637. */
  23638. freeRenderingGroups(): void;
  23639. /**
  23640. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23641. * @returns the view count
  23642. */
  23643. getViewCount(): number;
  23644. }
  23645. }
  23646. declare module BABYLON {
  23647. /**
  23648. * Class used to manipulate GUIDs
  23649. */
  23650. export class GUID {
  23651. /**
  23652. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23653. * Be aware Math.random() could cause collisions, but:
  23654. * "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"
  23655. * @returns a pseudo random id
  23656. */
  23657. static RandomId(): string;
  23658. }
  23659. }
  23660. declare module BABYLON {
  23661. /**
  23662. * Options to be used when creating a shadow depth material
  23663. */
  23664. export interface IIOptionShadowDepthMaterial {
  23665. /** Variables in the vertex shader code that need to have their names remapped.
  23666. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23667. * "var_name" should be either: worldPos or vNormalW
  23668. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23669. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23670. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23671. */
  23672. remappedVariables?: string[];
  23673. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23674. standalone?: boolean;
  23675. }
  23676. /**
  23677. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23678. */
  23679. export class ShadowDepthWrapper {
  23680. private _scene;
  23681. private _options?;
  23682. private _baseMaterial;
  23683. private _onEffectCreatedObserver;
  23684. private _subMeshToEffect;
  23685. private _subMeshToDepthEffect;
  23686. private _meshes;
  23687. /** @hidden */
  23688. _matriceNames: any;
  23689. /** Gets the standalone status of the wrapper */
  23690. get standalone(): boolean;
  23691. /** Gets the base material the wrapper is built upon */
  23692. get baseMaterial(): Material;
  23693. /**
  23694. * Instantiate a new shadow depth wrapper.
  23695. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23696. * generate the shadow depth map. For more information, please refer to the documentation:
  23697. * https://doc.babylonjs.com/babylon101/shadows
  23698. * @param baseMaterial Material to wrap
  23699. * @param scene Define the scene the material belongs to
  23700. * @param options Options used to create the wrapper
  23701. */
  23702. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23703. /**
  23704. * Gets the effect to use to generate the depth map
  23705. * @param subMesh subMesh to get the effect for
  23706. * @param shadowGenerator shadow generator to get the effect for
  23707. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23708. */
  23709. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23710. /**
  23711. * Specifies that the submesh is ready to be used for depth rendering
  23712. * @param subMesh submesh to check
  23713. * @param defines the list of defines to take into account when checking the effect
  23714. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23715. * @param useInstances specifies that instances should be used
  23716. * @returns a boolean indicating that the submesh is ready or not
  23717. */
  23718. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23719. /**
  23720. * Disposes the resources
  23721. */
  23722. dispose(): void;
  23723. private _makeEffect;
  23724. }
  23725. }
  23726. declare module BABYLON {
  23727. interface ThinEngine {
  23728. /**
  23729. * Unbind a list of render target textures from the webGL context
  23730. * This is used only when drawBuffer extension or webGL2 are active
  23731. * @param textures defines the render target textures to unbind
  23732. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23733. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23734. */
  23735. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23736. /**
  23737. * Create a multi render target texture
  23738. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23739. * @param size defines the size of the texture
  23740. * @param options defines the creation options
  23741. * @returns the cube texture as an InternalTexture
  23742. */
  23743. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23744. /**
  23745. * Update the sample count for a given multiple render target texture
  23746. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23747. * @param textures defines the textures to update
  23748. * @param samples defines the sample count to set
  23749. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23750. */
  23751. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23752. /**
  23753. * Select a subsets of attachments to draw to.
  23754. * @param attachments gl attachments
  23755. */
  23756. bindAttachments(attachments: number[]): void;
  23757. }
  23758. }
  23759. declare module BABYLON {
  23760. /**
  23761. * Creation options of the multi render target texture.
  23762. */
  23763. export interface IMultiRenderTargetOptions {
  23764. /**
  23765. * Define if the texture needs to create mip maps after render.
  23766. */
  23767. generateMipMaps?: boolean;
  23768. /**
  23769. * Define the types of all the draw buffers we want to create
  23770. */
  23771. types?: number[];
  23772. /**
  23773. * Define the sampling modes of all the draw buffers we want to create
  23774. */
  23775. samplingModes?: number[];
  23776. /**
  23777. * Define if a depth buffer is required
  23778. */
  23779. generateDepthBuffer?: boolean;
  23780. /**
  23781. * Define if a stencil buffer is required
  23782. */
  23783. generateStencilBuffer?: boolean;
  23784. /**
  23785. * Define if a depth texture is required instead of a depth buffer
  23786. */
  23787. generateDepthTexture?: boolean;
  23788. /**
  23789. * Define the number of desired draw buffers
  23790. */
  23791. textureCount?: number;
  23792. /**
  23793. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23794. */
  23795. doNotChangeAspectRatio?: boolean;
  23796. /**
  23797. * Define the default type of the buffers we are creating
  23798. */
  23799. defaultType?: number;
  23800. }
  23801. /**
  23802. * A multi render target, like a render target provides the ability to render to a texture.
  23803. * Unlike the render target, it can render to several draw buffers in one draw.
  23804. * This is specially interesting in deferred rendering or for any effects requiring more than
  23805. * just one color from a single pass.
  23806. */
  23807. export class MultiRenderTarget extends RenderTargetTexture {
  23808. private _internalTextures;
  23809. private _textures;
  23810. private _multiRenderTargetOptions;
  23811. private _count;
  23812. /**
  23813. * Get if draw buffers are currently supported by the used hardware and browser.
  23814. */
  23815. get isSupported(): boolean;
  23816. /**
  23817. * Get the list of textures generated by the multi render target.
  23818. */
  23819. get textures(): Texture[];
  23820. /**
  23821. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23822. */
  23823. get count(): number;
  23824. /**
  23825. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23826. */
  23827. get depthTexture(): Texture;
  23828. /**
  23829. * Set the wrapping mode on U of all the textures we are rendering to.
  23830. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23831. */
  23832. set wrapU(wrap: number);
  23833. /**
  23834. * Set the wrapping mode on V of all the textures we are rendering to.
  23835. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23836. */
  23837. set wrapV(wrap: number);
  23838. /**
  23839. * Instantiate a new multi render target texture.
  23840. * A multi render target, like a render target provides the ability to render to a texture.
  23841. * Unlike the render target, it can render to several draw buffers in one draw.
  23842. * This is specially interesting in deferred rendering or for any effects requiring more than
  23843. * just one color from a single pass.
  23844. * @param name Define the name of the texture
  23845. * @param size Define the size of the buffers to render to
  23846. * @param count Define the number of target we are rendering into
  23847. * @param scene Define the scene the texture belongs to
  23848. * @param options Define the options used to create the multi render target
  23849. */
  23850. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23851. /** @hidden */
  23852. _rebuild(): void;
  23853. private _createInternalTextures;
  23854. private _createTextures;
  23855. /**
  23856. * Define the number of samples used if MSAA is enabled.
  23857. */
  23858. get samples(): number;
  23859. set samples(value: number);
  23860. /**
  23861. * Resize all the textures in the multi render target.
  23862. * Be carrefull as it will recreate all the data in the new texture.
  23863. * @param size Define the new size
  23864. */
  23865. resize(size: any): void;
  23866. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23867. /**
  23868. * Dispose the render targets and their associated resources
  23869. */
  23870. dispose(): void;
  23871. /**
  23872. * Release all the underlying texture used as draw buffers.
  23873. */
  23874. releaseInternalTextures(): void;
  23875. }
  23876. }
  23877. declare module BABYLON {
  23878. /** @hidden */
  23879. export var imageProcessingPixelShader: {
  23880. name: string;
  23881. shader: string;
  23882. };
  23883. }
  23884. declare module BABYLON {
  23885. /**
  23886. * ImageProcessingPostProcess
  23887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23888. */
  23889. export class ImageProcessingPostProcess extends PostProcess {
  23890. /**
  23891. * Default configuration related to image processing available in the PBR Material.
  23892. */
  23893. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23894. /**
  23895. * Gets the image processing configuration used either in this material.
  23896. */
  23897. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23898. /**
  23899. * Sets the Default image processing configuration used either in the this material.
  23900. *
  23901. * If sets to null, the scene one is in use.
  23902. */
  23903. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23904. /**
  23905. * Keep track of the image processing observer to allow dispose and replace.
  23906. */
  23907. private _imageProcessingObserver;
  23908. /**
  23909. * Attaches a new image processing configuration to the PBR Material.
  23910. * @param configuration
  23911. */
  23912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23913. /**
  23914. * If the post process is supported.
  23915. */
  23916. get isSupported(): boolean;
  23917. /**
  23918. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23919. */
  23920. get colorCurves(): Nullable<ColorCurves>;
  23921. /**
  23922. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23923. */
  23924. set colorCurves(value: Nullable<ColorCurves>);
  23925. /**
  23926. * Gets wether the color curves effect is enabled.
  23927. */
  23928. get colorCurvesEnabled(): boolean;
  23929. /**
  23930. * Sets wether the color curves effect is enabled.
  23931. */
  23932. set colorCurvesEnabled(value: boolean);
  23933. /**
  23934. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23935. */
  23936. get colorGradingTexture(): Nullable<BaseTexture>;
  23937. /**
  23938. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23939. */
  23940. set colorGradingTexture(value: Nullable<BaseTexture>);
  23941. /**
  23942. * Gets wether the color grading effect is enabled.
  23943. */
  23944. get colorGradingEnabled(): boolean;
  23945. /**
  23946. * Gets wether the color grading effect is enabled.
  23947. */
  23948. set colorGradingEnabled(value: boolean);
  23949. /**
  23950. * Gets exposure used in the effect.
  23951. */
  23952. get exposure(): number;
  23953. /**
  23954. * Sets exposure used in the effect.
  23955. */
  23956. set exposure(value: number);
  23957. /**
  23958. * Gets wether tonemapping is enabled or not.
  23959. */
  23960. get toneMappingEnabled(): boolean;
  23961. /**
  23962. * Sets wether tonemapping is enabled or not
  23963. */
  23964. set toneMappingEnabled(value: boolean);
  23965. /**
  23966. * Gets the type of tone mapping effect.
  23967. */
  23968. get toneMappingType(): number;
  23969. /**
  23970. * Sets the type of tone mapping effect.
  23971. */
  23972. set toneMappingType(value: number);
  23973. /**
  23974. * Gets contrast used in the effect.
  23975. */
  23976. get contrast(): number;
  23977. /**
  23978. * Sets contrast used in the effect.
  23979. */
  23980. set contrast(value: number);
  23981. /**
  23982. * Gets Vignette stretch size.
  23983. */
  23984. get vignetteStretch(): number;
  23985. /**
  23986. * Sets Vignette stretch size.
  23987. */
  23988. set vignetteStretch(value: number);
  23989. /**
  23990. * Gets Vignette centre X Offset.
  23991. */
  23992. get vignetteCentreX(): number;
  23993. /**
  23994. * Sets Vignette centre X Offset.
  23995. */
  23996. set vignetteCentreX(value: number);
  23997. /**
  23998. * Gets Vignette centre Y Offset.
  23999. */
  24000. get vignetteCentreY(): number;
  24001. /**
  24002. * Sets Vignette centre Y Offset.
  24003. */
  24004. set vignetteCentreY(value: number);
  24005. /**
  24006. * Gets Vignette weight or intensity of the vignette effect.
  24007. */
  24008. get vignetteWeight(): number;
  24009. /**
  24010. * Sets Vignette weight or intensity of the vignette effect.
  24011. */
  24012. set vignetteWeight(value: number);
  24013. /**
  24014. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24015. * if vignetteEnabled is set to true.
  24016. */
  24017. get vignetteColor(): Color4;
  24018. /**
  24019. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24020. * if vignetteEnabled is set to true.
  24021. */
  24022. set vignetteColor(value: Color4);
  24023. /**
  24024. * Gets Camera field of view used by the Vignette effect.
  24025. */
  24026. get vignetteCameraFov(): number;
  24027. /**
  24028. * Sets Camera field of view used by the Vignette effect.
  24029. */
  24030. set vignetteCameraFov(value: number);
  24031. /**
  24032. * Gets the vignette blend mode allowing different kind of effect.
  24033. */
  24034. get vignetteBlendMode(): number;
  24035. /**
  24036. * Sets the vignette blend mode allowing different kind of effect.
  24037. */
  24038. set vignetteBlendMode(value: number);
  24039. /**
  24040. * Gets wether the vignette effect is enabled.
  24041. */
  24042. get vignetteEnabled(): boolean;
  24043. /**
  24044. * Sets wether the vignette effect is enabled.
  24045. */
  24046. set vignetteEnabled(value: boolean);
  24047. private _fromLinearSpace;
  24048. /**
  24049. * Gets wether the input of the processing is in Gamma or Linear Space.
  24050. */
  24051. get fromLinearSpace(): boolean;
  24052. /**
  24053. * Sets wether the input of the processing is in Gamma or Linear Space.
  24054. */
  24055. set fromLinearSpace(value: boolean);
  24056. /**
  24057. * Defines cache preventing GC.
  24058. */
  24059. private _defines;
  24060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24061. /**
  24062. * "ImageProcessingPostProcess"
  24063. * @returns "ImageProcessingPostProcess"
  24064. */
  24065. getClassName(): string;
  24066. /**
  24067. * @hidden
  24068. */
  24069. _updateParameters(): void;
  24070. dispose(camera?: Camera): void;
  24071. }
  24072. }
  24073. declare module BABYLON {
  24074. /** @hidden */
  24075. export var fibonacci: {
  24076. name: string;
  24077. shader: string;
  24078. };
  24079. }
  24080. declare module BABYLON {
  24081. /** @hidden */
  24082. export var subSurfaceScatteringFunctions: {
  24083. name: string;
  24084. shader: string;
  24085. };
  24086. }
  24087. declare module BABYLON {
  24088. /** @hidden */
  24089. export var diffusionProfile: {
  24090. name: string;
  24091. shader: string;
  24092. };
  24093. }
  24094. declare module BABYLON {
  24095. /** @hidden */
  24096. export var subSurfaceScatteringPixelShader: {
  24097. name: string;
  24098. shader: string;
  24099. };
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Sub surface scattering post process
  24104. */
  24105. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24106. /** @hidden */
  24107. texelWidth: number;
  24108. /** @hidden */
  24109. texelHeight: number;
  24110. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24111. }
  24112. }
  24113. declare module BABYLON {
  24114. /**
  24115. * Interface for defining prepass effects in the prepass post-process pipeline
  24116. */
  24117. export interface PrePassEffectConfiguration {
  24118. /**
  24119. * Post process to attach for this effect
  24120. */
  24121. postProcess: PostProcess;
  24122. /**
  24123. * Is the effect enabled
  24124. */
  24125. enabled: boolean;
  24126. /**
  24127. * Disposes the effect configuration
  24128. */
  24129. dispose(): void;
  24130. /**
  24131. * Disposes the effect configuration
  24132. */
  24133. createPostProcess: () => PostProcess;
  24134. }
  24135. }
  24136. declare module BABYLON {
  24137. /**
  24138. * Contains all parameters needed for the prepass to perform
  24139. * screen space subsurface scattering
  24140. */
  24141. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24142. private _ssDiffusionS;
  24143. private _ssFilterRadii;
  24144. private _ssDiffusionD;
  24145. /**
  24146. * Post process to attach for screen space subsurface scattering
  24147. */
  24148. postProcess: SubSurfaceScatteringPostProcess;
  24149. /**
  24150. * Diffusion profile color for subsurface scattering
  24151. */
  24152. get ssDiffusionS(): number[];
  24153. /**
  24154. * Diffusion profile max color channel value for subsurface scattering
  24155. */
  24156. get ssDiffusionD(): number[];
  24157. /**
  24158. * Diffusion profile filter radius for subsurface scattering
  24159. */
  24160. get ssFilterRadii(): number[];
  24161. /**
  24162. * Is subsurface enabled
  24163. */
  24164. enabled: boolean;
  24165. /**
  24166. * Diffusion profile colors for subsurface scattering
  24167. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24168. * See ...
  24169. * Note that you can only store up to 5 of them
  24170. */
  24171. ssDiffusionProfileColors: Color3[];
  24172. /**
  24173. * Defines the ratio real world => scene units.
  24174. * Used for subsurface scattering
  24175. */
  24176. metersPerUnit: number;
  24177. private _scene;
  24178. /**
  24179. * Builds a subsurface configuration object
  24180. * @param scene The scene
  24181. */
  24182. constructor(scene: Scene);
  24183. /**
  24184. * Adds a new diffusion profile.
  24185. * Useful for more realistic subsurface scattering on diverse materials.
  24186. * @param color The color of the diffusion profile. Should be the average color of the material.
  24187. * @return The index of the diffusion profile for the material subsurface configuration
  24188. */
  24189. addDiffusionProfile(color: Color3): number;
  24190. /**
  24191. * Creates the sss post process
  24192. * @return The created post process
  24193. */
  24194. createPostProcess(): SubSurfaceScatteringPostProcess;
  24195. /**
  24196. * Deletes all diffusion profiles.
  24197. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24198. */
  24199. clearAllDiffusionProfiles(): void;
  24200. /**
  24201. * Disposes this object
  24202. */
  24203. dispose(): void;
  24204. /**
  24205. * @hidden
  24206. * https://zero-radiance.github.io/post/sampling-diffusion/
  24207. *
  24208. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24209. * ------------------------------------------------------------------------------------
  24210. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24211. * PDF[r, phi, s] = r * R[r, phi, s]
  24212. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24213. * ------------------------------------------------------------------------------------
  24214. * We importance sample the color channel with the widest scattering distance.
  24215. */
  24216. getDiffusionProfileParameters(color: Color3): number;
  24217. /**
  24218. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24219. * 'u' is the random number (the value of the CDF): [0, 1).
  24220. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24221. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24222. */
  24223. private _sampleBurleyDiffusionProfile;
  24224. }
  24225. }
  24226. declare module BABYLON {
  24227. /**
  24228. * Renders a pre pass of the scene
  24229. * This means every mesh in the scene will be rendered to a render target texture
  24230. * And then this texture will be composited to the rendering canvas with post processes
  24231. * It is necessary for effects like subsurface scattering or deferred shading
  24232. */
  24233. export class PrePassRenderer {
  24234. /** @hidden */
  24235. static _SceneComponentInitialization: (scene: Scene) => void;
  24236. private _scene;
  24237. private _engine;
  24238. private _isDirty;
  24239. /**
  24240. * Number of textures in the multi render target texture where the scene is directly rendered
  24241. */
  24242. readonly mrtCount: number;
  24243. /**
  24244. * The render target where the scene is directly rendered
  24245. */
  24246. prePassRT: MultiRenderTarget;
  24247. private _mrtTypes;
  24248. private _multiRenderAttachments;
  24249. private _defaultAttachments;
  24250. private _clearAttachments;
  24251. private _postProcesses;
  24252. private readonly _clearColor;
  24253. /**
  24254. * Image processing post process for composition
  24255. */
  24256. imageProcessingPostProcess: ImageProcessingPostProcess;
  24257. /**
  24258. * Configuration for sub surface scattering post process
  24259. */
  24260. subSurfaceConfiguration: SubSurfaceConfiguration;
  24261. /**
  24262. * Should materials render their geometry on the MRT
  24263. */
  24264. materialsShouldRenderGeometry: boolean;
  24265. /**
  24266. * Should materials render the irradiance information on the MRT
  24267. */
  24268. materialsShouldRenderIrradiance: boolean;
  24269. private _enabled;
  24270. /**
  24271. * Indicates if the prepass is enabled
  24272. */
  24273. get enabled(): boolean;
  24274. /**
  24275. * How many samples are used for MSAA of the scene render target
  24276. */
  24277. get samples(): number;
  24278. set samples(n: number);
  24279. /**
  24280. * Instanciates a prepass renderer
  24281. * @param scene The scene
  24282. */
  24283. constructor(scene: Scene);
  24284. private _initializeAttachments;
  24285. private _createCompositionEffect;
  24286. /**
  24287. * Indicates if rendering a prepass is supported
  24288. */
  24289. get isSupported(): boolean;
  24290. /**
  24291. * Sets the proper output textures to draw in the engine.
  24292. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24293. */
  24294. bindAttachmentsForEffect(effect: Effect): void;
  24295. /**
  24296. * @hidden
  24297. */
  24298. _beforeCameraDraw(): void;
  24299. /**
  24300. * @hidden
  24301. */
  24302. _afterCameraDraw(): void;
  24303. private _checkRTSize;
  24304. private _bindFrameBuffer;
  24305. /**
  24306. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24307. */
  24308. clear(): void;
  24309. private _setState;
  24310. private _enable;
  24311. private _disable;
  24312. private _resetPostProcessChain;
  24313. private _bindPostProcessChain;
  24314. /**
  24315. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24316. */
  24317. markAsDirty(): void;
  24318. private _update;
  24319. /**
  24320. * Disposes the prepass renderer.
  24321. */
  24322. dispose(): void;
  24323. }
  24324. }
  24325. declare module BABYLON {
  24326. /**
  24327. * Options for compiling materials.
  24328. */
  24329. export interface IMaterialCompilationOptions {
  24330. /**
  24331. * Defines whether clip planes are enabled.
  24332. */
  24333. clipPlane: boolean;
  24334. /**
  24335. * Defines whether instances are enabled.
  24336. */
  24337. useInstances: boolean;
  24338. }
  24339. /**
  24340. * Options passed when calling customShaderNameResolve
  24341. */
  24342. export interface ICustomShaderNameResolveOptions {
  24343. /**
  24344. * 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
  24345. */
  24346. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24347. }
  24348. /**
  24349. * Base class for the main features of a material in Babylon.js
  24350. */
  24351. export class Material implements IAnimatable {
  24352. /**
  24353. * Returns the triangle fill mode
  24354. */
  24355. static readonly TriangleFillMode: number;
  24356. /**
  24357. * Returns the wireframe mode
  24358. */
  24359. static readonly WireFrameFillMode: number;
  24360. /**
  24361. * Returns the point fill mode
  24362. */
  24363. static readonly PointFillMode: number;
  24364. /**
  24365. * Returns the point list draw mode
  24366. */
  24367. static readonly PointListDrawMode: number;
  24368. /**
  24369. * Returns the line list draw mode
  24370. */
  24371. static readonly LineListDrawMode: number;
  24372. /**
  24373. * Returns the line loop draw mode
  24374. */
  24375. static readonly LineLoopDrawMode: number;
  24376. /**
  24377. * Returns the line strip draw mode
  24378. */
  24379. static readonly LineStripDrawMode: number;
  24380. /**
  24381. * Returns the triangle strip draw mode
  24382. */
  24383. static readonly TriangleStripDrawMode: number;
  24384. /**
  24385. * Returns the triangle fan draw mode
  24386. */
  24387. static readonly TriangleFanDrawMode: number;
  24388. /**
  24389. * Stores the clock-wise side orientation
  24390. */
  24391. static readonly ClockWiseSideOrientation: number;
  24392. /**
  24393. * Stores the counter clock-wise side orientation
  24394. */
  24395. static readonly CounterClockWiseSideOrientation: number;
  24396. /**
  24397. * The dirty texture flag value
  24398. */
  24399. static readonly TextureDirtyFlag: number;
  24400. /**
  24401. * The dirty light flag value
  24402. */
  24403. static readonly LightDirtyFlag: number;
  24404. /**
  24405. * The dirty fresnel flag value
  24406. */
  24407. static readonly FresnelDirtyFlag: number;
  24408. /**
  24409. * The dirty attribute flag value
  24410. */
  24411. static readonly AttributesDirtyFlag: number;
  24412. /**
  24413. * The dirty misc flag value
  24414. */
  24415. static readonly MiscDirtyFlag: number;
  24416. /**
  24417. * The all dirty flag value
  24418. */
  24419. static readonly AllDirtyFlag: number;
  24420. /**
  24421. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24422. */
  24423. static readonly MATERIAL_OPAQUE: number;
  24424. /**
  24425. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24426. */
  24427. static readonly MATERIAL_ALPHATEST: number;
  24428. /**
  24429. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24430. */
  24431. static readonly MATERIAL_ALPHABLEND: number;
  24432. /**
  24433. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24434. * They are also discarded below the alpha cutoff threshold to improve performances.
  24435. */
  24436. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24437. /**
  24438. * The Whiteout method is used to blend normals.
  24439. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24440. */
  24441. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24442. /**
  24443. * The Reoriented Normal Mapping method is used to blend normals.
  24444. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24445. */
  24446. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24447. /**
  24448. * Custom callback helping to override the default shader used in the material.
  24449. */
  24450. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24451. /**
  24452. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24453. */
  24454. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24455. /**
  24456. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24457. * This means that the material can keep using a previous shader while a new one is being compiled.
  24458. * This is mostly used when shader parallel compilation is supported (true by default)
  24459. */
  24460. allowShaderHotSwapping: boolean;
  24461. /**
  24462. * The ID of the material
  24463. */
  24464. id: string;
  24465. /**
  24466. * Gets or sets the unique id of the material
  24467. */
  24468. uniqueId: number;
  24469. /**
  24470. * The name of the material
  24471. */
  24472. name: string;
  24473. /**
  24474. * Gets or sets user defined metadata
  24475. */
  24476. metadata: any;
  24477. /**
  24478. * For internal use only. Please do not use.
  24479. */
  24480. reservedDataStore: any;
  24481. /**
  24482. * Specifies if the ready state should be checked on each call
  24483. */
  24484. checkReadyOnEveryCall: boolean;
  24485. /**
  24486. * Specifies if the ready state should be checked once
  24487. */
  24488. checkReadyOnlyOnce: boolean;
  24489. /**
  24490. * The state of the material
  24491. */
  24492. state: string;
  24493. /**
  24494. * If the material can be rendered to several textures with MRT extension
  24495. */
  24496. get canRenderToMRT(): boolean;
  24497. /**
  24498. * The alpha value of the material
  24499. */
  24500. protected _alpha: number;
  24501. /**
  24502. * List of inspectable custom properties (used by the Inspector)
  24503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24504. */
  24505. inspectableCustomProperties: IInspectable[];
  24506. /**
  24507. * Sets the alpha value of the material
  24508. */
  24509. set alpha(value: number);
  24510. /**
  24511. * Gets the alpha value of the material
  24512. */
  24513. get alpha(): number;
  24514. /**
  24515. * Specifies if back face culling is enabled
  24516. */
  24517. protected _backFaceCulling: boolean;
  24518. /**
  24519. * Sets the back-face culling state
  24520. */
  24521. set backFaceCulling(value: boolean);
  24522. /**
  24523. * Gets the back-face culling state
  24524. */
  24525. get backFaceCulling(): boolean;
  24526. /**
  24527. * Stores the value for side orientation
  24528. */
  24529. sideOrientation: number;
  24530. /**
  24531. * Callback triggered when the material is compiled
  24532. */
  24533. onCompiled: Nullable<(effect: Effect) => void>;
  24534. /**
  24535. * Callback triggered when an error occurs
  24536. */
  24537. onError: Nullable<(effect: Effect, errors: string) => void>;
  24538. /**
  24539. * Callback triggered to get the render target textures
  24540. */
  24541. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24542. /**
  24543. * Gets a boolean indicating that current material needs to register RTT
  24544. */
  24545. get hasRenderTargetTextures(): boolean;
  24546. /**
  24547. * Specifies if the material should be serialized
  24548. */
  24549. doNotSerialize: boolean;
  24550. /**
  24551. * @hidden
  24552. */
  24553. _storeEffectOnSubMeshes: boolean;
  24554. /**
  24555. * Stores the animations for the material
  24556. */
  24557. animations: Nullable<Array<Animation>>;
  24558. /**
  24559. * An event triggered when the material is disposed
  24560. */
  24561. onDisposeObservable: Observable<Material>;
  24562. /**
  24563. * An observer which watches for dispose events
  24564. */
  24565. private _onDisposeObserver;
  24566. private _onUnBindObservable;
  24567. /**
  24568. * Called during a dispose event
  24569. */
  24570. set onDispose(callback: () => void);
  24571. private _onBindObservable;
  24572. /**
  24573. * An event triggered when the material is bound
  24574. */
  24575. get onBindObservable(): Observable<AbstractMesh>;
  24576. /**
  24577. * An observer which watches for bind events
  24578. */
  24579. private _onBindObserver;
  24580. /**
  24581. * Called during a bind event
  24582. */
  24583. set onBind(callback: (Mesh: AbstractMesh) => void);
  24584. /**
  24585. * An event triggered when the material is unbound
  24586. */
  24587. get onUnBindObservable(): Observable<Material>;
  24588. protected _onEffectCreatedObservable: Nullable<Observable<{
  24589. effect: Effect;
  24590. subMesh: Nullable<SubMesh>;
  24591. }>>;
  24592. /**
  24593. * An event triggered when the effect is (re)created
  24594. */
  24595. get onEffectCreatedObservable(): Observable<{
  24596. effect: Effect;
  24597. subMesh: Nullable<SubMesh>;
  24598. }>;
  24599. /**
  24600. * Stores the value of the alpha mode
  24601. */
  24602. private _alphaMode;
  24603. /**
  24604. * Sets the value of the alpha mode.
  24605. *
  24606. * | Value | Type | Description |
  24607. * | --- | --- | --- |
  24608. * | 0 | ALPHA_DISABLE | |
  24609. * | 1 | ALPHA_ADD | |
  24610. * | 2 | ALPHA_COMBINE | |
  24611. * | 3 | ALPHA_SUBTRACT | |
  24612. * | 4 | ALPHA_MULTIPLY | |
  24613. * | 5 | ALPHA_MAXIMIZED | |
  24614. * | 6 | ALPHA_ONEONE | |
  24615. * | 7 | ALPHA_PREMULTIPLIED | |
  24616. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24617. * | 9 | ALPHA_INTERPOLATE | |
  24618. * | 10 | ALPHA_SCREENMODE | |
  24619. *
  24620. */
  24621. set alphaMode(value: number);
  24622. /**
  24623. * Gets the value of the alpha mode
  24624. */
  24625. get alphaMode(): number;
  24626. /**
  24627. * Stores the state of the need depth pre-pass value
  24628. */
  24629. private _needDepthPrePass;
  24630. /**
  24631. * Sets the need depth pre-pass value
  24632. */
  24633. set needDepthPrePass(value: boolean);
  24634. /**
  24635. * Gets the depth pre-pass value
  24636. */
  24637. get needDepthPrePass(): boolean;
  24638. /**
  24639. * Specifies if depth writing should be disabled
  24640. */
  24641. disableDepthWrite: boolean;
  24642. /**
  24643. * Specifies if color writing should be disabled
  24644. */
  24645. disableColorWrite: boolean;
  24646. /**
  24647. * Specifies if depth writing should be forced
  24648. */
  24649. forceDepthWrite: boolean;
  24650. /**
  24651. * Specifies the depth function that should be used. 0 means the default engine function
  24652. */
  24653. depthFunction: number;
  24654. /**
  24655. * Specifies if there should be a separate pass for culling
  24656. */
  24657. separateCullingPass: boolean;
  24658. /**
  24659. * Stores the state specifing if fog should be enabled
  24660. */
  24661. private _fogEnabled;
  24662. /**
  24663. * Sets the state for enabling fog
  24664. */
  24665. set fogEnabled(value: boolean);
  24666. /**
  24667. * Gets the value of the fog enabled state
  24668. */
  24669. get fogEnabled(): boolean;
  24670. /**
  24671. * Stores the size of points
  24672. */
  24673. pointSize: number;
  24674. /**
  24675. * Stores the z offset value
  24676. */
  24677. zOffset: number;
  24678. get wireframe(): boolean;
  24679. /**
  24680. * Sets the state of wireframe mode
  24681. */
  24682. set wireframe(value: boolean);
  24683. /**
  24684. * Gets the value specifying if point clouds are enabled
  24685. */
  24686. get pointsCloud(): boolean;
  24687. /**
  24688. * Sets the state of point cloud mode
  24689. */
  24690. set pointsCloud(value: boolean);
  24691. /**
  24692. * Gets the material fill mode
  24693. */
  24694. get fillMode(): number;
  24695. /**
  24696. * Sets the material fill mode
  24697. */
  24698. set fillMode(value: number);
  24699. /**
  24700. * @hidden
  24701. * Stores the effects for the material
  24702. */
  24703. _effect: Nullable<Effect>;
  24704. /**
  24705. * Specifies if uniform buffers should be used
  24706. */
  24707. private _useUBO;
  24708. /**
  24709. * Stores a reference to the scene
  24710. */
  24711. private _scene;
  24712. /**
  24713. * Stores the fill mode state
  24714. */
  24715. private _fillMode;
  24716. /**
  24717. * Specifies if the depth write state should be cached
  24718. */
  24719. private _cachedDepthWriteState;
  24720. /**
  24721. * Specifies if the color write state should be cached
  24722. */
  24723. private _cachedColorWriteState;
  24724. /**
  24725. * Specifies if the depth function state should be cached
  24726. */
  24727. private _cachedDepthFunctionState;
  24728. /**
  24729. * Stores the uniform buffer
  24730. */
  24731. protected _uniformBuffer: UniformBuffer;
  24732. /** @hidden */
  24733. _indexInSceneMaterialArray: number;
  24734. /** @hidden */
  24735. meshMap: Nullable<{
  24736. [id: string]: AbstractMesh | undefined;
  24737. }>;
  24738. /**
  24739. * Creates a material instance
  24740. * @param name defines the name of the material
  24741. * @param scene defines the scene to reference
  24742. * @param doNotAdd specifies if the material should be added to the scene
  24743. */
  24744. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24745. /**
  24746. * Returns a string representation of the current material
  24747. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24748. * @returns a string with material information
  24749. */
  24750. toString(fullDetails?: boolean): string;
  24751. /**
  24752. * Gets the class name of the material
  24753. * @returns a string with the class name of the material
  24754. */
  24755. getClassName(): string;
  24756. /**
  24757. * Specifies if updates for the material been locked
  24758. */
  24759. get isFrozen(): boolean;
  24760. /**
  24761. * Locks updates for the material
  24762. */
  24763. freeze(): void;
  24764. /**
  24765. * Unlocks updates for the material
  24766. */
  24767. unfreeze(): void;
  24768. /**
  24769. * Specifies if the material is ready to be used
  24770. * @param mesh defines the mesh to check
  24771. * @param useInstances specifies if instances should be used
  24772. * @returns a boolean indicating if the material is ready to be used
  24773. */
  24774. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24775. /**
  24776. * Specifies that the submesh is ready to be used
  24777. * @param mesh defines the mesh to check
  24778. * @param subMesh defines which submesh to check
  24779. * @param useInstances specifies that instances should be used
  24780. * @returns a boolean indicating that the submesh is ready or not
  24781. */
  24782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24783. /**
  24784. * Returns the material effect
  24785. * @returns the effect associated with the material
  24786. */
  24787. getEffect(): Nullable<Effect>;
  24788. /**
  24789. * Returns the current scene
  24790. * @returns a Scene
  24791. */
  24792. getScene(): Scene;
  24793. /**
  24794. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24795. */
  24796. protected _forceAlphaTest: boolean;
  24797. /**
  24798. * The transparency mode of the material.
  24799. */
  24800. protected _transparencyMode: Nullable<number>;
  24801. /**
  24802. * Gets the current transparency mode.
  24803. */
  24804. get transparencyMode(): Nullable<number>;
  24805. /**
  24806. * Sets the transparency mode of the material.
  24807. *
  24808. * | Value | Type | Description |
  24809. * | ----- | ----------------------------------- | ----------- |
  24810. * | 0 | OPAQUE | |
  24811. * | 1 | ALPHATEST | |
  24812. * | 2 | ALPHABLEND | |
  24813. * | 3 | ALPHATESTANDBLEND | |
  24814. *
  24815. */
  24816. set transparencyMode(value: Nullable<number>);
  24817. /**
  24818. * Returns true if alpha blending should be disabled.
  24819. */
  24820. protected get _disableAlphaBlending(): boolean;
  24821. /**
  24822. * Specifies whether or not this material should be rendered in alpha blend mode.
  24823. * @returns a boolean specifying if alpha blending is needed
  24824. */
  24825. needAlphaBlending(): boolean;
  24826. /**
  24827. * Specifies if the mesh will require alpha blending
  24828. * @param mesh defines the mesh to check
  24829. * @returns a boolean specifying if alpha blending is needed for the mesh
  24830. */
  24831. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24832. /**
  24833. * Specifies whether or not this material should be rendered in alpha test mode.
  24834. * @returns a boolean specifying if an alpha test is needed.
  24835. */
  24836. needAlphaTesting(): boolean;
  24837. /**
  24838. * Specifies if material alpha testing should be turned on for the mesh
  24839. * @param mesh defines the mesh to check
  24840. */
  24841. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24842. /**
  24843. * Gets the texture used for the alpha test
  24844. * @returns the texture to use for alpha testing
  24845. */
  24846. getAlphaTestTexture(): Nullable<BaseTexture>;
  24847. /**
  24848. * Marks the material to indicate that it needs to be re-calculated
  24849. */
  24850. markDirty(): void;
  24851. /** @hidden */
  24852. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24853. /**
  24854. * Binds the material to the mesh
  24855. * @param world defines the world transformation matrix
  24856. * @param mesh defines the mesh to bind the material to
  24857. */
  24858. bind(world: Matrix, mesh?: Mesh): void;
  24859. /**
  24860. * Binds the submesh to the material
  24861. * @param world defines the world transformation matrix
  24862. * @param mesh defines the mesh containing the submesh
  24863. * @param subMesh defines the submesh to bind the material to
  24864. */
  24865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24866. /**
  24867. * Binds the world matrix to the material
  24868. * @param world defines the world transformation matrix
  24869. */
  24870. bindOnlyWorldMatrix(world: Matrix): void;
  24871. /**
  24872. * Binds the scene's uniform buffer to the effect.
  24873. * @param effect defines the effect to bind to the scene uniform buffer
  24874. * @param sceneUbo defines the uniform buffer storing scene data
  24875. */
  24876. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24877. /**
  24878. * Binds the view matrix to the effect
  24879. * @param effect defines the effect to bind the view matrix to
  24880. */
  24881. bindView(effect: Effect): void;
  24882. /**
  24883. * Binds the view projection matrix to the effect
  24884. * @param effect defines the effect to bind the view projection matrix to
  24885. */
  24886. bindViewProjection(effect: Effect): void;
  24887. /**
  24888. * Processes to execute after binding the material to a mesh
  24889. * @param mesh defines the rendered mesh
  24890. */
  24891. protected _afterBind(mesh?: Mesh): void;
  24892. /**
  24893. * Unbinds the material from the mesh
  24894. */
  24895. unbind(): void;
  24896. /**
  24897. * Gets the active textures from the material
  24898. * @returns an array of textures
  24899. */
  24900. getActiveTextures(): BaseTexture[];
  24901. /**
  24902. * Specifies if the material uses a texture
  24903. * @param texture defines the texture to check against the material
  24904. * @returns a boolean specifying if the material uses the texture
  24905. */
  24906. hasTexture(texture: BaseTexture): boolean;
  24907. /**
  24908. * Makes a duplicate of the material, and gives it a new name
  24909. * @param name defines the new name for the duplicated material
  24910. * @returns the cloned material
  24911. */
  24912. clone(name: string): Nullable<Material>;
  24913. /**
  24914. * Gets the meshes bound to the material
  24915. * @returns an array of meshes bound to the material
  24916. */
  24917. getBindedMeshes(): AbstractMesh[];
  24918. /**
  24919. * Force shader compilation
  24920. * @param mesh defines the mesh associated with this material
  24921. * @param onCompiled defines a function to execute once the material is compiled
  24922. * @param options defines the options to configure the compilation
  24923. * @param onError defines a function to execute if the material fails compiling
  24924. */
  24925. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24926. /**
  24927. * Force shader compilation
  24928. * @param mesh defines the mesh that will use this material
  24929. * @param options defines additional options for compiling the shaders
  24930. * @returns a promise that resolves when the compilation completes
  24931. */
  24932. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24933. private static readonly _AllDirtyCallBack;
  24934. private static readonly _ImageProcessingDirtyCallBack;
  24935. private static readonly _TextureDirtyCallBack;
  24936. private static readonly _FresnelDirtyCallBack;
  24937. private static readonly _MiscDirtyCallBack;
  24938. private static readonly _LightsDirtyCallBack;
  24939. private static readonly _AttributeDirtyCallBack;
  24940. private static _FresnelAndMiscDirtyCallBack;
  24941. private static _TextureAndMiscDirtyCallBack;
  24942. private static readonly _DirtyCallbackArray;
  24943. private static readonly _RunDirtyCallBacks;
  24944. /**
  24945. * Marks a define in the material to indicate that it needs to be re-computed
  24946. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24947. */
  24948. markAsDirty(flag: number): void;
  24949. /**
  24950. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24951. * @param func defines a function which checks material defines against the submeshes
  24952. */
  24953. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24954. /**
  24955. * Indicates that the scene should check if the rendering now needs a prepass
  24956. */
  24957. protected _markScenePrePassDirty(): void;
  24958. /**
  24959. * Indicates that we need to re-calculated for all submeshes
  24960. */
  24961. protected _markAllSubMeshesAsAllDirty(): void;
  24962. /**
  24963. * Indicates that image processing needs to be re-calculated for all submeshes
  24964. */
  24965. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24966. /**
  24967. * Indicates that textures need to be re-calculated for all submeshes
  24968. */
  24969. protected _markAllSubMeshesAsTexturesDirty(): void;
  24970. /**
  24971. * Indicates that fresnel needs to be re-calculated for all submeshes
  24972. */
  24973. protected _markAllSubMeshesAsFresnelDirty(): void;
  24974. /**
  24975. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24976. */
  24977. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24978. /**
  24979. * Indicates that lights need to be re-calculated for all submeshes
  24980. */
  24981. protected _markAllSubMeshesAsLightsDirty(): void;
  24982. /**
  24983. * Indicates that attributes need to be re-calculated for all submeshes
  24984. */
  24985. protected _markAllSubMeshesAsAttributesDirty(): void;
  24986. /**
  24987. * Indicates that misc needs to be re-calculated for all submeshes
  24988. */
  24989. protected _markAllSubMeshesAsMiscDirty(): void;
  24990. /**
  24991. * Indicates that textures and misc need to be re-calculated for all submeshes
  24992. */
  24993. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24994. /**
  24995. * Sets the required values to the prepass renderer.
  24996. * @param prePassRenderer defines the prepass renderer to setup.
  24997. * @returns true if the pre pass is needed.
  24998. */
  24999. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25000. /**
  25001. * Disposes the material
  25002. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25003. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25004. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25005. */
  25006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25007. /** @hidden */
  25008. private releaseVertexArrayObject;
  25009. /**
  25010. * Serializes this material
  25011. * @returns the serialized material object
  25012. */
  25013. serialize(): any;
  25014. /**
  25015. * Creates a material from parsed material data
  25016. * @param parsedMaterial defines parsed material data
  25017. * @param scene defines the hosting scene
  25018. * @param rootUrl defines the root URL to use to load textures
  25019. * @returns a new material
  25020. */
  25021. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25022. }
  25023. }
  25024. declare module BABYLON {
  25025. /**
  25026. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25027. * separate meshes. This can be use to improve performances.
  25028. * @see https://doc.babylonjs.com/how_to/multi_materials
  25029. */
  25030. export class MultiMaterial extends Material {
  25031. private _subMaterials;
  25032. /**
  25033. * Gets or Sets the list of Materials used within the multi material.
  25034. * They need to be ordered according to the submeshes order in the associated mesh
  25035. */
  25036. get subMaterials(): Nullable<Material>[];
  25037. set subMaterials(value: Nullable<Material>[]);
  25038. /**
  25039. * Function used to align with Node.getChildren()
  25040. * @returns the list of Materials used within the multi material
  25041. */
  25042. getChildren(): Nullable<Material>[];
  25043. /**
  25044. * Instantiates a new Multi Material
  25045. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25046. * separate meshes. This can be use to improve performances.
  25047. * @see https://doc.babylonjs.com/how_to/multi_materials
  25048. * @param name Define the name in the scene
  25049. * @param scene Define the scene the material belongs to
  25050. */
  25051. constructor(name: string, scene: Scene);
  25052. private _hookArray;
  25053. /**
  25054. * Get one of the submaterial by its index in the submaterials array
  25055. * @param index The index to look the sub material at
  25056. * @returns The Material if the index has been defined
  25057. */
  25058. getSubMaterial(index: number): Nullable<Material>;
  25059. /**
  25060. * Get the list of active textures for the whole sub materials list.
  25061. * @returns All the textures that will be used during the rendering
  25062. */
  25063. getActiveTextures(): BaseTexture[];
  25064. /**
  25065. * Gets the current class name of the material e.g. "MultiMaterial"
  25066. * Mainly use in serialization.
  25067. * @returns the class name
  25068. */
  25069. getClassName(): string;
  25070. /**
  25071. * Checks if the material is ready to render the requested sub mesh
  25072. * @param mesh Define the mesh the submesh belongs to
  25073. * @param subMesh Define the sub mesh to look readyness for
  25074. * @param useInstances Define whether or not the material is used with instances
  25075. * @returns true if ready, otherwise false
  25076. */
  25077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25078. /**
  25079. * Clones the current material and its related sub materials
  25080. * @param name Define the name of the newly cloned material
  25081. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25082. * @returns the cloned material
  25083. */
  25084. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25085. /**
  25086. * Serializes the materials into a JSON representation.
  25087. * @returns the JSON representation
  25088. */
  25089. serialize(): any;
  25090. /**
  25091. * Dispose the material and release its associated resources
  25092. * @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)
  25093. * @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)
  25094. * @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)
  25095. */
  25096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25097. /**
  25098. * Creates a MultiMaterial from parsed MultiMaterial data.
  25099. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25100. * @param scene defines the hosting scene
  25101. * @returns a new MultiMaterial
  25102. */
  25103. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25104. }
  25105. }
  25106. declare module BABYLON {
  25107. /**
  25108. * Defines a subdivision inside a mesh
  25109. */
  25110. export class SubMesh implements ICullable {
  25111. /** the material index to use */
  25112. materialIndex: number;
  25113. /** vertex index start */
  25114. verticesStart: number;
  25115. /** vertices count */
  25116. verticesCount: number;
  25117. /** index start */
  25118. indexStart: number;
  25119. /** indices count */
  25120. indexCount: number;
  25121. /** @hidden */
  25122. _materialDefines: Nullable<MaterialDefines>;
  25123. /** @hidden */
  25124. _materialEffect: Nullable<Effect>;
  25125. /** @hidden */
  25126. _effectOverride: Nullable<Effect>;
  25127. /**
  25128. * Gets material defines used by the effect associated to the sub mesh
  25129. */
  25130. get materialDefines(): Nullable<MaterialDefines>;
  25131. /**
  25132. * Sets material defines used by the effect associated to the sub mesh
  25133. */
  25134. set materialDefines(defines: Nullable<MaterialDefines>);
  25135. /**
  25136. * Gets associated effect
  25137. */
  25138. get effect(): Nullable<Effect>;
  25139. /**
  25140. * Sets associated effect (effect used to render this submesh)
  25141. * @param effect defines the effect to associate with
  25142. * @param defines defines the set of defines used to compile this effect
  25143. */
  25144. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25145. /** @hidden */
  25146. _linesIndexCount: number;
  25147. private _mesh;
  25148. private _renderingMesh;
  25149. private _boundingInfo;
  25150. private _linesIndexBuffer;
  25151. /** @hidden */
  25152. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25153. /** @hidden */
  25154. _trianglePlanes: Plane[];
  25155. /** @hidden */
  25156. _lastColliderTransformMatrix: Nullable<Matrix>;
  25157. /** @hidden */
  25158. _renderId: number;
  25159. /** @hidden */
  25160. _alphaIndex: number;
  25161. /** @hidden */
  25162. _distanceToCamera: number;
  25163. /** @hidden */
  25164. _id: number;
  25165. private _currentMaterial;
  25166. /**
  25167. * Add a new submesh to a mesh
  25168. * @param materialIndex defines the material index to use
  25169. * @param verticesStart defines vertex index start
  25170. * @param verticesCount defines vertices count
  25171. * @param indexStart defines index start
  25172. * @param indexCount defines indices count
  25173. * @param mesh defines the parent mesh
  25174. * @param renderingMesh defines an optional rendering mesh
  25175. * @param createBoundingBox defines if bounding box should be created for this submesh
  25176. * @returns the new submesh
  25177. */
  25178. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25179. /**
  25180. * Creates a new submesh
  25181. * @param materialIndex defines the material index to use
  25182. * @param verticesStart defines vertex index start
  25183. * @param verticesCount defines vertices count
  25184. * @param indexStart defines index start
  25185. * @param indexCount defines indices count
  25186. * @param mesh defines the parent mesh
  25187. * @param renderingMesh defines an optional rendering mesh
  25188. * @param createBoundingBox defines if bounding box should be created for this submesh
  25189. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25190. */
  25191. constructor(
  25192. /** the material index to use */
  25193. materialIndex: number,
  25194. /** vertex index start */
  25195. verticesStart: number,
  25196. /** vertices count */
  25197. verticesCount: number,
  25198. /** index start */
  25199. indexStart: number,
  25200. /** indices count */
  25201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25202. /**
  25203. * Returns true if this submesh covers the entire parent mesh
  25204. * @ignorenaming
  25205. */
  25206. get IsGlobal(): boolean;
  25207. /**
  25208. * Returns the submesh BoudingInfo object
  25209. * @returns current bounding info (or mesh's one if the submesh is global)
  25210. */
  25211. getBoundingInfo(): BoundingInfo;
  25212. /**
  25213. * Sets the submesh BoundingInfo
  25214. * @param boundingInfo defines the new bounding info to use
  25215. * @returns the SubMesh
  25216. */
  25217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25218. /**
  25219. * Returns the mesh of the current submesh
  25220. * @return the parent mesh
  25221. */
  25222. getMesh(): AbstractMesh;
  25223. /**
  25224. * Returns the rendering mesh of the submesh
  25225. * @returns the rendering mesh (could be different from parent mesh)
  25226. */
  25227. getRenderingMesh(): Mesh;
  25228. /**
  25229. * Returns the replacement mesh of the submesh
  25230. * @returns the replacement mesh (could be different from parent mesh)
  25231. */
  25232. getReplacementMesh(): Nullable<AbstractMesh>;
  25233. /**
  25234. * Returns the effective mesh of the submesh
  25235. * @returns the effective mesh (could be different from parent mesh)
  25236. */
  25237. getEffectiveMesh(): AbstractMesh;
  25238. /**
  25239. * Returns the submesh material
  25240. * @returns null or the current material
  25241. */
  25242. getMaterial(): Nullable<Material>;
  25243. private _IsMultiMaterial;
  25244. /**
  25245. * Sets a new updated BoundingInfo object to the submesh
  25246. * @param data defines an optional position array to use to determine the bounding info
  25247. * @returns the SubMesh
  25248. */
  25249. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25250. /** @hidden */
  25251. _checkCollision(collider: Collider): boolean;
  25252. /**
  25253. * Updates the submesh BoundingInfo
  25254. * @param world defines the world matrix to use to update the bounding info
  25255. * @returns the submesh
  25256. */
  25257. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25258. /**
  25259. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25260. * @param frustumPlanes defines the frustum planes
  25261. * @returns true if the submesh is intersecting with the frustum
  25262. */
  25263. isInFrustum(frustumPlanes: Plane[]): boolean;
  25264. /**
  25265. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25266. * @param frustumPlanes defines the frustum planes
  25267. * @returns true if the submesh is inside the frustum
  25268. */
  25269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25270. /**
  25271. * Renders the submesh
  25272. * @param enableAlphaMode defines if alpha needs to be used
  25273. * @returns the submesh
  25274. */
  25275. render(enableAlphaMode: boolean): SubMesh;
  25276. /**
  25277. * @hidden
  25278. */
  25279. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25280. /**
  25281. * Checks if the submesh intersects with a ray
  25282. * @param ray defines the ray to test
  25283. * @returns true is the passed ray intersects the submesh bounding box
  25284. */
  25285. canIntersects(ray: Ray): boolean;
  25286. /**
  25287. * Intersects current submesh with a ray
  25288. * @param ray defines the ray to test
  25289. * @param positions defines mesh's positions array
  25290. * @param indices defines mesh's indices array
  25291. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25293. * @returns intersection info or null if no intersection
  25294. */
  25295. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25296. /** @hidden */
  25297. private _intersectLines;
  25298. /** @hidden */
  25299. private _intersectUnIndexedLines;
  25300. /** @hidden */
  25301. private _intersectTriangles;
  25302. /** @hidden */
  25303. private _intersectUnIndexedTriangles;
  25304. /** @hidden */
  25305. _rebuild(): void;
  25306. /**
  25307. * Creates a new submesh from the passed mesh
  25308. * @param newMesh defines the new hosting mesh
  25309. * @param newRenderingMesh defines an optional rendering mesh
  25310. * @returns the new submesh
  25311. */
  25312. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25313. /**
  25314. * Release associated resources
  25315. */
  25316. dispose(): void;
  25317. /**
  25318. * Gets the class name
  25319. * @returns the string "SubMesh".
  25320. */
  25321. getClassName(): string;
  25322. /**
  25323. * Creates a new submesh from indices data
  25324. * @param materialIndex the index of the main mesh material
  25325. * @param startIndex the index where to start the copy in the mesh indices array
  25326. * @param indexCount the number of indices to copy then from the startIndex
  25327. * @param mesh the main mesh to create the submesh from
  25328. * @param renderingMesh the optional rendering mesh
  25329. * @returns a new submesh
  25330. */
  25331. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25332. }
  25333. }
  25334. declare module BABYLON {
  25335. /**
  25336. * Class used to represent data loading progression
  25337. */
  25338. export class SceneLoaderFlags {
  25339. private static _ForceFullSceneLoadingForIncremental;
  25340. private static _ShowLoadingScreen;
  25341. private static _CleanBoneMatrixWeights;
  25342. private static _loggingLevel;
  25343. /**
  25344. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25345. */
  25346. static get ForceFullSceneLoadingForIncremental(): boolean;
  25347. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25348. /**
  25349. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25350. */
  25351. static get ShowLoadingScreen(): boolean;
  25352. static set ShowLoadingScreen(value: boolean);
  25353. /**
  25354. * Defines the current logging level (while loading the scene)
  25355. * @ignorenaming
  25356. */
  25357. static get loggingLevel(): number;
  25358. static set loggingLevel(value: number);
  25359. /**
  25360. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25361. */
  25362. static get CleanBoneMatrixWeights(): boolean;
  25363. static set CleanBoneMatrixWeights(value: boolean);
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * Class used to store geometry data (vertex buffers + index buffer)
  25369. */
  25370. export class Geometry implements IGetSetVerticesData {
  25371. /**
  25372. * Gets or sets the ID of the geometry
  25373. */
  25374. id: string;
  25375. /**
  25376. * Gets or sets the unique ID of the geometry
  25377. */
  25378. uniqueId: number;
  25379. /**
  25380. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25381. */
  25382. delayLoadState: number;
  25383. /**
  25384. * Gets the file containing the data to load when running in delay load state
  25385. */
  25386. delayLoadingFile: Nullable<string>;
  25387. /**
  25388. * Callback called when the geometry is updated
  25389. */
  25390. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25391. private _scene;
  25392. private _engine;
  25393. private _meshes;
  25394. private _totalVertices;
  25395. /** @hidden */
  25396. _indices: IndicesArray;
  25397. /** @hidden */
  25398. _vertexBuffers: {
  25399. [key: string]: VertexBuffer;
  25400. };
  25401. private _isDisposed;
  25402. private _extend;
  25403. private _boundingBias;
  25404. /** @hidden */
  25405. _delayInfo: Array<string>;
  25406. private _indexBuffer;
  25407. private _indexBufferIsUpdatable;
  25408. /** @hidden */
  25409. _boundingInfo: Nullable<BoundingInfo>;
  25410. /** @hidden */
  25411. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25412. /** @hidden */
  25413. _softwareSkinningFrameId: number;
  25414. private _vertexArrayObjects;
  25415. private _updatable;
  25416. /** @hidden */
  25417. _positions: Nullable<Vector3[]>;
  25418. /**
  25419. * 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
  25420. */
  25421. get boundingBias(): Vector2;
  25422. /**
  25423. * 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
  25424. */
  25425. set boundingBias(value: Vector2);
  25426. /**
  25427. * Static function used to attach a new empty geometry to a mesh
  25428. * @param mesh defines the mesh to attach the geometry to
  25429. * @returns the new Geometry
  25430. */
  25431. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25432. /** Get the list of meshes using this geometry */
  25433. get meshes(): Mesh[];
  25434. /**
  25435. * 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
  25436. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25437. */
  25438. useBoundingInfoFromGeometry: boolean;
  25439. /**
  25440. * Creates a new geometry
  25441. * @param id defines the unique ID
  25442. * @param scene defines the hosting scene
  25443. * @param vertexData defines the VertexData used to get geometry data
  25444. * @param updatable defines if geometry must be updatable (false by default)
  25445. * @param mesh defines the mesh that will be associated with the geometry
  25446. */
  25447. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25448. /**
  25449. * Gets the current extend of the geometry
  25450. */
  25451. get extend(): {
  25452. minimum: Vector3;
  25453. maximum: Vector3;
  25454. };
  25455. /**
  25456. * Gets the hosting scene
  25457. * @returns the hosting Scene
  25458. */
  25459. getScene(): Scene;
  25460. /**
  25461. * Gets the hosting engine
  25462. * @returns the hosting Engine
  25463. */
  25464. getEngine(): Engine;
  25465. /**
  25466. * Defines if the geometry is ready to use
  25467. * @returns true if the geometry is ready to be used
  25468. */
  25469. isReady(): boolean;
  25470. /**
  25471. * Gets a value indicating that the geometry should not be serialized
  25472. */
  25473. get doNotSerialize(): boolean;
  25474. /** @hidden */
  25475. _rebuild(): void;
  25476. /**
  25477. * Affects all geometry data in one call
  25478. * @param vertexData defines the geometry data
  25479. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25480. */
  25481. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25482. /**
  25483. * Set specific vertex data
  25484. * @param kind defines the data kind (Position, normal, etc...)
  25485. * @param data defines the vertex data to use
  25486. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25487. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25488. */
  25489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25490. /**
  25491. * Removes a specific vertex data
  25492. * @param kind defines the data kind (Position, normal, etc...)
  25493. */
  25494. removeVerticesData(kind: string): void;
  25495. /**
  25496. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25497. * @param buffer defines the vertex buffer to use
  25498. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25499. */
  25500. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25501. /**
  25502. * Update a specific vertex buffer
  25503. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25504. * It will do nothing if the buffer is not updatable
  25505. * @param kind defines the data kind (Position, normal, etc...)
  25506. * @param data defines the data to use
  25507. * @param offset defines the offset in the target buffer where to store the data
  25508. * @param useBytes set to true if the offset is in bytes
  25509. */
  25510. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25511. /**
  25512. * Update a specific vertex buffer
  25513. * This function will create a new buffer if the current one is not updatable
  25514. * @param kind defines the data kind (Position, normal, etc...)
  25515. * @param data defines the data to use
  25516. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25517. */
  25518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25519. private _updateBoundingInfo;
  25520. /** @hidden */
  25521. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25522. /**
  25523. * Gets total number of vertices
  25524. * @returns the total number of vertices
  25525. */
  25526. getTotalVertices(): number;
  25527. /**
  25528. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25529. * @param kind defines the data kind (Position, normal, etc...)
  25530. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25532. * @returns a float array containing vertex data
  25533. */
  25534. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25535. /**
  25536. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25537. * @param kind defines the data kind (Position, normal, etc...)
  25538. * @returns true if the vertex buffer with the specified kind is updatable
  25539. */
  25540. isVertexBufferUpdatable(kind: string): boolean;
  25541. /**
  25542. * Gets a specific vertex buffer
  25543. * @param kind defines the data kind (Position, normal, etc...)
  25544. * @returns a VertexBuffer
  25545. */
  25546. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25547. /**
  25548. * Returns all vertex buffers
  25549. * @return an object holding all vertex buffers indexed by kind
  25550. */
  25551. getVertexBuffers(): Nullable<{
  25552. [key: string]: VertexBuffer;
  25553. }>;
  25554. /**
  25555. * Gets a boolean indicating if specific vertex buffer is present
  25556. * @param kind defines the data kind (Position, normal, etc...)
  25557. * @returns true if data is present
  25558. */
  25559. isVerticesDataPresent(kind: string): boolean;
  25560. /**
  25561. * Gets a list of all attached data kinds (Position, normal, etc...)
  25562. * @returns a list of string containing all kinds
  25563. */
  25564. getVerticesDataKinds(): string[];
  25565. /**
  25566. * Update index buffer
  25567. * @param indices defines the indices to store in the index buffer
  25568. * @param offset defines the offset in the target buffer where to store the data
  25569. * @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)
  25570. */
  25571. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25572. /**
  25573. * Creates a new index buffer
  25574. * @param indices defines the indices to store in the index buffer
  25575. * @param totalVertices defines the total number of vertices (could be null)
  25576. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25577. */
  25578. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25579. /**
  25580. * Return the total number of indices
  25581. * @returns the total number of indices
  25582. */
  25583. getTotalIndices(): number;
  25584. /**
  25585. * Gets the index buffer array
  25586. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25587. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25588. * @returns the index buffer array
  25589. */
  25590. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25591. /**
  25592. * Gets the index buffer
  25593. * @return the index buffer
  25594. */
  25595. getIndexBuffer(): Nullable<DataBuffer>;
  25596. /** @hidden */
  25597. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25598. /**
  25599. * Release the associated resources for a specific mesh
  25600. * @param mesh defines the source mesh
  25601. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25602. */
  25603. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25604. /**
  25605. * Apply current geometry to a given mesh
  25606. * @param mesh defines the mesh to apply geometry to
  25607. */
  25608. applyToMesh(mesh: Mesh): void;
  25609. private _updateExtend;
  25610. private _applyToMesh;
  25611. private notifyUpdate;
  25612. /**
  25613. * Load the geometry if it was flagged as delay loaded
  25614. * @param scene defines the hosting scene
  25615. * @param onLoaded defines a callback called when the geometry is loaded
  25616. */
  25617. load(scene: Scene, onLoaded?: () => void): void;
  25618. private _queueLoad;
  25619. /**
  25620. * Invert the geometry to move from a right handed system to a left handed one.
  25621. */
  25622. toLeftHanded(): void;
  25623. /** @hidden */
  25624. _resetPointsArrayCache(): void;
  25625. /** @hidden */
  25626. _generatePointsArray(): boolean;
  25627. /**
  25628. * Gets a value indicating if the geometry is disposed
  25629. * @returns true if the geometry was disposed
  25630. */
  25631. isDisposed(): boolean;
  25632. private _disposeVertexArrayObjects;
  25633. /**
  25634. * Free all associated resources
  25635. */
  25636. dispose(): void;
  25637. /**
  25638. * Clone the current geometry into a new geometry
  25639. * @param id defines the unique ID of the new geometry
  25640. * @returns a new geometry object
  25641. */
  25642. copy(id: string): Geometry;
  25643. /**
  25644. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25645. * @return a JSON representation of the current geometry data (without the vertices data)
  25646. */
  25647. serialize(): any;
  25648. private toNumberArray;
  25649. /**
  25650. * Serialize all vertices data into a JSON oject
  25651. * @returns a JSON representation of the current geometry data
  25652. */
  25653. serializeVerticeData(): any;
  25654. /**
  25655. * Extracts a clone of a mesh geometry
  25656. * @param mesh defines the source mesh
  25657. * @param id defines the unique ID of the new geometry object
  25658. * @returns the new geometry object
  25659. */
  25660. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25661. /**
  25662. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25663. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25664. * Be aware Math.random() could cause collisions, but:
  25665. * "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"
  25666. * @returns a string containing a new GUID
  25667. */
  25668. static RandomId(): string;
  25669. /** @hidden */
  25670. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25671. private static _CleanMatricesWeights;
  25672. /**
  25673. * Create a new geometry from persisted data (Using .babylon file format)
  25674. * @param parsedVertexData defines the persisted data
  25675. * @param scene defines the hosting scene
  25676. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25677. * @returns the new geometry object
  25678. */
  25679. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25680. }
  25681. }
  25682. declare module BABYLON {
  25683. /**
  25684. * Define an interface for all classes that will get and set the data on vertices
  25685. */
  25686. export interface IGetSetVerticesData {
  25687. /**
  25688. * Gets a boolean indicating if specific vertex data is present
  25689. * @param kind defines the vertex data kind to use
  25690. * @returns true is data kind is present
  25691. */
  25692. isVerticesDataPresent(kind: string): boolean;
  25693. /**
  25694. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25695. * @param kind defines the data kind (Position, normal, etc...)
  25696. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25697. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25698. * @returns a float array containing vertex data
  25699. */
  25700. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25701. /**
  25702. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25703. * @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.
  25704. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25705. * @returns the indices array or an empty array if the mesh has no geometry
  25706. */
  25707. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25708. /**
  25709. * Set specific vertex data
  25710. * @param kind defines the data kind (Position, normal, etc...)
  25711. * @param data defines the vertex data to use
  25712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25714. */
  25715. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25716. /**
  25717. * Update a specific associated vertex buffer
  25718. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25719. * - VertexBuffer.PositionKind
  25720. * - VertexBuffer.UVKind
  25721. * - VertexBuffer.UV2Kind
  25722. * - VertexBuffer.UV3Kind
  25723. * - VertexBuffer.UV4Kind
  25724. * - VertexBuffer.UV5Kind
  25725. * - VertexBuffer.UV6Kind
  25726. * - VertexBuffer.ColorKind
  25727. * - VertexBuffer.MatricesIndicesKind
  25728. * - VertexBuffer.MatricesIndicesExtraKind
  25729. * - VertexBuffer.MatricesWeightsKind
  25730. * - VertexBuffer.MatricesWeightsExtraKind
  25731. * @param data defines the data source
  25732. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25733. * @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)
  25734. */
  25735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25736. /**
  25737. * Creates a new index buffer
  25738. * @param indices defines the indices to store in the index buffer
  25739. * @param totalVertices defines the total number of vertices (could be null)
  25740. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25741. */
  25742. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25743. }
  25744. /**
  25745. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25746. */
  25747. export class VertexData {
  25748. /**
  25749. * Mesh side orientation : usually the external or front surface
  25750. */
  25751. static readonly FRONTSIDE: number;
  25752. /**
  25753. * Mesh side orientation : usually the internal or back surface
  25754. */
  25755. static readonly BACKSIDE: number;
  25756. /**
  25757. * Mesh side orientation : both internal and external or front and back surfaces
  25758. */
  25759. static readonly DOUBLESIDE: number;
  25760. /**
  25761. * Mesh side orientation : by default, `FRONTSIDE`
  25762. */
  25763. static readonly DEFAULTSIDE: number;
  25764. /**
  25765. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25766. */
  25767. positions: Nullable<FloatArray>;
  25768. /**
  25769. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25770. */
  25771. normals: Nullable<FloatArray>;
  25772. /**
  25773. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25774. */
  25775. tangents: Nullable<FloatArray>;
  25776. /**
  25777. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25778. */
  25779. uvs: Nullable<FloatArray>;
  25780. /**
  25781. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25782. */
  25783. uvs2: Nullable<FloatArray>;
  25784. /**
  25785. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25786. */
  25787. uvs3: Nullable<FloatArray>;
  25788. /**
  25789. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25790. */
  25791. uvs4: Nullable<FloatArray>;
  25792. /**
  25793. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25794. */
  25795. uvs5: Nullable<FloatArray>;
  25796. /**
  25797. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25798. */
  25799. uvs6: Nullable<FloatArray>;
  25800. /**
  25801. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25802. */
  25803. colors: Nullable<FloatArray>;
  25804. /**
  25805. * 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).
  25806. */
  25807. matricesIndices: Nullable<FloatArray>;
  25808. /**
  25809. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25810. */
  25811. matricesWeights: Nullable<FloatArray>;
  25812. /**
  25813. * An array extending the number of possible indices
  25814. */
  25815. matricesIndicesExtra: Nullable<FloatArray>;
  25816. /**
  25817. * An array extending the number of possible weights when the number of indices is extended
  25818. */
  25819. matricesWeightsExtra: Nullable<FloatArray>;
  25820. /**
  25821. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25822. */
  25823. indices: Nullable<IndicesArray>;
  25824. /**
  25825. * Uses the passed data array to set the set the values for the specified kind of data
  25826. * @param data a linear array of floating numbers
  25827. * @param kind the type of data that is being set, eg positions, colors etc
  25828. */
  25829. set(data: FloatArray, kind: string): void;
  25830. /**
  25831. * Associates the vertexData to the passed Mesh.
  25832. * Sets it as updatable or not (default `false`)
  25833. * @param mesh the mesh the vertexData is applied to
  25834. * @param updatable when used and having the value true allows new data to update the vertexData
  25835. * @returns the VertexData
  25836. */
  25837. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25838. /**
  25839. * Associates the vertexData to the passed Geometry.
  25840. * Sets it as updatable or not (default `false`)
  25841. * @param geometry the geometry the vertexData is applied to
  25842. * @param updatable when used and having the value true allows new data to update the vertexData
  25843. * @returns VertexData
  25844. */
  25845. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25846. /**
  25847. * Updates the associated mesh
  25848. * @param mesh the mesh to be updated
  25849. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25850. * @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
  25851. * @returns VertexData
  25852. */
  25853. updateMesh(mesh: Mesh): VertexData;
  25854. /**
  25855. * Updates the associated geometry
  25856. * @param geometry the geometry to be updated
  25857. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25858. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  25859. * @returns VertexData.
  25860. */
  25861. updateGeometry(geometry: Geometry): VertexData;
  25862. private _applyTo;
  25863. private _update;
  25864. /**
  25865. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25866. * @param matrix the transforming matrix
  25867. * @returns the VertexData
  25868. */
  25869. transform(matrix: Matrix): VertexData;
  25870. /**
  25871. * Merges the passed VertexData into the current one
  25872. * @param other the VertexData to be merged into the current one
  25873. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25874. * @returns the modified VertexData
  25875. */
  25876. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25877. private _mergeElement;
  25878. private _validate;
  25879. /**
  25880. * Serializes the VertexData
  25881. * @returns a serialized object
  25882. */
  25883. serialize(): any;
  25884. /**
  25885. * Extracts the vertexData from a mesh
  25886. * @param mesh the mesh from which to extract the VertexData
  25887. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25888. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25889. * @returns the object VertexData associated to the passed mesh
  25890. */
  25891. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25892. /**
  25893. * Extracts the vertexData from the geometry
  25894. * @param geometry the geometry from which to extract the VertexData
  25895. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25897. * @returns the object VertexData associated to the passed mesh
  25898. */
  25899. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25900. private static _ExtractFrom;
  25901. /**
  25902. * Creates the VertexData for a Ribbon
  25903. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25904. * * pathArray array of paths, each of which an array of successive Vector3
  25905. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25906. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25907. * * 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
  25908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25909. * * 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)
  25910. * * 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)
  25911. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25912. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25913. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25914. * @returns the VertexData of the ribbon
  25915. */
  25916. static CreateRibbon(options: {
  25917. pathArray: Vector3[][];
  25918. closeArray?: boolean;
  25919. closePath?: boolean;
  25920. offset?: number;
  25921. sideOrientation?: number;
  25922. frontUVs?: Vector4;
  25923. backUVs?: Vector4;
  25924. invertUV?: boolean;
  25925. uvs?: Vector2[];
  25926. colors?: Color4[];
  25927. }): VertexData;
  25928. /**
  25929. * Creates the VertexData for a box
  25930. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25931. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25932. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25933. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25934. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25935. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25936. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25938. * * 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)
  25939. * * 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)
  25940. * @returns the VertexData of the box
  25941. */
  25942. static CreateBox(options: {
  25943. size?: number;
  25944. width?: number;
  25945. height?: number;
  25946. depth?: number;
  25947. faceUV?: Vector4[];
  25948. faceColors?: Color4[];
  25949. sideOrientation?: number;
  25950. frontUVs?: Vector4;
  25951. backUVs?: Vector4;
  25952. }): VertexData;
  25953. /**
  25954. * Creates the VertexData for a tiled box
  25955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25956. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25957. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25958. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25960. * @returns the VertexData of the box
  25961. */
  25962. static CreateTiledBox(options: {
  25963. pattern?: number;
  25964. width?: number;
  25965. height?: number;
  25966. depth?: number;
  25967. tileSize?: number;
  25968. tileWidth?: number;
  25969. tileHeight?: number;
  25970. alignHorizontal?: number;
  25971. alignVertical?: number;
  25972. faceUV?: Vector4[];
  25973. faceColors?: Color4[];
  25974. sideOrientation?: number;
  25975. }): VertexData;
  25976. /**
  25977. * Creates the VertexData for a tiled plane
  25978. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25979. * * pattern a limited pattern arrangement depending on the number
  25980. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25981. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25982. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25984. * * 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)
  25985. * * 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)
  25986. * @returns the VertexData of the tiled plane
  25987. */
  25988. static CreateTiledPlane(options: {
  25989. pattern?: number;
  25990. tileSize?: number;
  25991. tileWidth?: number;
  25992. tileHeight?: number;
  25993. size?: number;
  25994. width?: number;
  25995. height?: number;
  25996. alignHorizontal?: number;
  25997. alignVertical?: number;
  25998. sideOrientation?: number;
  25999. frontUVs?: Vector4;
  26000. backUVs?: Vector4;
  26001. }): VertexData;
  26002. /**
  26003. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26005. * * segments sets the number of horizontal strips optional, default 32
  26006. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26007. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26008. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26009. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26010. * * 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
  26011. * * 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
  26012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26013. * * 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)
  26014. * * 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)
  26015. * @returns the VertexData of the ellipsoid
  26016. */
  26017. static CreateSphere(options: {
  26018. segments?: number;
  26019. diameter?: number;
  26020. diameterX?: number;
  26021. diameterY?: number;
  26022. diameterZ?: number;
  26023. arc?: number;
  26024. slice?: number;
  26025. sideOrientation?: number;
  26026. frontUVs?: Vector4;
  26027. backUVs?: Vector4;
  26028. }): VertexData;
  26029. /**
  26030. * Creates the VertexData for a cylinder, cone or prism
  26031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26032. * * height sets the height (y direction) of the cylinder, optional, default 2
  26033. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26034. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26035. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26036. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26037. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26038. * * 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
  26039. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26041. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26042. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26044. * * 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)
  26045. * * 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)
  26046. * @returns the VertexData of the cylinder, cone or prism
  26047. */
  26048. static CreateCylinder(options: {
  26049. height?: number;
  26050. diameterTop?: number;
  26051. diameterBottom?: number;
  26052. diameter?: number;
  26053. tessellation?: number;
  26054. subdivisions?: number;
  26055. arc?: number;
  26056. faceColors?: Color4[];
  26057. faceUV?: Vector4[];
  26058. hasRings?: boolean;
  26059. enclose?: boolean;
  26060. sideOrientation?: number;
  26061. frontUVs?: Vector4;
  26062. backUVs?: Vector4;
  26063. }): VertexData;
  26064. /**
  26065. * Creates the VertexData for a torus
  26066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26067. * * diameter the diameter of the torus, optional default 1
  26068. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26071. * * 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)
  26072. * * 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)
  26073. * @returns the VertexData of the torus
  26074. */
  26075. static CreateTorus(options: {
  26076. diameter?: number;
  26077. thickness?: number;
  26078. tessellation?: number;
  26079. sideOrientation?: number;
  26080. frontUVs?: Vector4;
  26081. backUVs?: Vector4;
  26082. }): VertexData;
  26083. /**
  26084. * Creates the VertexData of the LineSystem
  26085. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26086. * - lines an array of lines, each line being an array of successive Vector3
  26087. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26088. * @returns the VertexData of the LineSystem
  26089. */
  26090. static CreateLineSystem(options: {
  26091. lines: Vector3[][];
  26092. colors?: Nullable<Color4[][]>;
  26093. }): VertexData;
  26094. /**
  26095. * Create the VertexData for a DashedLines
  26096. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26097. * - points an array successive Vector3
  26098. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26099. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26100. * - dashNb the intended total number of dashes, optional, default 200
  26101. * @returns the VertexData for the DashedLines
  26102. */
  26103. static CreateDashedLines(options: {
  26104. points: Vector3[];
  26105. dashSize?: number;
  26106. gapSize?: number;
  26107. dashNb?: number;
  26108. }): VertexData;
  26109. /**
  26110. * Creates the VertexData for a Ground
  26111. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26112. * - width the width (x direction) of the ground, optional, default 1
  26113. * - height the height (z direction) of the ground, optional, default 1
  26114. * - subdivisions the number of subdivisions per side, optional, default 1
  26115. * @returns the VertexData of the Ground
  26116. */
  26117. static CreateGround(options: {
  26118. width?: number;
  26119. height?: number;
  26120. subdivisions?: number;
  26121. subdivisionsX?: number;
  26122. subdivisionsY?: number;
  26123. }): VertexData;
  26124. /**
  26125. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26126. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26127. * * xmin the ground minimum X coordinate, optional, default -1
  26128. * * zmin the ground minimum Z coordinate, optional, default -1
  26129. * * xmax the ground maximum X coordinate, optional, default 1
  26130. * * zmax the ground maximum Z coordinate, optional, default 1
  26131. * * 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}
  26132. * * 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}
  26133. * @returns the VertexData of the TiledGround
  26134. */
  26135. static CreateTiledGround(options: {
  26136. xmin: number;
  26137. zmin: number;
  26138. xmax: number;
  26139. zmax: number;
  26140. subdivisions?: {
  26141. w: number;
  26142. h: number;
  26143. };
  26144. precision?: {
  26145. w: number;
  26146. h: number;
  26147. };
  26148. }): VertexData;
  26149. /**
  26150. * Creates the VertexData of the Ground designed from a heightmap
  26151. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26152. * * width the width (x direction) of the ground
  26153. * * height the height (z direction) of the ground
  26154. * * subdivisions the number of subdivisions per side
  26155. * * minHeight the minimum altitude on the ground, optional, default 0
  26156. * * maxHeight the maximum altitude on the ground, optional default 1
  26157. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26158. * * buffer the array holding the image color data
  26159. * * bufferWidth the width of image
  26160. * * bufferHeight the height of image
  26161. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26162. * @returns the VertexData of the Ground designed from a heightmap
  26163. */
  26164. static CreateGroundFromHeightMap(options: {
  26165. width: number;
  26166. height: number;
  26167. subdivisions: number;
  26168. minHeight: number;
  26169. maxHeight: number;
  26170. colorFilter: Color3;
  26171. buffer: Uint8Array;
  26172. bufferWidth: number;
  26173. bufferHeight: number;
  26174. alphaFilter: number;
  26175. }): VertexData;
  26176. /**
  26177. * Creates the VertexData for a Plane
  26178. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26179. * * size sets the width and height of the plane to the value of size, optional default 1
  26180. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26181. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26183. * * 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)
  26184. * * 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)
  26185. * @returns the VertexData of the box
  26186. */
  26187. static CreatePlane(options: {
  26188. size?: number;
  26189. width?: number;
  26190. height?: number;
  26191. sideOrientation?: number;
  26192. frontUVs?: Vector4;
  26193. backUVs?: Vector4;
  26194. }): VertexData;
  26195. /**
  26196. * Creates the VertexData of the Disc or regular Polygon
  26197. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26198. * * radius the radius of the disc, optional default 0.5
  26199. * * tessellation the number of polygon sides, optional, default 64
  26200. * * 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
  26201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26202. * * 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)
  26203. * * 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)
  26204. * @returns the VertexData of the box
  26205. */
  26206. static CreateDisc(options: {
  26207. radius?: number;
  26208. tessellation?: number;
  26209. arc?: number;
  26210. sideOrientation?: number;
  26211. frontUVs?: Vector4;
  26212. backUVs?: Vector4;
  26213. }): VertexData;
  26214. /**
  26215. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26216. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26217. * @param polygon a mesh built from polygonTriangulation.build()
  26218. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26219. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26220. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26221. * @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)
  26222. * @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)
  26223. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26224. * @returns the VertexData of the Polygon
  26225. */
  26226. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26227. /**
  26228. * Creates the VertexData of the IcoSphere
  26229. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26230. * * radius the radius of the IcoSphere, optional default 1
  26231. * * radiusX allows stretching in the x direction, optional, default radius
  26232. * * radiusY allows stretching in the y direction, optional, default radius
  26233. * * radiusZ allows stretching in the z direction, optional, default radius
  26234. * * flat when true creates a flat shaded mesh, optional, default true
  26235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26237. * * 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)
  26238. * * 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)
  26239. * @returns the VertexData of the IcoSphere
  26240. */
  26241. static CreateIcoSphere(options: {
  26242. radius?: number;
  26243. radiusX?: number;
  26244. radiusY?: number;
  26245. radiusZ?: number;
  26246. flat?: boolean;
  26247. subdivisions?: number;
  26248. sideOrientation?: number;
  26249. frontUVs?: Vector4;
  26250. backUVs?: Vector4;
  26251. }): VertexData;
  26252. /**
  26253. * Creates the VertexData for a Polyhedron
  26254. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26255. * * type provided types are:
  26256. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26257. * * 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)
  26258. * * size the size of the IcoSphere, optional default 1
  26259. * * sizeX allows stretching in the x direction, optional, default size
  26260. * * sizeY allows stretching in the y direction, optional, default size
  26261. * * sizeZ allows stretching in the z direction, optional, default size
  26262. * * 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
  26263. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26264. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26265. * * flat when true creates a flat shaded mesh, optional, default true
  26266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26268. * * 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)
  26269. * * 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)
  26270. * @returns the VertexData of the Polyhedron
  26271. */
  26272. static CreatePolyhedron(options: {
  26273. type?: number;
  26274. size?: number;
  26275. sizeX?: number;
  26276. sizeY?: number;
  26277. sizeZ?: number;
  26278. custom?: any;
  26279. faceUV?: Vector4[];
  26280. faceColors?: Color4[];
  26281. flat?: boolean;
  26282. sideOrientation?: number;
  26283. frontUVs?: Vector4;
  26284. backUVs?: Vector4;
  26285. }): VertexData;
  26286. /**
  26287. * Creates the VertexData for a TorusKnot
  26288. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26289. * * radius the radius of the torus knot, optional, default 2
  26290. * * tube the thickness of the tube, optional, default 0.5
  26291. * * radialSegments the number of sides on each tube segments, optional, default 32
  26292. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26293. * * p the number of windings around the z axis, optional, default 2
  26294. * * q the number of windings around the x axis, optional, default 3
  26295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26296. * * 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)
  26297. * * 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)
  26298. * @returns the VertexData of the Torus Knot
  26299. */
  26300. static CreateTorusKnot(options: {
  26301. radius?: number;
  26302. tube?: number;
  26303. radialSegments?: number;
  26304. tubularSegments?: number;
  26305. p?: number;
  26306. q?: number;
  26307. sideOrientation?: number;
  26308. frontUVs?: Vector4;
  26309. backUVs?: Vector4;
  26310. }): VertexData;
  26311. /**
  26312. * Compute normals for given positions and indices
  26313. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26314. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26315. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26316. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26317. * * facetNormals : optional array of facet normals (vector3)
  26318. * * facetPositions : optional array of facet positions (vector3)
  26319. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26320. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26321. * * bInfo : optional bounding info, required for facetPartitioning computation
  26322. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26323. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26324. * * useRightHandedSystem: optional boolean to for right handed system computation
  26325. * * depthSort : optional boolean to enable the facet depth sort computation
  26326. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26327. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26328. */
  26329. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26330. facetNormals?: any;
  26331. facetPositions?: any;
  26332. facetPartitioning?: any;
  26333. ratio?: number;
  26334. bInfo?: any;
  26335. bbSize?: Vector3;
  26336. subDiv?: any;
  26337. useRightHandedSystem?: boolean;
  26338. depthSort?: boolean;
  26339. distanceTo?: Vector3;
  26340. depthSortedFacets?: any;
  26341. }): void;
  26342. /** @hidden */
  26343. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26344. /**
  26345. * Applies VertexData created from the imported parameters to the geometry
  26346. * @param parsedVertexData the parsed data from an imported file
  26347. * @param geometry the geometry to apply the VertexData to
  26348. */
  26349. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26350. }
  26351. }
  26352. declare module BABYLON {
  26353. /**
  26354. * Defines a target to use with MorphTargetManager
  26355. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26356. */
  26357. export class MorphTarget implements IAnimatable {
  26358. /** defines the name of the target */
  26359. name: string;
  26360. /**
  26361. * Gets or sets the list of animations
  26362. */
  26363. animations: Animation[];
  26364. private _scene;
  26365. private _positions;
  26366. private _normals;
  26367. private _tangents;
  26368. private _uvs;
  26369. private _influence;
  26370. private _uniqueId;
  26371. /**
  26372. * Observable raised when the influence changes
  26373. */
  26374. onInfluenceChanged: Observable<boolean>;
  26375. /** @hidden */
  26376. _onDataLayoutChanged: Observable<void>;
  26377. /**
  26378. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26379. */
  26380. get influence(): number;
  26381. set influence(influence: number);
  26382. /**
  26383. * Gets or sets the id of the morph Target
  26384. */
  26385. id: string;
  26386. private _animationPropertiesOverride;
  26387. /**
  26388. * Gets or sets the animation properties override
  26389. */
  26390. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26391. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26392. /**
  26393. * Creates a new MorphTarget
  26394. * @param name defines the name of the target
  26395. * @param influence defines the influence to use
  26396. * @param scene defines the scene the morphtarget belongs to
  26397. */
  26398. constructor(
  26399. /** defines the name of the target */
  26400. name: string, influence?: number, scene?: Nullable<Scene>);
  26401. /**
  26402. * Gets the unique ID of this manager
  26403. */
  26404. get uniqueId(): number;
  26405. /**
  26406. * Gets a boolean defining if the target contains position data
  26407. */
  26408. get hasPositions(): boolean;
  26409. /**
  26410. * Gets a boolean defining if the target contains normal data
  26411. */
  26412. get hasNormals(): boolean;
  26413. /**
  26414. * Gets a boolean defining if the target contains tangent data
  26415. */
  26416. get hasTangents(): boolean;
  26417. /**
  26418. * Gets a boolean defining if the target contains texture coordinates data
  26419. */
  26420. get hasUVs(): boolean;
  26421. /**
  26422. * Affects position data to this target
  26423. * @param data defines the position data to use
  26424. */
  26425. setPositions(data: Nullable<FloatArray>): void;
  26426. /**
  26427. * Gets the position data stored in this target
  26428. * @returns a FloatArray containing the position data (or null if not present)
  26429. */
  26430. getPositions(): Nullable<FloatArray>;
  26431. /**
  26432. * Affects normal data to this target
  26433. * @param data defines the normal data to use
  26434. */
  26435. setNormals(data: Nullable<FloatArray>): void;
  26436. /**
  26437. * Gets the normal data stored in this target
  26438. * @returns a FloatArray containing the normal data (or null if not present)
  26439. */
  26440. getNormals(): Nullable<FloatArray>;
  26441. /**
  26442. * Affects tangent data to this target
  26443. * @param data defines the tangent data to use
  26444. */
  26445. setTangents(data: Nullable<FloatArray>): void;
  26446. /**
  26447. * Gets the tangent data stored in this target
  26448. * @returns a FloatArray containing the tangent data (or null if not present)
  26449. */
  26450. getTangents(): Nullable<FloatArray>;
  26451. /**
  26452. * Affects texture coordinates data to this target
  26453. * @param data defines the texture coordinates data to use
  26454. */
  26455. setUVs(data: Nullable<FloatArray>): void;
  26456. /**
  26457. * Gets the texture coordinates data stored in this target
  26458. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26459. */
  26460. getUVs(): Nullable<FloatArray>;
  26461. /**
  26462. * Clone the current target
  26463. * @returns a new MorphTarget
  26464. */
  26465. clone(): MorphTarget;
  26466. /**
  26467. * Serializes the current target into a Serialization object
  26468. * @returns the serialized object
  26469. */
  26470. serialize(): any;
  26471. /**
  26472. * Returns the string "MorphTarget"
  26473. * @returns "MorphTarget"
  26474. */
  26475. getClassName(): string;
  26476. /**
  26477. * Creates a new target from serialized data
  26478. * @param serializationObject defines the serialized data to use
  26479. * @returns a new MorphTarget
  26480. */
  26481. static Parse(serializationObject: any): MorphTarget;
  26482. /**
  26483. * Creates a MorphTarget from mesh data
  26484. * @param mesh defines the source mesh
  26485. * @param name defines the name to use for the new target
  26486. * @param influence defines the influence to attach to the target
  26487. * @returns a new MorphTarget
  26488. */
  26489. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26490. }
  26491. }
  26492. declare module BABYLON {
  26493. /**
  26494. * This class is used to deform meshes using morphing between different targets
  26495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26496. */
  26497. export class MorphTargetManager {
  26498. private _targets;
  26499. private _targetInfluenceChangedObservers;
  26500. private _targetDataLayoutChangedObservers;
  26501. private _activeTargets;
  26502. private _scene;
  26503. private _influences;
  26504. private _supportsNormals;
  26505. private _supportsTangents;
  26506. private _supportsUVs;
  26507. private _vertexCount;
  26508. private _uniqueId;
  26509. private _tempInfluences;
  26510. /**
  26511. * Gets or sets a boolean indicating if normals must be morphed
  26512. */
  26513. enableNormalMorphing: boolean;
  26514. /**
  26515. * Gets or sets a boolean indicating if tangents must be morphed
  26516. */
  26517. enableTangentMorphing: boolean;
  26518. /**
  26519. * Gets or sets a boolean indicating if UV must be morphed
  26520. */
  26521. enableUVMorphing: boolean;
  26522. /**
  26523. * Creates a new MorphTargetManager
  26524. * @param scene defines the current scene
  26525. */
  26526. constructor(scene?: Nullable<Scene>);
  26527. /**
  26528. * Gets the unique ID of this manager
  26529. */
  26530. get uniqueId(): number;
  26531. /**
  26532. * Gets the number of vertices handled by this manager
  26533. */
  26534. get vertexCount(): number;
  26535. /**
  26536. * Gets a boolean indicating if this manager supports morphing of normals
  26537. */
  26538. get supportsNormals(): boolean;
  26539. /**
  26540. * Gets a boolean indicating if this manager supports morphing of tangents
  26541. */
  26542. get supportsTangents(): boolean;
  26543. /**
  26544. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26545. */
  26546. get supportsUVs(): boolean;
  26547. /**
  26548. * Gets the number of targets stored in this manager
  26549. */
  26550. get numTargets(): number;
  26551. /**
  26552. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26553. */
  26554. get numInfluencers(): number;
  26555. /**
  26556. * Gets the list of influences (one per target)
  26557. */
  26558. get influences(): Float32Array;
  26559. /**
  26560. * Gets the active target at specified index. An active target is a target with an influence > 0
  26561. * @param index defines the index to check
  26562. * @returns the requested target
  26563. */
  26564. getActiveTarget(index: number): MorphTarget;
  26565. /**
  26566. * Gets the target at specified index
  26567. * @param index defines the index to check
  26568. * @returns the requested target
  26569. */
  26570. getTarget(index: number): MorphTarget;
  26571. /**
  26572. * Add a new target to this manager
  26573. * @param target defines the target to add
  26574. */
  26575. addTarget(target: MorphTarget): void;
  26576. /**
  26577. * Removes a target from the manager
  26578. * @param target defines the target to remove
  26579. */
  26580. removeTarget(target: MorphTarget): void;
  26581. /**
  26582. * Clone the current manager
  26583. * @returns a new MorphTargetManager
  26584. */
  26585. clone(): MorphTargetManager;
  26586. /**
  26587. * Serializes the current manager into a Serialization object
  26588. * @returns the serialized object
  26589. */
  26590. serialize(): any;
  26591. private _syncActiveTargets;
  26592. /**
  26593. * Syncrhonize the targets with all the meshes using this morph target manager
  26594. */
  26595. synchronize(): void;
  26596. /**
  26597. * Creates a new MorphTargetManager from serialized data
  26598. * @param serializationObject defines the serialized data
  26599. * @param scene defines the hosting scene
  26600. * @returns the new MorphTargetManager
  26601. */
  26602. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26603. }
  26604. }
  26605. declare module BABYLON {
  26606. /**
  26607. * Class used to represent a specific level of detail of a mesh
  26608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26609. */
  26610. export class MeshLODLevel {
  26611. /** Defines the distance where this level should start being displayed */
  26612. distance: number;
  26613. /** Defines the mesh to use to render this level */
  26614. mesh: Nullable<Mesh>;
  26615. /**
  26616. * Creates a new LOD level
  26617. * @param distance defines the distance where this level should star being displayed
  26618. * @param mesh defines the mesh to use to render this level
  26619. */
  26620. constructor(
  26621. /** Defines the distance where this level should start being displayed */
  26622. distance: number,
  26623. /** Defines the mesh to use to render this level */
  26624. mesh: Nullable<Mesh>);
  26625. }
  26626. }
  26627. declare module BABYLON {
  26628. /**
  26629. * Helper class used to generate a canvas to manipulate images
  26630. */
  26631. export class CanvasGenerator {
  26632. /**
  26633. * Create a new canvas (or offscreen canvas depending on the context)
  26634. * @param width defines the expected width
  26635. * @param height defines the expected height
  26636. * @return a new canvas or offscreen canvas
  26637. */
  26638. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. /**
  26643. * Mesh representing the gorund
  26644. */
  26645. export class GroundMesh extends Mesh {
  26646. /** If octree should be generated */
  26647. generateOctree: boolean;
  26648. private _heightQuads;
  26649. /** @hidden */
  26650. _subdivisionsX: number;
  26651. /** @hidden */
  26652. _subdivisionsY: number;
  26653. /** @hidden */
  26654. _width: number;
  26655. /** @hidden */
  26656. _height: number;
  26657. /** @hidden */
  26658. _minX: number;
  26659. /** @hidden */
  26660. _maxX: number;
  26661. /** @hidden */
  26662. _minZ: number;
  26663. /** @hidden */
  26664. _maxZ: number;
  26665. constructor(name: string, scene: Scene);
  26666. /**
  26667. * "GroundMesh"
  26668. * @returns "GroundMesh"
  26669. */
  26670. getClassName(): string;
  26671. /**
  26672. * The minimum of x and y subdivisions
  26673. */
  26674. get subdivisions(): number;
  26675. /**
  26676. * X subdivisions
  26677. */
  26678. get subdivisionsX(): number;
  26679. /**
  26680. * Y subdivisions
  26681. */
  26682. get subdivisionsY(): number;
  26683. /**
  26684. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26685. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26686. * @param chunksCount the number of subdivisions for x and y
  26687. * @param octreeBlocksSize (Default: 32)
  26688. */
  26689. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26690. /**
  26691. * Returns a height (y) value in the Worl system :
  26692. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26693. * @param x x coordinate
  26694. * @param z z coordinate
  26695. * @returns the ground y position if (x, z) are outside the ground surface.
  26696. */
  26697. getHeightAtCoordinates(x: number, z: number): number;
  26698. /**
  26699. * Returns a normalized vector (Vector3) orthogonal to the ground
  26700. * at the ground coordinates (x, z) expressed in the World system.
  26701. * @param x x coordinate
  26702. * @param z z coordinate
  26703. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26704. */
  26705. getNormalAtCoordinates(x: number, z: number): Vector3;
  26706. /**
  26707. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26708. * at the ground coordinates (x, z) expressed in the World system.
  26709. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26710. * @param x x coordinate
  26711. * @param z z coordinate
  26712. * @param ref vector to store the result
  26713. * @returns the GroundMesh.
  26714. */
  26715. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26716. /**
  26717. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26718. * if the ground has been updated.
  26719. * This can be used in the render loop.
  26720. * @returns the GroundMesh.
  26721. */
  26722. updateCoordinateHeights(): GroundMesh;
  26723. private _getFacetAt;
  26724. private _initHeightQuads;
  26725. private _computeHeightQuads;
  26726. /**
  26727. * Serializes this ground mesh
  26728. * @param serializationObject object to write serialization to
  26729. */
  26730. serialize(serializationObject: any): void;
  26731. /**
  26732. * Parses a serialized ground mesh
  26733. * @param parsedMesh the serialized mesh
  26734. * @param scene the scene to create the ground mesh in
  26735. * @returns the created ground mesh
  26736. */
  26737. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26738. }
  26739. }
  26740. declare module BABYLON {
  26741. /**
  26742. * Interface for Physics-Joint data
  26743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26744. */
  26745. export interface PhysicsJointData {
  26746. /**
  26747. * The main pivot of the joint
  26748. */
  26749. mainPivot?: Vector3;
  26750. /**
  26751. * The connected pivot of the joint
  26752. */
  26753. connectedPivot?: Vector3;
  26754. /**
  26755. * The main axis of the joint
  26756. */
  26757. mainAxis?: Vector3;
  26758. /**
  26759. * The connected axis of the joint
  26760. */
  26761. connectedAxis?: Vector3;
  26762. /**
  26763. * The collision of the joint
  26764. */
  26765. collision?: boolean;
  26766. /**
  26767. * Native Oimo/Cannon/Energy data
  26768. */
  26769. nativeParams?: any;
  26770. }
  26771. /**
  26772. * This is a holder class for the physics joint created by the physics plugin
  26773. * It holds a set of functions to control the underlying joint
  26774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26775. */
  26776. export class PhysicsJoint {
  26777. /**
  26778. * The type of the physics joint
  26779. */
  26780. type: number;
  26781. /**
  26782. * The data for the physics joint
  26783. */
  26784. jointData: PhysicsJointData;
  26785. private _physicsJoint;
  26786. protected _physicsPlugin: IPhysicsEnginePlugin;
  26787. /**
  26788. * Initializes the physics joint
  26789. * @param type The type of the physics joint
  26790. * @param jointData The data for the physics joint
  26791. */
  26792. constructor(
  26793. /**
  26794. * The type of the physics joint
  26795. */
  26796. type: number,
  26797. /**
  26798. * The data for the physics joint
  26799. */
  26800. jointData: PhysicsJointData);
  26801. /**
  26802. * Gets the physics joint
  26803. */
  26804. get physicsJoint(): any;
  26805. /**
  26806. * Sets the physics joint
  26807. */
  26808. set physicsJoint(newJoint: any);
  26809. /**
  26810. * Sets the physics plugin
  26811. */
  26812. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26813. /**
  26814. * Execute a function that is physics-plugin specific.
  26815. * @param {Function} func the function that will be executed.
  26816. * It accepts two parameters: the physics world and the physics joint
  26817. */
  26818. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26819. /**
  26820. * Distance-Joint type
  26821. */
  26822. static DistanceJoint: number;
  26823. /**
  26824. * Hinge-Joint type
  26825. */
  26826. static HingeJoint: number;
  26827. /**
  26828. * Ball-and-Socket joint type
  26829. */
  26830. static BallAndSocketJoint: number;
  26831. /**
  26832. * Wheel-Joint type
  26833. */
  26834. static WheelJoint: number;
  26835. /**
  26836. * Slider-Joint type
  26837. */
  26838. static SliderJoint: number;
  26839. /**
  26840. * Prismatic-Joint type
  26841. */
  26842. static PrismaticJoint: number;
  26843. /**
  26844. * Universal-Joint type
  26845. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26846. */
  26847. static UniversalJoint: number;
  26848. /**
  26849. * Hinge-Joint 2 type
  26850. */
  26851. static Hinge2Joint: number;
  26852. /**
  26853. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26854. */
  26855. static PointToPointJoint: number;
  26856. /**
  26857. * Spring-Joint type
  26858. */
  26859. static SpringJoint: number;
  26860. /**
  26861. * Lock-Joint type
  26862. */
  26863. static LockJoint: number;
  26864. }
  26865. /**
  26866. * A class representing a physics distance joint
  26867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26868. */
  26869. export class DistanceJoint extends PhysicsJoint {
  26870. /**
  26871. *
  26872. * @param jointData The data for the Distance-Joint
  26873. */
  26874. constructor(jointData: DistanceJointData);
  26875. /**
  26876. * Update the predefined distance.
  26877. * @param maxDistance The maximum preferred distance
  26878. * @param minDistance The minimum preferred distance
  26879. */
  26880. updateDistance(maxDistance: number, minDistance?: number): void;
  26881. }
  26882. /**
  26883. * Represents a Motor-Enabled Joint
  26884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26885. */
  26886. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26887. /**
  26888. * Initializes the Motor-Enabled Joint
  26889. * @param type The type of the joint
  26890. * @param jointData The physica joint data for the joint
  26891. */
  26892. constructor(type: number, jointData: PhysicsJointData);
  26893. /**
  26894. * Set the motor values.
  26895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26896. * @param force the force to apply
  26897. * @param maxForce max force for this motor.
  26898. */
  26899. setMotor(force?: number, maxForce?: number): void;
  26900. /**
  26901. * Set the motor's limits.
  26902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26903. * @param upperLimit The upper limit of the motor
  26904. * @param lowerLimit The lower limit of the motor
  26905. */
  26906. setLimit(upperLimit: number, lowerLimit?: number): void;
  26907. }
  26908. /**
  26909. * This class represents a single physics Hinge-Joint
  26910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26911. */
  26912. export class HingeJoint extends MotorEnabledJoint {
  26913. /**
  26914. * Initializes the Hinge-Joint
  26915. * @param jointData The joint data for the Hinge-Joint
  26916. */
  26917. constructor(jointData: PhysicsJointData);
  26918. /**
  26919. * Set the motor values.
  26920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26921. * @param {number} force the force to apply
  26922. * @param {number} maxForce max force for this motor.
  26923. */
  26924. setMotor(force?: number, maxForce?: number): void;
  26925. /**
  26926. * Set the motor's limits.
  26927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26928. * @param upperLimit The upper limit of the motor
  26929. * @param lowerLimit The lower limit of the motor
  26930. */
  26931. setLimit(upperLimit: number, lowerLimit?: number): void;
  26932. }
  26933. /**
  26934. * This class represents a dual hinge physics joint (same as wheel joint)
  26935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26936. */
  26937. export class Hinge2Joint extends MotorEnabledJoint {
  26938. /**
  26939. * Initializes the Hinge2-Joint
  26940. * @param jointData The joint data for the Hinge2-Joint
  26941. */
  26942. constructor(jointData: PhysicsJointData);
  26943. /**
  26944. * Set the motor values.
  26945. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26946. * @param {number} targetSpeed the speed the motor is to reach
  26947. * @param {number} maxForce max force for this motor.
  26948. * @param {motorIndex} the motor's index, 0 or 1.
  26949. */
  26950. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26951. /**
  26952. * Set the motor limits.
  26953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26954. * @param {number} upperLimit the upper limit
  26955. * @param {number} lowerLimit lower limit
  26956. * @param {motorIndex} the motor's index, 0 or 1.
  26957. */
  26958. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26959. }
  26960. /**
  26961. * Interface for a motor enabled joint
  26962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26963. */
  26964. export interface IMotorEnabledJoint {
  26965. /**
  26966. * Physics joint
  26967. */
  26968. physicsJoint: any;
  26969. /**
  26970. * Sets the motor of the motor-enabled joint
  26971. * @param force The force of the motor
  26972. * @param maxForce The maximum force of the motor
  26973. * @param motorIndex The index of the motor
  26974. */
  26975. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26976. /**
  26977. * Sets the limit of the motor
  26978. * @param upperLimit The upper limit of the motor
  26979. * @param lowerLimit The lower limit of the motor
  26980. * @param motorIndex The index of the motor
  26981. */
  26982. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26983. }
  26984. /**
  26985. * Joint data for a Distance-Joint
  26986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26987. */
  26988. export interface DistanceJointData extends PhysicsJointData {
  26989. /**
  26990. * Max distance the 2 joint objects can be apart
  26991. */
  26992. maxDistance: number;
  26993. }
  26994. /**
  26995. * Joint data from a spring joint
  26996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26997. */
  26998. export interface SpringJointData extends PhysicsJointData {
  26999. /**
  27000. * Length of the spring
  27001. */
  27002. length: number;
  27003. /**
  27004. * Stiffness of the spring
  27005. */
  27006. stiffness: number;
  27007. /**
  27008. * Damping of the spring
  27009. */
  27010. damping: number;
  27011. /** this callback will be called when applying the force to the impostors. */
  27012. forceApplicationCallback: () => void;
  27013. }
  27014. }
  27015. declare module BABYLON {
  27016. /**
  27017. * Holds the data for the raycast result
  27018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27019. */
  27020. export class PhysicsRaycastResult {
  27021. private _hasHit;
  27022. private _hitDistance;
  27023. private _hitNormalWorld;
  27024. private _hitPointWorld;
  27025. private _rayFromWorld;
  27026. private _rayToWorld;
  27027. /**
  27028. * Gets if there was a hit
  27029. */
  27030. get hasHit(): boolean;
  27031. /**
  27032. * Gets the distance from the hit
  27033. */
  27034. get hitDistance(): number;
  27035. /**
  27036. * Gets the hit normal/direction in the world
  27037. */
  27038. get hitNormalWorld(): Vector3;
  27039. /**
  27040. * Gets the hit point in the world
  27041. */
  27042. get hitPointWorld(): Vector3;
  27043. /**
  27044. * Gets the ray "start point" of the ray in the world
  27045. */
  27046. get rayFromWorld(): Vector3;
  27047. /**
  27048. * Gets the ray "end point" of the ray in the world
  27049. */
  27050. get rayToWorld(): Vector3;
  27051. /**
  27052. * Sets the hit data (normal & point in world space)
  27053. * @param hitNormalWorld defines the normal in world space
  27054. * @param hitPointWorld defines the point in world space
  27055. */
  27056. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27057. /**
  27058. * Sets the distance from the start point to the hit point
  27059. * @param distance
  27060. */
  27061. setHitDistance(distance: number): void;
  27062. /**
  27063. * Calculates the distance manually
  27064. */
  27065. calculateHitDistance(): void;
  27066. /**
  27067. * Resets all the values to default
  27068. * @param from The from point on world space
  27069. * @param to The to point on world space
  27070. */
  27071. reset(from?: Vector3, to?: Vector3): void;
  27072. }
  27073. /**
  27074. * Interface for the size containing width and height
  27075. */
  27076. interface IXYZ {
  27077. /**
  27078. * X
  27079. */
  27080. x: number;
  27081. /**
  27082. * Y
  27083. */
  27084. y: number;
  27085. /**
  27086. * Z
  27087. */
  27088. z: number;
  27089. }
  27090. }
  27091. declare module BABYLON {
  27092. /**
  27093. * Interface used to describe a physics joint
  27094. */
  27095. export interface PhysicsImpostorJoint {
  27096. /** Defines the main impostor to which the joint is linked */
  27097. mainImpostor: PhysicsImpostor;
  27098. /** Defines the impostor that is connected to the main impostor using this joint */
  27099. connectedImpostor: PhysicsImpostor;
  27100. /** Defines the joint itself */
  27101. joint: PhysicsJoint;
  27102. }
  27103. /** @hidden */
  27104. export interface IPhysicsEnginePlugin {
  27105. world: any;
  27106. name: string;
  27107. setGravity(gravity: Vector3): void;
  27108. setTimeStep(timeStep: number): void;
  27109. getTimeStep(): number;
  27110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27114. removePhysicsBody(impostor: PhysicsImpostor): void;
  27115. generateJoint(joint: PhysicsImpostorJoint): void;
  27116. removeJoint(joint: PhysicsImpostorJoint): void;
  27117. isSupported(): boolean;
  27118. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27119. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27120. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27121. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27122. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27123. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27124. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27125. getBodyMass(impostor: PhysicsImpostor): number;
  27126. getBodyFriction(impostor: PhysicsImpostor): number;
  27127. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27128. getBodyRestitution(impostor: PhysicsImpostor): number;
  27129. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27130. getBodyPressure?(impostor: PhysicsImpostor): number;
  27131. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27132. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27133. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27134. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27135. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27136. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27137. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27138. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27139. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27140. sleepBody(impostor: PhysicsImpostor): void;
  27141. wakeUpBody(impostor: PhysicsImpostor): void;
  27142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27144. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27146. getRadius(impostor: PhysicsImpostor): number;
  27147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27149. dispose(): void;
  27150. }
  27151. /**
  27152. * Interface used to define a physics engine
  27153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27154. */
  27155. export interface IPhysicsEngine {
  27156. /**
  27157. * Gets the gravity vector used by the simulation
  27158. */
  27159. gravity: Vector3;
  27160. /**
  27161. * Sets the gravity vector used by the simulation
  27162. * @param gravity defines the gravity vector to use
  27163. */
  27164. setGravity(gravity: Vector3): void;
  27165. /**
  27166. * Set the time step of the physics engine.
  27167. * Default is 1/60.
  27168. * To slow it down, enter 1/600 for example.
  27169. * To speed it up, 1/30
  27170. * @param newTimeStep the new timestep to apply to this world.
  27171. */
  27172. setTimeStep(newTimeStep: number): void;
  27173. /**
  27174. * Get the time step of the physics engine.
  27175. * @returns the current time step
  27176. */
  27177. getTimeStep(): number;
  27178. /**
  27179. * Set the sub time step of the physics engine.
  27180. * Default is 0 meaning there is no sub steps
  27181. * To increase physics resolution precision, set a small value (like 1 ms)
  27182. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27183. */
  27184. setSubTimeStep(subTimeStep: number): void;
  27185. /**
  27186. * Get the sub time step of the physics engine.
  27187. * @returns the current sub time step
  27188. */
  27189. getSubTimeStep(): number;
  27190. /**
  27191. * Release all resources
  27192. */
  27193. dispose(): void;
  27194. /**
  27195. * Gets the name of the current physics plugin
  27196. * @returns the name of the plugin
  27197. */
  27198. getPhysicsPluginName(): string;
  27199. /**
  27200. * Adding a new impostor for the impostor tracking.
  27201. * This will be done by the impostor itself.
  27202. * @param impostor the impostor to add
  27203. */
  27204. addImpostor(impostor: PhysicsImpostor): void;
  27205. /**
  27206. * Remove an impostor from the engine.
  27207. * This impostor and its mesh will not longer be updated by the physics engine.
  27208. * @param impostor the impostor to remove
  27209. */
  27210. removeImpostor(impostor: PhysicsImpostor): void;
  27211. /**
  27212. * Add a joint to the physics engine
  27213. * @param mainImpostor defines the main impostor to which the joint is added.
  27214. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27215. * @param joint defines the joint that will connect both impostors.
  27216. */
  27217. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27218. /**
  27219. * Removes a joint from the simulation
  27220. * @param mainImpostor defines the impostor used with the joint
  27221. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27222. * @param joint defines the joint to remove
  27223. */
  27224. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27225. /**
  27226. * Gets the current plugin used to run the simulation
  27227. * @returns current plugin
  27228. */
  27229. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27230. /**
  27231. * Gets the list of physic impostors
  27232. * @returns an array of PhysicsImpostor
  27233. */
  27234. getImpostors(): Array<PhysicsImpostor>;
  27235. /**
  27236. * Gets the impostor for a physics enabled object
  27237. * @param object defines the object impersonated by the impostor
  27238. * @returns the PhysicsImpostor or null if not found
  27239. */
  27240. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27241. /**
  27242. * Gets the impostor for a physics body object
  27243. * @param body defines physics body used by the impostor
  27244. * @returns the PhysicsImpostor or null if not found
  27245. */
  27246. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27247. /**
  27248. * Does a raycast in the physics world
  27249. * @param from when should the ray start?
  27250. * @param to when should the ray end?
  27251. * @returns PhysicsRaycastResult
  27252. */
  27253. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27254. /**
  27255. * Called by the scene. No need to call it.
  27256. * @param delta defines the timespam between frames
  27257. */
  27258. _step(delta: number): void;
  27259. }
  27260. }
  27261. declare module BABYLON {
  27262. /**
  27263. * The interface for the physics imposter parameters
  27264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27265. */
  27266. export interface PhysicsImpostorParameters {
  27267. /**
  27268. * The mass of the physics imposter
  27269. */
  27270. mass: number;
  27271. /**
  27272. * The friction of the physics imposter
  27273. */
  27274. friction?: number;
  27275. /**
  27276. * The coefficient of restitution of the physics imposter
  27277. */
  27278. restitution?: number;
  27279. /**
  27280. * The native options of the physics imposter
  27281. */
  27282. nativeOptions?: any;
  27283. /**
  27284. * Specifies if the parent should be ignored
  27285. */
  27286. ignoreParent?: boolean;
  27287. /**
  27288. * Specifies if bi-directional transformations should be disabled
  27289. */
  27290. disableBidirectionalTransformation?: boolean;
  27291. /**
  27292. * The pressure inside the physics imposter, soft object only
  27293. */
  27294. pressure?: number;
  27295. /**
  27296. * The stiffness the physics imposter, soft object only
  27297. */
  27298. stiffness?: number;
  27299. /**
  27300. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27301. */
  27302. velocityIterations?: number;
  27303. /**
  27304. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27305. */
  27306. positionIterations?: number;
  27307. /**
  27308. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27309. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27310. * Add to fix multiple points
  27311. */
  27312. fixedPoints?: number;
  27313. /**
  27314. * The collision margin around a soft object
  27315. */
  27316. margin?: number;
  27317. /**
  27318. * The collision margin around a soft object
  27319. */
  27320. damping?: number;
  27321. /**
  27322. * The path for a rope based on an extrusion
  27323. */
  27324. path?: any;
  27325. /**
  27326. * The shape of an extrusion used for a rope based on an extrusion
  27327. */
  27328. shape?: any;
  27329. }
  27330. /**
  27331. * Interface for a physics-enabled object
  27332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27333. */
  27334. export interface IPhysicsEnabledObject {
  27335. /**
  27336. * The position of the physics-enabled object
  27337. */
  27338. position: Vector3;
  27339. /**
  27340. * The rotation of the physics-enabled object
  27341. */
  27342. rotationQuaternion: Nullable<Quaternion>;
  27343. /**
  27344. * The scale of the physics-enabled object
  27345. */
  27346. scaling: Vector3;
  27347. /**
  27348. * The rotation of the physics-enabled object
  27349. */
  27350. rotation?: Vector3;
  27351. /**
  27352. * The parent of the physics-enabled object
  27353. */
  27354. parent?: any;
  27355. /**
  27356. * The bounding info of the physics-enabled object
  27357. * @returns The bounding info of the physics-enabled object
  27358. */
  27359. getBoundingInfo(): BoundingInfo;
  27360. /**
  27361. * Computes the world matrix
  27362. * @param force Specifies if the world matrix should be computed by force
  27363. * @returns A world matrix
  27364. */
  27365. computeWorldMatrix(force: boolean): Matrix;
  27366. /**
  27367. * Gets the world matrix
  27368. * @returns A world matrix
  27369. */
  27370. getWorldMatrix?(): Matrix;
  27371. /**
  27372. * Gets the child meshes
  27373. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27374. * @returns An array of abstract meshes
  27375. */
  27376. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27377. /**
  27378. * Gets the vertex data
  27379. * @param kind The type of vertex data
  27380. * @returns A nullable array of numbers, or a float32 array
  27381. */
  27382. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27383. /**
  27384. * Gets the indices from the mesh
  27385. * @returns A nullable array of index arrays
  27386. */
  27387. getIndices?(): Nullable<IndicesArray>;
  27388. /**
  27389. * Gets the scene from the mesh
  27390. * @returns the indices array or null
  27391. */
  27392. getScene?(): Scene;
  27393. /**
  27394. * Gets the absolute position from the mesh
  27395. * @returns the absolute position
  27396. */
  27397. getAbsolutePosition(): Vector3;
  27398. /**
  27399. * Gets the absolute pivot point from the mesh
  27400. * @returns the absolute pivot point
  27401. */
  27402. getAbsolutePivotPoint(): Vector3;
  27403. /**
  27404. * Rotates the mesh
  27405. * @param axis The axis of rotation
  27406. * @param amount The amount of rotation
  27407. * @param space The space of the rotation
  27408. * @returns The rotation transform node
  27409. */
  27410. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27411. /**
  27412. * Translates the mesh
  27413. * @param axis The axis of translation
  27414. * @param distance The distance of translation
  27415. * @param space The space of the translation
  27416. * @returns The transform node
  27417. */
  27418. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27419. /**
  27420. * Sets the absolute position of the mesh
  27421. * @param absolutePosition The absolute position of the mesh
  27422. * @returns The transform node
  27423. */
  27424. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27425. /**
  27426. * Gets the class name of the mesh
  27427. * @returns The class name
  27428. */
  27429. getClassName(): string;
  27430. }
  27431. /**
  27432. * Represents a physics imposter
  27433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27434. */
  27435. export class PhysicsImpostor {
  27436. /**
  27437. * The physics-enabled object used as the physics imposter
  27438. */
  27439. object: IPhysicsEnabledObject;
  27440. /**
  27441. * The type of the physics imposter
  27442. */
  27443. type: number;
  27444. private _options;
  27445. private _scene?;
  27446. /**
  27447. * The default object size of the imposter
  27448. */
  27449. static DEFAULT_OBJECT_SIZE: Vector3;
  27450. /**
  27451. * The identity quaternion of the imposter
  27452. */
  27453. static IDENTITY_QUATERNION: Quaternion;
  27454. /** @hidden */
  27455. _pluginData: any;
  27456. private _physicsEngine;
  27457. private _physicsBody;
  27458. private _bodyUpdateRequired;
  27459. private _onBeforePhysicsStepCallbacks;
  27460. private _onAfterPhysicsStepCallbacks;
  27461. /** @hidden */
  27462. _onPhysicsCollideCallbacks: Array<{
  27463. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27464. otherImpostors: Array<PhysicsImpostor>;
  27465. }>;
  27466. private _deltaPosition;
  27467. private _deltaRotation;
  27468. private _deltaRotationConjugated;
  27469. /** @hidden */
  27470. _isFromLine: boolean;
  27471. private _parent;
  27472. private _isDisposed;
  27473. private static _tmpVecs;
  27474. private static _tmpQuat;
  27475. /**
  27476. * Specifies if the physics imposter is disposed
  27477. */
  27478. get isDisposed(): boolean;
  27479. /**
  27480. * Gets the mass of the physics imposter
  27481. */
  27482. get mass(): number;
  27483. set mass(value: number);
  27484. /**
  27485. * Gets the coefficient of friction
  27486. */
  27487. get friction(): number;
  27488. /**
  27489. * Sets the coefficient of friction
  27490. */
  27491. set friction(value: number);
  27492. /**
  27493. * Gets the coefficient of restitution
  27494. */
  27495. get restitution(): number;
  27496. /**
  27497. * Sets the coefficient of restitution
  27498. */
  27499. set restitution(value: number);
  27500. /**
  27501. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27502. */
  27503. get pressure(): number;
  27504. /**
  27505. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27506. */
  27507. set pressure(value: number);
  27508. /**
  27509. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27510. */
  27511. get stiffness(): number;
  27512. /**
  27513. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27514. */
  27515. set stiffness(value: number);
  27516. /**
  27517. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27518. */
  27519. get velocityIterations(): number;
  27520. /**
  27521. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27522. */
  27523. set velocityIterations(value: number);
  27524. /**
  27525. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27526. */
  27527. get positionIterations(): number;
  27528. /**
  27529. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27530. */
  27531. set positionIterations(value: number);
  27532. /**
  27533. * The unique id of the physics imposter
  27534. * set by the physics engine when adding this impostor to the array
  27535. */
  27536. uniqueId: number;
  27537. /**
  27538. * @hidden
  27539. */
  27540. soft: boolean;
  27541. /**
  27542. * @hidden
  27543. */
  27544. segments: number;
  27545. private _joints;
  27546. /**
  27547. * Initializes the physics imposter
  27548. * @param object The physics-enabled object used as the physics imposter
  27549. * @param type The type of the physics imposter
  27550. * @param _options The options for the physics imposter
  27551. * @param _scene The Babylon scene
  27552. */
  27553. constructor(
  27554. /**
  27555. * The physics-enabled object used as the physics imposter
  27556. */
  27557. object: IPhysicsEnabledObject,
  27558. /**
  27559. * The type of the physics imposter
  27560. */
  27561. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27562. /**
  27563. * This function will completly initialize this impostor.
  27564. * It will create a new body - but only if this mesh has no parent.
  27565. * If it has, this impostor will not be used other than to define the impostor
  27566. * of the child mesh.
  27567. * @hidden
  27568. */
  27569. _init(): void;
  27570. private _getPhysicsParent;
  27571. /**
  27572. * Should a new body be generated.
  27573. * @returns boolean specifying if body initialization is required
  27574. */
  27575. isBodyInitRequired(): boolean;
  27576. /**
  27577. * Sets the updated scaling
  27578. * @param updated Specifies if the scaling is updated
  27579. */
  27580. setScalingUpdated(): void;
  27581. /**
  27582. * Force a regeneration of this or the parent's impostor's body.
  27583. * Use under cautious - This will remove all joints already implemented.
  27584. */
  27585. forceUpdate(): void;
  27586. /**
  27587. * Gets the body that holds this impostor. Either its own, or its parent.
  27588. */
  27589. get physicsBody(): any;
  27590. /**
  27591. * Get the parent of the physics imposter
  27592. * @returns Physics imposter or null
  27593. */
  27594. get parent(): Nullable<PhysicsImpostor>;
  27595. /**
  27596. * Sets the parent of the physics imposter
  27597. */
  27598. set parent(value: Nullable<PhysicsImpostor>);
  27599. /**
  27600. * Set the physics body. Used mainly by the physics engine/plugin
  27601. */
  27602. set physicsBody(physicsBody: any);
  27603. /**
  27604. * Resets the update flags
  27605. */
  27606. resetUpdateFlags(): void;
  27607. /**
  27608. * Gets the object extend size
  27609. * @returns the object extend size
  27610. */
  27611. getObjectExtendSize(): Vector3;
  27612. /**
  27613. * Gets the object center
  27614. * @returns The object center
  27615. */
  27616. getObjectCenter(): Vector3;
  27617. /**
  27618. * Get a specific parameter from the options parameters
  27619. * @param paramName The object parameter name
  27620. * @returns The object parameter
  27621. */
  27622. getParam(paramName: string): any;
  27623. /**
  27624. * Sets a specific parameter in the options given to the physics plugin
  27625. * @param paramName The parameter name
  27626. * @param value The value of the parameter
  27627. */
  27628. setParam(paramName: string, value: number): void;
  27629. /**
  27630. * Specifically change the body's mass option. Won't recreate the physics body object
  27631. * @param mass The mass of the physics imposter
  27632. */
  27633. setMass(mass: number): void;
  27634. /**
  27635. * Gets the linear velocity
  27636. * @returns linear velocity or null
  27637. */
  27638. getLinearVelocity(): Nullable<Vector3>;
  27639. /**
  27640. * Sets the linear velocity
  27641. * @param velocity linear velocity or null
  27642. */
  27643. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27644. /**
  27645. * Gets the angular velocity
  27646. * @returns angular velocity or null
  27647. */
  27648. getAngularVelocity(): Nullable<Vector3>;
  27649. /**
  27650. * Sets the angular velocity
  27651. * @param velocity The velocity or null
  27652. */
  27653. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27654. /**
  27655. * Execute a function with the physics plugin native code
  27656. * Provide a function the will have two variables - the world object and the physics body object
  27657. * @param func The function to execute with the physics plugin native code
  27658. */
  27659. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27660. /**
  27661. * Register a function that will be executed before the physics world is stepping forward
  27662. * @param func The function to execute before the physics world is stepped forward
  27663. */
  27664. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27665. /**
  27666. * Unregister a function that will be executed before the physics world is stepping forward
  27667. * @param func The function to execute before the physics world is stepped forward
  27668. */
  27669. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27670. /**
  27671. * Register a function that will be executed after the physics step
  27672. * @param func The function to execute after physics step
  27673. */
  27674. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27675. /**
  27676. * Unregisters a function that will be executed after the physics step
  27677. * @param func The function to execute after physics step
  27678. */
  27679. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27680. /**
  27681. * register a function that will be executed when this impostor collides against a different body
  27682. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27683. * @param func Callback that is executed on collision
  27684. */
  27685. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27686. /**
  27687. * Unregisters the physics imposter on contact
  27688. * @param collideAgainst The physics object to collide against
  27689. * @param func Callback to execute on collision
  27690. */
  27691. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27692. private _tmpQuat;
  27693. private _tmpQuat2;
  27694. /**
  27695. * Get the parent rotation
  27696. * @returns The parent rotation
  27697. */
  27698. getParentsRotation(): Quaternion;
  27699. /**
  27700. * this function is executed by the physics engine.
  27701. */
  27702. beforeStep: () => void;
  27703. /**
  27704. * this function is executed by the physics engine
  27705. */
  27706. afterStep: () => void;
  27707. /**
  27708. * Legacy collision detection event support
  27709. */
  27710. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27711. /**
  27712. * event and body object due to cannon's event-based architecture.
  27713. */
  27714. onCollide: (e: {
  27715. body: any;
  27716. }) => void;
  27717. /**
  27718. * Apply a force
  27719. * @param force The force to apply
  27720. * @param contactPoint The contact point for the force
  27721. * @returns The physics imposter
  27722. */
  27723. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27724. /**
  27725. * Apply an impulse
  27726. * @param force The impulse force
  27727. * @param contactPoint The contact point for the impulse force
  27728. * @returns The physics imposter
  27729. */
  27730. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27731. /**
  27732. * A help function to create a joint
  27733. * @param otherImpostor A physics imposter used to create a joint
  27734. * @param jointType The type of joint
  27735. * @param jointData The data for the joint
  27736. * @returns The physics imposter
  27737. */
  27738. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27739. /**
  27740. * Add a joint to this impostor with a different impostor
  27741. * @param otherImpostor A physics imposter used to add a joint
  27742. * @param joint The joint to add
  27743. * @returns The physics imposter
  27744. */
  27745. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27746. /**
  27747. * Add an anchor to a cloth impostor
  27748. * @param otherImpostor rigid impostor to anchor to
  27749. * @param width ratio across width from 0 to 1
  27750. * @param height ratio up height from 0 to 1
  27751. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27752. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27753. * @returns impostor the soft imposter
  27754. */
  27755. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27756. /**
  27757. * Add a hook to a rope impostor
  27758. * @param otherImpostor rigid impostor to anchor to
  27759. * @param length ratio across rope from 0 to 1
  27760. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27761. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27762. * @returns impostor the rope imposter
  27763. */
  27764. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27765. /**
  27766. * Will keep this body still, in a sleep mode.
  27767. * @returns the physics imposter
  27768. */
  27769. sleep(): PhysicsImpostor;
  27770. /**
  27771. * Wake the body up.
  27772. * @returns The physics imposter
  27773. */
  27774. wakeUp(): PhysicsImpostor;
  27775. /**
  27776. * Clones the physics imposter
  27777. * @param newObject The physics imposter clones to this physics-enabled object
  27778. * @returns A nullable physics imposter
  27779. */
  27780. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27781. /**
  27782. * Disposes the physics imposter
  27783. */
  27784. dispose(): void;
  27785. /**
  27786. * Sets the delta position
  27787. * @param position The delta position amount
  27788. */
  27789. setDeltaPosition(position: Vector3): void;
  27790. /**
  27791. * Sets the delta rotation
  27792. * @param rotation The delta rotation amount
  27793. */
  27794. setDeltaRotation(rotation: Quaternion): void;
  27795. /**
  27796. * Gets the box size of the physics imposter and stores the result in the input parameter
  27797. * @param result Stores the box size
  27798. * @returns The physics imposter
  27799. */
  27800. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27801. /**
  27802. * Gets the radius of the physics imposter
  27803. * @returns Radius of the physics imposter
  27804. */
  27805. getRadius(): number;
  27806. /**
  27807. * Sync a bone with this impostor
  27808. * @param bone The bone to sync to the impostor.
  27809. * @param boneMesh The mesh that the bone is influencing.
  27810. * @param jointPivot The pivot of the joint / bone in local space.
  27811. * @param distToJoint Optional distance from the impostor to the joint.
  27812. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27813. */
  27814. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27815. /**
  27816. * Sync impostor to a bone
  27817. * @param bone The bone that the impostor will be synced to.
  27818. * @param boneMesh The mesh that the bone is influencing.
  27819. * @param jointPivot The pivot of the joint / bone in local space.
  27820. * @param distToJoint Optional distance from the impostor to the joint.
  27821. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27822. * @param boneAxis Optional vector3 axis the bone is aligned with
  27823. */
  27824. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27825. /**
  27826. * No-Imposter type
  27827. */
  27828. static NoImpostor: number;
  27829. /**
  27830. * Sphere-Imposter type
  27831. */
  27832. static SphereImpostor: number;
  27833. /**
  27834. * Box-Imposter type
  27835. */
  27836. static BoxImpostor: number;
  27837. /**
  27838. * Plane-Imposter type
  27839. */
  27840. static PlaneImpostor: number;
  27841. /**
  27842. * Mesh-imposter type
  27843. */
  27844. static MeshImpostor: number;
  27845. /**
  27846. * Capsule-Impostor type (Ammo.js plugin only)
  27847. */
  27848. static CapsuleImpostor: number;
  27849. /**
  27850. * Cylinder-Imposter type
  27851. */
  27852. static CylinderImpostor: number;
  27853. /**
  27854. * Particle-Imposter type
  27855. */
  27856. static ParticleImpostor: number;
  27857. /**
  27858. * Heightmap-Imposter type
  27859. */
  27860. static HeightmapImpostor: number;
  27861. /**
  27862. * ConvexHull-Impostor type (Ammo.js plugin only)
  27863. */
  27864. static ConvexHullImpostor: number;
  27865. /**
  27866. * Custom-Imposter type (Ammo.js plugin only)
  27867. */
  27868. static CustomImpostor: number;
  27869. /**
  27870. * Rope-Imposter type
  27871. */
  27872. static RopeImpostor: number;
  27873. /**
  27874. * Cloth-Imposter type
  27875. */
  27876. static ClothImpostor: number;
  27877. /**
  27878. * Softbody-Imposter type
  27879. */
  27880. static SoftbodyImpostor: number;
  27881. }
  27882. }
  27883. declare module BABYLON {
  27884. /**
  27885. * @hidden
  27886. **/
  27887. export class _CreationDataStorage {
  27888. closePath?: boolean;
  27889. closeArray?: boolean;
  27890. idx: number[];
  27891. dashSize: number;
  27892. gapSize: number;
  27893. path3D: Path3D;
  27894. pathArray: Vector3[][];
  27895. arc: number;
  27896. radius: number;
  27897. cap: number;
  27898. tessellation: number;
  27899. }
  27900. /**
  27901. * @hidden
  27902. **/
  27903. class _InstanceDataStorage {
  27904. visibleInstances: any;
  27905. batchCache: _InstancesBatch;
  27906. instancesBufferSize: number;
  27907. instancesBuffer: Nullable<Buffer>;
  27908. instancesData: Float32Array;
  27909. overridenInstanceCount: number;
  27910. isFrozen: boolean;
  27911. previousBatch: Nullable<_InstancesBatch>;
  27912. hardwareInstancedRendering: boolean;
  27913. sideOrientation: number;
  27914. manualUpdate: boolean;
  27915. }
  27916. /**
  27917. * @hidden
  27918. **/
  27919. export class _InstancesBatch {
  27920. mustReturn: boolean;
  27921. visibleInstances: Nullable<InstancedMesh[]>[];
  27922. renderSelf: boolean[];
  27923. hardwareInstancedRendering: boolean[];
  27924. }
  27925. /**
  27926. * @hidden
  27927. **/
  27928. class _ThinInstanceDataStorage {
  27929. instancesCount: number;
  27930. matrixBuffer: Nullable<Buffer>;
  27931. matrixBufferSize: number;
  27932. matrixData: Nullable<Float32Array>;
  27933. boundingVectors: Array<Vector3>;
  27934. }
  27935. /**
  27936. * Class used to represent renderable models
  27937. */
  27938. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27939. /**
  27940. * Mesh side orientation : usually the external or front surface
  27941. */
  27942. static readonly FRONTSIDE: number;
  27943. /**
  27944. * Mesh side orientation : usually the internal or back surface
  27945. */
  27946. static readonly BACKSIDE: number;
  27947. /**
  27948. * Mesh side orientation : both internal and external or front and back surfaces
  27949. */
  27950. static readonly DOUBLESIDE: number;
  27951. /**
  27952. * Mesh side orientation : by default, `FRONTSIDE`
  27953. */
  27954. static readonly DEFAULTSIDE: number;
  27955. /**
  27956. * Mesh cap setting : no cap
  27957. */
  27958. static readonly NO_CAP: number;
  27959. /**
  27960. * Mesh cap setting : one cap at the beginning of the mesh
  27961. */
  27962. static readonly CAP_START: number;
  27963. /**
  27964. * Mesh cap setting : one cap at the end of the mesh
  27965. */
  27966. static readonly CAP_END: number;
  27967. /**
  27968. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27969. */
  27970. static readonly CAP_ALL: number;
  27971. /**
  27972. * Mesh pattern setting : no flip or rotate
  27973. */
  27974. static readonly NO_FLIP: number;
  27975. /**
  27976. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27977. */
  27978. static readonly FLIP_TILE: number;
  27979. /**
  27980. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27981. */
  27982. static readonly ROTATE_TILE: number;
  27983. /**
  27984. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27985. */
  27986. static readonly FLIP_ROW: number;
  27987. /**
  27988. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27989. */
  27990. static readonly ROTATE_ROW: number;
  27991. /**
  27992. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27993. */
  27994. static readonly FLIP_N_ROTATE_TILE: number;
  27995. /**
  27996. * Mesh pattern setting : rotate pattern and rotate
  27997. */
  27998. static readonly FLIP_N_ROTATE_ROW: number;
  27999. /**
  28000. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28001. */
  28002. static readonly CENTER: number;
  28003. /**
  28004. * Mesh tile positioning : part tiles on left
  28005. */
  28006. static readonly LEFT: number;
  28007. /**
  28008. * Mesh tile positioning : part tiles on right
  28009. */
  28010. static readonly RIGHT: number;
  28011. /**
  28012. * Mesh tile positioning : part tiles on top
  28013. */
  28014. static readonly TOP: number;
  28015. /**
  28016. * Mesh tile positioning : part tiles on bottom
  28017. */
  28018. static readonly BOTTOM: number;
  28019. /**
  28020. * Gets the default side orientation.
  28021. * @param orientation the orientation to value to attempt to get
  28022. * @returns the default orientation
  28023. * @hidden
  28024. */
  28025. static _GetDefaultSideOrientation(orientation?: number): number;
  28026. private _internalMeshDataInfo;
  28027. get computeBonesUsingShaders(): boolean;
  28028. set computeBonesUsingShaders(value: boolean);
  28029. /**
  28030. * An event triggered before rendering the mesh
  28031. */
  28032. get onBeforeRenderObservable(): Observable<Mesh>;
  28033. /**
  28034. * An event triggered before binding the mesh
  28035. */
  28036. get onBeforeBindObservable(): Observable<Mesh>;
  28037. /**
  28038. * An event triggered after rendering the mesh
  28039. */
  28040. get onAfterRenderObservable(): Observable<Mesh>;
  28041. /**
  28042. * An event triggered before drawing the mesh
  28043. */
  28044. get onBeforeDrawObservable(): Observable<Mesh>;
  28045. private _onBeforeDrawObserver;
  28046. /**
  28047. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28048. */
  28049. set onBeforeDraw(callback: () => void);
  28050. get hasInstances(): boolean;
  28051. get hasThinInstances(): boolean;
  28052. /**
  28053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28054. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28055. */
  28056. delayLoadState: number;
  28057. /**
  28058. * Gets the list of instances created from this mesh
  28059. * it is not supposed to be modified manually.
  28060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28062. */
  28063. instances: InstancedMesh[];
  28064. /**
  28065. * Gets the file containing delay loading data for this mesh
  28066. */
  28067. delayLoadingFile: string;
  28068. /** @hidden */
  28069. _binaryInfo: any;
  28070. /**
  28071. * User defined function used to change how LOD level selection is done
  28072. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28073. */
  28074. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28075. /**
  28076. * Gets or sets the morph target manager
  28077. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28078. */
  28079. get morphTargetManager(): Nullable<MorphTargetManager>;
  28080. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28081. /** @hidden */
  28082. _creationDataStorage: Nullable<_CreationDataStorage>;
  28083. /** @hidden */
  28084. _geometry: Nullable<Geometry>;
  28085. /** @hidden */
  28086. _delayInfo: Array<string>;
  28087. /** @hidden */
  28088. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28089. /** @hidden */
  28090. _instanceDataStorage: _InstanceDataStorage;
  28091. /** @hidden */
  28092. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28093. private _effectiveMaterial;
  28094. /** @hidden */
  28095. _shouldGenerateFlatShading: boolean;
  28096. /** @hidden */
  28097. _originalBuilderSideOrientation: number;
  28098. /**
  28099. * Use this property to change the original side orientation defined at construction time
  28100. */
  28101. overrideMaterialSideOrientation: Nullable<number>;
  28102. /**
  28103. * Gets the source mesh (the one used to clone this one from)
  28104. */
  28105. get source(): Nullable<Mesh>;
  28106. /**
  28107. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28108. */
  28109. get isUnIndexed(): boolean;
  28110. set isUnIndexed(value: boolean);
  28111. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28112. get worldMatrixInstancedBuffer(): Float32Array;
  28113. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28114. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28115. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28116. /**
  28117. * @constructor
  28118. * @param name The value used by scene.getMeshByName() to do a lookup.
  28119. * @param scene The scene to add this mesh to.
  28120. * @param parent The parent of this mesh, if it has one
  28121. * @param source An optional Mesh from which geometry is shared, cloned.
  28122. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28123. * When false, achieved by calling a clone(), also passing False.
  28124. * This will make creation of children, recursive.
  28125. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28126. */
  28127. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28128. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28129. doNotInstantiate: boolean;
  28130. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28131. /**
  28132. * Gets the class name
  28133. * @returns the string "Mesh".
  28134. */
  28135. getClassName(): string;
  28136. /** @hidden */
  28137. get _isMesh(): boolean;
  28138. /**
  28139. * Returns a description of this mesh
  28140. * @param fullDetails define if full details about this mesh must be used
  28141. * @returns a descriptive string representing this mesh
  28142. */
  28143. toString(fullDetails?: boolean): string;
  28144. /** @hidden */
  28145. _unBindEffect(): void;
  28146. /**
  28147. * Gets a boolean indicating if this mesh has LOD
  28148. */
  28149. get hasLODLevels(): boolean;
  28150. /**
  28151. * Gets the list of MeshLODLevel associated with the current mesh
  28152. * @returns an array of MeshLODLevel
  28153. */
  28154. getLODLevels(): MeshLODLevel[];
  28155. private _sortLODLevels;
  28156. /**
  28157. * Add a mesh as LOD level triggered at the given distance.
  28158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28159. * @param distance The distance from the center of the object to show this level
  28160. * @param mesh The mesh to be added as LOD level (can be null)
  28161. * @return This mesh (for chaining)
  28162. */
  28163. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28164. /**
  28165. * Returns the LOD level mesh at the passed distance or null if not found.
  28166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28167. * @param distance The distance from the center of the object to show this level
  28168. * @returns a Mesh or `null`
  28169. */
  28170. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28171. /**
  28172. * Remove a mesh from the LOD array
  28173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28174. * @param mesh defines the mesh to be removed
  28175. * @return This mesh (for chaining)
  28176. */
  28177. removeLODLevel(mesh: Mesh): Mesh;
  28178. /**
  28179. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28180. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28181. * @param camera defines the camera to use to compute distance
  28182. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28183. * @return This mesh (for chaining)
  28184. */
  28185. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28186. /**
  28187. * Gets the mesh internal Geometry object
  28188. */
  28189. get geometry(): Nullable<Geometry>;
  28190. /**
  28191. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28192. * @returns the total number of vertices
  28193. */
  28194. getTotalVertices(): number;
  28195. /**
  28196. * Returns the content of an associated vertex buffer
  28197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28198. * - VertexBuffer.PositionKind
  28199. * - VertexBuffer.UVKind
  28200. * - VertexBuffer.UV2Kind
  28201. * - VertexBuffer.UV3Kind
  28202. * - VertexBuffer.UV4Kind
  28203. * - VertexBuffer.UV5Kind
  28204. * - VertexBuffer.UV6Kind
  28205. * - VertexBuffer.ColorKind
  28206. * - VertexBuffer.MatricesIndicesKind
  28207. * - VertexBuffer.MatricesIndicesExtraKind
  28208. * - VertexBuffer.MatricesWeightsKind
  28209. * - VertexBuffer.MatricesWeightsExtraKind
  28210. * @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
  28211. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28212. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28213. */
  28214. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28215. /**
  28216. * Returns the mesh VertexBuffer object from the requested `kind`
  28217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28218. * - VertexBuffer.PositionKind
  28219. * - VertexBuffer.NormalKind
  28220. * - VertexBuffer.UVKind
  28221. * - VertexBuffer.UV2Kind
  28222. * - VertexBuffer.UV3Kind
  28223. * - VertexBuffer.UV4Kind
  28224. * - VertexBuffer.UV5Kind
  28225. * - VertexBuffer.UV6Kind
  28226. * - VertexBuffer.ColorKind
  28227. * - VertexBuffer.MatricesIndicesKind
  28228. * - VertexBuffer.MatricesIndicesExtraKind
  28229. * - VertexBuffer.MatricesWeightsKind
  28230. * - VertexBuffer.MatricesWeightsExtraKind
  28231. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28232. */
  28233. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28234. /**
  28235. * Tests if a specific vertex buffer is associated with this mesh
  28236. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28237. * - VertexBuffer.PositionKind
  28238. * - VertexBuffer.NormalKind
  28239. * - VertexBuffer.UVKind
  28240. * - VertexBuffer.UV2Kind
  28241. * - VertexBuffer.UV3Kind
  28242. * - VertexBuffer.UV4Kind
  28243. * - VertexBuffer.UV5Kind
  28244. * - VertexBuffer.UV6Kind
  28245. * - VertexBuffer.ColorKind
  28246. * - VertexBuffer.MatricesIndicesKind
  28247. * - VertexBuffer.MatricesIndicesExtraKind
  28248. * - VertexBuffer.MatricesWeightsKind
  28249. * - VertexBuffer.MatricesWeightsExtraKind
  28250. * @returns a boolean
  28251. */
  28252. isVerticesDataPresent(kind: string): boolean;
  28253. /**
  28254. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28255. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28256. * - VertexBuffer.PositionKind
  28257. * - VertexBuffer.UVKind
  28258. * - VertexBuffer.UV2Kind
  28259. * - VertexBuffer.UV3Kind
  28260. * - VertexBuffer.UV4Kind
  28261. * - VertexBuffer.UV5Kind
  28262. * - VertexBuffer.UV6Kind
  28263. * - VertexBuffer.ColorKind
  28264. * - VertexBuffer.MatricesIndicesKind
  28265. * - VertexBuffer.MatricesIndicesExtraKind
  28266. * - VertexBuffer.MatricesWeightsKind
  28267. * - VertexBuffer.MatricesWeightsExtraKind
  28268. * @returns a boolean
  28269. */
  28270. isVertexBufferUpdatable(kind: string): boolean;
  28271. /**
  28272. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28273. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28274. * - VertexBuffer.PositionKind
  28275. * - VertexBuffer.NormalKind
  28276. * - VertexBuffer.UVKind
  28277. * - VertexBuffer.UV2Kind
  28278. * - VertexBuffer.UV3Kind
  28279. * - VertexBuffer.UV4Kind
  28280. * - VertexBuffer.UV5Kind
  28281. * - VertexBuffer.UV6Kind
  28282. * - VertexBuffer.ColorKind
  28283. * - VertexBuffer.MatricesIndicesKind
  28284. * - VertexBuffer.MatricesIndicesExtraKind
  28285. * - VertexBuffer.MatricesWeightsKind
  28286. * - VertexBuffer.MatricesWeightsExtraKind
  28287. * @returns an array of strings
  28288. */
  28289. getVerticesDataKinds(): string[];
  28290. /**
  28291. * Returns a positive integer : the total number of indices in this mesh geometry.
  28292. * @returns the numner of indices or zero if the mesh has no geometry.
  28293. */
  28294. getTotalIndices(): number;
  28295. /**
  28296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28297. * @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.
  28298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28299. * @returns the indices array or an empty array if the mesh has no geometry
  28300. */
  28301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28302. get isBlocked(): boolean;
  28303. /**
  28304. * Determine if the current mesh is ready to be rendered
  28305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28306. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28307. * @returns true if all associated assets are ready (material, textures, shaders)
  28308. */
  28309. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28310. /**
  28311. * 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.
  28312. */
  28313. get areNormalsFrozen(): boolean;
  28314. /**
  28315. * 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.
  28316. * @returns the current mesh
  28317. */
  28318. freezeNormals(): Mesh;
  28319. /**
  28320. * 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
  28321. * @returns the current mesh
  28322. */
  28323. unfreezeNormals(): Mesh;
  28324. /**
  28325. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28326. */
  28327. set overridenInstanceCount(count: number);
  28328. /** @hidden */
  28329. _preActivate(): Mesh;
  28330. /** @hidden */
  28331. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28332. /** @hidden */
  28333. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28334. protected _afterComputeWorldMatrix(): void;
  28335. /** @hidden */
  28336. _postActivate(): void;
  28337. /**
  28338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28339. * This means the mesh underlying bounding box and sphere are recomputed.
  28340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28341. * @returns the current mesh
  28342. */
  28343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28344. /** @hidden */
  28345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28346. /**
  28347. * This function will subdivide the mesh into multiple submeshes
  28348. * @param count defines the expected number of submeshes
  28349. */
  28350. subdivide(count: number): void;
  28351. /**
  28352. * Copy a FloatArray into a specific associated vertex buffer
  28353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28354. * - VertexBuffer.PositionKind
  28355. * - VertexBuffer.UVKind
  28356. * - VertexBuffer.UV2Kind
  28357. * - VertexBuffer.UV3Kind
  28358. * - VertexBuffer.UV4Kind
  28359. * - VertexBuffer.UV5Kind
  28360. * - VertexBuffer.UV6Kind
  28361. * - VertexBuffer.ColorKind
  28362. * - VertexBuffer.MatricesIndicesKind
  28363. * - VertexBuffer.MatricesIndicesExtraKind
  28364. * - VertexBuffer.MatricesWeightsKind
  28365. * - VertexBuffer.MatricesWeightsExtraKind
  28366. * @param data defines the data source
  28367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28368. * @param stride defines the data stride size (can be null)
  28369. * @returns the current mesh
  28370. */
  28371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28372. /**
  28373. * Delete a vertex buffer associated with this mesh
  28374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28375. * - VertexBuffer.PositionKind
  28376. * - VertexBuffer.UVKind
  28377. * - VertexBuffer.UV2Kind
  28378. * - VertexBuffer.UV3Kind
  28379. * - VertexBuffer.UV4Kind
  28380. * - VertexBuffer.UV5Kind
  28381. * - VertexBuffer.UV6Kind
  28382. * - VertexBuffer.ColorKind
  28383. * - VertexBuffer.MatricesIndicesKind
  28384. * - VertexBuffer.MatricesIndicesExtraKind
  28385. * - VertexBuffer.MatricesWeightsKind
  28386. * - VertexBuffer.MatricesWeightsExtraKind
  28387. */
  28388. removeVerticesData(kind: string): void;
  28389. /**
  28390. * Flags an associated vertex buffer as updatable
  28391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28392. * - VertexBuffer.PositionKind
  28393. * - VertexBuffer.UVKind
  28394. * - VertexBuffer.UV2Kind
  28395. * - VertexBuffer.UV3Kind
  28396. * - VertexBuffer.UV4Kind
  28397. * - VertexBuffer.UV5Kind
  28398. * - VertexBuffer.UV6Kind
  28399. * - VertexBuffer.ColorKind
  28400. * - VertexBuffer.MatricesIndicesKind
  28401. * - VertexBuffer.MatricesIndicesExtraKind
  28402. * - VertexBuffer.MatricesWeightsKind
  28403. * - VertexBuffer.MatricesWeightsExtraKind
  28404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28405. */
  28406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28407. /**
  28408. * Sets the mesh global Vertex Buffer
  28409. * @param buffer defines the buffer to use
  28410. * @returns the current mesh
  28411. */
  28412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28413. /**
  28414. * Update a specific associated vertex buffer
  28415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28416. * - VertexBuffer.PositionKind
  28417. * - VertexBuffer.UVKind
  28418. * - VertexBuffer.UV2Kind
  28419. * - VertexBuffer.UV3Kind
  28420. * - VertexBuffer.UV4Kind
  28421. * - VertexBuffer.UV5Kind
  28422. * - VertexBuffer.UV6Kind
  28423. * - VertexBuffer.ColorKind
  28424. * - VertexBuffer.MatricesIndicesKind
  28425. * - VertexBuffer.MatricesIndicesExtraKind
  28426. * - VertexBuffer.MatricesWeightsKind
  28427. * - VertexBuffer.MatricesWeightsExtraKind
  28428. * @param data defines the data source
  28429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28430. * @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)
  28431. * @returns the current mesh
  28432. */
  28433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28434. /**
  28435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28436. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28439. * @returns the current mesh
  28440. */
  28441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28442. /**
  28443. * Creates a un-shared specific occurence of the geometry for the mesh.
  28444. * @returns the current mesh
  28445. */
  28446. makeGeometryUnique(): Mesh;
  28447. /**
  28448. * Set the index buffer of this mesh
  28449. * @param indices defines the source data
  28450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28452. * @returns the current mesh
  28453. */
  28454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28455. /**
  28456. * Update the current index buffer
  28457. * @param indices defines the source data
  28458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28459. * @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)
  28460. * @returns the current mesh
  28461. */
  28462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28463. /**
  28464. * Invert the geometry to move from a right handed system to a left handed one.
  28465. * @returns the current mesh
  28466. */
  28467. toLeftHanded(): Mesh;
  28468. /** @hidden */
  28469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28470. /** @hidden */
  28471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28472. /**
  28473. * Registers for this mesh a javascript function called just before the rendering process
  28474. * @param func defines the function to call before rendering this mesh
  28475. * @returns the current mesh
  28476. */
  28477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28478. /**
  28479. * Disposes a previously registered javascript function called before the rendering
  28480. * @param func defines the function to remove
  28481. * @returns the current mesh
  28482. */
  28483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28484. /**
  28485. * Registers for this mesh a javascript function called just after the rendering is complete
  28486. * @param func defines the function to call after rendering this mesh
  28487. * @returns the current mesh
  28488. */
  28489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28490. /**
  28491. * Disposes a previously registered javascript function called after the rendering.
  28492. * @param func defines the function to remove
  28493. * @returns the current mesh
  28494. */
  28495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28496. /** @hidden */
  28497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28498. /** @hidden */
  28499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28500. /** @hidden */
  28501. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28502. /** @hidden */
  28503. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28504. /** @hidden */
  28505. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28506. /** @hidden */
  28507. _rebuild(): void;
  28508. /** @hidden */
  28509. _freeze(): void;
  28510. /** @hidden */
  28511. _unFreeze(): void;
  28512. /**
  28513. * 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
  28514. * @param subMesh defines the subMesh to render
  28515. * @param enableAlphaMode defines if alpha mode can be changed
  28516. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28517. * @returns the current mesh
  28518. */
  28519. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28520. private _onBeforeDraw;
  28521. /**
  28522. * Renormalize the mesh and patch it up if there are no weights
  28523. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28524. * However in the case of zero weights then we set just a single influence to 1.
  28525. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28526. */
  28527. cleanMatrixWeights(): void;
  28528. private normalizeSkinFourWeights;
  28529. private normalizeSkinWeightsAndExtra;
  28530. /**
  28531. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28532. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28533. * the user know there was an issue with importing the mesh
  28534. * @returns a validation object with skinned, valid and report string
  28535. */
  28536. validateSkinning(): {
  28537. skinned: boolean;
  28538. valid: boolean;
  28539. report: string;
  28540. };
  28541. /** @hidden */
  28542. _checkDelayState(): Mesh;
  28543. private _queueLoad;
  28544. /**
  28545. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28546. * A mesh is in the frustum if its bounding box intersects the frustum
  28547. * @param frustumPlanes defines the frustum to test
  28548. * @returns true if the mesh is in the frustum planes
  28549. */
  28550. isInFrustum(frustumPlanes: Plane[]): boolean;
  28551. /**
  28552. * Sets the mesh material by the material or multiMaterial `id` property
  28553. * @param id is a string identifying the material or the multiMaterial
  28554. * @returns the current mesh
  28555. */
  28556. setMaterialByID(id: string): Mesh;
  28557. /**
  28558. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28559. * @returns an array of IAnimatable
  28560. */
  28561. getAnimatables(): IAnimatable[];
  28562. /**
  28563. * Modifies the mesh geometry according to the passed transformation matrix.
  28564. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28565. * The mesh normals are modified using the same transformation.
  28566. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28567. * @param transform defines the transform matrix to use
  28568. * @see https://doc.babylonjs.com/resources/baking_transformations
  28569. * @returns the current mesh
  28570. */
  28571. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28572. /**
  28573. * Modifies the mesh geometry according to its own current World Matrix.
  28574. * The mesh World Matrix is then reset.
  28575. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28576. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28577. * @see https://doc.babylonjs.com/resources/baking_transformations
  28578. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28579. * @returns the current mesh
  28580. */
  28581. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28582. /** @hidden */
  28583. get _positions(): Nullable<Vector3[]>;
  28584. /** @hidden */
  28585. _resetPointsArrayCache(): Mesh;
  28586. /** @hidden */
  28587. _generatePointsArray(): boolean;
  28588. /**
  28589. * Returns a new Mesh object generated from the current mesh properties.
  28590. * This method must not get confused with createInstance()
  28591. * @param name is a string, the name given to the new mesh
  28592. * @param newParent can be any Node object (default `null`)
  28593. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28594. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28595. * @returns a new mesh
  28596. */
  28597. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28598. /**
  28599. * Releases resources associated with this mesh.
  28600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28602. */
  28603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28604. /** @hidden */
  28605. _disposeInstanceSpecificData(): void;
  28606. /** @hidden */
  28607. _disposeThinInstanceSpecificData(): void;
  28608. /**
  28609. * Modifies the mesh geometry according to a displacement map.
  28610. * 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.
  28611. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28612. * @param url is a string, the URL from the image file is to be downloaded.
  28613. * @param minHeight is the lower limit of the displacement.
  28614. * @param maxHeight is the upper limit of the displacement.
  28615. * @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.
  28616. * @param uvOffset is an optional vector2 used to offset UV.
  28617. * @param uvScale is an optional vector2 used to scale UV.
  28618. * @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.
  28619. * @returns the Mesh.
  28620. */
  28621. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28622. /**
  28623. * Modifies the mesh geometry according to a displacementMap buffer.
  28624. * 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.
  28625. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28626. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28627. * @param heightMapWidth is the width of the buffer image.
  28628. * @param heightMapHeight is the height of the buffer image.
  28629. * @param minHeight is the lower limit of the displacement.
  28630. * @param maxHeight is the upper limit of the displacement.
  28631. * @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.
  28632. * @param uvOffset is an optional vector2 used to offset UV.
  28633. * @param uvScale is an optional vector2 used to scale UV.
  28634. * @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.
  28635. * @returns the Mesh.
  28636. */
  28637. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28638. /**
  28639. * Modify the mesh to get a flat shading rendering.
  28640. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28641. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28642. * @returns current mesh
  28643. */
  28644. convertToFlatShadedMesh(): Mesh;
  28645. /**
  28646. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28647. * In other words, more vertices, no more indices and a single bigger VBO.
  28648. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28649. * @returns current mesh
  28650. */
  28651. convertToUnIndexedMesh(): Mesh;
  28652. /**
  28653. * Inverses facet orientations.
  28654. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28655. * @param flipNormals will also inverts the normals
  28656. * @returns current mesh
  28657. */
  28658. flipFaces(flipNormals?: boolean): Mesh;
  28659. /**
  28660. * Increase the number of facets and hence vertices in a mesh
  28661. * Vertex normals are interpolated from existing vertex normals
  28662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28663. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28664. */
  28665. increaseVertices(numberPerEdge: number): void;
  28666. /**
  28667. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28668. * This will undo any application of covertToFlatShadedMesh
  28669. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28670. */
  28671. forceSharedVertices(): void;
  28672. /** @hidden */
  28673. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28674. /** @hidden */
  28675. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28676. /**
  28677. * Creates a new InstancedMesh object from the mesh model.
  28678. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28679. * @param name defines the name of the new instance
  28680. * @returns a new InstancedMesh
  28681. */
  28682. createInstance(name: string): InstancedMesh;
  28683. /**
  28684. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28685. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28686. * @returns the current mesh
  28687. */
  28688. synchronizeInstances(): Mesh;
  28689. /**
  28690. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28691. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28692. * This should be used together with the simplification to avoid disappearing triangles.
  28693. * @param successCallback an optional success callback to be called after the optimization finished.
  28694. * @returns the current mesh
  28695. */
  28696. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28697. /**
  28698. * Serialize current mesh
  28699. * @param serializationObject defines the object which will receive the serialization data
  28700. */
  28701. serialize(serializationObject: any): void;
  28702. /** @hidden */
  28703. _syncGeometryWithMorphTargetManager(): void;
  28704. /** @hidden */
  28705. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28706. /**
  28707. * Returns a new Mesh object parsed from the source provided.
  28708. * @param parsedMesh is the source
  28709. * @param scene defines the hosting scene
  28710. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28711. * @returns a new Mesh
  28712. */
  28713. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28714. /**
  28715. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28717. * @param name defines the name of the mesh to create
  28718. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28719. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28720. * @param closePath creates a seam between the first and the last points of each path of the path array
  28721. * @param offset is taken in account only if the `pathArray` is containing a single path
  28722. * @param scene defines the hosting scene
  28723. * @param updatable defines if the mesh must be flagged as updatable
  28724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28725. * @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)
  28726. * @returns a new Mesh
  28727. */
  28728. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28729. /**
  28730. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28731. * @param name defines the name of the mesh to create
  28732. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28733. * @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
  28734. * @param scene defines the hosting scene
  28735. * @param updatable defines if the mesh must be flagged as updatable
  28736. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28737. * @returns a new Mesh
  28738. */
  28739. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28740. /**
  28741. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28742. * @param name defines the name of the mesh to create
  28743. * @param size sets the size (float) of each box side (default 1)
  28744. * @param scene defines the hosting scene
  28745. * @param updatable defines if the mesh must be flagged as updatable
  28746. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28747. * @returns a new Mesh
  28748. */
  28749. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28750. /**
  28751. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28752. * @param name defines the name of the mesh to create
  28753. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28754. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28755. * @param scene defines the hosting scene
  28756. * @param updatable defines if the mesh must be flagged as updatable
  28757. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28758. * @returns a new Mesh
  28759. */
  28760. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28761. /**
  28762. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28763. * @param name defines the name of the mesh to create
  28764. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28765. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28766. * @param scene defines the hosting scene
  28767. * @returns a new Mesh
  28768. */
  28769. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28770. /**
  28771. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28772. * @param name defines the name of the mesh to create
  28773. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28774. * @param diameterTop set the top cap diameter (floats, default 1)
  28775. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28776. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28777. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28778. * @param scene defines the hosting scene
  28779. * @param updatable defines if the mesh must be flagged as updatable
  28780. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28781. * @returns a new Mesh
  28782. */
  28783. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28784. /**
  28785. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28786. * @param name defines the name of the mesh to create
  28787. * @param diameter sets the diameter size (float) of the torus (default 1)
  28788. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28789. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28790. * @param scene defines the hosting scene
  28791. * @param updatable defines if the mesh must be flagged as updatable
  28792. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28793. * @returns a new Mesh
  28794. */
  28795. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28796. /**
  28797. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28798. * @param name defines the name of the mesh to create
  28799. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28800. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28801. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28802. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28803. * @param p the number of windings on X axis (positive integers, default 2)
  28804. * @param q the number of windings on Y axis (positive integers, default 3)
  28805. * @param scene defines the hosting scene
  28806. * @param updatable defines if the mesh must be flagged as updatable
  28807. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28808. * @returns a new Mesh
  28809. */
  28810. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28811. /**
  28812. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28813. * @param name defines the name of the mesh to create
  28814. * @param points is an array successive Vector3
  28815. * @param scene defines the hosting scene
  28816. * @param updatable defines if the mesh must be flagged as updatable
  28817. * @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).
  28818. * @returns a new Mesh
  28819. */
  28820. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28821. /**
  28822. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28823. * @param name defines the name of the mesh to create
  28824. * @param points is an array successive Vector3
  28825. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28826. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28827. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28828. * @param scene defines the hosting scene
  28829. * @param updatable defines if the mesh must be flagged as updatable
  28830. * @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)
  28831. * @returns a new Mesh
  28832. */
  28833. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28834. /**
  28835. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28836. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28837. * 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.
  28838. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28839. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28840. * Remember you can only change the shape positions, not their number when updating a polygon.
  28841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28842. * @param name defines the name of the mesh to create
  28843. * @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
  28844. * @param scene defines the hosting scene
  28845. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28846. * @param updatable defines if the mesh must be flagged as updatable
  28847. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28848. * @param earcutInjection can be used to inject your own earcut reference
  28849. * @returns a new Mesh
  28850. */
  28851. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28852. /**
  28853. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28855. * @param name defines the name of the mesh to create
  28856. * @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
  28857. * @param depth defines the height of extrusion
  28858. * @param scene defines the hosting scene
  28859. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28860. * @param updatable defines if the mesh must be flagged as updatable
  28861. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28862. * @param earcutInjection can be used to inject your own earcut reference
  28863. * @returns a new Mesh
  28864. */
  28865. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28866. /**
  28867. * Creates an extruded shape mesh.
  28868. * 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
  28869. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28871. * @param name defines the name of the mesh to create
  28872. * @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
  28873. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28874. * @param scale is the value to scale the shape
  28875. * @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
  28876. * @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
  28877. * @param scene defines the hosting scene
  28878. * @param updatable defines if the mesh must be flagged as updatable
  28879. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28880. * @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)
  28881. * @returns a new Mesh
  28882. */
  28883. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28884. /**
  28885. * Creates an custom extruded shape mesh.
  28886. * The custom extrusion is a parametric shape.
  28887. * It has no predefined shape. Its final shape will depend on the input parameters.
  28888. * Please consider using the same method from the MeshBuilder class instead
  28889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28890. * @param name defines the name of the mesh to create
  28891. * @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
  28892. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28893. * @param scaleFunction is a custom Javascript function called on each path point
  28894. * @param rotationFunction is a custom Javascript function called on each path point
  28895. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28896. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28897. * @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
  28898. * @param scene defines the hosting scene
  28899. * @param updatable defines if the mesh must be flagged as updatable
  28900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28901. * @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)
  28902. * @returns a new Mesh
  28903. */
  28904. 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;
  28905. /**
  28906. * Creates lathe mesh.
  28907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28908. * Please consider using the same method from the MeshBuilder class instead
  28909. * @param name defines the name of the mesh to create
  28910. * @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
  28911. * @param radius is the radius value of the lathe
  28912. * @param tessellation is the side number of the lathe.
  28913. * @param scene defines the hosting scene
  28914. * @param updatable defines if the mesh must be flagged as updatable
  28915. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28916. * @returns a new Mesh
  28917. */
  28918. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28919. /**
  28920. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28921. * @param name defines the name of the mesh to create
  28922. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @returns a new Mesh
  28927. */
  28928. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28929. /**
  28930. * Creates a ground mesh.
  28931. * Please consider using the same method from the MeshBuilder class instead
  28932. * @param name defines the name of the mesh to create
  28933. * @param width set the width of the ground
  28934. * @param height set the height of the ground
  28935. * @param subdivisions sets the number of subdivisions per side
  28936. * @param scene defines the hosting scene
  28937. * @param updatable defines if the mesh must be flagged as updatable
  28938. * @returns a new Mesh
  28939. */
  28940. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28941. /**
  28942. * Creates a tiled ground mesh.
  28943. * Please consider using the same method from the MeshBuilder class instead
  28944. * @param name defines the name of the mesh to create
  28945. * @param xmin set the ground minimum X coordinate
  28946. * @param zmin set the ground minimum Y coordinate
  28947. * @param xmax set the ground maximum X coordinate
  28948. * @param zmax set the ground maximum Z coordinate
  28949. * @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
  28950. * @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
  28951. * @param scene defines the hosting scene
  28952. * @param updatable defines if the mesh must be flagged as updatable
  28953. * @returns a new Mesh
  28954. */
  28955. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28956. w: number;
  28957. h: number;
  28958. }, precision: {
  28959. w: number;
  28960. h: number;
  28961. }, scene: Scene, updatable?: boolean): Mesh;
  28962. /**
  28963. * Creates a ground mesh from a height map.
  28964. * Please consider using the same method from the MeshBuilder class instead
  28965. * @see https://doc.babylonjs.com/babylon101/height_map
  28966. * @param name defines the name of the mesh to create
  28967. * @param url sets the URL of the height map image resource
  28968. * @param width set the ground width size
  28969. * @param height set the ground height size
  28970. * @param subdivisions sets the number of subdivision per side
  28971. * @param minHeight is the minimum altitude on the ground
  28972. * @param maxHeight is the maximum altitude on the ground
  28973. * @param scene defines the hosting scene
  28974. * @param updatable defines if the mesh must be flagged as updatable
  28975. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28976. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28977. * @returns a new Mesh
  28978. */
  28979. 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;
  28980. /**
  28981. * Creates a tube mesh.
  28982. * The tube is a parametric shape.
  28983. * It has no predefined shape. Its final shape will depend on the input parameters.
  28984. * Please consider using the same method from the MeshBuilder class instead
  28985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28986. * @param name defines the name of the mesh to create
  28987. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28988. * @param radius sets the tube radius size
  28989. * @param tessellation is the number of sides on the tubular surface
  28990. * @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
  28991. * @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
  28992. * @param scene defines the hosting scene
  28993. * @param updatable defines if the mesh must be flagged as updatable
  28994. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28995. * @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)
  28996. * @returns a new Mesh
  28997. */
  28998. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28999. (i: number, distance: number): number;
  29000. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29001. /**
  29002. * Creates a polyhedron mesh.
  29003. * Please consider using the same method from the MeshBuilder class instead.
  29004. * * 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
  29005. * * The parameter `size` (positive float, default 1) sets the polygon size
  29006. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29007. * * 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`
  29008. * * 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
  29009. * * 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)`)
  29010. * * 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
  29011. * * 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
  29012. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29013. * * 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
  29014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29015. * @param name defines the name of the mesh to create
  29016. * @param options defines the options used to create the mesh
  29017. * @param scene defines the hosting scene
  29018. * @returns a new Mesh
  29019. */
  29020. static CreatePolyhedron(name: string, options: {
  29021. type?: number;
  29022. size?: number;
  29023. sizeX?: number;
  29024. sizeY?: number;
  29025. sizeZ?: number;
  29026. custom?: any;
  29027. faceUV?: Vector4[];
  29028. faceColors?: Color4[];
  29029. updatable?: boolean;
  29030. sideOrientation?: number;
  29031. }, scene: Scene): Mesh;
  29032. /**
  29033. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29034. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29035. * * 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`)
  29036. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29037. * * 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
  29038. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29039. * * 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
  29040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29041. * @param name defines the name of the mesh
  29042. * @param options defines the options used to create the mesh
  29043. * @param scene defines the hosting scene
  29044. * @returns a new Mesh
  29045. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29046. */
  29047. static CreateIcoSphere(name: string, options: {
  29048. radius?: number;
  29049. flat?: boolean;
  29050. subdivisions?: number;
  29051. sideOrientation?: number;
  29052. updatable?: boolean;
  29053. }, scene: Scene): Mesh;
  29054. /**
  29055. * Creates a decal mesh.
  29056. * Please consider using the same method from the MeshBuilder class instead.
  29057. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29058. * @param name defines the name of the mesh
  29059. * @param sourceMesh defines the mesh receiving the decal
  29060. * @param position sets the position of the decal in world coordinates
  29061. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29062. * @param size sets the decal scaling
  29063. * @param angle sets the angle to rotate the decal
  29064. * @returns a new Mesh
  29065. */
  29066. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29067. /**
  29068. * Prepare internal position array for software CPU skinning
  29069. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29070. */
  29071. setPositionsForCPUSkinning(): Float32Array;
  29072. /**
  29073. * Prepare internal normal array for software CPU skinning
  29074. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29075. */
  29076. setNormalsForCPUSkinning(): Float32Array;
  29077. /**
  29078. * Updates the vertex buffer by applying transformation from the bones
  29079. * @param skeleton defines the skeleton to apply to current mesh
  29080. * @returns the current mesh
  29081. */
  29082. applySkeleton(skeleton: Skeleton): Mesh;
  29083. /**
  29084. * 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
  29085. * @param meshes defines the list of meshes to scan
  29086. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29087. */
  29088. static MinMax(meshes: AbstractMesh[]): {
  29089. min: Vector3;
  29090. max: Vector3;
  29091. };
  29092. /**
  29093. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29094. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29095. * @returns a vector3
  29096. */
  29097. static Center(meshesOrMinMaxVector: {
  29098. min: Vector3;
  29099. max: Vector3;
  29100. } | AbstractMesh[]): Vector3;
  29101. /**
  29102. * Merge the array of meshes into a single mesh for performance reasons.
  29103. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29104. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29105. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29106. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29107. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29108. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29109. * @returns a new mesh
  29110. */
  29111. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29112. /** @hidden */
  29113. addInstance(instance: InstancedMesh): void;
  29114. /** @hidden */
  29115. removeInstance(instance: InstancedMesh): void;
  29116. }
  29117. }
  29118. declare module BABYLON {
  29119. /**
  29120. * This is the base class of all the camera used in the application.
  29121. * @see https://doc.babylonjs.com/features/cameras
  29122. */
  29123. export class Camera extends Node {
  29124. /** @hidden */
  29125. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29126. /**
  29127. * This is the default projection mode used by the cameras.
  29128. * It helps recreating a feeling of perspective and better appreciate depth.
  29129. * This is the best way to simulate real life cameras.
  29130. */
  29131. static readonly PERSPECTIVE_CAMERA: number;
  29132. /**
  29133. * This helps creating camera with an orthographic mode.
  29134. * 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.
  29135. */
  29136. static readonly ORTHOGRAPHIC_CAMERA: number;
  29137. /**
  29138. * This is the default FOV mode for perspective cameras.
  29139. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29140. */
  29141. static readonly FOVMODE_VERTICAL_FIXED: number;
  29142. /**
  29143. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29144. */
  29145. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29146. /**
  29147. * This specifies ther is no need for a camera rig.
  29148. * Basically only one eye is rendered corresponding to the camera.
  29149. */
  29150. static readonly RIG_MODE_NONE: number;
  29151. /**
  29152. * Simulates a camera Rig with one blue eye and one red eye.
  29153. * This can be use with 3d blue and red glasses.
  29154. */
  29155. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29156. /**
  29157. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29158. */
  29159. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29160. /**
  29161. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29162. */
  29163. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29164. /**
  29165. * Defines that both eyes of the camera will be rendered over under each other.
  29166. */
  29167. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29168. /**
  29169. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29170. */
  29171. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29172. /**
  29173. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29174. */
  29175. static readonly RIG_MODE_VR: number;
  29176. /**
  29177. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29178. */
  29179. static readonly RIG_MODE_WEBVR: number;
  29180. /**
  29181. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29182. */
  29183. static readonly RIG_MODE_CUSTOM: number;
  29184. /**
  29185. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29186. */
  29187. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29188. /**
  29189. * Define the input manager associated with the camera.
  29190. */
  29191. inputs: CameraInputsManager<Camera>;
  29192. /** @hidden */
  29193. _position: Vector3;
  29194. /**
  29195. * Define the current local position of the camera in the scene
  29196. */
  29197. get position(): Vector3;
  29198. set position(newPosition: Vector3);
  29199. /**
  29200. * The vector the camera should consider as up.
  29201. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29202. */
  29203. upVector: Vector3;
  29204. /**
  29205. * Define the current limit on the left side for an orthographic camera
  29206. * In scene unit
  29207. */
  29208. orthoLeft: Nullable<number>;
  29209. /**
  29210. * Define the current limit on the right side for an orthographic camera
  29211. * In scene unit
  29212. */
  29213. orthoRight: Nullable<number>;
  29214. /**
  29215. * Define the current limit on the bottom side for an orthographic camera
  29216. * In scene unit
  29217. */
  29218. orthoBottom: Nullable<number>;
  29219. /**
  29220. * Define the current limit on the top side for an orthographic camera
  29221. * In scene unit
  29222. */
  29223. orthoTop: Nullable<number>;
  29224. /**
  29225. * Field Of View is set in Radians. (default is 0.8)
  29226. */
  29227. fov: number;
  29228. /**
  29229. * Define the minimum distance the camera can see from.
  29230. * This is important to note that the depth buffer are not infinite and the closer it starts
  29231. * the more your scene might encounter depth fighting issue.
  29232. */
  29233. minZ: number;
  29234. /**
  29235. * Define the maximum distance the camera can see to.
  29236. * This is important to note that the depth buffer are not infinite and the further it end
  29237. * the more your scene might encounter depth fighting issue.
  29238. */
  29239. maxZ: number;
  29240. /**
  29241. * Define the default inertia of the camera.
  29242. * This helps giving a smooth feeling to the camera movement.
  29243. */
  29244. inertia: number;
  29245. /**
  29246. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29247. */
  29248. mode: number;
  29249. /**
  29250. * Define whether the camera is intermediate.
  29251. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29252. */
  29253. isIntermediate: boolean;
  29254. /**
  29255. * Define the viewport of the camera.
  29256. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29257. */
  29258. viewport: Viewport;
  29259. /**
  29260. * Restricts the camera to viewing objects with the same layerMask.
  29261. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29262. */
  29263. layerMask: number;
  29264. /**
  29265. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29266. */
  29267. fovMode: number;
  29268. /**
  29269. * Rig mode of the camera.
  29270. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29271. * This is normally controlled byt the camera themselves as internal use.
  29272. */
  29273. cameraRigMode: number;
  29274. /**
  29275. * Defines the distance between both "eyes" in case of a RIG
  29276. */
  29277. interaxialDistance: number;
  29278. /**
  29279. * Defines if stereoscopic rendering is done side by side or over under.
  29280. */
  29281. isStereoscopicSideBySide: boolean;
  29282. /**
  29283. * 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
  29284. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29285. * else in the scene. (Eg. security camera)
  29286. *
  29287. * 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)
  29288. */
  29289. customRenderTargets: RenderTargetTexture[];
  29290. /**
  29291. * When set, the camera will render to this render target instead of the default canvas
  29292. *
  29293. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29294. */
  29295. outputRenderTarget: Nullable<RenderTargetTexture>;
  29296. /**
  29297. * Observable triggered when the camera view matrix has changed.
  29298. */
  29299. onViewMatrixChangedObservable: Observable<Camera>;
  29300. /**
  29301. * Observable triggered when the camera Projection matrix has changed.
  29302. */
  29303. onProjectionMatrixChangedObservable: Observable<Camera>;
  29304. /**
  29305. * Observable triggered when the inputs have been processed.
  29306. */
  29307. onAfterCheckInputsObservable: Observable<Camera>;
  29308. /**
  29309. * Observable triggered when reset has been called and applied to the camera.
  29310. */
  29311. onRestoreStateObservable: Observable<Camera>;
  29312. /**
  29313. * Is this camera a part of a rig system?
  29314. */
  29315. isRigCamera: boolean;
  29316. /**
  29317. * If isRigCamera set to true this will be set with the parent camera.
  29318. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29319. */
  29320. rigParent?: Camera;
  29321. /** @hidden */
  29322. _cameraRigParams: any;
  29323. /** @hidden */
  29324. _rigCameras: Camera[];
  29325. /** @hidden */
  29326. _rigPostProcess: Nullable<PostProcess>;
  29327. protected _webvrViewMatrix: Matrix;
  29328. /** @hidden */
  29329. _skipRendering: boolean;
  29330. /** @hidden */
  29331. _projectionMatrix: Matrix;
  29332. /** @hidden */
  29333. _postProcesses: Nullable<PostProcess>[];
  29334. /** @hidden */
  29335. _activeMeshes: SmartArray<AbstractMesh>;
  29336. protected _globalPosition: Vector3;
  29337. /** @hidden */
  29338. _computedViewMatrix: Matrix;
  29339. private _doNotComputeProjectionMatrix;
  29340. private _transformMatrix;
  29341. private _frustumPlanes;
  29342. private _refreshFrustumPlanes;
  29343. private _storedFov;
  29344. private _stateStored;
  29345. /**
  29346. * Instantiates a new camera object.
  29347. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29348. * @see https://doc.babylonjs.com/features/cameras
  29349. * @param name Defines the name of the camera in the scene
  29350. * @param position Defines the position of the camera
  29351. * @param scene Defines the scene the camera belongs too
  29352. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29353. */
  29354. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29355. /**
  29356. * Store current camera state (fov, position, etc..)
  29357. * @returns the camera
  29358. */
  29359. storeState(): Camera;
  29360. /**
  29361. * Restores the camera state values if it has been stored. You must call storeState() first
  29362. */
  29363. protected _restoreStateValues(): boolean;
  29364. /**
  29365. * Restored camera state. You must call storeState() first.
  29366. * @returns true if restored and false otherwise
  29367. */
  29368. restoreState(): boolean;
  29369. /**
  29370. * Gets the class name of the camera.
  29371. * @returns the class name
  29372. */
  29373. getClassName(): string;
  29374. /** @hidden */
  29375. readonly _isCamera: boolean;
  29376. /**
  29377. * Gets a string representation of the camera useful for debug purpose.
  29378. * @param fullDetails Defines that a more verboe level of logging is required
  29379. * @returns the string representation
  29380. */
  29381. toString(fullDetails?: boolean): string;
  29382. /**
  29383. * Gets the current world space position of the camera.
  29384. */
  29385. get globalPosition(): Vector3;
  29386. /**
  29387. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29388. * @returns the active meshe list
  29389. */
  29390. getActiveMeshes(): SmartArray<AbstractMesh>;
  29391. /**
  29392. * Check whether a mesh is part of the current active mesh list of the camera
  29393. * @param mesh Defines the mesh to check
  29394. * @returns true if active, false otherwise
  29395. */
  29396. isActiveMesh(mesh: Mesh): boolean;
  29397. /**
  29398. * Is this camera ready to be used/rendered
  29399. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29400. * @return true if the camera is ready
  29401. */
  29402. isReady(completeCheck?: boolean): boolean;
  29403. /** @hidden */
  29404. _initCache(): void;
  29405. /** @hidden */
  29406. _updateCache(ignoreParentClass?: boolean): void;
  29407. /** @hidden */
  29408. _isSynchronized(): boolean;
  29409. /** @hidden */
  29410. _isSynchronizedViewMatrix(): boolean;
  29411. /** @hidden */
  29412. _isSynchronizedProjectionMatrix(): boolean;
  29413. /**
  29414. * Attach the input controls to a specific dom element to get the input from.
  29415. * @param element Defines the element the controls should be listened from
  29416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29417. */
  29418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29419. /**
  29420. * Detach the current controls from the specified dom element.
  29421. * @param element Defines the element to stop listening the inputs from
  29422. */
  29423. detachControl(element: HTMLElement): void;
  29424. /**
  29425. * Update the camera state according to the different inputs gathered during the frame.
  29426. */
  29427. update(): void;
  29428. /** @hidden */
  29429. _checkInputs(): void;
  29430. /** @hidden */
  29431. get rigCameras(): Camera[];
  29432. /**
  29433. * Gets the post process used by the rig cameras
  29434. */
  29435. get rigPostProcess(): Nullable<PostProcess>;
  29436. /**
  29437. * Internal, gets the first post proces.
  29438. * @returns the first post process to be run on this camera.
  29439. */
  29440. _getFirstPostProcess(): Nullable<PostProcess>;
  29441. private _cascadePostProcessesToRigCams;
  29442. /**
  29443. * Attach a post process to the camera.
  29444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29445. * @param postProcess The post process to attach to the camera
  29446. * @param insertAt The position of the post process in case several of them are in use in the scene
  29447. * @returns the position the post process has been inserted at
  29448. */
  29449. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29450. /**
  29451. * Detach a post process to the camera.
  29452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29453. * @param postProcess The post process to detach from the camera
  29454. */
  29455. detachPostProcess(postProcess: PostProcess): void;
  29456. /**
  29457. * Gets the current world matrix of the camera
  29458. */
  29459. getWorldMatrix(): Matrix;
  29460. /** @hidden */
  29461. _getViewMatrix(): Matrix;
  29462. /**
  29463. * Gets the current view matrix of the camera.
  29464. * @param force forces the camera to recompute the matrix without looking at the cached state
  29465. * @returns the view matrix
  29466. */
  29467. getViewMatrix(force?: boolean): Matrix;
  29468. /**
  29469. * Freeze the projection matrix.
  29470. * It will prevent the cache check of the camera projection compute and can speed up perf
  29471. * if no parameter of the camera are meant to change
  29472. * @param projection Defines manually a projection if necessary
  29473. */
  29474. freezeProjectionMatrix(projection?: Matrix): void;
  29475. /**
  29476. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29477. */
  29478. unfreezeProjectionMatrix(): void;
  29479. /**
  29480. * Gets the current projection matrix of the camera.
  29481. * @param force forces the camera to recompute the matrix without looking at the cached state
  29482. * @returns the projection matrix
  29483. */
  29484. getProjectionMatrix(force?: boolean): Matrix;
  29485. /**
  29486. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29487. * @returns a Matrix
  29488. */
  29489. getTransformationMatrix(): Matrix;
  29490. private _updateFrustumPlanes;
  29491. /**
  29492. * Checks if a cullable object (mesh...) is in the camera frustum
  29493. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29494. * @param target The object to check
  29495. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29496. * @returns true if the object is in frustum otherwise false
  29497. */
  29498. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29499. /**
  29500. * Checks if a cullable object (mesh...) is in the camera frustum
  29501. * Unlike isInFrustum this cheks the full bounding box
  29502. * @param target The object to check
  29503. * @returns true if the object is in frustum otherwise false
  29504. */
  29505. isCompletelyInFrustum(target: ICullable): boolean;
  29506. /**
  29507. * Gets a ray in the forward direction from the camera.
  29508. * @param length Defines the length of the ray to create
  29509. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29510. * @param origin Defines the start point of the ray which defaults to the camera position
  29511. * @returns the forward ray
  29512. */
  29513. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29514. /**
  29515. * Releases resources associated with this node.
  29516. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29517. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29518. */
  29519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29520. /** @hidden */
  29521. _isLeftCamera: boolean;
  29522. /**
  29523. * Gets the left camera of a rig setup in case of Rigged Camera
  29524. */
  29525. get isLeftCamera(): boolean;
  29526. /** @hidden */
  29527. _isRightCamera: boolean;
  29528. /**
  29529. * Gets the right camera of a rig setup in case of Rigged Camera
  29530. */
  29531. get isRightCamera(): boolean;
  29532. /**
  29533. * Gets the left camera of a rig setup in case of Rigged Camera
  29534. */
  29535. get leftCamera(): Nullable<FreeCamera>;
  29536. /**
  29537. * Gets the right camera of a rig setup in case of Rigged Camera
  29538. */
  29539. get rightCamera(): Nullable<FreeCamera>;
  29540. /**
  29541. * Gets the left camera target of a rig setup in case of Rigged Camera
  29542. * @returns the target position
  29543. */
  29544. getLeftTarget(): Nullable<Vector3>;
  29545. /**
  29546. * Gets the right camera target of a rig setup in case of Rigged Camera
  29547. * @returns the target position
  29548. */
  29549. getRightTarget(): Nullable<Vector3>;
  29550. /**
  29551. * @hidden
  29552. */
  29553. setCameraRigMode(mode: number, rigParams: any): void;
  29554. /** @hidden */
  29555. static _setStereoscopicRigMode(camera: Camera): void;
  29556. /** @hidden */
  29557. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29558. /** @hidden */
  29559. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29560. /** @hidden */
  29561. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29562. /** @hidden */
  29563. _getVRProjectionMatrix(): Matrix;
  29564. protected _updateCameraRotationMatrix(): void;
  29565. protected _updateWebVRCameraRotationMatrix(): void;
  29566. /**
  29567. * This function MUST be overwritten by the different WebVR cameras available.
  29568. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29569. * @hidden
  29570. */
  29571. _getWebVRProjectionMatrix(): Matrix;
  29572. /**
  29573. * This function MUST be overwritten by the different WebVR cameras available.
  29574. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29575. * @hidden
  29576. */
  29577. _getWebVRViewMatrix(): Matrix;
  29578. /** @hidden */
  29579. setCameraRigParameter(name: string, value: any): void;
  29580. /**
  29581. * needs to be overridden by children so sub has required properties to be copied
  29582. * @hidden
  29583. */
  29584. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29585. /**
  29586. * May need to be overridden by children
  29587. * @hidden
  29588. */
  29589. _updateRigCameras(): void;
  29590. /** @hidden */
  29591. _setupInputs(): void;
  29592. /**
  29593. * Serialiaze the camera setup to a json represention
  29594. * @returns the JSON representation
  29595. */
  29596. serialize(): any;
  29597. /**
  29598. * Clones the current camera.
  29599. * @param name The cloned camera name
  29600. * @returns the cloned camera
  29601. */
  29602. clone(name: string): Camera;
  29603. /**
  29604. * Gets the direction of the camera relative to a given local axis.
  29605. * @param localAxis Defines the reference axis to provide a relative direction.
  29606. * @return the direction
  29607. */
  29608. getDirection(localAxis: Vector3): Vector3;
  29609. /**
  29610. * Returns the current camera absolute rotation
  29611. */
  29612. get absoluteRotation(): Quaternion;
  29613. /**
  29614. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29615. * @param localAxis Defines the reference axis to provide a relative direction.
  29616. * @param result Defines the vector to store the result in
  29617. */
  29618. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29619. /**
  29620. * Gets a camera constructor for a given camera type
  29621. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29622. * @param name The name of the camera the result will be able to instantiate
  29623. * @param scene The scene the result will construct the camera in
  29624. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29625. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29626. * @returns a factory method to construc the camera
  29627. */
  29628. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29629. /**
  29630. * Compute the world matrix of the camera.
  29631. * @returns the camera world matrix
  29632. */
  29633. computeWorldMatrix(): Matrix;
  29634. /**
  29635. * Parse a JSON and creates the camera from the parsed information
  29636. * @param parsedCamera The JSON to parse
  29637. * @param scene The scene to instantiate the camera in
  29638. * @returns the newly constructed camera
  29639. */
  29640. static Parse(parsedCamera: any, scene: Scene): Camera;
  29641. }
  29642. }
  29643. declare module BABYLON {
  29644. /**
  29645. * Class containing static functions to help procedurally build meshes
  29646. */
  29647. export class DiscBuilder {
  29648. /**
  29649. * Creates a plane polygonal mesh. By default, this is a disc
  29650. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29651. * * 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
  29652. * * 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
  29653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29654. * * 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
  29655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29656. * @param name defines the name of the mesh
  29657. * @param options defines the options used to create the mesh
  29658. * @param scene defines the hosting scene
  29659. * @returns the plane polygonal mesh
  29660. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29661. */
  29662. static CreateDisc(name: string, options: {
  29663. radius?: number;
  29664. tessellation?: number;
  29665. arc?: number;
  29666. updatable?: boolean;
  29667. sideOrientation?: number;
  29668. frontUVs?: Vector4;
  29669. backUVs?: Vector4;
  29670. }, scene?: Nullable<Scene>): Mesh;
  29671. }
  29672. }
  29673. declare module BABYLON {
  29674. /**
  29675. * Options to be used when creating a FresnelParameters.
  29676. */
  29677. export type IFresnelParametersCreationOptions = {
  29678. /**
  29679. * Define the color used on edges (grazing angle)
  29680. */
  29681. leftColor?: Color3;
  29682. /**
  29683. * Define the color used on center
  29684. */
  29685. rightColor?: Color3;
  29686. /**
  29687. * Define bias applied to computed fresnel term
  29688. */
  29689. bias?: number;
  29690. /**
  29691. * Defined the power exponent applied to fresnel term
  29692. */
  29693. power?: number;
  29694. /**
  29695. * Define if the fresnel effect is enable or not.
  29696. */
  29697. isEnabled?: boolean;
  29698. };
  29699. /**
  29700. * Serialized format for FresnelParameters.
  29701. */
  29702. export type IFresnelParametersSerialized = {
  29703. /**
  29704. * Define the color used on edges (grazing angle) [as an array]
  29705. */
  29706. leftColor: number[];
  29707. /**
  29708. * Define the color used on center [as an array]
  29709. */
  29710. rightColor: number[];
  29711. /**
  29712. * Define bias applied to computed fresnel term
  29713. */
  29714. bias: number;
  29715. /**
  29716. * Defined the power exponent applied to fresnel term
  29717. */
  29718. power?: number;
  29719. /**
  29720. * Define if the fresnel effect is enable or not.
  29721. */
  29722. isEnabled: boolean;
  29723. };
  29724. /**
  29725. * This represents all the required information to add a fresnel effect on a material:
  29726. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29727. */
  29728. export class FresnelParameters {
  29729. private _isEnabled;
  29730. /**
  29731. * Define if the fresnel effect is enable or not.
  29732. */
  29733. get isEnabled(): boolean;
  29734. set isEnabled(value: boolean);
  29735. /**
  29736. * Define the color used on edges (grazing angle)
  29737. */
  29738. leftColor: Color3;
  29739. /**
  29740. * Define the color used on center
  29741. */
  29742. rightColor: Color3;
  29743. /**
  29744. * Define bias applied to computed fresnel term
  29745. */
  29746. bias: number;
  29747. /**
  29748. * Defined the power exponent applied to fresnel term
  29749. */
  29750. power: number;
  29751. /**
  29752. * Creates a new FresnelParameters object.
  29753. *
  29754. * @param options provide your own settings to optionally to override defaults
  29755. */
  29756. constructor(options?: IFresnelParametersCreationOptions);
  29757. /**
  29758. * Clones the current fresnel and its valuues
  29759. * @returns a clone fresnel configuration
  29760. */
  29761. clone(): FresnelParameters;
  29762. /**
  29763. * Determines equality between FresnelParameters objects
  29764. * @param otherFresnelParameters defines the second operand
  29765. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29766. */
  29767. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29768. /**
  29769. * Serializes the current fresnel parameters to a JSON representation.
  29770. * @return the JSON serialization
  29771. */
  29772. serialize(): IFresnelParametersSerialized;
  29773. /**
  29774. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29775. * @param parsedFresnelParameters Define the JSON representation
  29776. * @returns the parsed parameters
  29777. */
  29778. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29779. }
  29780. }
  29781. declare module BABYLON {
  29782. /**
  29783. * This groups all the flags used to control the materials channel.
  29784. */
  29785. export class MaterialFlags {
  29786. private static _DiffuseTextureEnabled;
  29787. /**
  29788. * Are diffuse textures enabled in the application.
  29789. */
  29790. static get DiffuseTextureEnabled(): boolean;
  29791. static set DiffuseTextureEnabled(value: boolean);
  29792. private static _DetailTextureEnabled;
  29793. /**
  29794. * Are detail textures enabled in the application.
  29795. */
  29796. static get DetailTextureEnabled(): boolean;
  29797. static set DetailTextureEnabled(value: boolean);
  29798. private static _AmbientTextureEnabled;
  29799. /**
  29800. * Are ambient textures enabled in the application.
  29801. */
  29802. static get AmbientTextureEnabled(): boolean;
  29803. static set AmbientTextureEnabled(value: boolean);
  29804. private static _OpacityTextureEnabled;
  29805. /**
  29806. * Are opacity textures enabled in the application.
  29807. */
  29808. static get OpacityTextureEnabled(): boolean;
  29809. static set OpacityTextureEnabled(value: boolean);
  29810. private static _ReflectionTextureEnabled;
  29811. /**
  29812. * Are reflection textures enabled in the application.
  29813. */
  29814. static get ReflectionTextureEnabled(): boolean;
  29815. static set ReflectionTextureEnabled(value: boolean);
  29816. private static _EmissiveTextureEnabled;
  29817. /**
  29818. * Are emissive textures enabled in the application.
  29819. */
  29820. static get EmissiveTextureEnabled(): boolean;
  29821. static set EmissiveTextureEnabled(value: boolean);
  29822. private static _SpecularTextureEnabled;
  29823. /**
  29824. * Are specular textures enabled in the application.
  29825. */
  29826. static get SpecularTextureEnabled(): boolean;
  29827. static set SpecularTextureEnabled(value: boolean);
  29828. private static _BumpTextureEnabled;
  29829. /**
  29830. * Are bump textures enabled in the application.
  29831. */
  29832. static get BumpTextureEnabled(): boolean;
  29833. static set BumpTextureEnabled(value: boolean);
  29834. private static _LightmapTextureEnabled;
  29835. /**
  29836. * Are lightmap textures enabled in the application.
  29837. */
  29838. static get LightmapTextureEnabled(): boolean;
  29839. static set LightmapTextureEnabled(value: boolean);
  29840. private static _RefractionTextureEnabled;
  29841. /**
  29842. * Are refraction textures enabled in the application.
  29843. */
  29844. static get RefractionTextureEnabled(): boolean;
  29845. static set RefractionTextureEnabled(value: boolean);
  29846. private static _ColorGradingTextureEnabled;
  29847. /**
  29848. * Are color grading textures enabled in the application.
  29849. */
  29850. static get ColorGradingTextureEnabled(): boolean;
  29851. static set ColorGradingTextureEnabled(value: boolean);
  29852. private static _FresnelEnabled;
  29853. /**
  29854. * Are fresnels enabled in the application.
  29855. */
  29856. static get FresnelEnabled(): boolean;
  29857. static set FresnelEnabled(value: boolean);
  29858. private static _ClearCoatTextureEnabled;
  29859. /**
  29860. * Are clear coat textures enabled in the application.
  29861. */
  29862. static get ClearCoatTextureEnabled(): boolean;
  29863. static set ClearCoatTextureEnabled(value: boolean);
  29864. private static _ClearCoatBumpTextureEnabled;
  29865. /**
  29866. * Are clear coat bump textures enabled in the application.
  29867. */
  29868. static get ClearCoatBumpTextureEnabled(): boolean;
  29869. static set ClearCoatBumpTextureEnabled(value: boolean);
  29870. private static _ClearCoatTintTextureEnabled;
  29871. /**
  29872. * Are clear coat tint textures enabled in the application.
  29873. */
  29874. static get ClearCoatTintTextureEnabled(): boolean;
  29875. static set ClearCoatTintTextureEnabled(value: boolean);
  29876. private static _SheenTextureEnabled;
  29877. /**
  29878. * Are sheen textures enabled in the application.
  29879. */
  29880. static get SheenTextureEnabled(): boolean;
  29881. static set SheenTextureEnabled(value: boolean);
  29882. private static _AnisotropicTextureEnabled;
  29883. /**
  29884. * Are anisotropic textures enabled in the application.
  29885. */
  29886. static get AnisotropicTextureEnabled(): boolean;
  29887. static set AnisotropicTextureEnabled(value: boolean);
  29888. private static _ThicknessTextureEnabled;
  29889. /**
  29890. * Are thickness textures enabled in the application.
  29891. */
  29892. static get ThicknessTextureEnabled(): boolean;
  29893. static set ThicknessTextureEnabled(value: boolean);
  29894. }
  29895. }
  29896. declare module BABYLON {
  29897. /** @hidden */
  29898. export var defaultFragmentDeclaration: {
  29899. name: string;
  29900. shader: string;
  29901. };
  29902. }
  29903. declare module BABYLON {
  29904. /** @hidden */
  29905. export var defaultUboDeclaration: {
  29906. name: string;
  29907. shader: string;
  29908. };
  29909. }
  29910. declare module BABYLON {
  29911. /** @hidden */
  29912. export var prePassDeclaration: {
  29913. name: string;
  29914. shader: string;
  29915. };
  29916. }
  29917. declare module BABYLON {
  29918. /** @hidden */
  29919. export var lightFragmentDeclaration: {
  29920. name: string;
  29921. shader: string;
  29922. };
  29923. }
  29924. declare module BABYLON {
  29925. /** @hidden */
  29926. export var lightUboDeclaration: {
  29927. name: string;
  29928. shader: string;
  29929. };
  29930. }
  29931. declare module BABYLON {
  29932. /** @hidden */
  29933. export var lightsFragmentFunctions: {
  29934. name: string;
  29935. shader: string;
  29936. };
  29937. }
  29938. declare module BABYLON {
  29939. /** @hidden */
  29940. export var shadowsFragmentFunctions: {
  29941. name: string;
  29942. shader: string;
  29943. };
  29944. }
  29945. declare module BABYLON {
  29946. /** @hidden */
  29947. export var fresnelFunction: {
  29948. name: string;
  29949. shader: string;
  29950. };
  29951. }
  29952. declare module BABYLON {
  29953. /** @hidden */
  29954. export var bumpFragmentMainFunctions: {
  29955. name: string;
  29956. shader: string;
  29957. };
  29958. }
  29959. declare module BABYLON {
  29960. /** @hidden */
  29961. export var bumpFragmentFunctions: {
  29962. name: string;
  29963. shader: string;
  29964. };
  29965. }
  29966. declare module BABYLON {
  29967. /** @hidden */
  29968. export var logDepthDeclaration: {
  29969. name: string;
  29970. shader: string;
  29971. };
  29972. }
  29973. declare module BABYLON {
  29974. /** @hidden */
  29975. export var bumpFragment: {
  29976. name: string;
  29977. shader: string;
  29978. };
  29979. }
  29980. declare module BABYLON {
  29981. /** @hidden */
  29982. export var depthPrePass: {
  29983. name: string;
  29984. shader: string;
  29985. };
  29986. }
  29987. declare module BABYLON {
  29988. /** @hidden */
  29989. export var lightFragment: {
  29990. name: string;
  29991. shader: string;
  29992. };
  29993. }
  29994. declare module BABYLON {
  29995. /** @hidden */
  29996. export var logDepthFragment: {
  29997. name: string;
  29998. shader: string;
  29999. };
  30000. }
  30001. declare module BABYLON {
  30002. /** @hidden */
  30003. export var defaultPixelShader: {
  30004. name: string;
  30005. shader: string;
  30006. };
  30007. }
  30008. declare module BABYLON {
  30009. /** @hidden */
  30010. export var defaultVertexDeclaration: {
  30011. name: string;
  30012. shader: string;
  30013. };
  30014. }
  30015. declare module BABYLON {
  30016. /** @hidden */
  30017. export var bumpVertexDeclaration: {
  30018. name: string;
  30019. shader: string;
  30020. };
  30021. }
  30022. declare module BABYLON {
  30023. /** @hidden */
  30024. export var bumpVertex: {
  30025. name: string;
  30026. shader: string;
  30027. };
  30028. }
  30029. declare module BABYLON {
  30030. /** @hidden */
  30031. export var fogVertex: {
  30032. name: string;
  30033. shader: string;
  30034. };
  30035. }
  30036. declare module BABYLON {
  30037. /** @hidden */
  30038. export var shadowsVertex: {
  30039. name: string;
  30040. shader: string;
  30041. };
  30042. }
  30043. declare module BABYLON {
  30044. /** @hidden */
  30045. export var pointCloudVertex: {
  30046. name: string;
  30047. shader: string;
  30048. };
  30049. }
  30050. declare module BABYLON {
  30051. /** @hidden */
  30052. export var logDepthVertex: {
  30053. name: string;
  30054. shader: string;
  30055. };
  30056. }
  30057. declare module BABYLON {
  30058. /** @hidden */
  30059. export var defaultVertexShader: {
  30060. name: string;
  30061. shader: string;
  30062. };
  30063. }
  30064. declare module BABYLON {
  30065. /**
  30066. * @hidden
  30067. */
  30068. export interface IMaterialDetailMapDefines {
  30069. DETAIL: boolean;
  30070. DETAILDIRECTUV: number;
  30071. DETAIL_NORMALBLENDMETHOD: number;
  30072. /** @hidden */
  30073. _areTexturesDirty: boolean;
  30074. }
  30075. /**
  30076. * Define the code related to the detail map parameters of a material
  30077. *
  30078. * Inspired from:
  30079. * 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
  30080. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30081. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30082. */
  30083. export class DetailMapConfiguration {
  30084. private _texture;
  30085. /**
  30086. * The detail texture of the material.
  30087. */
  30088. texture: Nullable<BaseTexture>;
  30089. /**
  30090. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30091. * Bigger values mean stronger blending
  30092. */
  30093. diffuseBlendLevel: number;
  30094. /**
  30095. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30096. * Bigger values mean stronger blending. Only used with PBR materials
  30097. */
  30098. roughnessBlendLevel: number;
  30099. /**
  30100. * Defines how strong the bump effect from the detail map is
  30101. * Bigger values mean stronger effect
  30102. */
  30103. bumpLevel: number;
  30104. private _normalBlendMethod;
  30105. /**
  30106. * The method used to blend the bump and detail normals together
  30107. */
  30108. normalBlendMethod: number;
  30109. private _isEnabled;
  30110. /**
  30111. * Enable or disable the detail map on this material
  30112. */
  30113. isEnabled: boolean;
  30114. /** @hidden */
  30115. private _internalMarkAllSubMeshesAsTexturesDirty;
  30116. /** @hidden */
  30117. _markAllSubMeshesAsTexturesDirty(): void;
  30118. /**
  30119. * Instantiate a new detail map
  30120. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30121. */
  30122. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30123. /**
  30124. * Gets whether the submesh is ready to be used or not.
  30125. * @param defines the list of "defines" to update.
  30126. * @param scene defines the scene the material belongs to.
  30127. * @returns - boolean indicating that the submesh is ready or not.
  30128. */
  30129. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30130. /**
  30131. * Update the defines for detail map usage
  30132. * @param defines the list of "defines" to update.
  30133. * @param scene defines the scene the material belongs to.
  30134. */
  30135. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30136. /**
  30137. * Binds the material data.
  30138. * @param uniformBuffer defines the Uniform buffer to fill in.
  30139. * @param scene defines the scene the material belongs to.
  30140. * @param isFrozen defines whether the material is frozen or not.
  30141. */
  30142. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30143. /**
  30144. * Checks to see if a texture is used in the material.
  30145. * @param texture - Base texture to use.
  30146. * @returns - Boolean specifying if a texture is used in the material.
  30147. */
  30148. hasTexture(texture: BaseTexture): boolean;
  30149. /**
  30150. * Returns an array of the actively used textures.
  30151. * @param activeTextures Array of BaseTextures
  30152. */
  30153. getActiveTextures(activeTextures: BaseTexture[]): void;
  30154. /**
  30155. * Returns the animatable textures.
  30156. * @param animatables Array of animatable textures.
  30157. */
  30158. getAnimatables(animatables: IAnimatable[]): void;
  30159. /**
  30160. * Disposes the resources of the material.
  30161. * @param forceDisposeTextures - Forces the disposal of all textures.
  30162. */
  30163. dispose(forceDisposeTextures?: boolean): void;
  30164. /**
  30165. * Get the current class name useful for serialization or dynamic coding.
  30166. * @returns "DetailMap"
  30167. */
  30168. getClassName(): string;
  30169. /**
  30170. * Add the required uniforms to the current list.
  30171. * @param uniforms defines the current uniform list.
  30172. */
  30173. static AddUniforms(uniforms: string[]): void;
  30174. /**
  30175. * Add the required samplers to the current list.
  30176. * @param samplers defines the current sampler list.
  30177. */
  30178. static AddSamplers(samplers: string[]): void;
  30179. /**
  30180. * Add the required uniforms to the current buffer.
  30181. * @param uniformBuffer defines the current uniform buffer.
  30182. */
  30183. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30184. /**
  30185. * Makes a duplicate of the current instance into another one.
  30186. * @param detailMap define the instance where to copy the info
  30187. */
  30188. copyTo(detailMap: DetailMapConfiguration): void;
  30189. /**
  30190. * Serializes this detail map instance
  30191. * @returns - An object with the serialized instance.
  30192. */
  30193. serialize(): any;
  30194. /**
  30195. * Parses a detail map setting from a serialized object.
  30196. * @param source - Serialized object.
  30197. * @param scene Defines the scene we are parsing for
  30198. * @param rootUrl Defines the rootUrl to load from
  30199. */
  30200. parse(source: any, scene: Scene, rootUrl: string): void;
  30201. }
  30202. }
  30203. declare module BABYLON {
  30204. /** @hidden */
  30205. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30206. MAINUV1: boolean;
  30207. MAINUV2: boolean;
  30208. DIFFUSE: boolean;
  30209. DIFFUSEDIRECTUV: number;
  30210. DETAIL: boolean;
  30211. DETAILDIRECTUV: number;
  30212. DETAIL_NORMALBLENDMETHOD: number;
  30213. AMBIENT: boolean;
  30214. AMBIENTDIRECTUV: number;
  30215. OPACITY: boolean;
  30216. OPACITYDIRECTUV: number;
  30217. OPACITYRGB: boolean;
  30218. REFLECTION: boolean;
  30219. EMISSIVE: boolean;
  30220. EMISSIVEDIRECTUV: number;
  30221. SPECULAR: boolean;
  30222. SPECULARDIRECTUV: number;
  30223. BUMP: boolean;
  30224. BUMPDIRECTUV: number;
  30225. PARALLAX: boolean;
  30226. PARALLAXOCCLUSION: boolean;
  30227. SPECULAROVERALPHA: boolean;
  30228. CLIPPLANE: boolean;
  30229. CLIPPLANE2: boolean;
  30230. CLIPPLANE3: boolean;
  30231. CLIPPLANE4: boolean;
  30232. CLIPPLANE5: boolean;
  30233. CLIPPLANE6: boolean;
  30234. ALPHATEST: boolean;
  30235. DEPTHPREPASS: boolean;
  30236. ALPHAFROMDIFFUSE: boolean;
  30237. POINTSIZE: boolean;
  30238. FOG: boolean;
  30239. SPECULARTERM: boolean;
  30240. DIFFUSEFRESNEL: boolean;
  30241. OPACITYFRESNEL: boolean;
  30242. REFLECTIONFRESNEL: boolean;
  30243. REFRACTIONFRESNEL: boolean;
  30244. EMISSIVEFRESNEL: boolean;
  30245. FRESNEL: boolean;
  30246. NORMAL: boolean;
  30247. UV1: boolean;
  30248. UV2: boolean;
  30249. VERTEXCOLOR: boolean;
  30250. VERTEXALPHA: boolean;
  30251. NUM_BONE_INFLUENCERS: number;
  30252. BonesPerMesh: number;
  30253. BONETEXTURE: boolean;
  30254. INSTANCES: boolean;
  30255. THIN_INSTANCES: boolean;
  30256. GLOSSINESS: boolean;
  30257. ROUGHNESS: boolean;
  30258. EMISSIVEASILLUMINATION: boolean;
  30259. LINKEMISSIVEWITHDIFFUSE: boolean;
  30260. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30261. LIGHTMAP: boolean;
  30262. LIGHTMAPDIRECTUV: number;
  30263. OBJECTSPACE_NORMALMAP: boolean;
  30264. USELIGHTMAPASSHADOWMAP: boolean;
  30265. REFLECTIONMAP_3D: boolean;
  30266. REFLECTIONMAP_SPHERICAL: boolean;
  30267. REFLECTIONMAP_PLANAR: boolean;
  30268. REFLECTIONMAP_CUBIC: boolean;
  30269. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30270. REFLECTIONMAP_PROJECTION: boolean;
  30271. REFLECTIONMAP_SKYBOX: boolean;
  30272. REFLECTIONMAP_EXPLICIT: boolean;
  30273. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30274. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30275. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30276. INVERTCUBICMAP: boolean;
  30277. LOGARITHMICDEPTH: boolean;
  30278. REFRACTION: boolean;
  30279. REFRACTIONMAP_3D: boolean;
  30280. REFLECTIONOVERALPHA: boolean;
  30281. TWOSIDEDLIGHTING: boolean;
  30282. SHADOWFLOAT: boolean;
  30283. MORPHTARGETS: boolean;
  30284. MORPHTARGETS_NORMAL: boolean;
  30285. MORPHTARGETS_TANGENT: boolean;
  30286. MORPHTARGETS_UV: boolean;
  30287. NUM_MORPH_INFLUENCERS: number;
  30288. NONUNIFORMSCALING: boolean;
  30289. PREMULTIPLYALPHA: boolean;
  30290. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30291. ALPHABLEND: boolean;
  30292. PREPASS: boolean;
  30293. SCENE_MRT_COUNT: number;
  30294. RGBDLIGHTMAP: boolean;
  30295. RGBDREFLECTION: boolean;
  30296. RGBDREFRACTION: boolean;
  30297. IMAGEPROCESSING: boolean;
  30298. VIGNETTE: boolean;
  30299. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30300. VIGNETTEBLENDMODEOPAQUE: boolean;
  30301. TONEMAPPING: boolean;
  30302. TONEMAPPING_ACES: boolean;
  30303. CONTRAST: boolean;
  30304. COLORCURVES: boolean;
  30305. COLORGRADING: boolean;
  30306. COLORGRADING3D: boolean;
  30307. SAMPLER3DGREENDEPTH: boolean;
  30308. SAMPLER3DBGRMAP: boolean;
  30309. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30310. MULTIVIEW: boolean;
  30311. /**
  30312. * If the reflection texture on this material is in linear color space
  30313. * @hidden
  30314. */
  30315. IS_REFLECTION_LINEAR: boolean;
  30316. /**
  30317. * If the refraction texture on this material is in linear color space
  30318. * @hidden
  30319. */
  30320. IS_REFRACTION_LINEAR: boolean;
  30321. EXPOSURE: boolean;
  30322. constructor();
  30323. setReflectionMode(modeToEnable: string): void;
  30324. }
  30325. /**
  30326. * This is the default material used in Babylon. It is the best trade off between quality
  30327. * and performances.
  30328. * @see https://doc.babylonjs.com/babylon101/materials
  30329. */
  30330. export class StandardMaterial extends PushMaterial {
  30331. private _diffuseTexture;
  30332. /**
  30333. * The basic texture of the material as viewed under a light.
  30334. */
  30335. diffuseTexture: Nullable<BaseTexture>;
  30336. private _ambientTexture;
  30337. /**
  30338. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30339. */
  30340. ambientTexture: Nullable<BaseTexture>;
  30341. private _opacityTexture;
  30342. /**
  30343. * Define the transparency of the material from a texture.
  30344. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30345. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30346. */
  30347. opacityTexture: Nullable<BaseTexture>;
  30348. private _reflectionTexture;
  30349. /**
  30350. * Define the texture used to display the reflection.
  30351. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30352. */
  30353. reflectionTexture: Nullable<BaseTexture>;
  30354. private _emissiveTexture;
  30355. /**
  30356. * Define texture of the material as if self lit.
  30357. * This will be mixed in the final result even in the absence of light.
  30358. */
  30359. emissiveTexture: Nullable<BaseTexture>;
  30360. private _specularTexture;
  30361. /**
  30362. * Define how the color and intensity of the highlight given by the light in the material.
  30363. */
  30364. specularTexture: Nullable<BaseTexture>;
  30365. private _bumpTexture;
  30366. /**
  30367. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30368. * 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.
  30369. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30370. */
  30371. bumpTexture: Nullable<BaseTexture>;
  30372. private _lightmapTexture;
  30373. /**
  30374. * Complex lighting can be computationally expensive to compute at runtime.
  30375. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30376. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30377. */
  30378. lightmapTexture: Nullable<BaseTexture>;
  30379. private _refractionTexture;
  30380. /**
  30381. * Define the texture used to display the refraction.
  30382. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30383. */
  30384. refractionTexture: Nullable<BaseTexture>;
  30385. /**
  30386. * The color of the material lit by the environmental background lighting.
  30387. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30388. */
  30389. ambientColor: Color3;
  30390. /**
  30391. * The basic color of the material as viewed under a light.
  30392. */
  30393. diffuseColor: Color3;
  30394. /**
  30395. * Define how the color and intensity of the highlight given by the light in the material.
  30396. */
  30397. specularColor: Color3;
  30398. /**
  30399. * Define the color of the material as if self lit.
  30400. * This will be mixed in the final result even in the absence of light.
  30401. */
  30402. emissiveColor: Color3;
  30403. /**
  30404. * Defines how sharp are the highlights in the material.
  30405. * The bigger the value the sharper giving a more glossy feeling to the result.
  30406. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30407. */
  30408. specularPower: number;
  30409. private _useAlphaFromDiffuseTexture;
  30410. /**
  30411. * Does the transparency come from the diffuse texture alpha channel.
  30412. */
  30413. useAlphaFromDiffuseTexture: boolean;
  30414. private _useEmissiveAsIllumination;
  30415. /**
  30416. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30417. */
  30418. useEmissiveAsIllumination: boolean;
  30419. private _linkEmissiveWithDiffuse;
  30420. /**
  30421. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30422. * the emissive level when the final color is close to one.
  30423. */
  30424. linkEmissiveWithDiffuse: boolean;
  30425. private _useSpecularOverAlpha;
  30426. /**
  30427. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30428. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30429. */
  30430. useSpecularOverAlpha: boolean;
  30431. private _useReflectionOverAlpha;
  30432. /**
  30433. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30434. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30435. */
  30436. useReflectionOverAlpha: boolean;
  30437. private _disableLighting;
  30438. /**
  30439. * Does lights from the scene impacts this material.
  30440. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30441. */
  30442. disableLighting: boolean;
  30443. private _useObjectSpaceNormalMap;
  30444. /**
  30445. * Allows using an object space normal map (instead of tangent space).
  30446. */
  30447. useObjectSpaceNormalMap: boolean;
  30448. private _useParallax;
  30449. /**
  30450. * Is parallax enabled or not.
  30451. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30452. */
  30453. useParallax: boolean;
  30454. private _useParallaxOcclusion;
  30455. /**
  30456. * Is parallax occlusion enabled or not.
  30457. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30458. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30459. */
  30460. useParallaxOcclusion: boolean;
  30461. /**
  30462. * 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.
  30463. */
  30464. parallaxScaleBias: number;
  30465. private _roughness;
  30466. /**
  30467. * Helps to define how blurry the reflections should appears in the material.
  30468. */
  30469. roughness: number;
  30470. /**
  30471. * In case of refraction, define the value of the index of refraction.
  30472. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30473. */
  30474. indexOfRefraction: number;
  30475. /**
  30476. * Invert the refraction texture alongside the y axis.
  30477. * It can be useful with procedural textures or probe for instance.
  30478. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30479. */
  30480. invertRefractionY: boolean;
  30481. /**
  30482. * Defines the alpha limits in alpha test mode.
  30483. */
  30484. alphaCutOff: number;
  30485. private _useLightmapAsShadowmap;
  30486. /**
  30487. * In case of light mapping, define whether the map contains light or shadow informations.
  30488. */
  30489. useLightmapAsShadowmap: boolean;
  30490. private _diffuseFresnelParameters;
  30491. /**
  30492. * Define the diffuse fresnel parameters of the material.
  30493. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30494. */
  30495. diffuseFresnelParameters: FresnelParameters;
  30496. private _opacityFresnelParameters;
  30497. /**
  30498. * Define the opacity fresnel parameters of the material.
  30499. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30500. */
  30501. opacityFresnelParameters: FresnelParameters;
  30502. private _reflectionFresnelParameters;
  30503. /**
  30504. * Define the reflection fresnel parameters of the material.
  30505. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30506. */
  30507. reflectionFresnelParameters: FresnelParameters;
  30508. private _refractionFresnelParameters;
  30509. /**
  30510. * Define the refraction fresnel parameters of the material.
  30511. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30512. */
  30513. refractionFresnelParameters: FresnelParameters;
  30514. private _emissiveFresnelParameters;
  30515. /**
  30516. * Define the emissive fresnel parameters of the material.
  30517. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30518. */
  30519. emissiveFresnelParameters: FresnelParameters;
  30520. private _useReflectionFresnelFromSpecular;
  30521. /**
  30522. * If true automatically deducts the fresnels values from the material specularity.
  30523. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30524. */
  30525. useReflectionFresnelFromSpecular: boolean;
  30526. private _useGlossinessFromSpecularMapAlpha;
  30527. /**
  30528. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30529. */
  30530. useGlossinessFromSpecularMapAlpha: boolean;
  30531. private _maxSimultaneousLights;
  30532. /**
  30533. * Defines the maximum number of lights that can be used in the material
  30534. */
  30535. maxSimultaneousLights: number;
  30536. private _invertNormalMapX;
  30537. /**
  30538. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30539. */
  30540. invertNormalMapX: boolean;
  30541. private _invertNormalMapY;
  30542. /**
  30543. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30544. */
  30545. invertNormalMapY: boolean;
  30546. private _twoSidedLighting;
  30547. /**
  30548. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30549. */
  30550. twoSidedLighting: boolean;
  30551. /**
  30552. * Default configuration related to image processing available in the standard Material.
  30553. */
  30554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30555. /**
  30556. * Gets the image processing configuration used either in this material.
  30557. */
  30558. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30559. /**
  30560. * Sets the Default image processing configuration used either in the this material.
  30561. *
  30562. * If sets to null, the scene one is in use.
  30563. */
  30564. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30565. /**
  30566. * Keep track of the image processing observer to allow dispose and replace.
  30567. */
  30568. private _imageProcessingObserver;
  30569. /**
  30570. * Attaches a new image processing configuration to the Standard Material.
  30571. * @param configuration
  30572. */
  30573. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30574. /**
  30575. * Gets wether the color curves effect is enabled.
  30576. */
  30577. get cameraColorCurvesEnabled(): boolean;
  30578. /**
  30579. * Sets wether the color curves effect is enabled.
  30580. */
  30581. set cameraColorCurvesEnabled(value: boolean);
  30582. /**
  30583. * Gets wether the color grading effect is enabled.
  30584. */
  30585. get cameraColorGradingEnabled(): boolean;
  30586. /**
  30587. * Gets wether the color grading effect is enabled.
  30588. */
  30589. set cameraColorGradingEnabled(value: boolean);
  30590. /**
  30591. * Gets wether tonemapping is enabled or not.
  30592. */
  30593. get cameraToneMappingEnabled(): boolean;
  30594. /**
  30595. * Sets wether tonemapping is enabled or not
  30596. */
  30597. set cameraToneMappingEnabled(value: boolean);
  30598. /**
  30599. * The camera exposure used on this material.
  30600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30601. * This corresponds to a photographic exposure.
  30602. */
  30603. get cameraExposure(): number;
  30604. /**
  30605. * The camera exposure used on this material.
  30606. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30607. * This corresponds to a photographic exposure.
  30608. */
  30609. set cameraExposure(value: number);
  30610. /**
  30611. * Gets The camera contrast used on this material.
  30612. */
  30613. get cameraContrast(): number;
  30614. /**
  30615. * Sets The camera contrast used on this material.
  30616. */
  30617. set cameraContrast(value: number);
  30618. /**
  30619. * Gets the Color Grading 2D Lookup Texture.
  30620. */
  30621. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30622. /**
  30623. * Sets the Color Grading 2D Lookup Texture.
  30624. */
  30625. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30626. /**
  30627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30629. * 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;
  30630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30631. */
  30632. get cameraColorCurves(): Nullable<ColorCurves>;
  30633. /**
  30634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30636. * 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;
  30637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30638. */
  30639. set cameraColorCurves(value: Nullable<ColorCurves>);
  30640. /**
  30641. * Can this material render to several textures at once
  30642. */
  30643. get canRenderToMRT(): boolean;
  30644. /**
  30645. * Defines the detail map parameters for the material.
  30646. */
  30647. readonly detailMap: DetailMapConfiguration;
  30648. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30649. protected _worldViewProjectionMatrix: Matrix;
  30650. protected _globalAmbientColor: Color3;
  30651. protected _useLogarithmicDepth: boolean;
  30652. protected _rebuildInParallel: boolean;
  30653. /**
  30654. * Instantiates a new standard material.
  30655. * This is the default material used in Babylon. It is the best trade off between quality
  30656. * and performances.
  30657. * @see https://doc.babylonjs.com/babylon101/materials
  30658. * @param name Define the name of the material in the scene
  30659. * @param scene Define the scene the material belong to
  30660. */
  30661. constructor(name: string, scene: Scene);
  30662. /**
  30663. * Gets a boolean indicating that current material needs to register RTT
  30664. */
  30665. get hasRenderTargetTextures(): boolean;
  30666. /**
  30667. * Gets the current class name of the material e.g. "StandardMaterial"
  30668. * Mainly use in serialization.
  30669. * @returns the class name
  30670. */
  30671. getClassName(): string;
  30672. /**
  30673. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30674. * You can try switching to logarithmic depth.
  30675. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30676. */
  30677. get useLogarithmicDepth(): boolean;
  30678. set useLogarithmicDepth(value: boolean);
  30679. /**
  30680. * Specifies if the material will require alpha blending
  30681. * @returns a boolean specifying if alpha blending is needed
  30682. */
  30683. needAlphaBlending(): boolean;
  30684. /**
  30685. * Specifies if this material should be rendered in alpha test mode
  30686. * @returns a boolean specifying if an alpha test is needed.
  30687. */
  30688. needAlphaTesting(): boolean;
  30689. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30690. /**
  30691. * Get the texture used for alpha test purpose.
  30692. * @returns the diffuse texture in case of the standard material.
  30693. */
  30694. getAlphaTestTexture(): Nullable<BaseTexture>;
  30695. /**
  30696. * Get if the submesh is ready to be used and all its information available.
  30697. * Child classes can use it to update shaders
  30698. * @param mesh defines the mesh to check
  30699. * @param subMesh defines which submesh to check
  30700. * @param useInstances specifies that instances should be used
  30701. * @returns a boolean indicating that the submesh is ready or not
  30702. */
  30703. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30704. /**
  30705. * Builds the material UBO layouts.
  30706. * Used internally during the effect preparation.
  30707. */
  30708. buildUniformLayout(): void;
  30709. /**
  30710. * Unbinds the material from the mesh
  30711. */
  30712. unbind(): void;
  30713. /**
  30714. * Binds the submesh to this material by preparing the effect and shader to draw
  30715. * @param world defines the world transformation matrix
  30716. * @param mesh defines the mesh containing the submesh
  30717. * @param subMesh defines the submesh to bind the material to
  30718. */
  30719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30720. /**
  30721. * Get the list of animatables in the material.
  30722. * @returns the list of animatables object used in the material
  30723. */
  30724. getAnimatables(): IAnimatable[];
  30725. /**
  30726. * Gets the active textures from the material
  30727. * @returns an array of textures
  30728. */
  30729. getActiveTextures(): BaseTexture[];
  30730. /**
  30731. * Specifies if the material uses a texture
  30732. * @param texture defines the texture to check against the material
  30733. * @returns a boolean specifying if the material uses the texture
  30734. */
  30735. hasTexture(texture: BaseTexture): boolean;
  30736. /**
  30737. * Disposes the material
  30738. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30739. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30740. */
  30741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30742. /**
  30743. * Makes a duplicate of the material, and gives it a new name
  30744. * @param name defines the new name for the duplicated material
  30745. * @returns the cloned material
  30746. */
  30747. clone(name: string): StandardMaterial;
  30748. /**
  30749. * Serializes this material in a JSON representation
  30750. * @returns the serialized material object
  30751. */
  30752. serialize(): any;
  30753. /**
  30754. * Creates a standard material from parsed material data
  30755. * @param source defines the JSON representation of the material
  30756. * @param scene defines the hosting scene
  30757. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30758. * @returns a new standard material
  30759. */
  30760. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30761. /**
  30762. * Are diffuse textures enabled in the application.
  30763. */
  30764. static get DiffuseTextureEnabled(): boolean;
  30765. static set DiffuseTextureEnabled(value: boolean);
  30766. /**
  30767. * Are detail textures enabled in the application.
  30768. */
  30769. static get DetailTextureEnabled(): boolean;
  30770. static set DetailTextureEnabled(value: boolean);
  30771. /**
  30772. * Are ambient textures enabled in the application.
  30773. */
  30774. static get AmbientTextureEnabled(): boolean;
  30775. static set AmbientTextureEnabled(value: boolean);
  30776. /**
  30777. * Are opacity textures enabled in the application.
  30778. */
  30779. static get OpacityTextureEnabled(): boolean;
  30780. static set OpacityTextureEnabled(value: boolean);
  30781. /**
  30782. * Are reflection textures enabled in the application.
  30783. */
  30784. static get ReflectionTextureEnabled(): boolean;
  30785. static set ReflectionTextureEnabled(value: boolean);
  30786. /**
  30787. * Are emissive textures enabled in the application.
  30788. */
  30789. static get EmissiveTextureEnabled(): boolean;
  30790. static set EmissiveTextureEnabled(value: boolean);
  30791. /**
  30792. * Are specular textures enabled in the application.
  30793. */
  30794. static get SpecularTextureEnabled(): boolean;
  30795. static set SpecularTextureEnabled(value: boolean);
  30796. /**
  30797. * Are bump textures enabled in the application.
  30798. */
  30799. static get BumpTextureEnabled(): boolean;
  30800. static set BumpTextureEnabled(value: boolean);
  30801. /**
  30802. * Are lightmap textures enabled in the application.
  30803. */
  30804. static get LightmapTextureEnabled(): boolean;
  30805. static set LightmapTextureEnabled(value: boolean);
  30806. /**
  30807. * Are refraction textures enabled in the application.
  30808. */
  30809. static get RefractionTextureEnabled(): boolean;
  30810. static set RefractionTextureEnabled(value: boolean);
  30811. /**
  30812. * Are color grading textures enabled in the application.
  30813. */
  30814. static get ColorGradingTextureEnabled(): boolean;
  30815. static set ColorGradingTextureEnabled(value: boolean);
  30816. /**
  30817. * Are fresnels enabled in the application.
  30818. */
  30819. static get FresnelEnabled(): boolean;
  30820. static set FresnelEnabled(value: boolean);
  30821. }
  30822. }
  30823. declare module BABYLON {
  30824. /**
  30825. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30826. *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.
  30827. * The SPS is also a particle system. It provides some methods to manage the particles.
  30828. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30829. *
  30830. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30831. */
  30832. export class SolidParticleSystem implements IDisposable {
  30833. /**
  30834. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30835. * Example : var p = SPS.particles[i];
  30836. */
  30837. particles: SolidParticle[];
  30838. /**
  30839. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30840. */
  30841. nbParticles: number;
  30842. /**
  30843. * If the particles must ever face the camera (default false). Useful for planar particles.
  30844. */
  30845. billboard: boolean;
  30846. /**
  30847. * Recompute normals when adding a shape
  30848. */
  30849. recomputeNormals: boolean;
  30850. /**
  30851. * This a counter ofr your own usage. It's not set by any SPS functions.
  30852. */
  30853. counter: number;
  30854. /**
  30855. * The SPS name. This name is also given to the underlying mesh.
  30856. */
  30857. name: string;
  30858. /**
  30859. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30860. */
  30861. mesh: Mesh;
  30862. /**
  30863. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30864. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30865. */
  30866. vars: any;
  30867. /**
  30868. * This array is populated when the SPS is set as 'pickable'.
  30869. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30870. * Each element of this array is an object `{idx: int, faceId: int}`.
  30871. * `idx` is the picked particle index in the `SPS.particles` array
  30872. * `faceId` is the picked face index counted within this particle.
  30873. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30874. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30875. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30876. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30877. */
  30878. pickedParticles: {
  30879. idx: number;
  30880. faceId: number;
  30881. }[];
  30882. /**
  30883. * This array is populated when the SPS is set as 'pickable'
  30884. * Each key of this array is a submesh index.
  30885. * Each element of this array is a second array defined like this :
  30886. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30887. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30888. * `idx` is the picked particle index in the `SPS.particles` array
  30889. * `faceId` is the picked face index counted within this particle.
  30890. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30891. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30892. */
  30893. pickedBySubMesh: {
  30894. idx: number;
  30895. faceId: number;
  30896. }[][];
  30897. /**
  30898. * This array is populated when `enableDepthSort` is set to true.
  30899. * Each element of this array is an instance of the class DepthSortedParticle.
  30900. */
  30901. depthSortedParticles: DepthSortedParticle[];
  30902. /**
  30903. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30904. * @hidden
  30905. */
  30906. _bSphereOnly: boolean;
  30907. /**
  30908. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30909. * @hidden
  30910. */
  30911. _bSphereRadiusFactor: number;
  30912. private _scene;
  30913. private _positions;
  30914. private _indices;
  30915. private _normals;
  30916. private _colors;
  30917. private _uvs;
  30918. private _indices32;
  30919. private _positions32;
  30920. private _normals32;
  30921. private _fixedNormal32;
  30922. private _colors32;
  30923. private _uvs32;
  30924. private _index;
  30925. private _updatable;
  30926. private _pickable;
  30927. private _isVisibilityBoxLocked;
  30928. private _alwaysVisible;
  30929. private _depthSort;
  30930. private _expandable;
  30931. private _shapeCounter;
  30932. private _copy;
  30933. private _color;
  30934. private _computeParticleColor;
  30935. private _computeParticleTexture;
  30936. private _computeParticleRotation;
  30937. private _computeParticleVertex;
  30938. private _computeBoundingBox;
  30939. private _depthSortParticles;
  30940. private _camera;
  30941. private _mustUnrotateFixedNormals;
  30942. private _particlesIntersect;
  30943. private _needs32Bits;
  30944. private _isNotBuilt;
  30945. private _lastParticleId;
  30946. private _idxOfId;
  30947. private _multimaterialEnabled;
  30948. private _useModelMaterial;
  30949. private _indicesByMaterial;
  30950. private _materialIndexes;
  30951. private _depthSortFunction;
  30952. private _materialSortFunction;
  30953. private _materials;
  30954. private _multimaterial;
  30955. private _materialIndexesById;
  30956. private _defaultMaterial;
  30957. private _autoUpdateSubMeshes;
  30958. private _tmpVertex;
  30959. /**
  30960. * Creates a SPS (Solid Particle System) object.
  30961. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30962. * @param scene (Scene) is the scene in which the SPS is added.
  30963. * @param options defines the options of the sps e.g.
  30964. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30965. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30966. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30967. * * 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.
  30968. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30969. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30970. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30971. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30972. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30973. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30974. */
  30975. constructor(name: string, scene: Scene, options?: {
  30976. updatable?: boolean;
  30977. isPickable?: boolean;
  30978. enableDepthSort?: boolean;
  30979. particleIntersection?: boolean;
  30980. boundingSphereOnly?: boolean;
  30981. bSphereRadiusFactor?: number;
  30982. expandable?: boolean;
  30983. useModelMaterial?: boolean;
  30984. enableMultiMaterial?: boolean;
  30985. });
  30986. /**
  30987. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30988. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30989. * @returns the created mesh
  30990. */
  30991. buildMesh(): Mesh;
  30992. /**
  30993. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30994. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30995. * Thus the particles generated from `digest()` have their property `position` set yet.
  30996. * @param mesh ( Mesh ) is the mesh to be digested
  30997. * @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
  30998. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30999. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31000. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31001. * @returns the current SPS
  31002. */
  31003. digest(mesh: Mesh, options?: {
  31004. facetNb?: number;
  31005. number?: number;
  31006. delta?: number;
  31007. storage?: [];
  31008. }): SolidParticleSystem;
  31009. /**
  31010. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31011. * @hidden
  31012. */
  31013. private _unrotateFixedNormals;
  31014. /**
  31015. * Resets the temporary working copy particle
  31016. * @hidden
  31017. */
  31018. private _resetCopy;
  31019. /**
  31020. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31021. * @param p the current index in the positions array to be updated
  31022. * @param ind the current index in the indices array
  31023. * @param shape a Vector3 array, the shape geometry
  31024. * @param positions the positions array to be updated
  31025. * @param meshInd the shape indices array
  31026. * @param indices the indices array to be updated
  31027. * @param meshUV the shape uv array
  31028. * @param uvs the uv array to be updated
  31029. * @param meshCol the shape color array
  31030. * @param colors the color array to be updated
  31031. * @param meshNor the shape normals array
  31032. * @param normals the normals array to be updated
  31033. * @param idx the particle index
  31034. * @param idxInShape the particle index in its shape
  31035. * @param options the addShape() method passed options
  31036. * @model the particle model
  31037. * @hidden
  31038. */
  31039. private _meshBuilder;
  31040. /**
  31041. * Returns a shape Vector3 array from positions float array
  31042. * @param positions float array
  31043. * @returns a vector3 array
  31044. * @hidden
  31045. */
  31046. private _posToShape;
  31047. /**
  31048. * Returns a shapeUV array from a float uvs (array deep copy)
  31049. * @param uvs as a float array
  31050. * @returns a shapeUV array
  31051. * @hidden
  31052. */
  31053. private _uvsToShapeUV;
  31054. /**
  31055. * Adds a new particle object in the particles array
  31056. * @param idx particle index in particles array
  31057. * @param id particle id
  31058. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31059. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31060. * @param model particle ModelShape object
  31061. * @param shapeId model shape identifier
  31062. * @param idxInShape index of the particle in the current model
  31063. * @param bInfo model bounding info object
  31064. * @param storage target storage array, if any
  31065. * @hidden
  31066. */
  31067. private _addParticle;
  31068. /**
  31069. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31070. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31071. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31072. * @param nb (positive integer) the number of particles to be created from this model
  31073. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31074. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31075. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31076. * @returns the number of shapes in the system
  31077. */
  31078. addShape(mesh: Mesh, nb: number, options?: {
  31079. positionFunction?: any;
  31080. vertexFunction?: any;
  31081. storage?: [];
  31082. }): number;
  31083. /**
  31084. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31085. * @hidden
  31086. */
  31087. private _rebuildParticle;
  31088. /**
  31089. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31090. * @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.
  31091. * @returns the SPS.
  31092. */
  31093. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31094. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31095. * Returns an array with the removed particles.
  31096. * 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.
  31097. * The SPS can't be empty so at least one particle needs to remain in place.
  31098. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31099. * @param start index of the first particle to remove
  31100. * @param end index of the last particle to remove (included)
  31101. * @returns an array populated with the removed particles
  31102. */
  31103. removeParticles(start: number, end: number): SolidParticle[];
  31104. /**
  31105. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31106. * @param solidParticleArray an array populated with Solid Particles objects
  31107. * @returns the SPS
  31108. */
  31109. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31110. /**
  31111. * Creates a new particle and modifies the SPS mesh geometry :
  31112. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31113. * - calls _addParticle() to populate the particle array
  31114. * factorized code from addShape() and insertParticlesFromArray()
  31115. * @param idx particle index in the particles array
  31116. * @param i particle index in its shape
  31117. * @param modelShape particle ModelShape object
  31118. * @param shape shape vertex array
  31119. * @param meshInd shape indices array
  31120. * @param meshUV shape uv array
  31121. * @param meshCol shape color array
  31122. * @param meshNor shape normals array
  31123. * @param bbInfo shape bounding info
  31124. * @param storage target particle storage
  31125. * @options addShape() passed options
  31126. * @hidden
  31127. */
  31128. private _insertNewParticle;
  31129. /**
  31130. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31131. * This method calls `updateParticle()` for each particle of the SPS.
  31132. * For an animated SPS, it is usually called within the render loop.
  31133. * 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.
  31134. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31135. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31136. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31137. * @returns the SPS.
  31138. */
  31139. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31140. /**
  31141. * Disposes the SPS.
  31142. */
  31143. dispose(): void;
  31144. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31145. * idx is the particle index in the SPS
  31146. * faceId is the picked face index counted within this particle.
  31147. * Returns null if the pickInfo can't identify a picked particle.
  31148. * @param pickingInfo (PickingInfo object)
  31149. * @returns {idx: number, faceId: number} or null
  31150. */
  31151. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31152. idx: number;
  31153. faceId: number;
  31154. }>;
  31155. /**
  31156. * Returns a SolidParticle object from its identifier : particle.id
  31157. * @param id (integer) the particle Id
  31158. * @returns the searched particle or null if not found in the SPS.
  31159. */
  31160. getParticleById(id: number): Nullable<SolidParticle>;
  31161. /**
  31162. * Returns a new array populated with the particles having the passed shapeId.
  31163. * @param shapeId (integer) the shape identifier
  31164. * @returns a new solid particle array
  31165. */
  31166. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31167. /**
  31168. * Populates the passed array "ref" with the particles having the passed shapeId.
  31169. * @param shapeId the shape identifier
  31170. * @returns the SPS
  31171. * @param ref
  31172. */
  31173. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31174. /**
  31175. * Computes the required SubMeshes according the materials assigned to the particles.
  31176. * @returns the solid particle system.
  31177. * Does nothing if called before the SPS mesh is built.
  31178. */
  31179. computeSubMeshes(): SolidParticleSystem;
  31180. /**
  31181. * Sorts the solid particles by material when MultiMaterial is enabled.
  31182. * Updates the indices32 array.
  31183. * Updates the indicesByMaterial array.
  31184. * Updates the mesh indices array.
  31185. * @returns the SPS
  31186. * @hidden
  31187. */
  31188. private _sortParticlesByMaterial;
  31189. /**
  31190. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31191. * @hidden
  31192. */
  31193. private _setMaterialIndexesById;
  31194. /**
  31195. * Returns an array with unique values of Materials from the passed array
  31196. * @param array the material array to be checked and filtered
  31197. * @hidden
  31198. */
  31199. private _filterUniqueMaterialId;
  31200. /**
  31201. * Sets a new Standard Material as _defaultMaterial if not already set.
  31202. * @hidden
  31203. */
  31204. private _setDefaultMaterial;
  31205. /**
  31206. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31207. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31208. * @returns the SPS.
  31209. */
  31210. refreshVisibleSize(): SolidParticleSystem;
  31211. /**
  31212. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31213. * @param size the size (float) of the visibility box
  31214. * note : this doesn't lock the SPS mesh bounding box.
  31215. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31216. */
  31217. setVisibilityBox(size: number): void;
  31218. /**
  31219. * Gets whether the SPS as always visible or not
  31220. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31221. */
  31222. get isAlwaysVisible(): boolean;
  31223. /**
  31224. * Sets the SPS as always visible or not
  31225. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31226. */
  31227. set isAlwaysVisible(val: boolean);
  31228. /**
  31229. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31230. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31231. */
  31232. set isVisibilityBoxLocked(val: boolean);
  31233. /**
  31234. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31235. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31236. */
  31237. get isVisibilityBoxLocked(): boolean;
  31238. /**
  31239. * Tells to `setParticles()` to compute the particle rotations or not.
  31240. * Default value : true. The SPS is faster when it's set to false.
  31241. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31242. */
  31243. set computeParticleRotation(val: boolean);
  31244. /**
  31245. * Tells to `setParticles()` to compute the particle colors or not.
  31246. * Default value : true. The SPS is faster when it's set to false.
  31247. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31248. */
  31249. set computeParticleColor(val: boolean);
  31250. set computeParticleTexture(val: boolean);
  31251. /**
  31252. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31253. * Default value : false. The SPS is faster when it's set to false.
  31254. * Note : the particle custom vertex positions aren't stored values.
  31255. */
  31256. set computeParticleVertex(val: boolean);
  31257. /**
  31258. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31259. */
  31260. set computeBoundingBox(val: boolean);
  31261. /**
  31262. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31263. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31264. * Default : `true`
  31265. */
  31266. set depthSortParticles(val: boolean);
  31267. /**
  31268. * Gets if `setParticles()` computes the particle rotations or not.
  31269. * Default value : true. The SPS is faster when it's set to false.
  31270. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31271. */
  31272. get computeParticleRotation(): boolean;
  31273. /**
  31274. * Gets if `setParticles()` computes the particle colors or not.
  31275. * Default value : true. The SPS is faster when it's set to false.
  31276. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31277. */
  31278. get computeParticleColor(): boolean;
  31279. /**
  31280. * Gets if `setParticles()` computes the particle textures or not.
  31281. * Default value : true. The SPS is faster when it's set to false.
  31282. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31283. */
  31284. get computeParticleTexture(): boolean;
  31285. /**
  31286. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31287. * Default value : false. The SPS is faster when it's set to false.
  31288. * Note : the particle custom vertex positions aren't stored values.
  31289. */
  31290. get computeParticleVertex(): boolean;
  31291. /**
  31292. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31293. */
  31294. get computeBoundingBox(): boolean;
  31295. /**
  31296. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31297. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31298. * Default : `true`
  31299. */
  31300. get depthSortParticles(): boolean;
  31301. /**
  31302. * Gets if the SPS is created as expandable at construction time.
  31303. * Default : `false`
  31304. */
  31305. get expandable(): boolean;
  31306. /**
  31307. * Gets if the SPS supports the Multi Materials
  31308. */
  31309. get multimaterialEnabled(): boolean;
  31310. /**
  31311. * Gets if the SPS uses the model materials for its own multimaterial.
  31312. */
  31313. get useModelMaterial(): boolean;
  31314. /**
  31315. * The SPS used material array.
  31316. */
  31317. get materials(): Material[];
  31318. /**
  31319. * Sets the SPS MultiMaterial from the passed materials.
  31320. * Note : the passed array is internally copied and not used then by reference.
  31321. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31322. */
  31323. setMultiMaterial(materials: Material[]): void;
  31324. /**
  31325. * The SPS computed multimaterial object
  31326. */
  31327. get multimaterial(): MultiMaterial;
  31328. set multimaterial(mm: MultiMaterial);
  31329. /**
  31330. * If the subMeshes must be updated on the next call to setParticles()
  31331. */
  31332. get autoUpdateSubMeshes(): boolean;
  31333. set autoUpdateSubMeshes(val: boolean);
  31334. /**
  31335. * This function does nothing. It may be overwritten to set all the particle first values.
  31336. * The SPS doesn't call this function, you may have to call it by your own.
  31337. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31338. */
  31339. initParticles(): void;
  31340. /**
  31341. * This function does nothing. It may be overwritten to recycle a particle.
  31342. * The SPS doesn't call this function, you may have to call it by your own.
  31343. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31344. * @param particle The particle to recycle
  31345. * @returns the recycled particle
  31346. */
  31347. recycleParticle(particle: SolidParticle): SolidParticle;
  31348. /**
  31349. * Updates a particle : this function should be overwritten by the user.
  31350. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31351. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31352. * @example : just set a particle position or velocity and recycle conditions
  31353. * @param particle The particle to update
  31354. * @returns the updated particle
  31355. */
  31356. updateParticle(particle: SolidParticle): SolidParticle;
  31357. /**
  31358. * Updates a vertex of a particle : it can be overwritten by the user.
  31359. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31360. * @param particle the current particle
  31361. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31362. * @param pt the index of the current vertex in the particle shape
  31363. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31364. * @example : just set a vertex particle position or color
  31365. * @returns the sps
  31366. */
  31367. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31368. /**
  31369. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31370. * This does nothing and may be overwritten by the user.
  31371. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31372. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31373. * @param update the boolean update value actually passed to setParticles()
  31374. */
  31375. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31376. /**
  31377. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31378. * This will be passed three parameters.
  31379. * This does nothing and may be overwritten by the user.
  31380. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31381. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31382. * @param update the boolean update value actually passed to setParticles()
  31383. */
  31384. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31385. }
  31386. }
  31387. declare module BABYLON {
  31388. /**
  31389. * Represents one particle of a solid particle system.
  31390. */
  31391. export class SolidParticle {
  31392. /**
  31393. * particle global index
  31394. */
  31395. idx: number;
  31396. /**
  31397. * particle identifier
  31398. */
  31399. id: number;
  31400. /**
  31401. * The color of the particle
  31402. */
  31403. color: Nullable<Color4>;
  31404. /**
  31405. * The world space position of the particle.
  31406. */
  31407. position: Vector3;
  31408. /**
  31409. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31410. */
  31411. rotation: Vector3;
  31412. /**
  31413. * The world space rotation quaternion of the particle.
  31414. */
  31415. rotationQuaternion: Nullable<Quaternion>;
  31416. /**
  31417. * The scaling of the particle.
  31418. */
  31419. scaling: Vector3;
  31420. /**
  31421. * The uvs of the particle.
  31422. */
  31423. uvs: Vector4;
  31424. /**
  31425. * The current speed of the particle.
  31426. */
  31427. velocity: Vector3;
  31428. /**
  31429. * The pivot point in the particle local space.
  31430. */
  31431. pivot: Vector3;
  31432. /**
  31433. * Must the particle be translated from its pivot point in its local space ?
  31434. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31435. * Default : false
  31436. */
  31437. translateFromPivot: boolean;
  31438. /**
  31439. * Is the particle active or not ?
  31440. */
  31441. alive: boolean;
  31442. /**
  31443. * Is the particle visible or not ?
  31444. */
  31445. isVisible: boolean;
  31446. /**
  31447. * Index of this particle in the global "positions" array (Internal use)
  31448. * @hidden
  31449. */
  31450. _pos: number;
  31451. /**
  31452. * @hidden Index of this particle in the global "indices" array (Internal use)
  31453. */
  31454. _ind: number;
  31455. /**
  31456. * @hidden ModelShape of this particle (Internal use)
  31457. */
  31458. _model: ModelShape;
  31459. /**
  31460. * ModelShape id of this particle
  31461. */
  31462. shapeId: number;
  31463. /**
  31464. * Index of the particle in its shape id
  31465. */
  31466. idxInShape: number;
  31467. /**
  31468. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31469. */
  31470. _modelBoundingInfo: BoundingInfo;
  31471. /**
  31472. * @hidden Particle BoundingInfo object (Internal use)
  31473. */
  31474. _boundingInfo: BoundingInfo;
  31475. /**
  31476. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31477. */
  31478. _sps: SolidParticleSystem;
  31479. /**
  31480. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31481. */
  31482. _stillInvisible: boolean;
  31483. /**
  31484. * @hidden Last computed particle rotation matrix
  31485. */
  31486. _rotationMatrix: number[];
  31487. /**
  31488. * Parent particle Id, if any.
  31489. * Default null.
  31490. */
  31491. parentId: Nullable<number>;
  31492. /**
  31493. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31494. */
  31495. materialIndex: Nullable<number>;
  31496. /**
  31497. * Custom object or properties.
  31498. */
  31499. props: Nullable<any>;
  31500. /**
  31501. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31502. * The possible values are :
  31503. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31504. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31505. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31506. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31507. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31508. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31509. * */
  31510. cullingStrategy: number;
  31511. /**
  31512. * @hidden Internal global position in the SPS.
  31513. */
  31514. _globalPosition: Vector3;
  31515. /**
  31516. * Creates a Solid Particle object.
  31517. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31518. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31519. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31520. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31521. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31522. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31523. * @param shapeId (integer) is the model shape identifier in the SPS.
  31524. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31525. * @param sps defines the sps it is associated to
  31526. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31527. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31528. */
  31529. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31530. /**
  31531. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31532. * @param target the particle target
  31533. * @returns the current particle
  31534. */
  31535. copyToRef(target: SolidParticle): SolidParticle;
  31536. /**
  31537. * Legacy support, changed scale to scaling
  31538. */
  31539. get scale(): Vector3;
  31540. /**
  31541. * Legacy support, changed scale to scaling
  31542. */
  31543. set scale(scale: Vector3);
  31544. /**
  31545. * Legacy support, changed quaternion to rotationQuaternion
  31546. */
  31547. get quaternion(): Nullable<Quaternion>;
  31548. /**
  31549. * Legacy support, changed quaternion to rotationQuaternion
  31550. */
  31551. set quaternion(q: Nullable<Quaternion>);
  31552. /**
  31553. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31554. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31555. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31556. * @returns true if it intersects
  31557. */
  31558. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31559. /**
  31560. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31561. * A particle is in the frustum if its bounding box intersects the frustum
  31562. * @param frustumPlanes defines the frustum to test
  31563. * @returns true if the particle is in the frustum planes
  31564. */
  31565. isInFrustum(frustumPlanes: Plane[]): boolean;
  31566. /**
  31567. * get the rotation matrix of the particle
  31568. * @hidden
  31569. */
  31570. getRotationMatrix(m: Matrix): void;
  31571. }
  31572. /**
  31573. * Represents the shape of the model used by one particle of a solid particle system.
  31574. * SPS internal tool, don't use it manually.
  31575. */
  31576. export class ModelShape {
  31577. /**
  31578. * The shape id
  31579. * @hidden
  31580. */
  31581. shapeID: number;
  31582. /**
  31583. * flat array of model positions (internal use)
  31584. * @hidden
  31585. */
  31586. _shape: Vector3[];
  31587. /**
  31588. * flat array of model UVs (internal use)
  31589. * @hidden
  31590. */
  31591. _shapeUV: number[];
  31592. /**
  31593. * color array of the model
  31594. * @hidden
  31595. */
  31596. _shapeColors: number[];
  31597. /**
  31598. * indices array of the model
  31599. * @hidden
  31600. */
  31601. _indices: number[];
  31602. /**
  31603. * normals array of the model
  31604. * @hidden
  31605. */
  31606. _normals: number[];
  31607. /**
  31608. * length of the shape in the model indices array (internal use)
  31609. * @hidden
  31610. */
  31611. _indicesLength: number;
  31612. /**
  31613. * Custom position function (internal use)
  31614. * @hidden
  31615. */
  31616. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31617. /**
  31618. * Custom vertex function (internal use)
  31619. * @hidden
  31620. */
  31621. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31622. /**
  31623. * Model material (internal use)
  31624. * @hidden
  31625. */
  31626. _material: Nullable<Material>;
  31627. /**
  31628. * 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.
  31629. * SPS internal tool, don't use it manually.
  31630. * @hidden
  31631. */
  31632. 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>);
  31633. }
  31634. /**
  31635. * Represents a Depth Sorted Particle in the solid particle system.
  31636. * @hidden
  31637. */
  31638. export class DepthSortedParticle {
  31639. /**
  31640. * Particle index
  31641. */
  31642. idx: number;
  31643. /**
  31644. * Index of the particle in the "indices" array
  31645. */
  31646. ind: number;
  31647. /**
  31648. * Length of the particle shape in the "indices" array
  31649. */
  31650. indicesLength: number;
  31651. /**
  31652. * Squared distance from the particle to the camera
  31653. */
  31654. sqDistance: number;
  31655. /**
  31656. * Material index when used with MultiMaterials
  31657. */
  31658. materialIndex: number;
  31659. /**
  31660. * Creates a new sorted particle
  31661. * @param materialIndex
  31662. */
  31663. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31664. }
  31665. /**
  31666. * Represents a solid particle vertex
  31667. */
  31668. export class SolidParticleVertex {
  31669. /**
  31670. * Vertex position
  31671. */
  31672. position: Vector3;
  31673. /**
  31674. * Vertex color
  31675. */
  31676. color: Color4;
  31677. /**
  31678. * Vertex UV
  31679. */
  31680. uv: Vector2;
  31681. /**
  31682. * Creates a new solid particle vertex
  31683. */
  31684. constructor();
  31685. /** Vertex x coordinate */
  31686. get x(): number;
  31687. set x(val: number);
  31688. /** Vertex y coordinate */
  31689. get y(): number;
  31690. set y(val: number);
  31691. /** Vertex z coordinate */
  31692. get z(): number;
  31693. set z(val: number);
  31694. }
  31695. }
  31696. declare module BABYLON {
  31697. /**
  31698. * @hidden
  31699. */
  31700. export class _MeshCollisionData {
  31701. _checkCollisions: boolean;
  31702. _collisionMask: number;
  31703. _collisionGroup: number;
  31704. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31705. _collider: Nullable<Collider>;
  31706. _oldPositionForCollisions: Vector3;
  31707. _diffPositionForCollisions: Vector3;
  31708. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31709. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31710. }
  31711. }
  31712. declare module BABYLON {
  31713. /** @hidden */
  31714. class _FacetDataStorage {
  31715. facetPositions: Vector3[];
  31716. facetNormals: Vector3[];
  31717. facetPartitioning: number[][];
  31718. facetNb: number;
  31719. partitioningSubdivisions: number;
  31720. partitioningBBoxRatio: number;
  31721. facetDataEnabled: boolean;
  31722. facetParameters: any;
  31723. bbSize: Vector3;
  31724. subDiv: {
  31725. max: number;
  31726. X: number;
  31727. Y: number;
  31728. Z: number;
  31729. };
  31730. facetDepthSort: boolean;
  31731. facetDepthSortEnabled: boolean;
  31732. depthSortedIndices: IndicesArray;
  31733. depthSortedFacets: {
  31734. ind: number;
  31735. sqDistance: number;
  31736. }[];
  31737. facetDepthSortFunction: (f1: {
  31738. ind: number;
  31739. sqDistance: number;
  31740. }, f2: {
  31741. ind: number;
  31742. sqDistance: number;
  31743. }) => number;
  31744. facetDepthSortFrom: Vector3;
  31745. facetDepthSortOrigin: Vector3;
  31746. invertedMatrix: Matrix;
  31747. }
  31748. /**
  31749. * @hidden
  31750. **/
  31751. class _InternalAbstractMeshDataInfo {
  31752. _hasVertexAlpha: boolean;
  31753. _useVertexColors: boolean;
  31754. _numBoneInfluencers: number;
  31755. _applyFog: boolean;
  31756. _receiveShadows: boolean;
  31757. _facetData: _FacetDataStorage;
  31758. _visibility: number;
  31759. _skeleton: Nullable<Skeleton>;
  31760. _layerMask: number;
  31761. _computeBonesUsingShaders: boolean;
  31762. _isActive: boolean;
  31763. _onlyForInstances: boolean;
  31764. _isActiveIntermediate: boolean;
  31765. _onlyForInstancesIntermediate: boolean;
  31766. _actAsRegularMesh: boolean;
  31767. }
  31768. /**
  31769. * Class used to store all common mesh properties
  31770. */
  31771. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31772. /** No occlusion */
  31773. static OCCLUSION_TYPE_NONE: number;
  31774. /** Occlusion set to optimisitic */
  31775. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31776. /** Occlusion set to strict */
  31777. static OCCLUSION_TYPE_STRICT: number;
  31778. /** Use an accurante occlusion algorithm */
  31779. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31780. /** Use a conservative occlusion algorithm */
  31781. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31783. * Test order :
  31784. * Is the bounding sphere outside the frustum ?
  31785. * If not, are the bounding box vertices outside the frustum ?
  31786. * It not, then the cullable object is in the frustum.
  31787. */
  31788. static readonly CULLINGSTRATEGY_STANDARD: number;
  31789. /** Culling strategy : Bounding Sphere Only.
  31790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31791. * It's also less accurate than the standard because some not visible objects can still be selected.
  31792. * Test : is the bounding sphere outside the frustum ?
  31793. * If not, then the cullable object is in the frustum.
  31794. */
  31795. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31796. /** Culling strategy : Optimistic Inclusion.
  31797. * This in an inclusion test first, then the standard exclusion test.
  31798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31799. * 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.
  31800. * Anyway, it's as accurate as the standard strategy.
  31801. * Test :
  31802. * Is the cullable object bounding sphere center in the frustum ?
  31803. * If not, apply the default culling strategy.
  31804. */
  31805. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31809. * 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.
  31810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31811. * Test :
  31812. * Is the cullable object bounding sphere center in the frustum ?
  31813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31814. */
  31815. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31816. /**
  31817. * No billboard
  31818. */
  31819. static get BILLBOARDMODE_NONE(): number;
  31820. /** Billboard on X axis */
  31821. static get BILLBOARDMODE_X(): number;
  31822. /** Billboard on Y axis */
  31823. static get BILLBOARDMODE_Y(): number;
  31824. /** Billboard on Z axis */
  31825. static get BILLBOARDMODE_Z(): number;
  31826. /** Billboard on all axes */
  31827. static get BILLBOARDMODE_ALL(): number;
  31828. /** Billboard on using position instead of orientation */
  31829. static get BILLBOARDMODE_USE_POSITION(): number;
  31830. /** @hidden */
  31831. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31832. /**
  31833. * The culling strategy to use to check whether the mesh must be rendered or not.
  31834. * This value can be changed at any time and will be used on the next render mesh selection.
  31835. * The possible values are :
  31836. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31837. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31838. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31839. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31840. * Please read each static variable documentation to get details about the culling process.
  31841. * */
  31842. cullingStrategy: number;
  31843. /**
  31844. * Gets the number of facets in the mesh
  31845. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31846. */
  31847. get facetNb(): number;
  31848. /**
  31849. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31850. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31851. */
  31852. get partitioningSubdivisions(): number;
  31853. set partitioningSubdivisions(nb: number);
  31854. /**
  31855. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31856. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31857. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31858. */
  31859. get partitioningBBoxRatio(): number;
  31860. set partitioningBBoxRatio(ratio: number);
  31861. /**
  31862. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31863. * Works only for updatable meshes.
  31864. * Doesn't work with multi-materials
  31865. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31866. */
  31867. get mustDepthSortFacets(): boolean;
  31868. set mustDepthSortFacets(sort: boolean);
  31869. /**
  31870. * The location (Vector3) where the facet depth sort must be computed from.
  31871. * By default, the active camera position.
  31872. * Used only when facet depth sort is enabled
  31873. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31874. */
  31875. get facetDepthSortFrom(): Vector3;
  31876. set facetDepthSortFrom(location: Vector3);
  31877. /**
  31878. * gets a boolean indicating if facetData is enabled
  31879. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31880. */
  31881. get isFacetDataEnabled(): boolean;
  31882. /** @hidden */
  31883. _updateNonUniformScalingState(value: boolean): boolean;
  31884. /**
  31885. * An event triggered when this mesh collides with another one
  31886. */
  31887. onCollideObservable: Observable<AbstractMesh>;
  31888. /** Set a function to call when this mesh collides with another one */
  31889. set onCollide(callback: () => void);
  31890. /**
  31891. * An event triggered when the collision's position changes
  31892. */
  31893. onCollisionPositionChangeObservable: Observable<Vector3>;
  31894. /** Set a function to call when the collision's position changes */
  31895. set onCollisionPositionChange(callback: () => void);
  31896. /**
  31897. * An event triggered when material is changed
  31898. */
  31899. onMaterialChangedObservable: Observable<AbstractMesh>;
  31900. /**
  31901. * Gets or sets the orientation for POV movement & rotation
  31902. */
  31903. definedFacingForward: boolean;
  31904. /** @hidden */
  31905. _occlusionQuery: Nullable<WebGLQuery>;
  31906. /** @hidden */
  31907. _renderingGroup: Nullable<RenderingGroup>;
  31908. /**
  31909. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31910. */
  31911. get visibility(): number;
  31912. /**
  31913. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31914. */
  31915. set visibility(value: number);
  31916. /** Gets or sets the alpha index used to sort transparent meshes
  31917. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31918. */
  31919. alphaIndex: number;
  31920. /**
  31921. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31922. */
  31923. isVisible: boolean;
  31924. /**
  31925. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31926. */
  31927. isPickable: boolean;
  31928. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31929. showSubMeshesBoundingBox: boolean;
  31930. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31931. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31932. */
  31933. isBlocker: boolean;
  31934. /**
  31935. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31936. */
  31937. enablePointerMoveEvents: boolean;
  31938. /**
  31939. * Specifies the rendering group id for this mesh (0 by default)
  31940. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31941. */
  31942. renderingGroupId: number;
  31943. private _material;
  31944. /** Gets or sets current material */
  31945. get material(): Nullable<Material>;
  31946. set material(value: Nullable<Material>);
  31947. /**
  31948. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31949. * @see https://doc.babylonjs.com/babylon101/shadows
  31950. */
  31951. get receiveShadows(): boolean;
  31952. set receiveShadows(value: boolean);
  31953. /** Defines color to use when rendering outline */
  31954. outlineColor: Color3;
  31955. /** Define width to use when rendering outline */
  31956. outlineWidth: number;
  31957. /** Defines color to use when rendering overlay */
  31958. overlayColor: Color3;
  31959. /** Defines alpha to use when rendering overlay */
  31960. overlayAlpha: number;
  31961. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31962. get hasVertexAlpha(): boolean;
  31963. set hasVertexAlpha(value: boolean);
  31964. /** 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) */
  31965. get useVertexColors(): boolean;
  31966. set useVertexColors(value: boolean);
  31967. /**
  31968. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31969. */
  31970. get computeBonesUsingShaders(): boolean;
  31971. set computeBonesUsingShaders(value: boolean);
  31972. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31973. get numBoneInfluencers(): number;
  31974. set numBoneInfluencers(value: number);
  31975. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31976. get applyFog(): boolean;
  31977. set applyFog(value: boolean);
  31978. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31979. useOctreeForRenderingSelection: boolean;
  31980. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31981. useOctreeForPicking: boolean;
  31982. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31983. useOctreeForCollisions: boolean;
  31984. /**
  31985. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31986. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31987. */
  31988. get layerMask(): number;
  31989. set layerMask(value: number);
  31990. /**
  31991. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31992. */
  31993. alwaysSelectAsActiveMesh: boolean;
  31994. /**
  31995. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31996. */
  31997. doNotSyncBoundingInfo: boolean;
  31998. /**
  31999. * Gets or sets the current action manager
  32000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32001. */
  32002. actionManager: Nullable<AbstractActionManager>;
  32003. private _meshCollisionData;
  32004. /**
  32005. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32006. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32007. */
  32008. ellipsoid: Vector3;
  32009. /**
  32010. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32011. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32012. */
  32013. ellipsoidOffset: Vector3;
  32014. /**
  32015. * Gets or sets a collision mask used to mask collisions (default is -1).
  32016. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32017. */
  32018. get collisionMask(): number;
  32019. set collisionMask(mask: number);
  32020. /**
  32021. * Gets or sets the current collision group mask (-1 by default).
  32022. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32023. */
  32024. get collisionGroup(): number;
  32025. set collisionGroup(mask: number);
  32026. /**
  32027. * Gets or sets current surrounding meshes (null by default).
  32028. *
  32029. * By default collision detection is tested against every mesh in the scene.
  32030. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32031. * meshes will be tested for the collision.
  32032. *
  32033. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32034. */
  32035. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32036. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32037. /**
  32038. * Defines edge width used when edgesRenderer is enabled
  32039. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32040. */
  32041. edgesWidth: number;
  32042. /**
  32043. * Defines edge color used when edgesRenderer is enabled
  32044. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32045. */
  32046. edgesColor: Color4;
  32047. /** @hidden */
  32048. _edgesRenderer: Nullable<IEdgesRenderer>;
  32049. /** @hidden */
  32050. _masterMesh: Nullable<AbstractMesh>;
  32051. /** @hidden */
  32052. _boundingInfo: Nullable<BoundingInfo>;
  32053. /** @hidden */
  32054. _renderId: number;
  32055. /**
  32056. * Gets or sets the list of subMeshes
  32057. * @see https://doc.babylonjs.com/how_to/multi_materials
  32058. */
  32059. subMeshes: SubMesh[];
  32060. /** @hidden */
  32061. _intersectionsInProgress: AbstractMesh[];
  32062. /** @hidden */
  32063. _unIndexed: boolean;
  32064. /** @hidden */
  32065. _lightSources: Light[];
  32066. /** Gets the list of lights affecting that mesh */
  32067. get lightSources(): Light[];
  32068. /** @hidden */
  32069. get _positions(): Nullable<Vector3[]>;
  32070. /** @hidden */
  32071. _waitingData: {
  32072. lods: Nullable<any>;
  32073. actions: Nullable<any>;
  32074. freezeWorldMatrix: Nullable<boolean>;
  32075. };
  32076. /** @hidden */
  32077. _bonesTransformMatrices: Nullable<Float32Array>;
  32078. /** @hidden */
  32079. _transformMatrixTexture: Nullable<RawTexture>;
  32080. /**
  32081. * Gets or sets a skeleton to apply skining transformations
  32082. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32083. */
  32084. set skeleton(value: Nullable<Skeleton>);
  32085. get skeleton(): Nullable<Skeleton>;
  32086. /**
  32087. * An event triggered when the mesh is rebuilt.
  32088. */
  32089. onRebuildObservable: Observable<AbstractMesh>;
  32090. /**
  32091. * Creates a new AbstractMesh
  32092. * @param name defines the name of the mesh
  32093. * @param scene defines the hosting scene
  32094. */
  32095. constructor(name: string, scene?: Nullable<Scene>);
  32096. /**
  32097. * Returns the string "AbstractMesh"
  32098. * @returns "AbstractMesh"
  32099. */
  32100. getClassName(): string;
  32101. /**
  32102. * Gets a string representation of the current mesh
  32103. * @param fullDetails defines a boolean indicating if full details must be included
  32104. * @returns a string representation of the current mesh
  32105. */
  32106. toString(fullDetails?: boolean): string;
  32107. /**
  32108. * @hidden
  32109. */
  32110. protected _getEffectiveParent(): Nullable<Node>;
  32111. /** @hidden */
  32112. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32113. /** @hidden */
  32114. _rebuild(): void;
  32115. /** @hidden */
  32116. _resyncLightSources(): void;
  32117. /** @hidden */
  32118. _resyncLightSource(light: Light): void;
  32119. /** @hidden */
  32120. _unBindEffect(): void;
  32121. /** @hidden */
  32122. _removeLightSource(light: Light, dispose: boolean): void;
  32123. private _markSubMeshesAsDirty;
  32124. /** @hidden */
  32125. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32126. /** @hidden */
  32127. _markSubMeshesAsAttributesDirty(): void;
  32128. /** @hidden */
  32129. _markSubMeshesAsMiscDirty(): void;
  32130. /**
  32131. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32132. */
  32133. get scaling(): Vector3;
  32134. set scaling(newScaling: Vector3);
  32135. /**
  32136. * Returns true if the mesh is blocked. Implemented by child classes
  32137. */
  32138. get isBlocked(): boolean;
  32139. /**
  32140. * Returns the mesh itself by default. Implemented by child classes
  32141. * @param camera defines the camera to use to pick the right LOD level
  32142. * @returns the currentAbstractMesh
  32143. */
  32144. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32145. /**
  32146. * Returns 0 by default. Implemented by child classes
  32147. * @returns an integer
  32148. */
  32149. getTotalVertices(): number;
  32150. /**
  32151. * Returns a positive integer : the total number of indices in this mesh geometry.
  32152. * @returns the numner of indices or zero if the mesh has no geometry.
  32153. */
  32154. getTotalIndices(): number;
  32155. /**
  32156. * Returns null by default. Implemented by child classes
  32157. * @returns null
  32158. */
  32159. getIndices(): Nullable<IndicesArray>;
  32160. /**
  32161. * Returns the array of the requested vertex data kind. Implemented by child classes
  32162. * @param kind defines the vertex data kind to use
  32163. * @returns null
  32164. */
  32165. getVerticesData(kind: string): Nullable<FloatArray>;
  32166. /**
  32167. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32168. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32169. * Note that a new underlying VertexBuffer object is created each call.
  32170. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32171. * @param kind defines vertex data kind:
  32172. * * VertexBuffer.PositionKind
  32173. * * VertexBuffer.UVKind
  32174. * * VertexBuffer.UV2Kind
  32175. * * VertexBuffer.UV3Kind
  32176. * * VertexBuffer.UV4Kind
  32177. * * VertexBuffer.UV5Kind
  32178. * * VertexBuffer.UV6Kind
  32179. * * VertexBuffer.ColorKind
  32180. * * VertexBuffer.MatricesIndicesKind
  32181. * * VertexBuffer.MatricesIndicesExtraKind
  32182. * * VertexBuffer.MatricesWeightsKind
  32183. * * VertexBuffer.MatricesWeightsExtraKind
  32184. * @param data defines the data source
  32185. * @param updatable defines if the data must be flagged as updatable (or static)
  32186. * @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
  32187. * @returns the current mesh
  32188. */
  32189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32190. /**
  32191. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32192. * If the mesh has no geometry, it is simply returned as it is.
  32193. * @param kind defines vertex data kind:
  32194. * * VertexBuffer.PositionKind
  32195. * * VertexBuffer.UVKind
  32196. * * VertexBuffer.UV2Kind
  32197. * * VertexBuffer.UV3Kind
  32198. * * VertexBuffer.UV4Kind
  32199. * * VertexBuffer.UV5Kind
  32200. * * VertexBuffer.UV6Kind
  32201. * * VertexBuffer.ColorKind
  32202. * * VertexBuffer.MatricesIndicesKind
  32203. * * VertexBuffer.MatricesIndicesExtraKind
  32204. * * VertexBuffer.MatricesWeightsKind
  32205. * * VertexBuffer.MatricesWeightsExtraKind
  32206. * @param data defines the data source
  32207. * @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
  32208. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32209. * @returns the current mesh
  32210. */
  32211. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32212. /**
  32213. * Sets the mesh indices,
  32214. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32215. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32216. * @param totalVertices Defines the total number of vertices
  32217. * @returns the current mesh
  32218. */
  32219. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32220. /**
  32221. * Gets a boolean indicating if specific vertex data is present
  32222. * @param kind defines the vertex data kind to use
  32223. * @returns true is data kind is present
  32224. */
  32225. isVerticesDataPresent(kind: string): boolean;
  32226. /**
  32227. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32228. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32229. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32230. * @returns a BoundingInfo
  32231. */
  32232. getBoundingInfo(): BoundingInfo;
  32233. /**
  32234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32238. * @returns the current mesh
  32239. */
  32240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32241. /**
  32242. * Overwrite the current bounding info
  32243. * @param boundingInfo defines the new bounding info
  32244. * @returns the current mesh
  32245. */
  32246. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32247. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32248. get useBones(): boolean;
  32249. /** @hidden */
  32250. _preActivate(): void;
  32251. /** @hidden */
  32252. _preActivateForIntermediateRendering(renderId: number): void;
  32253. /** @hidden */
  32254. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32255. /** @hidden */
  32256. _postActivate(): void;
  32257. /** @hidden */
  32258. _freeze(): void;
  32259. /** @hidden */
  32260. _unFreeze(): void;
  32261. /**
  32262. * Gets the current world matrix
  32263. * @returns a Matrix
  32264. */
  32265. getWorldMatrix(): Matrix;
  32266. /** @hidden */
  32267. _getWorldMatrixDeterminant(): number;
  32268. /**
  32269. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32270. */
  32271. get isAnInstance(): boolean;
  32272. /**
  32273. * Gets a boolean indicating if this mesh has instances
  32274. */
  32275. get hasInstances(): boolean;
  32276. /**
  32277. * Gets a boolean indicating if this mesh has thin instances
  32278. */
  32279. get hasThinInstances(): boolean;
  32280. /**
  32281. * Perform relative position change from the point of view of behind the front of the mesh.
  32282. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32283. * Supports definition of mesh facing forward or backward
  32284. * @param amountRight defines the distance on the right axis
  32285. * @param amountUp defines the distance on the up axis
  32286. * @param amountForward defines the distance on the forward axis
  32287. * @returns the current mesh
  32288. */
  32289. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32290. /**
  32291. * Calculate relative position change from the point of view of behind the front of the mesh.
  32292. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32293. * Supports definition of mesh facing forward or backward
  32294. * @param amountRight defines the distance on the right axis
  32295. * @param amountUp defines the distance on the up axis
  32296. * @param amountForward defines the distance on the forward axis
  32297. * @returns the new displacement vector
  32298. */
  32299. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32300. /**
  32301. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32302. * Supports definition of mesh facing forward or backward
  32303. * @param flipBack defines the flip
  32304. * @param twirlClockwise defines the twirl
  32305. * @param tiltRight defines the tilt
  32306. * @returns the current mesh
  32307. */
  32308. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32309. /**
  32310. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32311. * Supports definition of mesh facing forward or backward.
  32312. * @param flipBack defines the flip
  32313. * @param twirlClockwise defines the twirl
  32314. * @param tiltRight defines the tilt
  32315. * @returns the new rotation vector
  32316. */
  32317. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32318. /**
  32319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32320. * This means the mesh underlying bounding box and sphere are recomputed.
  32321. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32322. * @returns the current mesh
  32323. */
  32324. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32325. /** @hidden */
  32326. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32327. /** @hidden */
  32328. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32329. /** @hidden */
  32330. _updateBoundingInfo(): AbstractMesh;
  32331. /** @hidden */
  32332. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32333. /** @hidden */
  32334. protected _afterComputeWorldMatrix(): void;
  32335. /** @hidden */
  32336. get _effectiveMesh(): AbstractMesh;
  32337. /**
  32338. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32339. * A mesh is in the frustum if its bounding box intersects the frustum
  32340. * @param frustumPlanes defines the frustum to test
  32341. * @returns true if the mesh is in the frustum planes
  32342. */
  32343. isInFrustum(frustumPlanes: Plane[]): boolean;
  32344. /**
  32345. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32346. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32347. * @param frustumPlanes defines the frustum to test
  32348. * @returns true if the mesh is completely in the frustum planes
  32349. */
  32350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32351. /**
  32352. * True if the mesh intersects another mesh or a SolidParticle object
  32353. * @param mesh defines a target mesh or SolidParticle to test
  32354. * @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)
  32355. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32356. * @returns true if there is an intersection
  32357. */
  32358. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32359. /**
  32360. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32361. * @param point defines the point to test
  32362. * @returns true if there is an intersection
  32363. */
  32364. intersectsPoint(point: Vector3): boolean;
  32365. /**
  32366. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32367. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32368. */
  32369. get checkCollisions(): boolean;
  32370. set checkCollisions(collisionEnabled: boolean);
  32371. /**
  32372. * Gets Collider object used to compute collisions (not physics)
  32373. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32374. */
  32375. get collider(): Nullable<Collider>;
  32376. /**
  32377. * Move the mesh using collision engine
  32378. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32379. * @param displacement defines the requested displacement vector
  32380. * @returns the current mesh
  32381. */
  32382. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32383. private _onCollisionPositionChange;
  32384. /** @hidden */
  32385. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32386. /** @hidden */
  32387. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32388. /** @hidden */
  32389. _checkCollision(collider: Collider): AbstractMesh;
  32390. /** @hidden */
  32391. _generatePointsArray(): boolean;
  32392. /**
  32393. * Checks if the passed Ray intersects with the mesh
  32394. * @param ray defines the ray to use
  32395. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32396. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32397. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32398. * @returns the picking info
  32399. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32400. */
  32401. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32402. /**
  32403. * Clones the current mesh
  32404. * @param name defines the mesh name
  32405. * @param newParent defines the new mesh parent
  32406. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32407. * @returns the new mesh
  32408. */
  32409. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32410. /**
  32411. * Disposes all the submeshes of the current meshnp
  32412. * @returns the current mesh
  32413. */
  32414. releaseSubMeshes(): AbstractMesh;
  32415. /**
  32416. * Releases resources associated with this abstract mesh.
  32417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32419. */
  32420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32421. /**
  32422. * Adds the passed mesh as a child to the current mesh
  32423. * @param mesh defines the child mesh
  32424. * @returns the current mesh
  32425. */
  32426. addChild(mesh: AbstractMesh): AbstractMesh;
  32427. /**
  32428. * Removes the passed mesh from the current mesh children list
  32429. * @param mesh defines the child mesh
  32430. * @returns the current mesh
  32431. */
  32432. removeChild(mesh: AbstractMesh): AbstractMesh;
  32433. /** @hidden */
  32434. private _initFacetData;
  32435. /**
  32436. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32437. * This method can be called within the render loop.
  32438. * 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
  32439. * @returns the current mesh
  32440. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32441. */
  32442. updateFacetData(): AbstractMesh;
  32443. /**
  32444. * Returns the facetLocalNormals array.
  32445. * The normals are expressed in the mesh local spac
  32446. * @returns an array of Vector3
  32447. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32448. */
  32449. getFacetLocalNormals(): Vector3[];
  32450. /**
  32451. * Returns the facetLocalPositions array.
  32452. * The facet positions are expressed in the mesh local space
  32453. * @returns an array of Vector3
  32454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32455. */
  32456. getFacetLocalPositions(): Vector3[];
  32457. /**
  32458. * Returns the facetLocalPartioning array
  32459. * @returns an array of array of numbers
  32460. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32461. */
  32462. getFacetLocalPartitioning(): number[][];
  32463. /**
  32464. * Returns the i-th facet position in the world system.
  32465. * This method allocates a new Vector3 per call
  32466. * @param i defines the facet index
  32467. * @returns a new Vector3
  32468. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32469. */
  32470. getFacetPosition(i: number): Vector3;
  32471. /**
  32472. * Sets the reference Vector3 with the i-th facet position in the world system
  32473. * @param i defines the facet index
  32474. * @param ref defines the target vector
  32475. * @returns the current mesh
  32476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32477. */
  32478. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32479. /**
  32480. * Returns the i-th facet normal in the world system.
  32481. * This method allocates a new Vector3 per call
  32482. * @param i defines the facet index
  32483. * @returns a new Vector3
  32484. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32485. */
  32486. getFacetNormal(i: number): Vector3;
  32487. /**
  32488. * Sets the reference Vector3 with the i-th facet normal in the world system
  32489. * @param i defines the facet index
  32490. * @param ref defines the target vector
  32491. * @returns the current mesh
  32492. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32493. */
  32494. getFacetNormalToRef(i: number, ref: Vector3): this;
  32495. /**
  32496. * 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)
  32497. * @param x defines x coordinate
  32498. * @param y defines y coordinate
  32499. * @param z defines z coordinate
  32500. * @returns the array of facet indexes
  32501. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32502. */
  32503. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32504. /**
  32505. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32506. * @param projected sets as the (x,y,z) world projection on the facet
  32507. * @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
  32508. * @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
  32509. * @param x defines x coordinate
  32510. * @param y defines y coordinate
  32511. * @param z defines z coordinate
  32512. * @returns the face index if found (or null instead)
  32513. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32514. */
  32515. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32516. /**
  32517. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32518. * @param projected sets as the (x,y,z) local projection on the facet
  32519. * @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
  32520. * @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
  32521. * @param x defines x coordinate
  32522. * @param y defines y coordinate
  32523. * @param z defines z coordinate
  32524. * @returns the face index if found (or null instead)
  32525. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32526. */
  32527. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32528. /**
  32529. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32530. * @returns the parameters
  32531. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32532. */
  32533. getFacetDataParameters(): any;
  32534. /**
  32535. * Disables the feature FacetData and frees the related memory
  32536. * @returns the current mesh
  32537. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32538. */
  32539. disableFacetData(): AbstractMesh;
  32540. /**
  32541. * Updates the AbstractMesh indices array
  32542. * @param indices defines the data source
  32543. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32544. * @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)
  32545. * @returns the current mesh
  32546. */
  32547. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32548. /**
  32549. * Creates new normals data for the mesh
  32550. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32551. * @returns the current mesh
  32552. */
  32553. createNormals(updatable: boolean): AbstractMesh;
  32554. /**
  32555. * Align the mesh with a normal
  32556. * @param normal defines the normal to use
  32557. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32558. * @returns the current mesh
  32559. */
  32560. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32561. /** @hidden */
  32562. _checkOcclusionQuery(): boolean;
  32563. /**
  32564. * Disables the mesh edge rendering mode
  32565. * @returns the currentAbstractMesh
  32566. */
  32567. disableEdgesRendering(): AbstractMesh;
  32568. /**
  32569. * Enables the edge rendering mode on the mesh.
  32570. * This mode makes the mesh edges visible
  32571. * @param epsilon defines the maximal distance between two angles to detect a face
  32572. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32573. * @returns the currentAbstractMesh
  32574. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32575. */
  32576. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32577. /**
  32578. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32579. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32580. */
  32581. getConnectedParticleSystems(): IParticleSystem[];
  32582. }
  32583. }
  32584. declare module BABYLON {
  32585. /**
  32586. * Interface used to define ActionEvent
  32587. */
  32588. export interface IActionEvent {
  32589. /** The mesh or sprite that triggered the action */
  32590. source: any;
  32591. /** The X mouse cursor position at the time of the event */
  32592. pointerX: number;
  32593. /** The Y mouse cursor position at the time of the event */
  32594. pointerY: number;
  32595. /** The mesh that is currently pointed at (can be null) */
  32596. meshUnderPointer: Nullable<AbstractMesh>;
  32597. /** the original (browser) event that triggered the ActionEvent */
  32598. sourceEvent?: any;
  32599. /** additional data for the event */
  32600. additionalData?: any;
  32601. }
  32602. /**
  32603. * ActionEvent is the event being sent when an action is triggered.
  32604. */
  32605. export class ActionEvent implements IActionEvent {
  32606. /** The mesh or sprite that triggered the action */
  32607. source: any;
  32608. /** The X mouse cursor position at the time of the event */
  32609. pointerX: number;
  32610. /** The Y mouse cursor position at the time of the event */
  32611. pointerY: number;
  32612. /** The mesh that is currently pointed at (can be null) */
  32613. meshUnderPointer: Nullable<AbstractMesh>;
  32614. /** the original (browser) event that triggered the ActionEvent */
  32615. sourceEvent?: any;
  32616. /** additional data for the event */
  32617. additionalData?: any;
  32618. /**
  32619. * Creates a new ActionEvent
  32620. * @param source The mesh or sprite that triggered the action
  32621. * @param pointerX The X mouse cursor position at the time of the event
  32622. * @param pointerY The Y mouse cursor position at the time of the event
  32623. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32624. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32625. * @param additionalData additional data for the event
  32626. */
  32627. constructor(
  32628. /** The mesh or sprite that triggered the action */
  32629. source: any,
  32630. /** The X mouse cursor position at the time of the event */
  32631. pointerX: number,
  32632. /** The Y mouse cursor position at the time of the event */
  32633. pointerY: number,
  32634. /** The mesh that is currently pointed at (can be null) */
  32635. meshUnderPointer: Nullable<AbstractMesh>,
  32636. /** the original (browser) event that triggered the ActionEvent */
  32637. sourceEvent?: any,
  32638. /** additional data for the event */
  32639. additionalData?: any);
  32640. /**
  32641. * Helper function to auto-create an ActionEvent from a source mesh.
  32642. * @param source The source mesh that triggered the event
  32643. * @param evt The original (browser) event
  32644. * @param additionalData additional data for the event
  32645. * @returns the new ActionEvent
  32646. */
  32647. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32648. /**
  32649. * Helper function to auto-create an ActionEvent from a source sprite
  32650. * @param source The source sprite that triggered the event
  32651. * @param scene Scene associated with the sprite
  32652. * @param evt The original (browser) event
  32653. * @param additionalData additional data for the event
  32654. * @returns the new ActionEvent
  32655. */
  32656. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32657. /**
  32658. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32659. * @param scene the scene where the event occurred
  32660. * @param evt The original (browser) event
  32661. * @returns the new ActionEvent
  32662. */
  32663. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32664. /**
  32665. * Helper function to auto-create an ActionEvent from a primitive
  32666. * @param prim defines the target primitive
  32667. * @param pointerPos defines the pointer position
  32668. * @param evt The original (browser) event
  32669. * @param additionalData additional data for the event
  32670. * @returns the new ActionEvent
  32671. */
  32672. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32673. }
  32674. }
  32675. declare module BABYLON {
  32676. /**
  32677. * Abstract class used to decouple action Manager from scene and meshes.
  32678. * Do not instantiate.
  32679. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32680. */
  32681. export abstract class AbstractActionManager implements IDisposable {
  32682. /** Gets the list of active triggers */
  32683. static Triggers: {
  32684. [key: string]: number;
  32685. };
  32686. /** Gets the cursor to use when hovering items */
  32687. hoverCursor: string;
  32688. /** Gets the list of actions */
  32689. actions: IAction[];
  32690. /**
  32691. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32692. */
  32693. isRecursive: boolean;
  32694. /**
  32695. * Releases all associated resources
  32696. */
  32697. abstract dispose(): void;
  32698. /**
  32699. * Does this action manager has pointer triggers
  32700. */
  32701. abstract get hasPointerTriggers(): boolean;
  32702. /**
  32703. * Does this action manager has pick triggers
  32704. */
  32705. abstract get hasPickTriggers(): boolean;
  32706. /**
  32707. * Process a specific trigger
  32708. * @param trigger defines the trigger to process
  32709. * @param evt defines the event details to be processed
  32710. */
  32711. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32712. /**
  32713. * Does this action manager handles actions of any of the given triggers
  32714. * @param triggers defines the triggers to be tested
  32715. * @return a boolean indicating whether one (or more) of the triggers is handled
  32716. */
  32717. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32718. /**
  32719. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32720. * speed.
  32721. * @param triggerA defines the trigger to be tested
  32722. * @param triggerB defines the trigger to be tested
  32723. * @return a boolean indicating whether one (or more) of the triggers is handled
  32724. */
  32725. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32726. /**
  32727. * Does this action manager handles actions of a given trigger
  32728. * @param trigger defines the trigger to be tested
  32729. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32730. * @return whether the trigger is handled
  32731. */
  32732. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32733. /**
  32734. * Serialize this manager to a JSON object
  32735. * @param name defines the property name to store this manager
  32736. * @returns a JSON representation of this manager
  32737. */
  32738. abstract serialize(name: string): any;
  32739. /**
  32740. * Registers an action to this action manager
  32741. * @param action defines the action to be registered
  32742. * @return the action amended (prepared) after registration
  32743. */
  32744. abstract registerAction(action: IAction): Nullable<IAction>;
  32745. /**
  32746. * Unregisters an action to this action manager
  32747. * @param action defines the action to be unregistered
  32748. * @return a boolean indicating whether the action has been unregistered
  32749. */
  32750. abstract unregisterAction(action: IAction): Boolean;
  32751. /**
  32752. * Does exist one action manager with at least one trigger
  32753. **/
  32754. static get HasTriggers(): boolean;
  32755. /**
  32756. * Does exist one action manager with at least one pick trigger
  32757. **/
  32758. static get HasPickTriggers(): boolean;
  32759. /**
  32760. * Does exist one action manager that handles actions of a given trigger
  32761. * @param trigger defines the trigger to be tested
  32762. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32763. **/
  32764. static HasSpecificTrigger(trigger: number): boolean;
  32765. }
  32766. }
  32767. declare module BABYLON {
  32768. /**
  32769. * Defines how a node can be built from a string name.
  32770. */
  32771. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32772. /**
  32773. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32774. */
  32775. export class Node implements IBehaviorAware<Node> {
  32776. /** @hidden */
  32777. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32778. private static _NodeConstructors;
  32779. /**
  32780. * Add a new node constructor
  32781. * @param type defines the type name of the node to construct
  32782. * @param constructorFunc defines the constructor function
  32783. */
  32784. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32785. /**
  32786. * Returns a node constructor based on type name
  32787. * @param type defines the type name
  32788. * @param name defines the new node name
  32789. * @param scene defines the hosting scene
  32790. * @param options defines optional options to transmit to constructors
  32791. * @returns the new constructor or null
  32792. */
  32793. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32794. /**
  32795. * Gets or sets the name of the node
  32796. */
  32797. name: string;
  32798. /**
  32799. * Gets or sets the id of the node
  32800. */
  32801. id: string;
  32802. /**
  32803. * Gets or sets the unique id of the node
  32804. */
  32805. uniqueId: number;
  32806. /**
  32807. * Gets or sets a string used to store user defined state for the node
  32808. */
  32809. state: string;
  32810. /**
  32811. * Gets or sets an object used to store user defined information for the node
  32812. */
  32813. metadata: any;
  32814. /**
  32815. * For internal use only. Please do not use.
  32816. */
  32817. reservedDataStore: any;
  32818. /**
  32819. * List of inspectable custom properties (used by the Inspector)
  32820. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32821. */
  32822. inspectableCustomProperties: IInspectable[];
  32823. private _doNotSerialize;
  32824. /**
  32825. * Gets or sets a boolean used to define if the node must be serialized
  32826. */
  32827. get doNotSerialize(): boolean;
  32828. set doNotSerialize(value: boolean);
  32829. /** @hidden */
  32830. _isDisposed: boolean;
  32831. /**
  32832. * Gets a list of Animations associated with the node
  32833. */
  32834. animations: Animation[];
  32835. protected _ranges: {
  32836. [name: string]: Nullable<AnimationRange>;
  32837. };
  32838. /**
  32839. * Callback raised when the node is ready to be used
  32840. */
  32841. onReady: Nullable<(node: Node) => void>;
  32842. private _isEnabled;
  32843. private _isParentEnabled;
  32844. private _isReady;
  32845. /** @hidden */
  32846. _currentRenderId: number;
  32847. private _parentUpdateId;
  32848. /** @hidden */
  32849. _childUpdateId: number;
  32850. /** @hidden */
  32851. _waitingParentId: Nullable<string>;
  32852. /** @hidden */
  32853. _scene: Scene;
  32854. /** @hidden */
  32855. _cache: any;
  32856. private _parentNode;
  32857. private _children;
  32858. /** @hidden */
  32859. _worldMatrix: Matrix;
  32860. /** @hidden */
  32861. _worldMatrixDeterminant: number;
  32862. /** @hidden */
  32863. _worldMatrixDeterminantIsDirty: boolean;
  32864. /** @hidden */
  32865. private _sceneRootNodesIndex;
  32866. /**
  32867. * Gets a boolean indicating if the node has been disposed
  32868. * @returns true if the node was disposed
  32869. */
  32870. isDisposed(): boolean;
  32871. /**
  32872. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32873. * @see https://doc.babylonjs.com/how_to/parenting
  32874. */
  32875. set parent(parent: Nullable<Node>);
  32876. get parent(): Nullable<Node>;
  32877. /** @hidden */
  32878. _addToSceneRootNodes(): void;
  32879. /** @hidden */
  32880. _removeFromSceneRootNodes(): void;
  32881. private _animationPropertiesOverride;
  32882. /**
  32883. * Gets or sets the animation properties override
  32884. */
  32885. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32886. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32887. /**
  32888. * Gets a string idenfifying the name of the class
  32889. * @returns "Node" string
  32890. */
  32891. getClassName(): string;
  32892. /** @hidden */
  32893. readonly _isNode: boolean;
  32894. /**
  32895. * An event triggered when the mesh is disposed
  32896. */
  32897. onDisposeObservable: Observable<Node>;
  32898. private _onDisposeObserver;
  32899. /**
  32900. * Sets a callback that will be raised when the node will be disposed
  32901. */
  32902. set onDispose(callback: () => void);
  32903. /**
  32904. * Creates a new Node
  32905. * @param name the name and id to be given to this node
  32906. * @param scene the scene this node will be added to
  32907. */
  32908. constructor(name: string, scene?: Nullable<Scene>);
  32909. /**
  32910. * Gets the scene of the node
  32911. * @returns a scene
  32912. */
  32913. getScene(): Scene;
  32914. /**
  32915. * Gets the engine of the node
  32916. * @returns a Engine
  32917. */
  32918. getEngine(): Engine;
  32919. private _behaviors;
  32920. /**
  32921. * Attach a behavior to the node
  32922. * @see https://doc.babylonjs.com/features/behaviour
  32923. * @param behavior defines the behavior to attach
  32924. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32925. * @returns the current Node
  32926. */
  32927. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32928. /**
  32929. * Remove an attached behavior
  32930. * @see https://doc.babylonjs.com/features/behaviour
  32931. * @param behavior defines the behavior to attach
  32932. * @returns the current Node
  32933. */
  32934. removeBehavior(behavior: Behavior<Node>): Node;
  32935. /**
  32936. * Gets the list of attached behaviors
  32937. * @see https://doc.babylonjs.com/features/behaviour
  32938. */
  32939. get behaviors(): Behavior<Node>[];
  32940. /**
  32941. * Gets an attached behavior by name
  32942. * @param name defines the name of the behavior to look for
  32943. * @see https://doc.babylonjs.com/features/behaviour
  32944. * @returns null if behavior was not found else the requested behavior
  32945. */
  32946. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32947. /**
  32948. * Returns the latest update of the World matrix
  32949. * @returns a Matrix
  32950. */
  32951. getWorldMatrix(): Matrix;
  32952. /** @hidden */
  32953. _getWorldMatrixDeterminant(): number;
  32954. /**
  32955. * Returns directly the latest state of the mesh World matrix.
  32956. * A Matrix is returned.
  32957. */
  32958. get worldMatrixFromCache(): Matrix;
  32959. /** @hidden */
  32960. _initCache(): void;
  32961. /** @hidden */
  32962. updateCache(force?: boolean): void;
  32963. /** @hidden */
  32964. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32965. /** @hidden */
  32966. _updateCache(ignoreParentClass?: boolean): void;
  32967. /** @hidden */
  32968. _isSynchronized(): boolean;
  32969. /** @hidden */
  32970. _markSyncedWithParent(): void;
  32971. /** @hidden */
  32972. isSynchronizedWithParent(): boolean;
  32973. /** @hidden */
  32974. isSynchronized(): boolean;
  32975. /**
  32976. * Is this node ready to be used/rendered
  32977. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32978. * @return true if the node is ready
  32979. */
  32980. isReady(completeCheck?: boolean): boolean;
  32981. /**
  32982. * Is this node enabled?
  32983. * 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
  32984. * @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
  32985. * @return whether this node (and its parent) is enabled
  32986. */
  32987. isEnabled(checkAncestors?: boolean): boolean;
  32988. /** @hidden */
  32989. protected _syncParentEnabledState(): void;
  32990. /**
  32991. * Set the enabled state of this node
  32992. * @param value defines the new enabled state
  32993. */
  32994. setEnabled(value: boolean): void;
  32995. /**
  32996. * Is this node a descendant of the given node?
  32997. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32998. * @param ancestor defines the parent node to inspect
  32999. * @returns a boolean indicating if this node is a descendant of the given node
  33000. */
  33001. isDescendantOf(ancestor: Node): boolean;
  33002. /** @hidden */
  33003. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33004. /**
  33005. * Will return all nodes that have this node as ascendant
  33006. * @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
  33007. * @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
  33008. * @return all children nodes of all types
  33009. */
  33010. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33011. /**
  33012. * Get all child-meshes of this node
  33013. * @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)
  33014. * @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
  33015. * @returns an array of AbstractMesh
  33016. */
  33017. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33018. /**
  33019. * Get all direct children of this node
  33020. * @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
  33021. * @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)
  33022. * @returns an array of Node
  33023. */
  33024. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33025. /** @hidden */
  33026. _setReady(state: boolean): void;
  33027. /**
  33028. * Get an animation by name
  33029. * @param name defines the name of the animation to look for
  33030. * @returns null if not found else the requested animation
  33031. */
  33032. getAnimationByName(name: string): Nullable<Animation>;
  33033. /**
  33034. * Creates an animation range for this node
  33035. * @param name defines the name of the range
  33036. * @param from defines the starting key
  33037. * @param to defines the end key
  33038. */
  33039. createAnimationRange(name: string, from: number, to: number): void;
  33040. /**
  33041. * Delete a specific animation range
  33042. * @param name defines the name of the range to delete
  33043. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33044. */
  33045. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33046. /**
  33047. * Get an animation range by name
  33048. * @param name defines the name of the animation range to look for
  33049. * @returns null if not found else the requested animation range
  33050. */
  33051. getAnimationRange(name: string): Nullable<AnimationRange>;
  33052. /**
  33053. * Gets the list of all animation ranges defined on this node
  33054. * @returns an array
  33055. */
  33056. getAnimationRanges(): Nullable<AnimationRange>[];
  33057. /**
  33058. * Will start the animation sequence
  33059. * @param name defines the range frames for animation sequence
  33060. * @param loop defines if the animation should loop (false by default)
  33061. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33062. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33063. * @returns the object created for this animation. If range does not exist, it will return null
  33064. */
  33065. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33066. /**
  33067. * Serialize animation ranges into a JSON compatible object
  33068. * @returns serialization object
  33069. */
  33070. serializeAnimationRanges(): any;
  33071. /**
  33072. * Computes the world matrix of the node
  33073. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33074. * @returns the world matrix
  33075. */
  33076. computeWorldMatrix(force?: boolean): Matrix;
  33077. /**
  33078. * Releases resources associated with this node.
  33079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33081. */
  33082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33083. /**
  33084. * Parse animation range data from a serialization object and store them into a given node
  33085. * @param node defines where to store the animation ranges
  33086. * @param parsedNode defines the serialization object to read data from
  33087. * @param scene defines the hosting scene
  33088. */
  33089. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33090. /**
  33091. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33092. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33093. * @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
  33094. * @returns the new bounding vectors
  33095. */
  33096. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33097. min: Vector3;
  33098. max: Vector3;
  33099. };
  33100. }
  33101. }
  33102. declare module BABYLON {
  33103. /**
  33104. * @hidden
  33105. */
  33106. export class _IAnimationState {
  33107. key: number;
  33108. repeatCount: number;
  33109. workValue?: any;
  33110. loopMode?: number;
  33111. offsetValue?: any;
  33112. highLimitValue?: any;
  33113. }
  33114. /**
  33115. * Class used to store any kind of animation
  33116. */
  33117. export class Animation {
  33118. /**Name of the animation */
  33119. name: string;
  33120. /**Property to animate */
  33121. targetProperty: string;
  33122. /**The frames per second of the animation */
  33123. framePerSecond: number;
  33124. /**The data type of the animation */
  33125. dataType: number;
  33126. /**The loop mode of the animation */
  33127. loopMode?: number | undefined;
  33128. /**Specifies if blending should be enabled */
  33129. enableBlending?: boolean | undefined;
  33130. /**
  33131. * Use matrix interpolation instead of using direct key value when animating matrices
  33132. */
  33133. static AllowMatricesInterpolation: boolean;
  33134. /**
  33135. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33136. */
  33137. static AllowMatrixDecomposeForInterpolation: boolean;
  33138. /** Define the Url to load snippets */
  33139. static SnippetUrl: string;
  33140. /** Snippet ID if the animation was created from the snippet server */
  33141. snippetId: string;
  33142. /**
  33143. * Stores the key frames of the animation
  33144. */
  33145. private _keys;
  33146. /**
  33147. * Stores the easing function of the animation
  33148. */
  33149. private _easingFunction;
  33150. /**
  33151. * @hidden Internal use only
  33152. */
  33153. _runtimeAnimations: RuntimeAnimation[];
  33154. /**
  33155. * The set of event that will be linked to this animation
  33156. */
  33157. private _events;
  33158. /**
  33159. * Stores an array of target property paths
  33160. */
  33161. targetPropertyPath: string[];
  33162. /**
  33163. * Stores the blending speed of the animation
  33164. */
  33165. blendingSpeed: number;
  33166. /**
  33167. * Stores the animation ranges for the animation
  33168. */
  33169. private _ranges;
  33170. /**
  33171. * @hidden Internal use
  33172. */
  33173. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33174. /**
  33175. * Sets up an animation
  33176. * @param property The property to animate
  33177. * @param animationType The animation type to apply
  33178. * @param framePerSecond The frames per second of the animation
  33179. * @param easingFunction The easing function used in the animation
  33180. * @returns The created animation
  33181. */
  33182. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33183. /**
  33184. * Create and start an animation on a node
  33185. * @param name defines the name of the global animation that will be run on all nodes
  33186. * @param node defines the root node where the animation will take place
  33187. * @param targetProperty defines property to animate
  33188. * @param framePerSecond defines the number of frame per second yo use
  33189. * @param totalFrame defines the number of frames in total
  33190. * @param from defines the initial value
  33191. * @param to defines the final value
  33192. * @param loopMode defines which loop mode you want to use (off by default)
  33193. * @param easingFunction defines the easing function to use (linear by default)
  33194. * @param onAnimationEnd defines the callback to call when animation end
  33195. * @returns the animatable created for this animation
  33196. */
  33197. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33198. /**
  33199. * Create and start an animation on a node and its descendants
  33200. * @param name defines the name of the global animation that will be run on all nodes
  33201. * @param node defines the root node where the animation will take place
  33202. * @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
  33203. * @param targetProperty defines property to animate
  33204. * @param framePerSecond defines the number of frame per second to use
  33205. * @param totalFrame defines the number of frames in total
  33206. * @param from defines the initial value
  33207. * @param to defines the final value
  33208. * @param loopMode defines which loop mode you want to use (off by default)
  33209. * @param easingFunction defines the easing function to use (linear by default)
  33210. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33211. * @returns the list of animatables created for all nodes
  33212. * @example https://www.babylonjs-playground.com/#MH0VLI
  33213. */
  33214. 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[]>;
  33215. /**
  33216. * Creates a new animation, merges it with the existing animations and starts it
  33217. * @param name Name of the animation
  33218. * @param node Node which contains the scene that begins the animations
  33219. * @param targetProperty Specifies which property to animate
  33220. * @param framePerSecond The frames per second of the animation
  33221. * @param totalFrame The total number of frames
  33222. * @param from The frame at the beginning of the animation
  33223. * @param to The frame at the end of the animation
  33224. * @param loopMode Specifies the loop mode of the animation
  33225. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33226. * @param onAnimationEnd Callback to run once the animation is complete
  33227. * @returns Nullable animation
  33228. */
  33229. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33230. /**
  33231. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33232. * @param sourceAnimation defines the Animation containing keyframes to convert
  33233. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33234. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33235. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33236. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33237. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33238. */
  33239. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33240. /**
  33241. * Transition property of an host to the target Value
  33242. * @param property The property to transition
  33243. * @param targetValue The target Value of the property
  33244. * @param host The object where the property to animate belongs
  33245. * @param scene Scene used to run the animation
  33246. * @param frameRate Framerate (in frame/s) to use
  33247. * @param transition The transition type we want to use
  33248. * @param duration The duration of the animation, in milliseconds
  33249. * @param onAnimationEnd Callback trigger at the end of the animation
  33250. * @returns Nullable animation
  33251. */
  33252. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33253. /**
  33254. * Return the array of runtime animations currently using this animation
  33255. */
  33256. get runtimeAnimations(): RuntimeAnimation[];
  33257. /**
  33258. * Specifies if any of the runtime animations are currently running
  33259. */
  33260. get hasRunningRuntimeAnimations(): boolean;
  33261. /**
  33262. * Initializes the animation
  33263. * @param name Name of the animation
  33264. * @param targetProperty Property to animate
  33265. * @param framePerSecond The frames per second of the animation
  33266. * @param dataType The data type of the animation
  33267. * @param loopMode The loop mode of the animation
  33268. * @param enableBlending Specifies if blending should be enabled
  33269. */
  33270. constructor(
  33271. /**Name of the animation */
  33272. name: string,
  33273. /**Property to animate */
  33274. targetProperty: string,
  33275. /**The frames per second of the animation */
  33276. framePerSecond: number,
  33277. /**The data type of the animation */
  33278. dataType: number,
  33279. /**The loop mode of the animation */
  33280. loopMode?: number | undefined,
  33281. /**Specifies if blending should be enabled */
  33282. enableBlending?: boolean | undefined);
  33283. /**
  33284. * Converts the animation to a string
  33285. * @param fullDetails support for multiple levels of logging within scene loading
  33286. * @returns String form of the animation
  33287. */
  33288. toString(fullDetails?: boolean): string;
  33289. /**
  33290. * Add an event to this animation
  33291. * @param event Event to add
  33292. */
  33293. addEvent(event: AnimationEvent): void;
  33294. /**
  33295. * Remove all events found at the given frame
  33296. * @param frame The frame to remove events from
  33297. */
  33298. removeEvents(frame: number): void;
  33299. /**
  33300. * Retrieves all the events from the animation
  33301. * @returns Events from the animation
  33302. */
  33303. getEvents(): AnimationEvent[];
  33304. /**
  33305. * Creates an animation range
  33306. * @param name Name of the animation range
  33307. * @param from Starting frame of the animation range
  33308. * @param to Ending frame of the animation
  33309. */
  33310. createRange(name: string, from: number, to: number): void;
  33311. /**
  33312. * Deletes an animation range by name
  33313. * @param name Name of the animation range to delete
  33314. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33315. */
  33316. deleteRange(name: string, deleteFrames?: boolean): void;
  33317. /**
  33318. * Gets the animation range by name, or null if not defined
  33319. * @param name Name of the animation range
  33320. * @returns Nullable animation range
  33321. */
  33322. getRange(name: string): Nullable<AnimationRange>;
  33323. /**
  33324. * Gets the key frames from the animation
  33325. * @returns The key frames of the animation
  33326. */
  33327. getKeys(): Array<IAnimationKey>;
  33328. /**
  33329. * Gets the highest frame rate of the animation
  33330. * @returns Highest frame rate of the animation
  33331. */
  33332. getHighestFrame(): number;
  33333. /**
  33334. * Gets the easing function of the animation
  33335. * @returns Easing function of the animation
  33336. */
  33337. getEasingFunction(): IEasingFunction;
  33338. /**
  33339. * Sets the easing function of the animation
  33340. * @param easingFunction A custom mathematical formula for animation
  33341. */
  33342. setEasingFunction(easingFunction: EasingFunction): void;
  33343. /**
  33344. * Interpolates a scalar linearly
  33345. * @param startValue Start value of the animation curve
  33346. * @param endValue End value of the animation curve
  33347. * @param gradient Scalar amount to interpolate
  33348. * @returns Interpolated scalar value
  33349. */
  33350. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33351. /**
  33352. * Interpolates a scalar cubically
  33353. * @param startValue Start value of the animation curve
  33354. * @param outTangent End tangent of the animation
  33355. * @param endValue End value of the animation curve
  33356. * @param inTangent Start tangent of the animation curve
  33357. * @param gradient Scalar amount to interpolate
  33358. * @returns Interpolated scalar value
  33359. */
  33360. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33361. /**
  33362. * Interpolates a quaternion using a spherical linear interpolation
  33363. * @param startValue Start value of the animation curve
  33364. * @param endValue End value of the animation curve
  33365. * @param gradient Scalar amount to interpolate
  33366. * @returns Interpolated quaternion value
  33367. */
  33368. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33369. /**
  33370. * Interpolates a quaternion cubically
  33371. * @param startValue Start value of the animation curve
  33372. * @param outTangent End tangent of the animation curve
  33373. * @param endValue End value of the animation curve
  33374. * @param inTangent Start tangent of the animation curve
  33375. * @param gradient Scalar amount to interpolate
  33376. * @returns Interpolated quaternion value
  33377. */
  33378. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33379. /**
  33380. * Interpolates a Vector3 linearl
  33381. * @param startValue Start value of the animation curve
  33382. * @param endValue End value of the animation curve
  33383. * @param gradient Scalar amount to interpolate
  33384. * @returns Interpolated scalar value
  33385. */
  33386. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33387. /**
  33388. * Interpolates a Vector3 cubically
  33389. * @param startValue Start value of the animation curve
  33390. * @param outTangent End tangent of the animation
  33391. * @param endValue End value of the animation curve
  33392. * @param inTangent Start tangent of the animation curve
  33393. * @param gradient Scalar amount to interpolate
  33394. * @returns InterpolatedVector3 value
  33395. */
  33396. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33397. /**
  33398. * Interpolates a Vector2 linearly
  33399. * @param startValue Start value of the animation curve
  33400. * @param endValue End value of the animation curve
  33401. * @param gradient Scalar amount to interpolate
  33402. * @returns Interpolated Vector2 value
  33403. */
  33404. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33405. /**
  33406. * Interpolates a Vector2 cubically
  33407. * @param startValue Start value of the animation curve
  33408. * @param outTangent End tangent of the animation
  33409. * @param endValue End value of the animation curve
  33410. * @param inTangent Start tangent of the animation curve
  33411. * @param gradient Scalar amount to interpolate
  33412. * @returns Interpolated Vector2 value
  33413. */
  33414. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33415. /**
  33416. * Interpolates a size linearly
  33417. * @param startValue Start value of the animation curve
  33418. * @param endValue End value of the animation curve
  33419. * @param gradient Scalar amount to interpolate
  33420. * @returns Interpolated Size value
  33421. */
  33422. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33423. /**
  33424. * Interpolates a Color3 linearly
  33425. * @param startValue Start value of the animation curve
  33426. * @param endValue End value of the animation curve
  33427. * @param gradient Scalar amount to interpolate
  33428. * @returns Interpolated Color3 value
  33429. */
  33430. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33431. /**
  33432. * Interpolates a Color4 linearly
  33433. * @param startValue Start value of the animation curve
  33434. * @param endValue End value of the animation curve
  33435. * @param gradient Scalar amount to interpolate
  33436. * @returns Interpolated Color3 value
  33437. */
  33438. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33439. /**
  33440. * @hidden Internal use only
  33441. */
  33442. _getKeyValue(value: any): any;
  33443. /**
  33444. * @hidden Internal use only
  33445. */
  33446. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33447. /**
  33448. * Defines the function to use to interpolate matrices
  33449. * @param startValue defines the start matrix
  33450. * @param endValue defines the end matrix
  33451. * @param gradient defines the gradient between both matrices
  33452. * @param result defines an optional target matrix where to store the interpolation
  33453. * @returns the interpolated matrix
  33454. */
  33455. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33456. /**
  33457. * Makes a copy of the animation
  33458. * @returns Cloned animation
  33459. */
  33460. clone(): Animation;
  33461. /**
  33462. * Sets the key frames of the animation
  33463. * @param values The animation key frames to set
  33464. */
  33465. setKeys(values: Array<IAnimationKey>): void;
  33466. /**
  33467. * Serializes the animation to an object
  33468. * @returns Serialized object
  33469. */
  33470. serialize(): any;
  33471. /**
  33472. * Float animation type
  33473. */
  33474. static readonly ANIMATIONTYPE_FLOAT: number;
  33475. /**
  33476. * Vector3 animation type
  33477. */
  33478. static readonly ANIMATIONTYPE_VECTOR3: number;
  33479. /**
  33480. * Quaternion animation type
  33481. */
  33482. static readonly ANIMATIONTYPE_QUATERNION: number;
  33483. /**
  33484. * Matrix animation type
  33485. */
  33486. static readonly ANIMATIONTYPE_MATRIX: number;
  33487. /**
  33488. * Color3 animation type
  33489. */
  33490. static readonly ANIMATIONTYPE_COLOR3: number;
  33491. /**
  33492. * Color3 animation type
  33493. */
  33494. static readonly ANIMATIONTYPE_COLOR4: number;
  33495. /**
  33496. * Vector2 animation type
  33497. */
  33498. static readonly ANIMATIONTYPE_VECTOR2: number;
  33499. /**
  33500. * Size animation type
  33501. */
  33502. static readonly ANIMATIONTYPE_SIZE: number;
  33503. /**
  33504. * Relative Loop Mode
  33505. */
  33506. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33507. /**
  33508. * Cycle Loop Mode
  33509. */
  33510. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33511. /**
  33512. * Constant Loop Mode
  33513. */
  33514. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33515. /** @hidden */
  33516. static _UniversalLerp(left: any, right: any, amount: number): any;
  33517. /**
  33518. * Parses an animation object and creates an animation
  33519. * @param parsedAnimation Parsed animation object
  33520. * @returns Animation object
  33521. */
  33522. static Parse(parsedAnimation: any): Animation;
  33523. /**
  33524. * Appends the serialized animations from the source animations
  33525. * @param source Source containing the animations
  33526. * @param destination Target to store the animations
  33527. */
  33528. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33529. /**
  33530. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33531. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33532. * @param url defines the url to load from
  33533. * @returns a promise that will resolve to the new animation or an array of animations
  33534. */
  33535. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33536. /**
  33537. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33538. * @param snippetId defines the snippet to load
  33539. * @returns a promise that will resolve to the new animation or a new array of animations
  33540. */
  33541. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33542. }
  33543. }
  33544. declare module BABYLON {
  33545. /**
  33546. * Interface containing an array of animations
  33547. */
  33548. export interface IAnimatable {
  33549. /**
  33550. * Array of animations
  33551. */
  33552. animations: Nullable<Array<Animation>>;
  33553. }
  33554. }
  33555. declare module BABYLON {
  33556. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33557. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33558. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33559. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33560. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33561. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33562. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33563. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33564. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33565. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33566. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33567. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33568. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33569. /**
  33570. * Decorator used to define property that can be serialized as reference to a camera
  33571. * @param sourceName defines the name of the property to decorate
  33572. */
  33573. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33574. /**
  33575. * Class used to help serialization objects
  33576. */
  33577. export class SerializationHelper {
  33578. /** @hidden */
  33579. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33580. /** @hidden */
  33581. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33582. /** @hidden */
  33583. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33584. /** @hidden */
  33585. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33586. /**
  33587. * Appends the serialized animations from the source animations
  33588. * @param source Source containing the animations
  33589. * @param destination Target to store the animations
  33590. */
  33591. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33592. /**
  33593. * Static function used to serialized a specific entity
  33594. * @param entity defines the entity to serialize
  33595. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33596. * @returns a JSON compatible object representing the serialization of the entity
  33597. */
  33598. static Serialize<T>(entity: T, serializationObject?: any): any;
  33599. /**
  33600. * Creates a new entity from a serialization data object
  33601. * @param creationFunction defines a function used to instanciated the new entity
  33602. * @param source defines the source serialization data
  33603. * @param scene defines the hosting scene
  33604. * @param rootUrl defines the root url for resources
  33605. * @returns a new entity
  33606. */
  33607. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33608. /**
  33609. * Clones an object
  33610. * @param creationFunction defines the function used to instanciate the new object
  33611. * @param source defines the source object
  33612. * @returns the cloned object
  33613. */
  33614. static Clone<T>(creationFunction: () => T, source: T): T;
  33615. /**
  33616. * Instanciates a new object based on a source one (some data will be shared between both object)
  33617. * @param creationFunction defines the function used to instanciate the new object
  33618. * @param source defines the source object
  33619. * @returns the new object
  33620. */
  33621. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33622. }
  33623. }
  33624. declare module BABYLON {
  33625. /**
  33626. * Base class of all the textures in babylon.
  33627. * It groups all the common properties the materials, post process, lights... might need
  33628. * in order to make a correct use of the texture.
  33629. */
  33630. export class BaseTexture implements IAnimatable {
  33631. /**
  33632. * Default anisotropic filtering level for the application.
  33633. * It is set to 4 as a good tradeoff between perf and quality.
  33634. */
  33635. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33636. /**
  33637. * Gets or sets the unique id of the texture
  33638. */
  33639. uniqueId: number;
  33640. /**
  33641. * Define the name of the texture.
  33642. */
  33643. name: string;
  33644. /**
  33645. * Gets or sets an object used to store user defined information.
  33646. */
  33647. metadata: any;
  33648. /**
  33649. * For internal use only. Please do not use.
  33650. */
  33651. reservedDataStore: any;
  33652. private _hasAlpha;
  33653. /**
  33654. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33655. */
  33656. set hasAlpha(value: boolean);
  33657. get hasAlpha(): boolean;
  33658. /**
  33659. * Defines if the alpha value should be determined via the rgb values.
  33660. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33661. */
  33662. getAlphaFromRGB: boolean;
  33663. /**
  33664. * Intensity or strength of the texture.
  33665. * It is commonly used by materials to fine tune the intensity of the texture
  33666. */
  33667. level: number;
  33668. /**
  33669. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33670. * This is part of the texture as textures usually maps to one uv set.
  33671. */
  33672. coordinatesIndex: number;
  33673. private _coordinatesMode;
  33674. /**
  33675. * How a texture is mapped.
  33676. *
  33677. * | Value | Type | Description |
  33678. * | ----- | ----------------------------------- | ----------- |
  33679. * | 0 | EXPLICIT_MODE | |
  33680. * | 1 | SPHERICAL_MODE | |
  33681. * | 2 | PLANAR_MODE | |
  33682. * | 3 | CUBIC_MODE | |
  33683. * | 4 | PROJECTION_MODE | |
  33684. * | 5 | SKYBOX_MODE | |
  33685. * | 6 | INVCUBIC_MODE | |
  33686. * | 7 | EQUIRECTANGULAR_MODE | |
  33687. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33688. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33689. */
  33690. set coordinatesMode(value: number);
  33691. get coordinatesMode(): number;
  33692. /**
  33693. * | Value | Type | Description |
  33694. * | ----- | ------------------ | ----------- |
  33695. * | 0 | CLAMP_ADDRESSMODE | |
  33696. * | 1 | WRAP_ADDRESSMODE | |
  33697. * | 2 | MIRROR_ADDRESSMODE | |
  33698. */
  33699. wrapU: number;
  33700. /**
  33701. * | Value | Type | Description |
  33702. * | ----- | ------------------ | ----------- |
  33703. * | 0 | CLAMP_ADDRESSMODE | |
  33704. * | 1 | WRAP_ADDRESSMODE | |
  33705. * | 2 | MIRROR_ADDRESSMODE | |
  33706. */
  33707. wrapV: number;
  33708. /**
  33709. * | Value | Type | Description |
  33710. * | ----- | ------------------ | ----------- |
  33711. * | 0 | CLAMP_ADDRESSMODE | |
  33712. * | 1 | WRAP_ADDRESSMODE | |
  33713. * | 2 | MIRROR_ADDRESSMODE | |
  33714. */
  33715. wrapR: number;
  33716. /**
  33717. * With compliant hardware and browser (supporting anisotropic filtering)
  33718. * this defines the level of anisotropic filtering in the texture.
  33719. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33720. */
  33721. anisotropicFilteringLevel: number;
  33722. /**
  33723. * Define if the texture is a cube texture or if false a 2d texture.
  33724. */
  33725. get isCube(): boolean;
  33726. set isCube(value: boolean);
  33727. /**
  33728. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33729. */
  33730. get is3D(): boolean;
  33731. set is3D(value: boolean);
  33732. /**
  33733. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33734. */
  33735. get is2DArray(): boolean;
  33736. set is2DArray(value: boolean);
  33737. /**
  33738. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33739. * HDR texture are usually stored in linear space.
  33740. * This only impacts the PBR and Background materials
  33741. */
  33742. gammaSpace: boolean;
  33743. /**
  33744. * Gets or sets whether or not the texture contains RGBD data.
  33745. */
  33746. get isRGBD(): boolean;
  33747. set isRGBD(value: boolean);
  33748. /**
  33749. * Is Z inverted in the texture (useful in a cube texture).
  33750. */
  33751. invertZ: boolean;
  33752. /**
  33753. * Are mip maps generated for this texture or not.
  33754. */
  33755. get noMipmap(): boolean;
  33756. /**
  33757. * @hidden
  33758. */
  33759. lodLevelInAlpha: boolean;
  33760. /**
  33761. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33762. */
  33763. get lodGenerationOffset(): number;
  33764. set lodGenerationOffset(value: number);
  33765. /**
  33766. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33767. */
  33768. get lodGenerationScale(): number;
  33769. set lodGenerationScale(value: number);
  33770. /**
  33771. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33772. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33773. * average roughness values.
  33774. */
  33775. get linearSpecularLOD(): boolean;
  33776. set linearSpecularLOD(value: boolean);
  33777. /**
  33778. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33779. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33780. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33781. */
  33782. get irradianceTexture(): Nullable<BaseTexture>;
  33783. set irradianceTexture(value: Nullable<BaseTexture>);
  33784. /**
  33785. * Define if the texture is a render target.
  33786. */
  33787. isRenderTarget: boolean;
  33788. /**
  33789. * Define the unique id of the texture in the scene.
  33790. */
  33791. get uid(): string;
  33792. /** @hidden */
  33793. _prefiltered: boolean;
  33794. /**
  33795. * Return a string representation of the texture.
  33796. * @returns the texture as a string
  33797. */
  33798. toString(): string;
  33799. /**
  33800. * Get the class name of the texture.
  33801. * @returns "BaseTexture"
  33802. */
  33803. getClassName(): string;
  33804. /**
  33805. * Define the list of animation attached to the texture.
  33806. */
  33807. animations: Animation[];
  33808. /**
  33809. * An event triggered when the texture is disposed.
  33810. */
  33811. onDisposeObservable: Observable<BaseTexture>;
  33812. private _onDisposeObserver;
  33813. /**
  33814. * Callback triggered when the texture has been disposed.
  33815. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33816. */
  33817. set onDispose(callback: () => void);
  33818. /**
  33819. * Define the current state of the loading sequence when in delayed load mode.
  33820. */
  33821. delayLoadState: number;
  33822. private _scene;
  33823. private _engine;
  33824. /** @hidden */
  33825. _texture: Nullable<InternalTexture>;
  33826. private _uid;
  33827. /**
  33828. * Define if the texture is preventinga material to render or not.
  33829. * If not and the texture is not ready, the engine will use a default black texture instead.
  33830. */
  33831. get isBlocking(): boolean;
  33832. /**
  33833. * Instantiates a new BaseTexture.
  33834. * Base class of all the textures in babylon.
  33835. * It groups all the common properties the materials, post process, lights... might need
  33836. * in order to make a correct use of the texture.
  33837. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33838. */
  33839. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33840. /**
  33841. * Get the scene the texture belongs to.
  33842. * @returns the scene or null if undefined
  33843. */
  33844. getScene(): Nullable<Scene>;
  33845. /** @hidden */
  33846. protected _getEngine(): Nullable<ThinEngine>;
  33847. /**
  33848. * Get the texture transform matrix used to offset tile the texture for istance.
  33849. * @returns the transformation matrix
  33850. */
  33851. getTextureMatrix(): Matrix;
  33852. /**
  33853. * Get the texture reflection matrix used to rotate/transform the reflection.
  33854. * @returns the reflection matrix
  33855. */
  33856. getReflectionTextureMatrix(): Matrix;
  33857. /**
  33858. * Get the underlying lower level texture from Babylon.
  33859. * @returns the insternal texture
  33860. */
  33861. getInternalTexture(): Nullable<InternalTexture>;
  33862. /**
  33863. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33864. * @returns true if ready or not blocking
  33865. */
  33866. isReadyOrNotBlocking(): boolean;
  33867. /**
  33868. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33869. * @returns true if fully ready
  33870. */
  33871. isReady(): boolean;
  33872. private _cachedSize;
  33873. /**
  33874. * Get the size of the texture.
  33875. * @returns the texture size.
  33876. */
  33877. getSize(): ISize;
  33878. /**
  33879. * Get the base size of the texture.
  33880. * It can be different from the size if the texture has been resized for POT for instance
  33881. * @returns the base size
  33882. */
  33883. getBaseSize(): ISize;
  33884. /**
  33885. * Update the sampling mode of the texture.
  33886. * Default is Trilinear mode.
  33887. *
  33888. * | Value | Type | Description |
  33889. * | ----- | ------------------ | ----------- |
  33890. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33891. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33892. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33893. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33894. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33895. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33896. * | 7 | NEAREST_LINEAR | |
  33897. * | 8 | NEAREST_NEAREST | |
  33898. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33899. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33900. * | 11 | LINEAR_LINEAR | |
  33901. * | 12 | LINEAR_NEAREST | |
  33902. *
  33903. * > _mag_: magnification filter (close to the viewer)
  33904. * > _min_: minification filter (far from the viewer)
  33905. * > _mip_: filter used between mip map levels
  33906. *@param samplingMode Define the new sampling mode of the texture
  33907. */
  33908. updateSamplingMode(samplingMode: number): void;
  33909. /**
  33910. * Scales the texture if is `canRescale()`
  33911. * @param ratio the resize factor we want to use to rescale
  33912. */
  33913. scale(ratio: number): void;
  33914. /**
  33915. * Get if the texture can rescale.
  33916. */
  33917. get canRescale(): boolean;
  33918. /** @hidden */
  33919. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33920. /** @hidden */
  33921. _rebuild(): void;
  33922. /**
  33923. * Triggers the load sequence in delayed load mode.
  33924. */
  33925. delayLoad(): void;
  33926. /**
  33927. * Clones the texture.
  33928. * @returns the cloned texture
  33929. */
  33930. clone(): Nullable<BaseTexture>;
  33931. /**
  33932. * Get the texture underlying type (INT, FLOAT...)
  33933. */
  33934. get textureType(): number;
  33935. /**
  33936. * Get the texture underlying format (RGB, RGBA...)
  33937. */
  33938. get textureFormat(): number;
  33939. /**
  33940. * Indicates that textures need to be re-calculated for all materials
  33941. */
  33942. protected _markAllSubMeshesAsTexturesDirty(): void;
  33943. /**
  33944. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33945. * This will returns an RGBA array buffer containing either in values (0-255) or
  33946. * float values (0-1) depending of the underlying buffer type.
  33947. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33948. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33949. * @param buffer defines a user defined buffer to fill with data (can be null)
  33950. * @returns The Array buffer containing the pixels data.
  33951. */
  33952. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33953. /**
  33954. * Release and destroy the underlying lower level texture aka internalTexture.
  33955. */
  33956. releaseInternalTexture(): void;
  33957. /** @hidden */
  33958. get _lodTextureHigh(): Nullable<BaseTexture>;
  33959. /** @hidden */
  33960. get _lodTextureMid(): Nullable<BaseTexture>;
  33961. /** @hidden */
  33962. get _lodTextureLow(): Nullable<BaseTexture>;
  33963. /**
  33964. * Dispose the texture and release its associated resources.
  33965. */
  33966. dispose(): void;
  33967. /**
  33968. * Serialize the texture into a JSON representation that can be parsed later on.
  33969. * @returns the JSON representation of the texture
  33970. */
  33971. serialize(): any;
  33972. /**
  33973. * Helper function to be called back once a list of texture contains only ready textures.
  33974. * @param textures Define the list of textures to wait for
  33975. * @param callback Define the callback triggered once the entire list will be ready
  33976. */
  33977. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33978. private static _isScene;
  33979. }
  33980. }
  33981. declare module BABYLON {
  33982. /**
  33983. * Options to be used when creating an effect.
  33984. */
  33985. export interface IEffectCreationOptions {
  33986. /**
  33987. * Atrributes that will be used in the shader.
  33988. */
  33989. attributes: string[];
  33990. /**
  33991. * Uniform varible names that will be set in the shader.
  33992. */
  33993. uniformsNames: string[];
  33994. /**
  33995. * Uniform buffer variable names that will be set in the shader.
  33996. */
  33997. uniformBuffersNames: string[];
  33998. /**
  33999. * Sampler texture variable names that will be set in the shader.
  34000. */
  34001. samplers: string[];
  34002. /**
  34003. * Define statements that will be set in the shader.
  34004. */
  34005. defines: any;
  34006. /**
  34007. * Possible fallbacks for this effect to improve performance when needed.
  34008. */
  34009. fallbacks: Nullable<IEffectFallbacks>;
  34010. /**
  34011. * Callback that will be called when the shader is compiled.
  34012. */
  34013. onCompiled: Nullable<(effect: Effect) => void>;
  34014. /**
  34015. * Callback that will be called if an error occurs during shader compilation.
  34016. */
  34017. onError: Nullable<(effect: Effect, errors: string) => void>;
  34018. /**
  34019. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34020. */
  34021. indexParameters?: any;
  34022. /**
  34023. * Max number of lights that can be used in the shader.
  34024. */
  34025. maxSimultaneousLights?: number;
  34026. /**
  34027. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34028. */
  34029. transformFeedbackVaryings?: Nullable<string[]>;
  34030. /**
  34031. * 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
  34032. */
  34033. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34034. /**
  34035. * Is this effect rendering to several color attachments ?
  34036. */
  34037. multiTarget?: boolean;
  34038. }
  34039. /**
  34040. * Effect containing vertex and fragment shader that can be executed on an object.
  34041. */
  34042. export class Effect implements IDisposable {
  34043. /**
  34044. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34045. */
  34046. static ShadersRepository: string;
  34047. /**
  34048. * Enable logging of the shader code when a compilation error occurs
  34049. */
  34050. static LogShaderCodeOnCompilationError: boolean;
  34051. /**
  34052. * Name of the effect.
  34053. */
  34054. name: any;
  34055. /**
  34056. * String container all the define statements that should be set on the shader.
  34057. */
  34058. defines: string;
  34059. /**
  34060. * Callback that will be called when the shader is compiled.
  34061. */
  34062. onCompiled: Nullable<(effect: Effect) => void>;
  34063. /**
  34064. * Callback that will be called if an error occurs during shader compilation.
  34065. */
  34066. onError: Nullable<(effect: Effect, errors: string) => void>;
  34067. /**
  34068. * Callback that will be called when effect is bound.
  34069. */
  34070. onBind: Nullable<(effect: Effect) => void>;
  34071. /**
  34072. * Unique ID of the effect.
  34073. */
  34074. uniqueId: number;
  34075. /**
  34076. * Observable that will be called when the shader is compiled.
  34077. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34078. */
  34079. onCompileObservable: Observable<Effect>;
  34080. /**
  34081. * Observable that will be called if an error occurs during shader compilation.
  34082. */
  34083. onErrorObservable: Observable<Effect>;
  34084. /** @hidden */
  34085. _onBindObservable: Nullable<Observable<Effect>>;
  34086. /**
  34087. * @hidden
  34088. * Specifies if the effect was previously ready
  34089. */
  34090. _wasPreviouslyReady: boolean;
  34091. /**
  34092. * Observable that will be called when effect is bound.
  34093. */
  34094. get onBindObservable(): Observable<Effect>;
  34095. /** @hidden */
  34096. _bonesComputationForcedToCPU: boolean;
  34097. /** @hidden */
  34098. _multiTarget: boolean;
  34099. private static _uniqueIdSeed;
  34100. private _engine;
  34101. private _uniformBuffersNames;
  34102. private _uniformBuffersNamesList;
  34103. private _uniformsNames;
  34104. private _samplerList;
  34105. private _samplers;
  34106. private _isReady;
  34107. private _compilationError;
  34108. private _allFallbacksProcessed;
  34109. private _attributesNames;
  34110. private _attributes;
  34111. private _attributeLocationByName;
  34112. private _uniforms;
  34113. /**
  34114. * Key for the effect.
  34115. * @hidden
  34116. */
  34117. _key: string;
  34118. private _indexParameters;
  34119. private _fallbacks;
  34120. private _vertexSourceCode;
  34121. private _fragmentSourceCode;
  34122. private _vertexSourceCodeOverride;
  34123. private _fragmentSourceCodeOverride;
  34124. private _transformFeedbackVaryings;
  34125. /**
  34126. * Compiled shader to webGL program.
  34127. * @hidden
  34128. */
  34129. _pipelineContext: Nullable<IPipelineContext>;
  34130. private _valueCache;
  34131. private static _baseCache;
  34132. /**
  34133. * Instantiates an effect.
  34134. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34135. * @param baseName Name of the effect.
  34136. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34137. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34138. * @param samplers List of sampler variables that will be passed to the shader.
  34139. * @param engine Engine to be used to render the effect
  34140. * @param defines Define statements to be added to the shader.
  34141. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34142. * @param onCompiled Callback that will be called when the shader is compiled.
  34143. * @param onError Callback that will be called if an error occurs during shader compilation.
  34144. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34145. */
  34146. 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);
  34147. private _useFinalCode;
  34148. /**
  34149. * Unique key for this effect
  34150. */
  34151. get key(): string;
  34152. /**
  34153. * If the effect has been compiled and prepared.
  34154. * @returns if the effect is compiled and prepared.
  34155. */
  34156. isReady(): boolean;
  34157. private _isReadyInternal;
  34158. /**
  34159. * The engine the effect was initialized with.
  34160. * @returns the engine.
  34161. */
  34162. getEngine(): Engine;
  34163. /**
  34164. * The pipeline context for this effect
  34165. * @returns the associated pipeline context
  34166. */
  34167. getPipelineContext(): Nullable<IPipelineContext>;
  34168. /**
  34169. * The set of names of attribute variables for the shader.
  34170. * @returns An array of attribute names.
  34171. */
  34172. getAttributesNames(): string[];
  34173. /**
  34174. * Returns the attribute at the given index.
  34175. * @param index The index of the attribute.
  34176. * @returns The location of the attribute.
  34177. */
  34178. getAttributeLocation(index: number): number;
  34179. /**
  34180. * Returns the attribute based on the name of the variable.
  34181. * @param name of the attribute to look up.
  34182. * @returns the attribute location.
  34183. */
  34184. getAttributeLocationByName(name: string): number;
  34185. /**
  34186. * The number of attributes.
  34187. * @returns the numnber of attributes.
  34188. */
  34189. getAttributesCount(): number;
  34190. /**
  34191. * Gets the index of a uniform variable.
  34192. * @param uniformName of the uniform to look up.
  34193. * @returns the index.
  34194. */
  34195. getUniformIndex(uniformName: string): number;
  34196. /**
  34197. * Returns the attribute based on the name of the variable.
  34198. * @param uniformName of the uniform to look up.
  34199. * @returns the location of the uniform.
  34200. */
  34201. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34202. /**
  34203. * Returns an array of sampler variable names
  34204. * @returns The array of sampler variable names.
  34205. */
  34206. getSamplers(): string[];
  34207. /**
  34208. * Returns an array of uniform variable names
  34209. * @returns The array of uniform variable names.
  34210. */
  34211. getUniformNames(): string[];
  34212. /**
  34213. * Returns an array of uniform buffer variable names
  34214. * @returns The array of uniform buffer variable names.
  34215. */
  34216. getUniformBuffersNames(): string[];
  34217. /**
  34218. * Returns the index parameters used to create the effect
  34219. * @returns The index parameters object
  34220. */
  34221. getIndexParameters(): any;
  34222. /**
  34223. * The error from the last compilation.
  34224. * @returns the error string.
  34225. */
  34226. getCompilationError(): string;
  34227. /**
  34228. * Gets a boolean indicating that all fallbacks were used during compilation
  34229. * @returns true if all fallbacks were used
  34230. */
  34231. allFallbacksProcessed(): boolean;
  34232. /**
  34233. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34234. * @param func The callback to be used.
  34235. */
  34236. executeWhenCompiled(func: (effect: Effect) => void): void;
  34237. private _checkIsReady;
  34238. private _loadShader;
  34239. /**
  34240. * Gets the vertex shader source code of this effect
  34241. */
  34242. get vertexSourceCode(): string;
  34243. /**
  34244. * Gets the fragment shader source code of this effect
  34245. */
  34246. get fragmentSourceCode(): string;
  34247. /**
  34248. * Recompiles the webGL program
  34249. * @param vertexSourceCode The source code for the vertex shader.
  34250. * @param fragmentSourceCode The source code for the fragment shader.
  34251. * @param onCompiled Callback called when completed.
  34252. * @param onError Callback called on error.
  34253. * @hidden
  34254. */
  34255. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34256. /**
  34257. * Prepares the effect
  34258. * @hidden
  34259. */
  34260. _prepareEffect(): void;
  34261. private _getShaderCodeAndErrorLine;
  34262. private _processCompilationErrors;
  34263. /**
  34264. * Checks if the effect is supported. (Must be called after compilation)
  34265. */
  34266. get isSupported(): boolean;
  34267. /**
  34268. * Binds a texture to the engine to be used as output of the shader.
  34269. * @param channel Name of the output variable.
  34270. * @param texture Texture to bind.
  34271. * @hidden
  34272. */
  34273. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34274. /**
  34275. * Sets a texture on the engine to be used in the shader.
  34276. * @param channel Name of the sampler variable.
  34277. * @param texture Texture to set.
  34278. */
  34279. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34280. /**
  34281. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34282. * @param channel Name of the sampler variable.
  34283. * @param texture Texture to set.
  34284. */
  34285. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34286. /**
  34287. * Sets an array of textures on the engine to be used in the shader.
  34288. * @param channel Name of the variable.
  34289. * @param textures Textures to set.
  34290. */
  34291. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34292. /**
  34293. * 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)
  34294. * @param channel Name of the sampler variable.
  34295. * @param postProcess Post process to get the input texture from.
  34296. */
  34297. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34298. /**
  34299. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34300. * 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)
  34301. * @param channel Name of the sampler variable.
  34302. * @param postProcess Post process to get the output texture from.
  34303. */
  34304. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34305. /** @hidden */
  34306. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34307. /** @hidden */
  34308. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34309. /** @hidden */
  34310. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34311. /** @hidden */
  34312. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34313. /**
  34314. * Binds a buffer to a uniform.
  34315. * @param buffer Buffer to bind.
  34316. * @param name Name of the uniform variable to bind to.
  34317. */
  34318. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34319. /**
  34320. * Binds block to a uniform.
  34321. * @param blockName Name of the block to bind.
  34322. * @param index Index to bind.
  34323. */
  34324. bindUniformBlock(blockName: string, index: number): void;
  34325. /**
  34326. * Sets an interger value on a uniform variable.
  34327. * @param uniformName Name of the variable.
  34328. * @param value Value to be set.
  34329. * @returns this effect.
  34330. */
  34331. setInt(uniformName: string, value: number): Effect;
  34332. /**
  34333. * Sets an int array on a uniform variable.
  34334. * @param uniformName Name of the variable.
  34335. * @param array array to be set.
  34336. * @returns this effect.
  34337. */
  34338. setIntArray(uniformName: string, array: Int32Array): Effect;
  34339. /**
  34340. * 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)
  34341. * @param uniformName Name of the variable.
  34342. * @param array array to be set.
  34343. * @returns this effect.
  34344. */
  34345. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34346. /**
  34347. * 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)
  34348. * @param uniformName Name of the variable.
  34349. * @param array array to be set.
  34350. * @returns this effect.
  34351. */
  34352. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34353. /**
  34354. * 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)
  34355. * @param uniformName Name of the variable.
  34356. * @param array array to be set.
  34357. * @returns this effect.
  34358. */
  34359. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34360. /**
  34361. * Sets an float array on a uniform variable.
  34362. * @param uniformName Name of the variable.
  34363. * @param array array to be set.
  34364. * @returns this effect.
  34365. */
  34366. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34367. /**
  34368. * 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)
  34369. * @param uniformName Name of the variable.
  34370. * @param array array to be set.
  34371. * @returns this effect.
  34372. */
  34373. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34374. /**
  34375. * 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)
  34376. * @param uniformName Name of the variable.
  34377. * @param array array to be set.
  34378. * @returns this effect.
  34379. */
  34380. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34381. /**
  34382. * 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)
  34383. * @param uniformName Name of the variable.
  34384. * @param array array to be set.
  34385. * @returns this effect.
  34386. */
  34387. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34388. /**
  34389. * Sets an array on a uniform variable.
  34390. * @param uniformName Name of the variable.
  34391. * @param array array to be set.
  34392. * @returns this effect.
  34393. */
  34394. setArray(uniformName: string, array: number[]): Effect;
  34395. /**
  34396. * 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)
  34397. * @param uniformName Name of the variable.
  34398. * @param array array to be set.
  34399. * @returns this effect.
  34400. */
  34401. setArray2(uniformName: string, array: number[]): Effect;
  34402. /**
  34403. * 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)
  34404. * @param uniformName Name of the variable.
  34405. * @param array array to be set.
  34406. * @returns this effect.
  34407. */
  34408. setArray3(uniformName: string, array: number[]): Effect;
  34409. /**
  34410. * 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)
  34411. * @param uniformName Name of the variable.
  34412. * @param array array to be set.
  34413. * @returns this effect.
  34414. */
  34415. setArray4(uniformName: string, array: number[]): Effect;
  34416. /**
  34417. * Sets matrices on a uniform variable.
  34418. * @param uniformName Name of the variable.
  34419. * @param matrices matrices to be set.
  34420. * @returns this effect.
  34421. */
  34422. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34423. /**
  34424. * Sets matrix on a uniform variable.
  34425. * @param uniformName Name of the variable.
  34426. * @param matrix matrix to be set.
  34427. * @returns this effect.
  34428. */
  34429. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34430. /**
  34431. * 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)
  34432. * @param uniformName Name of the variable.
  34433. * @param matrix matrix to be set.
  34434. * @returns this effect.
  34435. */
  34436. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34437. /**
  34438. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34439. * @param uniformName Name of the variable.
  34440. * @param matrix matrix to be set.
  34441. * @returns this effect.
  34442. */
  34443. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34444. /**
  34445. * Sets a float on a uniform variable.
  34446. * @param uniformName Name of the variable.
  34447. * @param value value to be set.
  34448. * @returns this effect.
  34449. */
  34450. setFloat(uniformName: string, value: number): Effect;
  34451. /**
  34452. * Sets a boolean on a uniform variable.
  34453. * @param uniformName Name of the variable.
  34454. * @param bool value to be set.
  34455. * @returns this effect.
  34456. */
  34457. setBool(uniformName: string, bool: boolean): Effect;
  34458. /**
  34459. * Sets a Vector2 on a uniform variable.
  34460. * @param uniformName Name of the variable.
  34461. * @param vector2 vector2 to be set.
  34462. * @returns this effect.
  34463. */
  34464. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34465. /**
  34466. * Sets a float2 on a uniform variable.
  34467. * @param uniformName Name of the variable.
  34468. * @param x First float in float2.
  34469. * @param y Second float in float2.
  34470. * @returns this effect.
  34471. */
  34472. setFloat2(uniformName: string, x: number, y: number): Effect;
  34473. /**
  34474. * Sets a Vector3 on a uniform variable.
  34475. * @param uniformName Name of the variable.
  34476. * @param vector3 Value to be set.
  34477. * @returns this effect.
  34478. */
  34479. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34480. /**
  34481. * Sets a float3 on a uniform variable.
  34482. * @param uniformName Name of the variable.
  34483. * @param x First float in float3.
  34484. * @param y Second float in float3.
  34485. * @param z Third float in float3.
  34486. * @returns this effect.
  34487. */
  34488. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34489. /**
  34490. * Sets a Vector4 on a uniform variable.
  34491. * @param uniformName Name of the variable.
  34492. * @param vector4 Value to be set.
  34493. * @returns this effect.
  34494. */
  34495. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34496. /**
  34497. * Sets a float4 on a uniform variable.
  34498. * @param uniformName Name of the variable.
  34499. * @param x First float in float4.
  34500. * @param y Second float in float4.
  34501. * @param z Third float in float4.
  34502. * @param w Fourth float in float4.
  34503. * @returns this effect.
  34504. */
  34505. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34506. /**
  34507. * Sets a Color3 on a uniform variable.
  34508. * @param uniformName Name of the variable.
  34509. * @param color3 Value to be set.
  34510. * @returns this effect.
  34511. */
  34512. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34513. /**
  34514. * Sets a Color4 on a uniform variable.
  34515. * @param uniformName Name of the variable.
  34516. * @param color3 Value to be set.
  34517. * @param alpha Alpha value to be set.
  34518. * @returns this effect.
  34519. */
  34520. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34521. /**
  34522. * Sets a Color4 on a uniform variable
  34523. * @param uniformName defines the name of the variable
  34524. * @param color4 defines the value to be set
  34525. * @returns this effect.
  34526. */
  34527. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34528. /** Release all associated resources */
  34529. dispose(): void;
  34530. /**
  34531. * This function will add a new shader to the shader store
  34532. * @param name the name of the shader
  34533. * @param pixelShader optional pixel shader content
  34534. * @param vertexShader optional vertex shader content
  34535. */
  34536. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34537. /**
  34538. * Store of each shader (The can be looked up using effect.key)
  34539. */
  34540. static ShadersStore: {
  34541. [key: string]: string;
  34542. };
  34543. /**
  34544. * Store of each included file for a shader (The can be looked up using effect.key)
  34545. */
  34546. static IncludesShadersStore: {
  34547. [key: string]: string;
  34548. };
  34549. /**
  34550. * Resets the cache of effects.
  34551. */
  34552. static ResetCache(): void;
  34553. }
  34554. }
  34555. declare module BABYLON {
  34556. /**
  34557. * Interface used to describe the capabilities of the engine relatively to the current browser
  34558. */
  34559. export interface EngineCapabilities {
  34560. /** Maximum textures units per fragment shader */
  34561. maxTexturesImageUnits: number;
  34562. /** Maximum texture units per vertex shader */
  34563. maxVertexTextureImageUnits: number;
  34564. /** Maximum textures units in the entire pipeline */
  34565. maxCombinedTexturesImageUnits: number;
  34566. /** Maximum texture size */
  34567. maxTextureSize: number;
  34568. /** Maximum texture samples */
  34569. maxSamples?: number;
  34570. /** Maximum cube texture size */
  34571. maxCubemapTextureSize: number;
  34572. /** Maximum render texture size */
  34573. maxRenderTextureSize: number;
  34574. /** Maximum number of vertex attributes */
  34575. maxVertexAttribs: number;
  34576. /** Maximum number of varyings */
  34577. maxVaryingVectors: number;
  34578. /** Maximum number of uniforms per vertex shader */
  34579. maxVertexUniformVectors: number;
  34580. /** Maximum number of uniforms per fragment shader */
  34581. maxFragmentUniformVectors: number;
  34582. /** Defines if standard derivates (dx/dy) are supported */
  34583. standardDerivatives: boolean;
  34584. /** Defines if s3tc texture compression is supported */
  34585. s3tc?: WEBGL_compressed_texture_s3tc;
  34586. /** Defines if pvrtc texture compression is supported */
  34587. pvrtc: any;
  34588. /** Defines if etc1 texture compression is supported */
  34589. etc1: any;
  34590. /** Defines if etc2 texture compression is supported */
  34591. etc2: any;
  34592. /** Defines if astc texture compression is supported */
  34593. astc: any;
  34594. /** Defines if float textures are supported */
  34595. textureFloat: boolean;
  34596. /** Defines if vertex array objects are supported */
  34597. vertexArrayObject: boolean;
  34598. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34599. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34600. /** Gets the maximum level of anisotropy supported */
  34601. maxAnisotropy: number;
  34602. /** Defines if instancing is supported */
  34603. instancedArrays: boolean;
  34604. /** Defines if 32 bits indices are supported */
  34605. uintIndices: boolean;
  34606. /** Defines if high precision shaders are supported */
  34607. highPrecisionShaderSupported: boolean;
  34608. /** Defines if depth reading in the fragment shader is supported */
  34609. fragmentDepthSupported: boolean;
  34610. /** Defines if float texture linear filtering is supported*/
  34611. textureFloatLinearFiltering: boolean;
  34612. /** Defines if rendering to float textures is supported */
  34613. textureFloatRender: boolean;
  34614. /** Defines if half float textures are supported*/
  34615. textureHalfFloat: boolean;
  34616. /** Defines if half float texture linear filtering is supported*/
  34617. textureHalfFloatLinearFiltering: boolean;
  34618. /** Defines if rendering to half float textures is supported */
  34619. textureHalfFloatRender: boolean;
  34620. /** Defines if textureLOD shader command is supported */
  34621. textureLOD: boolean;
  34622. /** Defines if draw buffers extension is supported */
  34623. drawBuffersExtension: boolean;
  34624. /** Defines if depth textures are supported */
  34625. depthTextureExtension: boolean;
  34626. /** Defines if float color buffer are supported */
  34627. colorBufferFloat: boolean;
  34628. /** Gets disjoint timer query extension (null if not supported) */
  34629. timerQuery?: EXT_disjoint_timer_query;
  34630. /** Defines if timestamp can be used with timer query */
  34631. canUseTimestampForTimerQuery: boolean;
  34632. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34633. multiview?: any;
  34634. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34635. oculusMultiview?: any;
  34636. /** Function used to let the system compiles shaders in background */
  34637. parallelShaderCompile?: {
  34638. COMPLETION_STATUS_KHR: number;
  34639. };
  34640. /** Max number of texture samples for MSAA */
  34641. maxMSAASamples: number;
  34642. /** Defines if the blend min max extension is supported */
  34643. blendMinMax: boolean;
  34644. }
  34645. }
  34646. declare module BABYLON {
  34647. /**
  34648. * @hidden
  34649. **/
  34650. export class DepthCullingState {
  34651. private _isDepthTestDirty;
  34652. private _isDepthMaskDirty;
  34653. private _isDepthFuncDirty;
  34654. private _isCullFaceDirty;
  34655. private _isCullDirty;
  34656. private _isZOffsetDirty;
  34657. private _isFrontFaceDirty;
  34658. private _depthTest;
  34659. private _depthMask;
  34660. private _depthFunc;
  34661. private _cull;
  34662. private _cullFace;
  34663. private _zOffset;
  34664. private _frontFace;
  34665. /**
  34666. * Initializes the state.
  34667. */
  34668. constructor();
  34669. get isDirty(): boolean;
  34670. get zOffset(): number;
  34671. set zOffset(value: number);
  34672. get cullFace(): Nullable<number>;
  34673. set cullFace(value: Nullable<number>);
  34674. get cull(): Nullable<boolean>;
  34675. set cull(value: Nullable<boolean>);
  34676. get depthFunc(): Nullable<number>;
  34677. set depthFunc(value: Nullable<number>);
  34678. get depthMask(): boolean;
  34679. set depthMask(value: boolean);
  34680. get depthTest(): boolean;
  34681. set depthTest(value: boolean);
  34682. get frontFace(): Nullable<number>;
  34683. set frontFace(value: Nullable<number>);
  34684. reset(): void;
  34685. apply(gl: WebGLRenderingContext): void;
  34686. }
  34687. }
  34688. declare module BABYLON {
  34689. /**
  34690. * @hidden
  34691. **/
  34692. export class StencilState {
  34693. /** 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 */
  34694. static readonly ALWAYS: number;
  34695. /** Passed to stencilOperation to specify that stencil value must be kept */
  34696. static readonly KEEP: number;
  34697. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34698. static readonly REPLACE: number;
  34699. private _isStencilTestDirty;
  34700. private _isStencilMaskDirty;
  34701. private _isStencilFuncDirty;
  34702. private _isStencilOpDirty;
  34703. private _stencilTest;
  34704. private _stencilMask;
  34705. private _stencilFunc;
  34706. private _stencilFuncRef;
  34707. private _stencilFuncMask;
  34708. private _stencilOpStencilFail;
  34709. private _stencilOpDepthFail;
  34710. private _stencilOpStencilDepthPass;
  34711. get isDirty(): boolean;
  34712. get stencilFunc(): number;
  34713. set stencilFunc(value: number);
  34714. get stencilFuncRef(): number;
  34715. set stencilFuncRef(value: number);
  34716. get stencilFuncMask(): number;
  34717. set stencilFuncMask(value: number);
  34718. get stencilOpStencilFail(): number;
  34719. set stencilOpStencilFail(value: number);
  34720. get stencilOpDepthFail(): number;
  34721. set stencilOpDepthFail(value: number);
  34722. get stencilOpStencilDepthPass(): number;
  34723. set stencilOpStencilDepthPass(value: number);
  34724. get stencilMask(): number;
  34725. set stencilMask(value: number);
  34726. get stencilTest(): boolean;
  34727. set stencilTest(value: boolean);
  34728. constructor();
  34729. reset(): void;
  34730. apply(gl: WebGLRenderingContext): void;
  34731. }
  34732. }
  34733. declare module BABYLON {
  34734. /**
  34735. * @hidden
  34736. **/
  34737. export class AlphaState {
  34738. private _isAlphaBlendDirty;
  34739. private _isBlendFunctionParametersDirty;
  34740. private _isBlendEquationParametersDirty;
  34741. private _isBlendConstantsDirty;
  34742. private _alphaBlend;
  34743. private _blendFunctionParameters;
  34744. private _blendEquationParameters;
  34745. private _blendConstants;
  34746. /**
  34747. * Initializes the state.
  34748. */
  34749. constructor();
  34750. get isDirty(): boolean;
  34751. get alphaBlend(): boolean;
  34752. set alphaBlend(value: boolean);
  34753. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34754. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34755. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34756. reset(): void;
  34757. apply(gl: WebGLRenderingContext): void;
  34758. }
  34759. }
  34760. declare module BABYLON {
  34761. /** @hidden */
  34762. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34763. attributeProcessor(attribute: string): string;
  34764. varyingProcessor(varying: string, isFragment: boolean): string;
  34765. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34766. }
  34767. }
  34768. declare module BABYLON {
  34769. /**
  34770. * Interface for attribute information associated with buffer instanciation
  34771. */
  34772. export interface InstancingAttributeInfo {
  34773. /**
  34774. * Name of the GLSL attribute
  34775. * if attribute index is not specified, this is used to retrieve the index from the effect
  34776. */
  34777. attributeName: string;
  34778. /**
  34779. * Index/offset of the attribute in the vertex shader
  34780. * if not specified, this will be computes from the name.
  34781. */
  34782. index?: number;
  34783. /**
  34784. * size of the attribute, 1, 2, 3 or 4
  34785. */
  34786. attributeSize: number;
  34787. /**
  34788. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34789. */
  34790. offset: number;
  34791. /**
  34792. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34793. * default to 1
  34794. */
  34795. divisor?: number;
  34796. /**
  34797. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34798. * default is FLOAT
  34799. */
  34800. attributeType?: number;
  34801. /**
  34802. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34803. */
  34804. normalized?: boolean;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. interface ThinEngine {
  34809. /**
  34810. * Update a video texture
  34811. * @param texture defines the texture to update
  34812. * @param video defines the video element to use
  34813. * @param invertY defines if data must be stored with Y axis inverted
  34814. */
  34815. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34816. }
  34817. }
  34818. declare module BABYLON {
  34819. interface ThinEngine {
  34820. /**
  34821. * Creates a dynamic texture
  34822. * @param width defines the width of the texture
  34823. * @param height defines the height of the texture
  34824. * @param generateMipMaps defines if the engine should generate the mip levels
  34825. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34826. * @returns the dynamic texture inside an InternalTexture
  34827. */
  34828. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34829. /**
  34830. * Update the content of a dynamic texture
  34831. * @param texture defines the texture to update
  34832. * @param canvas defines the canvas containing the source
  34833. * @param invertY defines if data must be stored with Y axis inverted
  34834. * @param premulAlpha defines if alpha is stored as premultiplied
  34835. * @param format defines the format of the data
  34836. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34837. */
  34838. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34839. }
  34840. }
  34841. declare module BABYLON {
  34842. /**
  34843. * Settings for finer control over video usage
  34844. */
  34845. export interface VideoTextureSettings {
  34846. /**
  34847. * Applies `autoplay` to video, if specified
  34848. */
  34849. autoPlay?: boolean;
  34850. /**
  34851. * Applies `loop` to video, if specified
  34852. */
  34853. loop?: boolean;
  34854. /**
  34855. * Automatically updates internal texture from video at every frame in the render loop
  34856. */
  34857. autoUpdateTexture: boolean;
  34858. /**
  34859. * Image src displayed during the video loading or until the user interacts with the video.
  34860. */
  34861. poster?: string;
  34862. }
  34863. /**
  34864. * If you want to display a video in your scene, this is the special texture for that.
  34865. * This special texture works similar to other textures, with the exception of a few parameters.
  34866. * @see https://doc.babylonjs.com/how_to/video_texture
  34867. */
  34868. export class VideoTexture extends Texture {
  34869. /**
  34870. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34871. */
  34872. readonly autoUpdateTexture: boolean;
  34873. /**
  34874. * The video instance used by the texture internally
  34875. */
  34876. readonly video: HTMLVideoElement;
  34877. private _onUserActionRequestedObservable;
  34878. /**
  34879. * Event triggerd when a dom action is required by the user to play the video.
  34880. * This happens due to recent changes in browser policies preventing video to auto start.
  34881. */
  34882. get onUserActionRequestedObservable(): Observable<Texture>;
  34883. private _generateMipMaps;
  34884. private _stillImageCaptured;
  34885. private _displayingPosterTexture;
  34886. private _settings;
  34887. private _createInternalTextureOnEvent;
  34888. private _frameId;
  34889. private _currentSrc;
  34890. /**
  34891. * Creates a video texture.
  34892. * If you want to display a video in your scene, this is the special texture for that.
  34893. * This special texture works similar to other textures, with the exception of a few parameters.
  34894. * @see https://doc.babylonjs.com/how_to/video_texture
  34895. * @param name optional name, will detect from video source, if not defined
  34896. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34897. * @param scene is obviously the current scene.
  34898. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34899. * @param invertY is false by default but can be used to invert video on Y axis
  34900. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34901. * @param settings allows finer control over video usage
  34902. */
  34903. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34904. private _getName;
  34905. private _getVideo;
  34906. private _createInternalTexture;
  34907. private reset;
  34908. /**
  34909. * @hidden Internal method to initiate `update`.
  34910. */
  34911. _rebuild(): void;
  34912. /**
  34913. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34914. */
  34915. update(): void;
  34916. /**
  34917. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34918. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34919. */
  34920. updateTexture(isVisible: boolean): void;
  34921. protected _updateInternalTexture: () => void;
  34922. /**
  34923. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34924. * @param url New url.
  34925. */
  34926. updateURL(url: string): void;
  34927. /**
  34928. * Clones the texture.
  34929. * @returns the cloned texture
  34930. */
  34931. clone(): VideoTexture;
  34932. /**
  34933. * Dispose the texture and release its associated resources.
  34934. */
  34935. dispose(): void;
  34936. /**
  34937. * Creates a video texture straight from a stream.
  34938. * @param scene Define the scene the texture should be created in
  34939. * @param stream Define the stream the texture should be created from
  34940. * @returns The created video texture as a promise
  34941. */
  34942. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34943. /**
  34944. * Creates a video texture straight from your WebCam video feed.
  34945. * @param scene Define the scene the texture should be created in
  34946. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34947. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34948. * @returns The created video texture as a promise
  34949. */
  34950. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34951. minWidth: number;
  34952. maxWidth: number;
  34953. minHeight: number;
  34954. maxHeight: number;
  34955. deviceId: string;
  34956. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34957. /**
  34958. * Creates a video texture straight from your WebCam video feed.
  34959. * @param scene Define the scene the texture should be created in
  34960. * @param onReady Define a callback to triggered once the texture will be ready
  34961. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34962. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34963. */
  34964. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34965. minWidth: number;
  34966. maxWidth: number;
  34967. minHeight: number;
  34968. maxHeight: number;
  34969. deviceId: string;
  34970. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34971. }
  34972. }
  34973. declare module BABYLON {
  34974. /**
  34975. * Defines the interface used by objects working like Scene
  34976. * @hidden
  34977. */
  34978. export interface ISceneLike {
  34979. _addPendingData(data: any): void;
  34980. _removePendingData(data: any): void;
  34981. offlineProvider: IOfflineProvider;
  34982. }
  34983. /** Interface defining initialization parameters for Engine class */
  34984. export interface EngineOptions extends WebGLContextAttributes {
  34985. /**
  34986. * Defines if the engine should no exceed a specified device ratio
  34987. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34988. */
  34989. limitDeviceRatio?: number;
  34990. /**
  34991. * Defines if webvr should be enabled automatically
  34992. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34993. */
  34994. autoEnableWebVR?: boolean;
  34995. /**
  34996. * Defines if webgl2 should be turned off even if supported
  34997. * @see https://doc.babylonjs.com/features/webgl2
  34998. */
  34999. disableWebGL2Support?: boolean;
  35000. /**
  35001. * Defines if webaudio should be initialized as well
  35002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35003. */
  35004. audioEngine?: boolean;
  35005. /**
  35006. * Defines if animations should run using a deterministic lock step
  35007. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35008. */
  35009. deterministicLockstep?: boolean;
  35010. /** Defines the maximum steps to use with deterministic lock step mode */
  35011. lockstepMaxSteps?: number;
  35012. /** Defines the seconds between each deterministic lock step */
  35013. timeStep?: number;
  35014. /**
  35015. * Defines that engine should ignore context lost events
  35016. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35017. */
  35018. doNotHandleContextLost?: boolean;
  35019. /**
  35020. * Defines that engine should ignore modifying touch action attribute and style
  35021. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35022. */
  35023. doNotHandleTouchAction?: boolean;
  35024. /**
  35025. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35026. */
  35027. useHighPrecisionFloats?: boolean;
  35028. /**
  35029. * Make the canvas XR Compatible for XR sessions
  35030. */
  35031. xrCompatible?: boolean;
  35032. /**
  35033. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35034. */
  35035. useHighPrecisionMatrix?: boolean;
  35036. }
  35037. /**
  35038. * The base engine class (root of all engines)
  35039. */
  35040. export class ThinEngine {
  35041. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35042. static ExceptionList: ({
  35043. key: string;
  35044. capture: string;
  35045. captureConstraint: number;
  35046. targets: string[];
  35047. } | {
  35048. key: string;
  35049. capture: null;
  35050. captureConstraint: null;
  35051. targets: string[];
  35052. })[];
  35053. /** @hidden */
  35054. static _TextureLoaders: IInternalTextureLoader[];
  35055. /**
  35056. * Returns the current npm package of the sdk
  35057. */
  35058. static get NpmPackage(): string;
  35059. /**
  35060. * Returns the current version of the framework
  35061. */
  35062. static get Version(): string;
  35063. /**
  35064. * Returns a string describing the current engine
  35065. */
  35066. get description(): string;
  35067. /**
  35068. * Gets or sets the epsilon value used by collision engine
  35069. */
  35070. static CollisionsEpsilon: number;
  35071. /**
  35072. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35073. */
  35074. static get ShadersRepository(): string;
  35075. static set ShadersRepository(value: string);
  35076. /** @hidden */
  35077. _shaderProcessor: IShaderProcessor;
  35078. /**
  35079. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35080. */
  35081. forcePOTTextures: boolean;
  35082. /**
  35083. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35084. */
  35085. isFullscreen: boolean;
  35086. /**
  35087. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35088. */
  35089. cullBackFaces: boolean;
  35090. /**
  35091. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35092. */
  35093. renderEvenInBackground: boolean;
  35094. /**
  35095. * Gets or sets a boolean indicating that cache can be kept between frames
  35096. */
  35097. preventCacheWipeBetweenFrames: boolean;
  35098. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35099. validateShaderPrograms: boolean;
  35100. /**
  35101. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35102. * This can provide greater z depth for distant objects.
  35103. */
  35104. useReverseDepthBuffer: boolean;
  35105. /**
  35106. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35107. */
  35108. disableUniformBuffers: boolean;
  35109. /** @hidden */
  35110. _uniformBuffers: UniformBuffer[];
  35111. /**
  35112. * Gets a boolean indicating that the engine supports uniform buffers
  35113. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35114. */
  35115. get supportsUniformBuffers(): boolean;
  35116. /** @hidden */
  35117. _gl: WebGLRenderingContext;
  35118. /** @hidden */
  35119. _webGLVersion: number;
  35120. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35121. protected _windowIsBackground: boolean;
  35122. protected _creationOptions: EngineOptions;
  35123. protected _highPrecisionShadersAllowed: boolean;
  35124. /** @hidden */
  35125. get _shouldUseHighPrecisionShader(): boolean;
  35126. /**
  35127. * Gets a boolean indicating that only power of 2 textures are supported
  35128. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35129. */
  35130. get needPOTTextures(): boolean;
  35131. /** @hidden */
  35132. _badOS: boolean;
  35133. /** @hidden */
  35134. _badDesktopOS: boolean;
  35135. private _hardwareScalingLevel;
  35136. /** @hidden */
  35137. _caps: EngineCapabilities;
  35138. private _isStencilEnable;
  35139. private _glVersion;
  35140. private _glRenderer;
  35141. private _glVendor;
  35142. /** @hidden */
  35143. _videoTextureSupported: boolean;
  35144. protected _renderingQueueLaunched: boolean;
  35145. protected _activeRenderLoops: (() => void)[];
  35146. /**
  35147. * Observable signaled when a context lost event is raised
  35148. */
  35149. onContextLostObservable: Observable<ThinEngine>;
  35150. /**
  35151. * Observable signaled when a context restored event is raised
  35152. */
  35153. onContextRestoredObservable: Observable<ThinEngine>;
  35154. private _onContextLost;
  35155. private _onContextRestored;
  35156. protected _contextWasLost: boolean;
  35157. /** @hidden */
  35158. _doNotHandleContextLost: boolean;
  35159. /**
  35160. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35162. */
  35163. get doNotHandleContextLost(): boolean;
  35164. set doNotHandleContextLost(value: boolean);
  35165. /**
  35166. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35167. */
  35168. disableVertexArrayObjects: boolean;
  35169. /** @hidden */
  35170. protected _colorWrite: boolean;
  35171. /** @hidden */
  35172. protected _colorWriteChanged: boolean;
  35173. /** @hidden */
  35174. protected _depthCullingState: DepthCullingState;
  35175. /** @hidden */
  35176. protected _stencilState: StencilState;
  35177. /** @hidden */
  35178. _alphaState: AlphaState;
  35179. /** @hidden */
  35180. _alphaMode: number;
  35181. /** @hidden */
  35182. _alphaEquation: number;
  35183. /** @hidden */
  35184. _internalTexturesCache: InternalTexture[];
  35185. /** @hidden */
  35186. protected _activeChannel: number;
  35187. private _currentTextureChannel;
  35188. /** @hidden */
  35189. protected _boundTexturesCache: {
  35190. [key: string]: Nullable<InternalTexture>;
  35191. };
  35192. /** @hidden */
  35193. protected _currentEffect: Nullable<Effect>;
  35194. /** @hidden */
  35195. protected _currentProgram: Nullable<WebGLProgram>;
  35196. private _compiledEffects;
  35197. private _vertexAttribArraysEnabled;
  35198. /** @hidden */
  35199. protected _cachedViewport: Nullable<IViewportLike>;
  35200. private _cachedVertexArrayObject;
  35201. /** @hidden */
  35202. protected _cachedVertexBuffers: any;
  35203. /** @hidden */
  35204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35205. /** @hidden */
  35206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35207. /** @hidden */
  35208. _currentRenderTarget: Nullable<InternalTexture>;
  35209. private _uintIndicesCurrentlySet;
  35210. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35211. /** @hidden */
  35212. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35213. /** @hidden */
  35214. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35215. private _currentBufferPointers;
  35216. private _currentInstanceLocations;
  35217. private _currentInstanceBuffers;
  35218. private _textureUnits;
  35219. /** @hidden */
  35220. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35221. /** @hidden */
  35222. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35223. /** @hidden */
  35224. _boundRenderFunction: any;
  35225. private _vaoRecordInProgress;
  35226. private _mustWipeVertexAttributes;
  35227. private _emptyTexture;
  35228. private _emptyCubeTexture;
  35229. private _emptyTexture3D;
  35230. private _emptyTexture2DArray;
  35231. /** @hidden */
  35232. _frameHandler: number;
  35233. private _nextFreeTextureSlots;
  35234. private _maxSimultaneousTextures;
  35235. private _activeRequests;
  35236. /** @hidden */
  35237. _transformTextureUrl: Nullable<(url: string) => string>;
  35238. protected get _supportsHardwareTextureRescaling(): boolean;
  35239. private _framebufferDimensionsObject;
  35240. /**
  35241. * sets the object from which width and height will be taken from when getting render width and height
  35242. * Will fallback to the gl object
  35243. * @param dimensions the framebuffer width and height that will be used.
  35244. */
  35245. set framebufferDimensionsObject(dimensions: Nullable<{
  35246. framebufferWidth: number;
  35247. framebufferHeight: number;
  35248. }>);
  35249. /**
  35250. * Gets the current viewport
  35251. */
  35252. get currentViewport(): Nullable<IViewportLike>;
  35253. /**
  35254. * Gets the default empty texture
  35255. */
  35256. get emptyTexture(): InternalTexture;
  35257. /**
  35258. * Gets the default empty 3D texture
  35259. */
  35260. get emptyTexture3D(): InternalTexture;
  35261. /**
  35262. * Gets the default empty 2D array texture
  35263. */
  35264. get emptyTexture2DArray(): InternalTexture;
  35265. /**
  35266. * Gets the default empty cube texture
  35267. */
  35268. get emptyCubeTexture(): InternalTexture;
  35269. /**
  35270. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35271. */
  35272. readonly premultipliedAlpha: boolean;
  35273. /**
  35274. * Observable event triggered before each texture is initialized
  35275. */
  35276. onBeforeTextureInitObservable: Observable<Texture>;
  35277. /**
  35278. * Creates a new engine
  35279. * @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
  35280. * @param antialias defines enable antialiasing (default: false)
  35281. * @param options defines further options to be sent to the getContext() function
  35282. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35283. */
  35284. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35285. private _rebuildInternalTextures;
  35286. private _rebuildEffects;
  35287. /**
  35288. * Gets a boolean indicating if all created effects are ready
  35289. * @returns true if all effects are ready
  35290. */
  35291. areAllEffectsReady(): boolean;
  35292. protected _rebuildBuffers(): void;
  35293. protected _initGLContext(): void;
  35294. /**
  35295. * Gets version of the current webGL context
  35296. */
  35297. get webGLVersion(): number;
  35298. /**
  35299. * Gets a string idenfifying the name of the class
  35300. * @returns "Engine" string
  35301. */
  35302. getClassName(): string;
  35303. /**
  35304. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35305. */
  35306. get isStencilEnable(): boolean;
  35307. /** @hidden */
  35308. _prepareWorkingCanvas(): void;
  35309. /**
  35310. * Reset the texture cache to empty state
  35311. */
  35312. resetTextureCache(): void;
  35313. /**
  35314. * Gets an object containing information about the current webGL context
  35315. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35316. */
  35317. getGlInfo(): {
  35318. vendor: string;
  35319. renderer: string;
  35320. version: string;
  35321. };
  35322. /**
  35323. * Defines the hardware scaling level.
  35324. * By default the hardware scaling level is computed from the window device ratio.
  35325. * 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.
  35326. * @param level defines the level to use
  35327. */
  35328. setHardwareScalingLevel(level: number): void;
  35329. /**
  35330. * Gets the current hardware scaling level.
  35331. * By default the hardware scaling level is computed from the window device ratio.
  35332. * 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.
  35333. * @returns a number indicating the current hardware scaling level
  35334. */
  35335. getHardwareScalingLevel(): number;
  35336. /**
  35337. * Gets the list of loaded textures
  35338. * @returns an array containing all loaded textures
  35339. */
  35340. getLoadedTexturesCache(): InternalTexture[];
  35341. /**
  35342. * Gets the object containing all engine capabilities
  35343. * @returns the EngineCapabilities object
  35344. */
  35345. getCaps(): EngineCapabilities;
  35346. /**
  35347. * stop executing a render loop function and remove it from the execution array
  35348. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35349. */
  35350. stopRenderLoop(renderFunction?: () => void): void;
  35351. /** @hidden */
  35352. _renderLoop(): void;
  35353. /**
  35354. * Gets the HTML canvas attached with the current webGL context
  35355. * @returns a HTML canvas
  35356. */
  35357. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35358. /**
  35359. * Gets host window
  35360. * @returns the host window object
  35361. */
  35362. getHostWindow(): Nullable<Window>;
  35363. /**
  35364. * Gets the current render width
  35365. * @param useScreen defines if screen size must be used (or the current render target if any)
  35366. * @returns a number defining the current render width
  35367. */
  35368. getRenderWidth(useScreen?: boolean): number;
  35369. /**
  35370. * Gets the current render height
  35371. * @param useScreen defines if screen size must be used (or the current render target if any)
  35372. * @returns a number defining the current render height
  35373. */
  35374. getRenderHeight(useScreen?: boolean): number;
  35375. /**
  35376. * Can be used to override the current requestAnimationFrame requester.
  35377. * @hidden
  35378. */
  35379. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35380. /**
  35381. * Register and execute a render loop. The engine can have more than one render function
  35382. * @param renderFunction defines the function to continuously execute
  35383. */
  35384. runRenderLoop(renderFunction: () => void): void;
  35385. /**
  35386. * Clear the current render buffer or the current render target (if any is set up)
  35387. * @param color defines the color to use
  35388. * @param backBuffer defines if the back buffer must be cleared
  35389. * @param depth defines if the depth buffer must be cleared
  35390. * @param stencil defines if the stencil buffer must be cleared
  35391. */
  35392. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35393. private _viewportCached;
  35394. /** @hidden */
  35395. _viewport(x: number, y: number, width: number, height: number): void;
  35396. /**
  35397. * Set the WebGL's viewport
  35398. * @param viewport defines the viewport element to be used
  35399. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35400. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35401. */
  35402. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35403. /**
  35404. * Begin a new frame
  35405. */
  35406. beginFrame(): void;
  35407. /**
  35408. * Enf the current frame
  35409. */
  35410. endFrame(): void;
  35411. /**
  35412. * Resize the view according to the canvas' size
  35413. */
  35414. resize(): void;
  35415. /**
  35416. * Force a specific size of the canvas
  35417. * @param width defines the new canvas' width
  35418. * @param height defines the new canvas' height
  35419. * @returns true if the size was changed
  35420. */
  35421. setSize(width: number, height: number): boolean;
  35422. /**
  35423. * Binds the frame buffer to the specified texture.
  35424. * @param texture The texture to render to or null for the default canvas
  35425. * @param faceIndex The face of the texture to render to in case of cube texture
  35426. * @param requiredWidth The width of the target to render to
  35427. * @param requiredHeight The height of the target to render to
  35428. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35429. * @param lodLevel defines the lod level to bind to the frame buffer
  35430. * @param layer defines the 2d array index to bind to frame buffer to
  35431. */
  35432. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35433. /** @hidden */
  35434. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35435. /**
  35436. * Unbind the current render target texture from the webGL context
  35437. * @param texture defines the render target texture to unbind
  35438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35440. */
  35441. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35442. /**
  35443. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35444. */
  35445. flushFramebuffer(): void;
  35446. /**
  35447. * Unbind the current render target and bind the default framebuffer
  35448. */
  35449. restoreDefaultFramebuffer(): void;
  35450. /** @hidden */
  35451. protected _resetVertexBufferBinding(): void;
  35452. /**
  35453. * Creates a vertex buffer
  35454. * @param data the data for the vertex buffer
  35455. * @returns the new WebGL static buffer
  35456. */
  35457. createVertexBuffer(data: DataArray): DataBuffer;
  35458. private _createVertexBuffer;
  35459. /**
  35460. * Creates a dynamic vertex buffer
  35461. * @param data the data for the dynamic vertex buffer
  35462. * @returns the new WebGL dynamic buffer
  35463. */
  35464. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35465. protected _resetIndexBufferBinding(): void;
  35466. /**
  35467. * Creates a new index buffer
  35468. * @param indices defines the content of the index buffer
  35469. * @param updatable defines if the index buffer must be updatable
  35470. * @returns a new webGL buffer
  35471. */
  35472. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35473. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35474. /**
  35475. * Bind a webGL buffer to the webGL context
  35476. * @param buffer defines the buffer to bind
  35477. */
  35478. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35479. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35480. private bindBuffer;
  35481. /**
  35482. * update the bound buffer with the given data
  35483. * @param data defines the data to update
  35484. */
  35485. updateArrayBuffer(data: Float32Array): void;
  35486. private _vertexAttribPointer;
  35487. /** @hidden */
  35488. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35489. private _bindVertexBuffersAttributes;
  35490. /**
  35491. * Records a vertex array object
  35492. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35493. * @param vertexBuffers defines the list of vertex buffers to store
  35494. * @param indexBuffer defines the index buffer to store
  35495. * @param effect defines the effect to store
  35496. * @returns the new vertex array object
  35497. */
  35498. recordVertexArrayObject(vertexBuffers: {
  35499. [key: string]: VertexBuffer;
  35500. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35501. /**
  35502. * Bind a specific vertex array object
  35503. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35504. * @param vertexArrayObject defines the vertex array object to bind
  35505. * @param indexBuffer defines the index buffer to bind
  35506. */
  35507. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35508. /**
  35509. * Bind webGl buffers directly to the webGL context
  35510. * @param vertexBuffer defines the vertex buffer to bind
  35511. * @param indexBuffer defines the index buffer to bind
  35512. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35513. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35514. * @param effect defines the effect associated with the vertex buffer
  35515. */
  35516. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35517. private _unbindVertexArrayObject;
  35518. /**
  35519. * Bind a list of vertex buffers to the webGL context
  35520. * @param vertexBuffers defines the list of vertex buffers to bind
  35521. * @param indexBuffer defines the index buffer to bind
  35522. * @param effect defines the effect associated with the vertex buffers
  35523. */
  35524. bindBuffers(vertexBuffers: {
  35525. [key: string]: Nullable<VertexBuffer>;
  35526. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35527. /**
  35528. * Unbind all instance attributes
  35529. */
  35530. unbindInstanceAttributes(): void;
  35531. /**
  35532. * Release and free the memory of a vertex array object
  35533. * @param vao defines the vertex array object to delete
  35534. */
  35535. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35536. /** @hidden */
  35537. _releaseBuffer(buffer: DataBuffer): boolean;
  35538. protected _deleteBuffer(buffer: DataBuffer): void;
  35539. /**
  35540. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35541. * @param instancesBuffer defines the webGL buffer to update and bind
  35542. * @param data defines the data to store in the buffer
  35543. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35544. */
  35545. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35546. /**
  35547. * Bind the content of a webGL buffer used with instantiation
  35548. * @param instancesBuffer defines the webGL buffer to bind
  35549. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35550. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35551. */
  35552. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35553. /**
  35554. * Disable the instance attribute corresponding to the name in parameter
  35555. * @param name defines the name of the attribute to disable
  35556. */
  35557. disableInstanceAttributeByName(name: string): void;
  35558. /**
  35559. * Disable the instance attribute corresponding to the location in parameter
  35560. * @param attributeLocation defines the attribute location of the attribute to disable
  35561. */
  35562. disableInstanceAttribute(attributeLocation: number): void;
  35563. /**
  35564. * Disable the attribute corresponding to the location in parameter
  35565. * @param attributeLocation defines the attribute location of the attribute to disable
  35566. */
  35567. disableAttributeByIndex(attributeLocation: number): void;
  35568. /**
  35569. * Send a draw order
  35570. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35571. * @param indexStart defines the starting index
  35572. * @param indexCount defines the number of index to draw
  35573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35574. */
  35575. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35576. /**
  35577. * Draw a list of points
  35578. * @param verticesStart defines the index of first vertex to draw
  35579. * @param verticesCount defines the count of vertices to draw
  35580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35581. */
  35582. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35583. /**
  35584. * Draw a list of unindexed primitives
  35585. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35586. * @param verticesStart defines the index of first vertex to draw
  35587. * @param verticesCount defines the count of vertices to draw
  35588. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35589. */
  35590. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35591. /**
  35592. * Draw a list of indexed primitives
  35593. * @param fillMode defines the primitive to use
  35594. * @param indexStart defines the starting index
  35595. * @param indexCount defines the number of index to draw
  35596. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35597. */
  35598. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35599. /**
  35600. * Draw a list of unindexed primitives
  35601. * @param fillMode defines the primitive to use
  35602. * @param verticesStart defines the index of first vertex to draw
  35603. * @param verticesCount defines the count of vertices to draw
  35604. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35605. */
  35606. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35607. private _drawMode;
  35608. /** @hidden */
  35609. protected _reportDrawCall(): void;
  35610. /** @hidden */
  35611. _releaseEffect(effect: Effect): void;
  35612. /** @hidden */
  35613. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35614. /**
  35615. * Create a new effect (used to store vertex/fragment shaders)
  35616. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35617. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35618. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35619. * @param samplers defines an array of string used to represent textures
  35620. * @param defines defines the string containing the defines to use to compile the shaders
  35621. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35622. * @param onCompiled defines a function to call when the effect creation is successful
  35623. * @param onError defines a function to call when the effect creation has failed
  35624. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35625. * @returns the new Effect
  35626. */
  35627. 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;
  35628. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35629. private _compileShader;
  35630. private _compileRawShader;
  35631. /** @hidden */
  35632. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35633. /**
  35634. * Directly creates a webGL program
  35635. * @param pipelineContext defines the pipeline context to attach to
  35636. * @param vertexCode defines the vertex shader code to use
  35637. * @param fragmentCode defines the fragment shader code to use
  35638. * @param context defines the webGL context to use (if not set, the current one will be used)
  35639. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35640. * @returns the new webGL program
  35641. */
  35642. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35643. /**
  35644. * Creates a webGL program
  35645. * @param pipelineContext defines the pipeline context to attach to
  35646. * @param vertexCode defines the vertex shader code to use
  35647. * @param fragmentCode defines the fragment shader code to use
  35648. * @param defines defines the string containing the defines to use to compile the shaders
  35649. * @param context defines the webGL context to use (if not set, the current one will be used)
  35650. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35651. * @returns the new webGL program
  35652. */
  35653. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35654. /**
  35655. * Creates a new pipeline context
  35656. * @returns the new pipeline
  35657. */
  35658. createPipelineContext(): IPipelineContext;
  35659. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35660. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35661. /** @hidden */
  35662. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35663. /** @hidden */
  35664. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35665. /** @hidden */
  35666. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35667. /**
  35668. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35669. * @param pipelineContext defines the pipeline context to use
  35670. * @param uniformsNames defines the list of uniform names
  35671. * @returns an array of webGL uniform locations
  35672. */
  35673. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35674. /**
  35675. * Gets the lsit of active attributes for a given webGL program
  35676. * @param pipelineContext defines the pipeline context to use
  35677. * @param attributesNames defines the list of attribute names to get
  35678. * @returns an array of indices indicating the offset of each attribute
  35679. */
  35680. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35681. /**
  35682. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35683. * @param effect defines the effect to activate
  35684. */
  35685. enableEffect(effect: Nullable<Effect>): void;
  35686. /**
  35687. * Set the value of an uniform to a number (int)
  35688. * @param uniform defines the webGL uniform location where to store the value
  35689. * @param value defines the int number to store
  35690. */
  35691. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35692. /**
  35693. * Set the value of an uniform to an array of int32
  35694. * @param uniform defines the webGL uniform location where to store the value
  35695. * @param array defines the array of int32 to store
  35696. */
  35697. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35698. /**
  35699. * Set the value of an uniform to an array of int32 (stored as vec2)
  35700. * @param uniform defines the webGL uniform location where to store the value
  35701. * @param array defines the array of int32 to store
  35702. */
  35703. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35704. /**
  35705. * Set the value of an uniform to an array of int32 (stored as vec3)
  35706. * @param uniform defines the webGL uniform location where to store the value
  35707. * @param array defines the array of int32 to store
  35708. */
  35709. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35710. /**
  35711. * Set the value of an uniform to an array of int32 (stored as vec4)
  35712. * @param uniform defines the webGL uniform location where to store the value
  35713. * @param array defines the array of int32 to store
  35714. */
  35715. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35716. /**
  35717. * Set the value of an uniform to an array of number
  35718. * @param uniform defines the webGL uniform location where to store the value
  35719. * @param array defines the array of number to store
  35720. */
  35721. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35722. /**
  35723. * Set the value of an uniform to an array of number (stored as vec2)
  35724. * @param uniform defines the webGL uniform location where to store the value
  35725. * @param array defines the array of number to store
  35726. */
  35727. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35728. /**
  35729. * Set the value of an uniform to an array of number (stored as vec3)
  35730. * @param uniform defines the webGL uniform location where to store the value
  35731. * @param array defines the array of number to store
  35732. */
  35733. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35734. /**
  35735. * Set the value of an uniform to an array of number (stored as vec4)
  35736. * @param uniform defines the webGL uniform location where to store the value
  35737. * @param array defines the array of number to store
  35738. */
  35739. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35740. /**
  35741. * Set the value of an uniform to an array of float32 (stored as matrices)
  35742. * @param uniform defines the webGL uniform location where to store the value
  35743. * @param matrices defines the array of float32 to store
  35744. */
  35745. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35746. /**
  35747. * Set the value of an uniform to a matrix (3x3)
  35748. * @param uniform defines the webGL uniform location where to store the value
  35749. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35750. */
  35751. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35752. /**
  35753. * Set the value of an uniform to a matrix (2x2)
  35754. * @param uniform defines the webGL uniform location where to store the value
  35755. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35756. */
  35757. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35758. /**
  35759. * Set the value of an uniform to a number (float)
  35760. * @param uniform defines the webGL uniform location where to store the value
  35761. * @param value defines the float number to store
  35762. */
  35763. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35764. /**
  35765. * Set the value of an uniform to a vec2
  35766. * @param uniform defines the webGL uniform location where to store the value
  35767. * @param x defines the 1st component of the value
  35768. * @param y defines the 2nd component of the value
  35769. */
  35770. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35771. /**
  35772. * Set the value of an uniform to a vec3
  35773. * @param uniform defines the webGL uniform location where to store the value
  35774. * @param x defines the 1st component of the value
  35775. * @param y defines the 2nd component of the value
  35776. * @param z defines the 3rd component of the value
  35777. */
  35778. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35779. /**
  35780. * Set the value of an uniform to a vec4
  35781. * @param uniform defines the webGL uniform location where to store the value
  35782. * @param x defines the 1st component of the value
  35783. * @param y defines the 2nd component of the value
  35784. * @param z defines the 3rd component of the value
  35785. * @param w defines the 4th component of the value
  35786. */
  35787. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35788. /**
  35789. * Apply all cached states (depth, culling, stencil and alpha)
  35790. */
  35791. applyStates(): void;
  35792. /**
  35793. * Enable or disable color writing
  35794. * @param enable defines the state to set
  35795. */
  35796. setColorWrite(enable: boolean): void;
  35797. /**
  35798. * Gets a boolean indicating if color writing is enabled
  35799. * @returns the current color writing state
  35800. */
  35801. getColorWrite(): boolean;
  35802. /**
  35803. * Gets the depth culling state manager
  35804. */
  35805. get depthCullingState(): DepthCullingState;
  35806. /**
  35807. * Gets the alpha state manager
  35808. */
  35809. get alphaState(): AlphaState;
  35810. /**
  35811. * Gets the stencil state manager
  35812. */
  35813. get stencilState(): StencilState;
  35814. /**
  35815. * Clears the list of texture accessible through engine.
  35816. * This can help preventing texture load conflict due to name collision.
  35817. */
  35818. clearInternalTexturesCache(): void;
  35819. /**
  35820. * Force the entire cache to be cleared
  35821. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35822. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35823. */
  35824. wipeCaches(bruteForce?: boolean): void;
  35825. /** @hidden */
  35826. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35827. min: number;
  35828. mag: number;
  35829. };
  35830. /** @hidden */
  35831. _createTexture(): WebGLTexture;
  35832. /**
  35833. * Usually called from Texture.ts.
  35834. * Passed information to create a WebGLTexture
  35835. * @param url defines a value which contains one of the following:
  35836. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35837. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35838. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35840. * @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)
  35841. * @param scene needed for loading to the correct scene
  35842. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35843. * @param onLoad optional callback to be called upon successful completion
  35844. * @param onError optional callback to be called upon failure
  35845. * @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
  35846. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35847. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35848. * @param forcedExtension defines the extension to use to pick the right loader
  35849. * @param mimeType defines an optional mime type
  35850. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35851. */
  35852. 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;
  35853. /**
  35854. * Loads an image as an HTMLImageElement.
  35855. * @param input url string, ArrayBuffer, or Blob to load
  35856. * @param onLoad callback called when the image successfully loads
  35857. * @param onError callback called when the image fails to load
  35858. * @param offlineProvider offline provider for caching
  35859. * @param mimeType optional mime type
  35860. * @returns the HTMLImageElement of the loaded image
  35861. * @hidden
  35862. */
  35863. 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>;
  35864. /**
  35865. * @hidden
  35866. */
  35867. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35868. private _unpackFlipYCached;
  35869. /**
  35870. * In case you are sharing the context with other applications, it might
  35871. * be interested to not cache the unpack flip y state to ensure a consistent
  35872. * value would be set.
  35873. */
  35874. enableUnpackFlipYCached: boolean;
  35875. /** @hidden */
  35876. _unpackFlipY(value: boolean): void;
  35877. /** @hidden */
  35878. _getUnpackAlignement(): number;
  35879. private _getTextureTarget;
  35880. /**
  35881. * Update the sampling mode of a given texture
  35882. * @param samplingMode defines the required sampling mode
  35883. * @param texture defines the texture to update
  35884. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35885. */
  35886. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35887. /**
  35888. * Update the sampling mode of a given texture
  35889. * @param texture defines the texture to update
  35890. * @param wrapU defines the texture wrap mode of the u coordinates
  35891. * @param wrapV defines the texture wrap mode of the v coordinates
  35892. * @param wrapR defines the texture wrap mode of the r coordinates
  35893. */
  35894. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35895. /** @hidden */
  35896. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35897. width: number;
  35898. height: number;
  35899. layers?: number;
  35900. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35901. /** @hidden */
  35902. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35903. /** @hidden */
  35904. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35905. /**
  35906. * Update a portion of an internal texture
  35907. * @param texture defines the texture to update
  35908. * @param imageData defines the data to store into the texture
  35909. * @param xOffset defines the x coordinates of the update rectangle
  35910. * @param yOffset defines the y coordinates of the update rectangle
  35911. * @param width defines the width of the update rectangle
  35912. * @param height defines the height of the update rectangle
  35913. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35914. * @param lod defines the lod level to update (0 by default)
  35915. */
  35916. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35917. /** @hidden */
  35918. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35919. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35920. private _prepareWebGLTexture;
  35921. /** @hidden */
  35922. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35923. private _getDepthStencilBuffer;
  35924. /** @hidden */
  35925. _releaseFramebufferObjects(texture: InternalTexture): void;
  35926. /** @hidden */
  35927. _releaseTexture(texture: InternalTexture): void;
  35928. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35929. protected _setProgram(program: WebGLProgram): void;
  35930. protected _boundUniforms: {
  35931. [key: number]: WebGLUniformLocation;
  35932. };
  35933. /**
  35934. * Binds an effect to the webGL context
  35935. * @param effect defines the effect to bind
  35936. */
  35937. bindSamplers(effect: Effect): void;
  35938. private _activateCurrentTexture;
  35939. /** @hidden */
  35940. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35941. /** @hidden */
  35942. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35943. /**
  35944. * Unbind all textures from the webGL context
  35945. */
  35946. unbindAllTextures(): void;
  35947. /**
  35948. * Sets a texture to the according uniform.
  35949. * @param channel The texture channel
  35950. * @param uniform The uniform to set
  35951. * @param texture The texture to apply
  35952. */
  35953. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35954. private _bindSamplerUniformToChannel;
  35955. private _getTextureWrapMode;
  35956. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35957. /**
  35958. * Sets an array of texture to the webGL context
  35959. * @param channel defines the channel where the texture array must be set
  35960. * @param uniform defines the associated uniform location
  35961. * @param textures defines the array of textures to bind
  35962. */
  35963. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35964. /** @hidden */
  35965. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35966. private _setTextureParameterFloat;
  35967. private _setTextureParameterInteger;
  35968. /**
  35969. * Unbind all vertex attributes from the webGL context
  35970. */
  35971. unbindAllAttributes(): void;
  35972. /**
  35973. * 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
  35974. */
  35975. releaseEffects(): void;
  35976. /**
  35977. * Dispose and release all associated resources
  35978. */
  35979. dispose(): void;
  35980. /**
  35981. * Attach a new callback raised when context lost event is fired
  35982. * @param callback defines the callback to call
  35983. */
  35984. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35985. /**
  35986. * Attach a new callback raised when context restored event is fired
  35987. * @param callback defines the callback to call
  35988. */
  35989. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35990. /**
  35991. * Get the current error code of the webGL context
  35992. * @returns the error code
  35993. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35994. */
  35995. getError(): number;
  35996. private _canRenderToFloatFramebuffer;
  35997. private _canRenderToHalfFloatFramebuffer;
  35998. private _canRenderToFramebuffer;
  35999. /** @hidden */
  36000. _getWebGLTextureType(type: number): number;
  36001. /** @hidden */
  36002. _getInternalFormat(format: number): number;
  36003. /** @hidden */
  36004. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36005. /** @hidden */
  36006. _getRGBAMultiSampleBufferFormat(type: number): number;
  36007. /** @hidden */
  36008. _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;
  36009. /**
  36010. * Loads a file from a url
  36011. * @param url url to load
  36012. * @param onSuccess callback called when the file successfully loads
  36013. * @param onProgress callback called while file is loading (if the server supports this mode)
  36014. * @param offlineProvider defines the offline provider for caching
  36015. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36016. * @param onError callback called when the file fails to load
  36017. * @returns a file request object
  36018. * @hidden
  36019. */
  36020. 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;
  36021. /**
  36022. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36023. * @param x defines the x coordinate of the rectangle where pixels must be read
  36024. * @param y defines the y coordinate of the rectangle where pixels must be read
  36025. * @param width defines the width of the rectangle where pixels must be read
  36026. * @param height defines the height of the rectangle where pixels must be read
  36027. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36028. * @returns a Uint8Array containing RGBA colors
  36029. */
  36030. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36031. private static _isSupported;
  36032. /**
  36033. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36034. * @returns true if the engine can be created
  36035. * @ignorenaming
  36036. */
  36037. static isSupported(): boolean;
  36038. /**
  36039. * Find the next highest power of two.
  36040. * @param x Number to start search from.
  36041. * @return Next highest power of two.
  36042. */
  36043. static CeilingPOT(x: number): number;
  36044. /**
  36045. * Find the next lowest power of two.
  36046. * @param x Number to start search from.
  36047. * @return Next lowest power of two.
  36048. */
  36049. static FloorPOT(x: number): number;
  36050. /**
  36051. * Find the nearest power of two.
  36052. * @param x Number to start search from.
  36053. * @return Next nearest power of two.
  36054. */
  36055. static NearestPOT(x: number): number;
  36056. /**
  36057. * Get the closest exponent of two
  36058. * @param value defines the value to approximate
  36059. * @param max defines the maximum value to return
  36060. * @param mode defines how to define the closest value
  36061. * @returns closest exponent of two of the given value
  36062. */
  36063. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36064. /**
  36065. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36066. * @param func - the function to be called
  36067. * @param requester - the object that will request the next frame. Falls back to window.
  36068. * @returns frame number
  36069. */
  36070. static QueueNewFrame(func: () => void, requester?: any): number;
  36071. /**
  36072. * Gets host document
  36073. * @returns the host document object
  36074. */
  36075. getHostDocument(): Nullable<Document>;
  36076. }
  36077. }
  36078. declare module BABYLON {
  36079. /**
  36080. * Class representing spherical harmonics coefficients to the 3rd degree
  36081. */
  36082. export class SphericalHarmonics {
  36083. /**
  36084. * Defines whether or not the harmonics have been prescaled for rendering.
  36085. */
  36086. preScaled: boolean;
  36087. /**
  36088. * The l0,0 coefficients of the spherical harmonics
  36089. */
  36090. l00: Vector3;
  36091. /**
  36092. * The l1,-1 coefficients of the spherical harmonics
  36093. */
  36094. l1_1: Vector3;
  36095. /**
  36096. * The l1,0 coefficients of the spherical harmonics
  36097. */
  36098. l10: Vector3;
  36099. /**
  36100. * The l1,1 coefficients of the spherical harmonics
  36101. */
  36102. l11: Vector3;
  36103. /**
  36104. * The l2,-2 coefficients of the spherical harmonics
  36105. */
  36106. l2_2: Vector3;
  36107. /**
  36108. * The l2,-1 coefficients of the spherical harmonics
  36109. */
  36110. l2_1: Vector3;
  36111. /**
  36112. * The l2,0 coefficients of the spherical harmonics
  36113. */
  36114. l20: Vector3;
  36115. /**
  36116. * The l2,1 coefficients of the spherical harmonics
  36117. */
  36118. l21: Vector3;
  36119. /**
  36120. * The l2,2 coefficients of the spherical harmonics
  36121. */
  36122. l22: Vector3;
  36123. /**
  36124. * Adds a light to the spherical harmonics
  36125. * @param direction the direction of the light
  36126. * @param color the color of the light
  36127. * @param deltaSolidAngle the delta solid angle of the light
  36128. */
  36129. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36130. /**
  36131. * Scales the spherical harmonics by the given amount
  36132. * @param scale the amount to scale
  36133. */
  36134. scaleInPlace(scale: number): void;
  36135. /**
  36136. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36137. *
  36138. * ```
  36139. * E_lm = A_l * L_lm
  36140. * ```
  36141. *
  36142. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36143. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36144. * the scaling factors are given in equation 9.
  36145. */
  36146. convertIncidentRadianceToIrradiance(): void;
  36147. /**
  36148. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36149. *
  36150. * ```
  36151. * L = (1/pi) * E * rho
  36152. * ```
  36153. *
  36154. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36155. */
  36156. convertIrradianceToLambertianRadiance(): void;
  36157. /**
  36158. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36159. * required operations at run time.
  36160. *
  36161. * This is simply done by scaling back the SH with Ylm constants parameter.
  36162. * The trigonometric part being applied by the shader at run time.
  36163. */
  36164. preScaleForRendering(): void;
  36165. /**
  36166. * Constructs a spherical harmonics from an array.
  36167. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36168. * @returns the spherical harmonics
  36169. */
  36170. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36171. /**
  36172. * Gets the spherical harmonics from polynomial
  36173. * @param polynomial the spherical polynomial
  36174. * @returns the spherical harmonics
  36175. */
  36176. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36177. }
  36178. /**
  36179. * Class representing spherical polynomial coefficients to the 3rd degree
  36180. */
  36181. export class SphericalPolynomial {
  36182. private _harmonics;
  36183. /**
  36184. * The spherical harmonics used to create the polynomials.
  36185. */
  36186. get preScaledHarmonics(): SphericalHarmonics;
  36187. /**
  36188. * The x coefficients of the spherical polynomial
  36189. */
  36190. x: Vector3;
  36191. /**
  36192. * The y coefficients of the spherical polynomial
  36193. */
  36194. y: Vector3;
  36195. /**
  36196. * The z coefficients of the spherical polynomial
  36197. */
  36198. z: Vector3;
  36199. /**
  36200. * The xx coefficients of the spherical polynomial
  36201. */
  36202. xx: Vector3;
  36203. /**
  36204. * The yy coefficients of the spherical polynomial
  36205. */
  36206. yy: Vector3;
  36207. /**
  36208. * The zz coefficients of the spherical polynomial
  36209. */
  36210. zz: Vector3;
  36211. /**
  36212. * The xy coefficients of the spherical polynomial
  36213. */
  36214. xy: Vector3;
  36215. /**
  36216. * The yz coefficients of the spherical polynomial
  36217. */
  36218. yz: Vector3;
  36219. /**
  36220. * The zx coefficients of the spherical polynomial
  36221. */
  36222. zx: Vector3;
  36223. /**
  36224. * Adds an ambient color to the spherical polynomial
  36225. * @param color the color to add
  36226. */
  36227. addAmbient(color: Color3): void;
  36228. /**
  36229. * Scales the spherical polynomial by the given amount
  36230. * @param scale the amount to scale
  36231. */
  36232. scaleInPlace(scale: number): void;
  36233. /**
  36234. * Gets the spherical polynomial from harmonics
  36235. * @param harmonics the spherical harmonics
  36236. * @returns the spherical polynomial
  36237. */
  36238. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36239. /**
  36240. * Constructs a spherical polynomial from an array.
  36241. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36242. * @returns the spherical polynomial
  36243. */
  36244. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36245. }
  36246. }
  36247. declare module BABYLON {
  36248. /**
  36249. * Defines the source of the internal texture
  36250. */
  36251. export enum InternalTextureSource {
  36252. /**
  36253. * The source of the texture data is unknown
  36254. */
  36255. Unknown = 0,
  36256. /**
  36257. * Texture data comes from an URL
  36258. */
  36259. Url = 1,
  36260. /**
  36261. * Texture data is only used for temporary storage
  36262. */
  36263. Temp = 2,
  36264. /**
  36265. * Texture data comes from raw data (ArrayBuffer)
  36266. */
  36267. Raw = 3,
  36268. /**
  36269. * Texture content is dynamic (video or dynamic texture)
  36270. */
  36271. Dynamic = 4,
  36272. /**
  36273. * Texture content is generated by rendering to it
  36274. */
  36275. RenderTarget = 5,
  36276. /**
  36277. * Texture content is part of a multi render target process
  36278. */
  36279. MultiRenderTarget = 6,
  36280. /**
  36281. * Texture data comes from a cube data file
  36282. */
  36283. Cube = 7,
  36284. /**
  36285. * Texture data comes from a raw cube data
  36286. */
  36287. CubeRaw = 8,
  36288. /**
  36289. * Texture data come from a prefiltered cube data file
  36290. */
  36291. CubePrefiltered = 9,
  36292. /**
  36293. * Texture content is raw 3D data
  36294. */
  36295. Raw3D = 10,
  36296. /**
  36297. * Texture content is raw 2D array data
  36298. */
  36299. Raw2DArray = 11,
  36300. /**
  36301. * Texture content is a depth texture
  36302. */
  36303. Depth = 12,
  36304. /**
  36305. * Texture data comes from a raw cube data encoded with RGBD
  36306. */
  36307. CubeRawRGBD = 13
  36308. }
  36309. /**
  36310. * Class used to store data associated with WebGL texture data for the engine
  36311. * This class should not be used directly
  36312. */
  36313. export class InternalTexture {
  36314. /** @hidden */
  36315. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36316. /**
  36317. * Defines if the texture is ready
  36318. */
  36319. isReady: boolean;
  36320. /**
  36321. * Defines if the texture is a cube texture
  36322. */
  36323. isCube: boolean;
  36324. /**
  36325. * Defines if the texture contains 3D data
  36326. */
  36327. is3D: boolean;
  36328. /**
  36329. * Defines if the texture contains 2D array data
  36330. */
  36331. is2DArray: boolean;
  36332. /**
  36333. * Defines if the texture contains multiview data
  36334. */
  36335. isMultiview: boolean;
  36336. /**
  36337. * Gets the URL used to load this texture
  36338. */
  36339. url: string;
  36340. /**
  36341. * Gets the sampling mode of the texture
  36342. */
  36343. samplingMode: number;
  36344. /**
  36345. * Gets a boolean indicating if the texture needs mipmaps generation
  36346. */
  36347. generateMipMaps: boolean;
  36348. /**
  36349. * Gets the number of samples used by the texture (WebGL2+ only)
  36350. */
  36351. samples: number;
  36352. /**
  36353. * Gets the type of the texture (int, float...)
  36354. */
  36355. type: number;
  36356. /**
  36357. * Gets the format of the texture (RGB, RGBA...)
  36358. */
  36359. format: number;
  36360. /**
  36361. * Observable called when the texture is loaded
  36362. */
  36363. onLoadedObservable: Observable<InternalTexture>;
  36364. /**
  36365. * Gets the width of the texture
  36366. */
  36367. width: number;
  36368. /**
  36369. * Gets the height of the texture
  36370. */
  36371. height: number;
  36372. /**
  36373. * Gets the depth of the texture
  36374. */
  36375. depth: number;
  36376. /**
  36377. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36378. */
  36379. baseWidth: number;
  36380. /**
  36381. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36382. */
  36383. baseHeight: number;
  36384. /**
  36385. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36386. */
  36387. baseDepth: number;
  36388. /**
  36389. * Gets a boolean indicating if the texture is inverted on Y axis
  36390. */
  36391. invertY: boolean;
  36392. /** @hidden */
  36393. _invertVScale: boolean;
  36394. /** @hidden */
  36395. _associatedChannel: number;
  36396. /** @hidden */
  36397. _source: InternalTextureSource;
  36398. /** @hidden */
  36399. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36400. /** @hidden */
  36401. _bufferView: Nullable<ArrayBufferView>;
  36402. /** @hidden */
  36403. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36404. /** @hidden */
  36405. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36406. /** @hidden */
  36407. _size: number;
  36408. /** @hidden */
  36409. _extension: string;
  36410. /** @hidden */
  36411. _files: Nullable<string[]>;
  36412. /** @hidden */
  36413. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36414. /** @hidden */
  36415. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36416. /** @hidden */
  36417. _framebuffer: Nullable<WebGLFramebuffer>;
  36418. /** @hidden */
  36419. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36420. /** @hidden */
  36421. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36422. /** @hidden */
  36423. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36424. /** @hidden */
  36425. _attachments: Nullable<number[]>;
  36426. /** @hidden */
  36427. _textureArray: Nullable<InternalTexture[]>;
  36428. /** @hidden */
  36429. _cachedCoordinatesMode: Nullable<number>;
  36430. /** @hidden */
  36431. _cachedWrapU: Nullable<number>;
  36432. /** @hidden */
  36433. _cachedWrapV: Nullable<number>;
  36434. /** @hidden */
  36435. _cachedWrapR: Nullable<number>;
  36436. /** @hidden */
  36437. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36438. /** @hidden */
  36439. _isDisabled: boolean;
  36440. /** @hidden */
  36441. _compression: Nullable<string>;
  36442. /** @hidden */
  36443. _generateStencilBuffer: boolean;
  36444. /** @hidden */
  36445. _generateDepthBuffer: boolean;
  36446. /** @hidden */
  36447. _comparisonFunction: number;
  36448. /** @hidden */
  36449. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36450. /** @hidden */
  36451. _lodGenerationScale: number;
  36452. /** @hidden */
  36453. _lodGenerationOffset: number;
  36454. /** @hidden */
  36455. _depthStencilTexture: Nullable<InternalTexture>;
  36456. /** @hidden */
  36457. _colorTextureArray: Nullable<WebGLTexture>;
  36458. /** @hidden */
  36459. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36460. /** @hidden */
  36461. _lodTextureHigh: Nullable<BaseTexture>;
  36462. /** @hidden */
  36463. _lodTextureMid: Nullable<BaseTexture>;
  36464. /** @hidden */
  36465. _lodTextureLow: Nullable<BaseTexture>;
  36466. /** @hidden */
  36467. _isRGBD: boolean;
  36468. /** @hidden */
  36469. _linearSpecularLOD: boolean;
  36470. /** @hidden */
  36471. _irradianceTexture: Nullable<BaseTexture>;
  36472. /** @hidden */
  36473. _webGLTexture: Nullable<WebGLTexture>;
  36474. /** @hidden */
  36475. _references: number;
  36476. private _engine;
  36477. /**
  36478. * Gets the Engine the texture belongs to.
  36479. * @returns The babylon engine
  36480. */
  36481. getEngine(): ThinEngine;
  36482. /**
  36483. * Gets the data source type of the texture
  36484. */
  36485. get source(): InternalTextureSource;
  36486. /**
  36487. * Creates a new InternalTexture
  36488. * @param engine defines the engine to use
  36489. * @param source defines the type of data that will be used
  36490. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36491. */
  36492. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36493. /**
  36494. * Increments the number of references (ie. the number of Texture that point to it)
  36495. */
  36496. incrementReferences(): void;
  36497. /**
  36498. * Change the size of the texture (not the size of the content)
  36499. * @param width defines the new width
  36500. * @param height defines the new height
  36501. * @param depth defines the new depth (1 by default)
  36502. */
  36503. updateSize(width: int, height: int, depth?: int): void;
  36504. /** @hidden */
  36505. _rebuild(): void;
  36506. /** @hidden */
  36507. _swapAndDie(target: InternalTexture): void;
  36508. /**
  36509. * Dispose the current allocated resources
  36510. */
  36511. dispose(): void;
  36512. }
  36513. }
  36514. declare module BABYLON {
  36515. /**
  36516. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36518. */
  36519. export class Analyser {
  36520. /**
  36521. * Gets or sets the smoothing
  36522. * @ignorenaming
  36523. */
  36524. SMOOTHING: number;
  36525. /**
  36526. * Gets or sets the FFT table size
  36527. * @ignorenaming
  36528. */
  36529. FFT_SIZE: number;
  36530. /**
  36531. * Gets or sets the bar graph amplitude
  36532. * @ignorenaming
  36533. */
  36534. BARGRAPHAMPLITUDE: number;
  36535. /**
  36536. * Gets or sets the position of the debug canvas
  36537. * @ignorenaming
  36538. */
  36539. DEBUGCANVASPOS: {
  36540. x: number;
  36541. y: number;
  36542. };
  36543. /**
  36544. * Gets or sets the debug canvas size
  36545. * @ignorenaming
  36546. */
  36547. DEBUGCANVASSIZE: {
  36548. width: number;
  36549. height: number;
  36550. };
  36551. private _byteFreqs;
  36552. private _byteTime;
  36553. private _floatFreqs;
  36554. private _webAudioAnalyser;
  36555. private _debugCanvas;
  36556. private _debugCanvasContext;
  36557. private _scene;
  36558. private _registerFunc;
  36559. private _audioEngine;
  36560. /**
  36561. * Creates a new analyser
  36562. * @param scene defines hosting scene
  36563. */
  36564. constructor(scene: Scene);
  36565. /**
  36566. * Get the number of data values you will have to play with for the visualization
  36567. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36568. * @returns a number
  36569. */
  36570. getFrequencyBinCount(): number;
  36571. /**
  36572. * Gets the current frequency data as a byte array
  36573. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36574. * @returns a Uint8Array
  36575. */
  36576. getByteFrequencyData(): Uint8Array;
  36577. /**
  36578. * Gets the current waveform as a byte array
  36579. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36580. * @returns a Uint8Array
  36581. */
  36582. getByteTimeDomainData(): Uint8Array;
  36583. /**
  36584. * Gets the current frequency data as a float array
  36585. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36586. * @returns a Float32Array
  36587. */
  36588. getFloatFrequencyData(): Float32Array;
  36589. /**
  36590. * Renders the debug canvas
  36591. */
  36592. drawDebugCanvas(): void;
  36593. /**
  36594. * Stops rendering the debug canvas and removes it
  36595. */
  36596. stopDebugCanvas(): void;
  36597. /**
  36598. * Connects two audio nodes
  36599. * @param inputAudioNode defines first node to connect
  36600. * @param outputAudioNode defines second node to connect
  36601. */
  36602. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36603. /**
  36604. * Releases all associated resources
  36605. */
  36606. dispose(): void;
  36607. }
  36608. }
  36609. declare module BABYLON {
  36610. /**
  36611. * This represents an audio engine and it is responsible
  36612. * to play, synchronize and analyse sounds throughout the application.
  36613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36614. */
  36615. export interface IAudioEngine extends IDisposable {
  36616. /**
  36617. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36618. */
  36619. readonly canUseWebAudio: boolean;
  36620. /**
  36621. * Gets the current AudioContext if available.
  36622. */
  36623. readonly audioContext: Nullable<AudioContext>;
  36624. /**
  36625. * The master gain node defines the global audio volume of your audio engine.
  36626. */
  36627. readonly masterGain: GainNode;
  36628. /**
  36629. * Gets whether or not mp3 are supported by your browser.
  36630. */
  36631. readonly isMP3supported: boolean;
  36632. /**
  36633. * Gets whether or not ogg are supported by your browser.
  36634. */
  36635. readonly isOGGsupported: boolean;
  36636. /**
  36637. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36638. * @ignoreNaming
  36639. */
  36640. WarnedWebAudioUnsupported: boolean;
  36641. /**
  36642. * Defines if the audio engine relies on a custom unlocked button.
  36643. * In this case, the embedded button will not be displayed.
  36644. */
  36645. useCustomUnlockedButton: boolean;
  36646. /**
  36647. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36648. */
  36649. readonly unlocked: boolean;
  36650. /**
  36651. * Event raised when audio has been unlocked on the browser.
  36652. */
  36653. onAudioUnlockedObservable: Observable<AudioEngine>;
  36654. /**
  36655. * Event raised when audio has been locked on the browser.
  36656. */
  36657. onAudioLockedObservable: Observable<AudioEngine>;
  36658. /**
  36659. * Flags the audio engine in Locked state.
  36660. * This happens due to new browser policies preventing audio to autoplay.
  36661. */
  36662. lock(): void;
  36663. /**
  36664. * Unlocks the audio engine once a user action has been done on the dom.
  36665. * This is helpful to resume play once browser policies have been satisfied.
  36666. */
  36667. unlock(): void;
  36668. /**
  36669. * Gets the global volume sets on the master gain.
  36670. * @returns the global volume if set or -1 otherwise
  36671. */
  36672. getGlobalVolume(): number;
  36673. /**
  36674. * Sets the global volume of your experience (sets on the master gain).
  36675. * @param newVolume Defines the new global volume of the application
  36676. */
  36677. setGlobalVolume(newVolume: number): void;
  36678. /**
  36679. * Connect the audio engine to an audio analyser allowing some amazing
  36680. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36682. * @param analyser The analyser to connect to the engine
  36683. */
  36684. connectToAnalyser(analyser: Analyser): void;
  36685. }
  36686. /**
  36687. * This represents the default audio engine used in babylon.
  36688. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36690. */
  36691. export class AudioEngine implements IAudioEngine {
  36692. private _audioContext;
  36693. private _audioContextInitialized;
  36694. private _muteButton;
  36695. private _hostElement;
  36696. /**
  36697. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36698. */
  36699. canUseWebAudio: boolean;
  36700. /**
  36701. * The master gain node defines the global audio volume of your audio engine.
  36702. */
  36703. masterGain: GainNode;
  36704. /**
  36705. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36706. * @ignoreNaming
  36707. */
  36708. WarnedWebAudioUnsupported: boolean;
  36709. /**
  36710. * Gets whether or not mp3 are supported by your browser.
  36711. */
  36712. isMP3supported: boolean;
  36713. /**
  36714. * Gets whether or not ogg are supported by your browser.
  36715. */
  36716. isOGGsupported: boolean;
  36717. /**
  36718. * Gets whether audio has been unlocked on the device.
  36719. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36720. * a user interaction has happened.
  36721. */
  36722. unlocked: boolean;
  36723. /**
  36724. * Defines if the audio engine relies on a custom unlocked button.
  36725. * In this case, the embedded button will not be displayed.
  36726. */
  36727. useCustomUnlockedButton: boolean;
  36728. /**
  36729. * Event raised when audio has been unlocked on the browser.
  36730. */
  36731. onAudioUnlockedObservable: Observable<AudioEngine>;
  36732. /**
  36733. * Event raised when audio has been locked on the browser.
  36734. */
  36735. onAudioLockedObservable: Observable<AudioEngine>;
  36736. /**
  36737. * Gets the current AudioContext if available.
  36738. */
  36739. get audioContext(): Nullable<AudioContext>;
  36740. private _connectedAnalyser;
  36741. /**
  36742. * Instantiates a new audio engine.
  36743. *
  36744. * There should be only one per page as some browsers restrict the number
  36745. * of audio contexts you can create.
  36746. * @param hostElement defines the host element where to display the mute icon if necessary
  36747. */
  36748. constructor(hostElement?: Nullable<HTMLElement>);
  36749. /**
  36750. * Flags the audio engine in Locked state.
  36751. * This happens due to new browser policies preventing audio to autoplay.
  36752. */
  36753. lock(): void;
  36754. /**
  36755. * Unlocks the audio engine once a user action has been done on the dom.
  36756. * This is helpful to resume play once browser policies have been satisfied.
  36757. */
  36758. unlock(): void;
  36759. private _resumeAudioContext;
  36760. private _initializeAudioContext;
  36761. private _tryToRun;
  36762. private _triggerRunningState;
  36763. private _triggerSuspendedState;
  36764. private _displayMuteButton;
  36765. private _moveButtonToTopLeft;
  36766. private _onResize;
  36767. private _hideMuteButton;
  36768. /**
  36769. * Destroy and release the resources associated with the audio ccontext.
  36770. */
  36771. dispose(): void;
  36772. /**
  36773. * Gets the global volume sets on the master gain.
  36774. * @returns the global volume if set or -1 otherwise
  36775. */
  36776. getGlobalVolume(): number;
  36777. /**
  36778. * Sets the global volume of your experience (sets on the master gain).
  36779. * @param newVolume Defines the new global volume of the application
  36780. */
  36781. setGlobalVolume(newVolume: number): void;
  36782. /**
  36783. * Connect the audio engine to an audio analyser allowing some amazing
  36784. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36786. * @param analyser The analyser to connect to the engine
  36787. */
  36788. connectToAnalyser(analyser: Analyser): void;
  36789. }
  36790. }
  36791. declare module BABYLON {
  36792. /**
  36793. * Interface used to present a loading screen while loading a scene
  36794. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36795. */
  36796. export interface ILoadingScreen {
  36797. /**
  36798. * Function called to display the loading screen
  36799. */
  36800. displayLoadingUI: () => void;
  36801. /**
  36802. * Function called to hide the loading screen
  36803. */
  36804. hideLoadingUI: () => void;
  36805. /**
  36806. * Gets or sets the color to use for the background
  36807. */
  36808. loadingUIBackgroundColor: string;
  36809. /**
  36810. * Gets or sets the text to display while loading
  36811. */
  36812. loadingUIText: string;
  36813. }
  36814. /**
  36815. * Class used for the default loading screen
  36816. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36817. */
  36818. export class DefaultLoadingScreen implements ILoadingScreen {
  36819. private _renderingCanvas;
  36820. private _loadingText;
  36821. private _loadingDivBackgroundColor;
  36822. private _loadingDiv;
  36823. private _loadingTextDiv;
  36824. /** Gets or sets the logo url to use for the default loading screen */
  36825. static DefaultLogoUrl: string;
  36826. /** Gets or sets the spinner url to use for the default loading screen */
  36827. static DefaultSpinnerUrl: string;
  36828. /**
  36829. * Creates a new default loading screen
  36830. * @param _renderingCanvas defines the canvas used to render the scene
  36831. * @param _loadingText defines the default text to display
  36832. * @param _loadingDivBackgroundColor defines the default background color
  36833. */
  36834. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36835. /**
  36836. * Function called to display the loading screen
  36837. */
  36838. displayLoadingUI(): void;
  36839. /**
  36840. * Function called to hide the loading screen
  36841. */
  36842. hideLoadingUI(): void;
  36843. /**
  36844. * Gets or sets the text to display while loading
  36845. */
  36846. set loadingUIText(text: string);
  36847. get loadingUIText(): string;
  36848. /**
  36849. * Gets or sets the color to use for the background
  36850. */
  36851. get loadingUIBackgroundColor(): string;
  36852. set loadingUIBackgroundColor(color: string);
  36853. private _resizeLoadingUI;
  36854. }
  36855. }
  36856. declare module BABYLON {
  36857. /**
  36858. * Interface for any object that can request an animation frame
  36859. */
  36860. export interface ICustomAnimationFrameRequester {
  36861. /**
  36862. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36863. */
  36864. renderFunction?: Function;
  36865. /**
  36866. * Called to request the next frame to render to
  36867. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36868. */
  36869. requestAnimationFrame: Function;
  36870. /**
  36871. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36872. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36873. */
  36874. requestID?: number;
  36875. }
  36876. }
  36877. declare module BABYLON {
  36878. /**
  36879. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36880. */
  36881. export class PerformanceMonitor {
  36882. private _enabled;
  36883. private _rollingFrameTime;
  36884. private _lastFrameTimeMs;
  36885. /**
  36886. * constructor
  36887. * @param frameSampleSize The number of samples required to saturate the sliding window
  36888. */
  36889. constructor(frameSampleSize?: number);
  36890. /**
  36891. * Samples current frame
  36892. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36893. */
  36894. sampleFrame(timeMs?: number): void;
  36895. /**
  36896. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36897. */
  36898. get averageFrameTime(): number;
  36899. /**
  36900. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36901. */
  36902. get averageFrameTimeVariance(): number;
  36903. /**
  36904. * Returns the frame time of the most recent frame
  36905. */
  36906. get instantaneousFrameTime(): number;
  36907. /**
  36908. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36909. */
  36910. get averageFPS(): number;
  36911. /**
  36912. * Returns the average framerate in frames per second using the most recent frame time
  36913. */
  36914. get instantaneousFPS(): number;
  36915. /**
  36916. * Returns true if enough samples have been taken to completely fill the sliding window
  36917. */
  36918. get isSaturated(): boolean;
  36919. /**
  36920. * Enables contributions to the sliding window sample set
  36921. */
  36922. enable(): void;
  36923. /**
  36924. * Disables contributions to the sliding window sample set
  36925. * Samples will not be interpolated over the disabled period
  36926. */
  36927. disable(): void;
  36928. /**
  36929. * Returns true if sampling is enabled
  36930. */
  36931. get isEnabled(): boolean;
  36932. /**
  36933. * Resets performance monitor
  36934. */
  36935. reset(): void;
  36936. }
  36937. /**
  36938. * RollingAverage
  36939. *
  36940. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36941. */
  36942. export class RollingAverage {
  36943. /**
  36944. * Current average
  36945. */
  36946. average: number;
  36947. /**
  36948. * Current variance
  36949. */
  36950. variance: number;
  36951. protected _samples: Array<number>;
  36952. protected _sampleCount: number;
  36953. protected _pos: number;
  36954. protected _m2: number;
  36955. /**
  36956. * constructor
  36957. * @param length The number of samples required to saturate the sliding window
  36958. */
  36959. constructor(length: number);
  36960. /**
  36961. * Adds a sample to the sample set
  36962. * @param v The sample value
  36963. */
  36964. add(v: number): void;
  36965. /**
  36966. * Returns previously added values or null if outside of history or outside the sliding window domain
  36967. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36968. * @return Value previously recorded with add() or null if outside of range
  36969. */
  36970. history(i: number): number;
  36971. /**
  36972. * Returns true if enough samples have been taken to completely fill the sliding window
  36973. * @return true if sample-set saturated
  36974. */
  36975. isSaturated(): boolean;
  36976. /**
  36977. * Resets the rolling average (equivalent to 0 samples taken so far)
  36978. */
  36979. reset(): void;
  36980. /**
  36981. * Wraps a value around the sample range boundaries
  36982. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36983. * @return Wrapped position in sample range
  36984. */
  36985. protected _wrapPosition(i: number): number;
  36986. }
  36987. }
  36988. declare module BABYLON {
  36989. /**
  36990. * This class is used to track a performance counter which is number based.
  36991. * The user has access to many properties which give statistics of different nature.
  36992. *
  36993. * The implementer can track two kinds of Performance Counter: time and count.
  36994. * 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.
  36995. * 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.
  36996. */
  36997. export class PerfCounter {
  36998. /**
  36999. * Gets or sets a global boolean to turn on and off all the counters
  37000. */
  37001. static Enabled: boolean;
  37002. /**
  37003. * Returns the smallest value ever
  37004. */
  37005. get min(): number;
  37006. /**
  37007. * Returns the biggest value ever
  37008. */
  37009. get max(): number;
  37010. /**
  37011. * Returns the average value since the performance counter is running
  37012. */
  37013. get average(): number;
  37014. /**
  37015. * Returns the average value of the last second the counter was monitored
  37016. */
  37017. get lastSecAverage(): number;
  37018. /**
  37019. * Returns the current value
  37020. */
  37021. get current(): number;
  37022. /**
  37023. * Gets the accumulated total
  37024. */
  37025. get total(): number;
  37026. /**
  37027. * Gets the total value count
  37028. */
  37029. get count(): number;
  37030. /**
  37031. * Creates a new counter
  37032. */
  37033. constructor();
  37034. /**
  37035. * Call this method to start monitoring a new frame.
  37036. * 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.
  37037. */
  37038. fetchNewFrame(): void;
  37039. /**
  37040. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37041. * @param newCount the count value to add to the monitored count
  37042. * @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.
  37043. */
  37044. addCount(newCount: number, fetchResult: boolean): void;
  37045. /**
  37046. * Start monitoring this performance counter
  37047. */
  37048. beginMonitoring(): void;
  37049. /**
  37050. * Compute the time lapsed since the previous beginMonitoring() call.
  37051. * @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
  37052. */
  37053. endMonitoring(newFrame?: boolean): void;
  37054. private _fetchResult;
  37055. private _startMonitoringTime;
  37056. private _min;
  37057. private _max;
  37058. private _average;
  37059. private _current;
  37060. private _totalValueCount;
  37061. private _totalAccumulated;
  37062. private _lastSecAverage;
  37063. private _lastSecAccumulated;
  37064. private _lastSecTime;
  37065. private _lastSecValueCount;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. interface ThinEngine {
  37070. /**
  37071. * Sets alpha constants used by some alpha blending modes
  37072. * @param r defines the red component
  37073. * @param g defines the green component
  37074. * @param b defines the blue component
  37075. * @param a defines the alpha component
  37076. */
  37077. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37078. /**
  37079. * Sets the current alpha mode
  37080. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37081. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37082. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37083. */
  37084. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37085. /**
  37086. * Gets the current alpha mode
  37087. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37088. * @returns the current alpha mode
  37089. */
  37090. getAlphaMode(): number;
  37091. /**
  37092. * Sets the current alpha equation
  37093. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37094. */
  37095. setAlphaEquation(equation: number): void;
  37096. /**
  37097. * Gets the current alpha equation.
  37098. * @returns the current alpha equation
  37099. */
  37100. getAlphaEquation(): number;
  37101. }
  37102. }
  37103. declare module BABYLON {
  37104. interface ThinEngine {
  37105. /** @hidden */
  37106. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37107. }
  37108. }
  37109. declare module BABYLON {
  37110. /**
  37111. * Defines the interface used by display changed events
  37112. */
  37113. export interface IDisplayChangedEventArgs {
  37114. /** Gets the vrDisplay object (if any) */
  37115. vrDisplay: Nullable<any>;
  37116. /** Gets a boolean indicating if webVR is supported */
  37117. vrSupported: boolean;
  37118. }
  37119. /**
  37120. * Defines the interface used by objects containing a viewport (like a camera)
  37121. */
  37122. interface IViewportOwnerLike {
  37123. /**
  37124. * Gets or sets the viewport
  37125. */
  37126. viewport: IViewportLike;
  37127. }
  37128. /**
  37129. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37130. */
  37131. export class Engine extends ThinEngine {
  37132. /** Defines that alpha blending is disabled */
  37133. static readonly ALPHA_DISABLE: number;
  37134. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37135. static readonly ALPHA_ADD: number;
  37136. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37137. static readonly ALPHA_COMBINE: number;
  37138. /** Defines that alpha blending to DEST - SRC * DEST */
  37139. static readonly ALPHA_SUBTRACT: number;
  37140. /** Defines that alpha blending to SRC * DEST */
  37141. static readonly ALPHA_MULTIPLY: number;
  37142. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37143. static readonly ALPHA_MAXIMIZED: number;
  37144. /** Defines that alpha blending to SRC + DEST */
  37145. static readonly ALPHA_ONEONE: number;
  37146. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37147. static readonly ALPHA_PREMULTIPLIED: number;
  37148. /**
  37149. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37150. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37151. */
  37152. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37153. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37154. static readonly ALPHA_INTERPOLATE: number;
  37155. /**
  37156. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37157. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37158. */
  37159. static readonly ALPHA_SCREENMODE: number;
  37160. /** Defines that the ressource is not delayed*/
  37161. static readonly DELAYLOADSTATE_NONE: number;
  37162. /** Defines that the ressource was successfully delay loaded */
  37163. static readonly DELAYLOADSTATE_LOADED: number;
  37164. /** Defines that the ressource is currently delay loading */
  37165. static readonly DELAYLOADSTATE_LOADING: number;
  37166. /** Defines that the ressource is delayed and has not started loading */
  37167. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37169. static readonly NEVER: number;
  37170. /** 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 */
  37171. static readonly ALWAYS: number;
  37172. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37173. static readonly LESS: number;
  37174. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37175. static readonly EQUAL: number;
  37176. /** 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 */
  37177. static readonly LEQUAL: number;
  37178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37179. static readonly GREATER: number;
  37180. /** 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 */
  37181. static readonly GEQUAL: number;
  37182. /** 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 */
  37183. static readonly NOTEQUAL: number;
  37184. /** Passed to stencilOperation to specify that stencil value must be kept */
  37185. static readonly KEEP: number;
  37186. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37187. static readonly REPLACE: number;
  37188. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37189. static readonly INCR: number;
  37190. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37191. static readonly DECR: number;
  37192. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37193. static readonly INVERT: number;
  37194. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37195. static readonly INCR_WRAP: number;
  37196. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37197. static readonly DECR_WRAP: number;
  37198. /** Texture is not repeating outside of 0..1 UVs */
  37199. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37200. /** Texture is repeating outside of 0..1 UVs */
  37201. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37202. /** Texture is repeating and mirrored */
  37203. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37204. /** ALPHA */
  37205. static readonly TEXTUREFORMAT_ALPHA: number;
  37206. /** LUMINANCE */
  37207. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37208. /** LUMINANCE_ALPHA */
  37209. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37210. /** RGB */
  37211. static readonly TEXTUREFORMAT_RGB: number;
  37212. /** RGBA */
  37213. static readonly TEXTUREFORMAT_RGBA: number;
  37214. /** RED */
  37215. static readonly TEXTUREFORMAT_RED: number;
  37216. /** RED (2nd reference) */
  37217. static readonly TEXTUREFORMAT_R: number;
  37218. /** RG */
  37219. static readonly TEXTUREFORMAT_RG: number;
  37220. /** RED_INTEGER */
  37221. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37222. /** RED_INTEGER (2nd reference) */
  37223. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37224. /** RG_INTEGER */
  37225. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37226. /** RGB_INTEGER */
  37227. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37228. /** RGBA_INTEGER */
  37229. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37230. /** UNSIGNED_BYTE */
  37231. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37232. /** UNSIGNED_BYTE (2nd reference) */
  37233. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37234. /** FLOAT */
  37235. static readonly TEXTURETYPE_FLOAT: number;
  37236. /** HALF_FLOAT */
  37237. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37238. /** BYTE */
  37239. static readonly TEXTURETYPE_BYTE: number;
  37240. /** SHORT */
  37241. static readonly TEXTURETYPE_SHORT: number;
  37242. /** UNSIGNED_SHORT */
  37243. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37244. /** INT */
  37245. static readonly TEXTURETYPE_INT: number;
  37246. /** UNSIGNED_INT */
  37247. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37248. /** UNSIGNED_SHORT_4_4_4_4 */
  37249. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37250. /** UNSIGNED_SHORT_5_5_5_1 */
  37251. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37252. /** UNSIGNED_SHORT_5_6_5 */
  37253. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37254. /** UNSIGNED_INT_2_10_10_10_REV */
  37255. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37256. /** UNSIGNED_INT_24_8 */
  37257. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37258. /** UNSIGNED_INT_10F_11F_11F_REV */
  37259. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37260. /** UNSIGNED_INT_5_9_9_9_REV */
  37261. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37262. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37263. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37264. /** nearest is mag = nearest and min = nearest and mip = linear */
  37265. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37266. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37267. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37268. /** Trilinear is mag = linear and min = linear and mip = linear */
  37269. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37270. /** nearest is mag = nearest and min = nearest and mip = linear */
  37271. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37272. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37273. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37274. /** Trilinear is mag = linear and min = linear and mip = linear */
  37275. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37276. /** mag = nearest and min = nearest and mip = nearest */
  37277. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37278. /** mag = nearest and min = linear and mip = nearest */
  37279. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37280. /** mag = nearest and min = linear and mip = linear */
  37281. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37282. /** mag = nearest and min = linear and mip = none */
  37283. static readonly TEXTURE_NEAREST_LINEAR: number;
  37284. /** mag = nearest and min = nearest and mip = none */
  37285. static readonly TEXTURE_NEAREST_NEAREST: number;
  37286. /** mag = linear and min = nearest and mip = nearest */
  37287. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37288. /** mag = linear and min = nearest and mip = linear */
  37289. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37290. /** mag = linear and min = linear and mip = none */
  37291. static readonly TEXTURE_LINEAR_LINEAR: number;
  37292. /** mag = linear and min = nearest and mip = none */
  37293. static readonly TEXTURE_LINEAR_NEAREST: number;
  37294. /** Explicit coordinates mode */
  37295. static readonly TEXTURE_EXPLICIT_MODE: number;
  37296. /** Spherical coordinates mode */
  37297. static readonly TEXTURE_SPHERICAL_MODE: number;
  37298. /** Planar coordinates mode */
  37299. static readonly TEXTURE_PLANAR_MODE: number;
  37300. /** Cubic coordinates mode */
  37301. static readonly TEXTURE_CUBIC_MODE: number;
  37302. /** Projection coordinates mode */
  37303. static readonly TEXTURE_PROJECTION_MODE: number;
  37304. /** Skybox coordinates mode */
  37305. static readonly TEXTURE_SKYBOX_MODE: number;
  37306. /** Inverse Cubic coordinates mode */
  37307. static readonly TEXTURE_INVCUBIC_MODE: number;
  37308. /** Equirectangular coordinates mode */
  37309. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37310. /** Equirectangular Fixed coordinates mode */
  37311. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37312. /** Equirectangular Fixed Mirrored coordinates mode */
  37313. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37314. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37315. static readonly SCALEMODE_FLOOR: number;
  37316. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37317. static readonly SCALEMODE_NEAREST: number;
  37318. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37319. static readonly SCALEMODE_CEILING: number;
  37320. /**
  37321. * Returns the current npm package of the sdk
  37322. */
  37323. static get NpmPackage(): string;
  37324. /**
  37325. * Returns the current version of the framework
  37326. */
  37327. static get Version(): string;
  37328. /** Gets the list of created engines */
  37329. static get Instances(): Engine[];
  37330. /**
  37331. * Gets the latest created engine
  37332. */
  37333. static get LastCreatedEngine(): Nullable<Engine>;
  37334. /**
  37335. * Gets the latest created scene
  37336. */
  37337. static get LastCreatedScene(): Nullable<Scene>;
  37338. /**
  37339. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37340. * @param flag defines which part of the materials must be marked as dirty
  37341. * @param predicate defines a predicate used to filter which materials should be affected
  37342. */
  37343. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37344. /**
  37345. * Method called to create the default loading screen.
  37346. * This can be overriden in your own app.
  37347. * @param canvas The rendering canvas element
  37348. * @returns The loading screen
  37349. */
  37350. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37351. /**
  37352. * Method called to create the default rescale post process on each engine.
  37353. */
  37354. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37355. /**
  37356. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37357. **/
  37358. enableOfflineSupport: boolean;
  37359. /**
  37360. * 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)
  37361. **/
  37362. disableManifestCheck: boolean;
  37363. /**
  37364. * Gets the list of created scenes
  37365. */
  37366. scenes: Scene[];
  37367. /**
  37368. * Event raised when a new scene is created
  37369. */
  37370. onNewSceneAddedObservable: Observable<Scene>;
  37371. /**
  37372. * Gets the list of created postprocesses
  37373. */
  37374. postProcesses: PostProcess[];
  37375. /**
  37376. * Gets a boolean indicating if the pointer is currently locked
  37377. */
  37378. isPointerLock: boolean;
  37379. /**
  37380. * Observable event triggered each time the rendering canvas is resized
  37381. */
  37382. onResizeObservable: Observable<Engine>;
  37383. /**
  37384. * Observable event triggered each time the canvas loses focus
  37385. */
  37386. onCanvasBlurObservable: Observable<Engine>;
  37387. /**
  37388. * Observable event triggered each time the canvas gains focus
  37389. */
  37390. onCanvasFocusObservable: Observable<Engine>;
  37391. /**
  37392. * Observable event triggered each time the canvas receives pointerout event
  37393. */
  37394. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37395. /**
  37396. * Observable raised when the engine begins a new frame
  37397. */
  37398. onBeginFrameObservable: Observable<Engine>;
  37399. /**
  37400. * If set, will be used to request the next animation frame for the render loop
  37401. */
  37402. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37403. /**
  37404. * Observable raised when the engine ends the current frame
  37405. */
  37406. onEndFrameObservable: Observable<Engine>;
  37407. /**
  37408. * Observable raised when the engine is about to compile a shader
  37409. */
  37410. onBeforeShaderCompilationObservable: Observable<Engine>;
  37411. /**
  37412. * Observable raised when the engine has jsut compiled a shader
  37413. */
  37414. onAfterShaderCompilationObservable: Observable<Engine>;
  37415. /**
  37416. * Gets the audio engine
  37417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37418. * @ignorenaming
  37419. */
  37420. static audioEngine: IAudioEngine;
  37421. /**
  37422. * Default AudioEngine factory responsible of creating the Audio Engine.
  37423. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37424. */
  37425. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37426. /**
  37427. * Default offline support factory responsible of creating a tool used to store data locally.
  37428. * By default, this will create a Database object if the workload has been embedded.
  37429. */
  37430. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37431. private _loadingScreen;
  37432. private _pointerLockRequested;
  37433. private _rescalePostProcess;
  37434. private _deterministicLockstep;
  37435. private _lockstepMaxSteps;
  37436. private _timeStep;
  37437. protected get _supportsHardwareTextureRescaling(): boolean;
  37438. private _fps;
  37439. private _deltaTime;
  37440. /** @hidden */
  37441. _drawCalls: PerfCounter;
  37442. /** 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 */
  37443. canvasTabIndex: number;
  37444. /**
  37445. * Turn this value on if you want to pause FPS computation when in background
  37446. */
  37447. disablePerformanceMonitorInBackground: boolean;
  37448. private _performanceMonitor;
  37449. /**
  37450. * Gets the performance monitor attached to this engine
  37451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37452. */
  37453. get performanceMonitor(): PerformanceMonitor;
  37454. private _onFocus;
  37455. private _onBlur;
  37456. private _onCanvasPointerOut;
  37457. private _onCanvasBlur;
  37458. private _onCanvasFocus;
  37459. private _onFullscreenChange;
  37460. private _onPointerLockChange;
  37461. /**
  37462. * Gets the HTML element used to attach event listeners
  37463. * @returns a HTML element
  37464. */
  37465. getInputElement(): Nullable<HTMLElement>;
  37466. /**
  37467. * Creates a new engine
  37468. * @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
  37469. * @param antialias defines enable antialiasing (default: false)
  37470. * @param options defines further options to be sent to the getContext() function
  37471. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37472. */
  37473. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37474. /**
  37475. * Gets current aspect ratio
  37476. * @param viewportOwner defines the camera to use to get the aspect ratio
  37477. * @param useScreen defines if screen size must be used (or the current render target if any)
  37478. * @returns a number defining the aspect ratio
  37479. */
  37480. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37481. /**
  37482. * Gets current screen aspect ratio
  37483. * @returns a number defining the aspect ratio
  37484. */
  37485. getScreenAspectRatio(): number;
  37486. /**
  37487. * Gets the client rect of the HTML canvas attached with the current webGL context
  37488. * @returns a client rectanglee
  37489. */
  37490. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37491. /**
  37492. * Gets the client rect of the HTML element used for events
  37493. * @returns a client rectanglee
  37494. */
  37495. getInputElementClientRect(): Nullable<ClientRect>;
  37496. /**
  37497. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37498. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37499. * @returns true if engine is in deterministic lock step mode
  37500. */
  37501. isDeterministicLockStep(): boolean;
  37502. /**
  37503. * Gets the max steps when engine is running in deterministic lock step
  37504. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37505. * @returns the max steps
  37506. */
  37507. getLockstepMaxSteps(): number;
  37508. /**
  37509. * Returns the time in ms between steps when using deterministic lock step.
  37510. * @returns time step in (ms)
  37511. */
  37512. getTimeStep(): number;
  37513. /**
  37514. * Force the mipmap generation for the given render target texture
  37515. * @param texture defines the render target texture to use
  37516. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37517. */
  37518. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37519. /** States */
  37520. /**
  37521. * Set various states to the webGL context
  37522. * @param culling defines backface culling state
  37523. * @param zOffset defines the value to apply to zOffset (0 by default)
  37524. * @param force defines if states must be applied even if cache is up to date
  37525. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37526. */
  37527. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37528. /**
  37529. * Set the z offset to apply to current rendering
  37530. * @param value defines the offset to apply
  37531. */
  37532. setZOffset(value: number): void;
  37533. /**
  37534. * Gets the current value of the zOffset
  37535. * @returns the current zOffset state
  37536. */
  37537. getZOffset(): number;
  37538. /**
  37539. * Enable or disable depth buffering
  37540. * @param enable defines the state to set
  37541. */
  37542. setDepthBuffer(enable: boolean): void;
  37543. /**
  37544. * Gets a boolean indicating if depth writing is enabled
  37545. * @returns the current depth writing state
  37546. */
  37547. getDepthWrite(): boolean;
  37548. /**
  37549. * Enable or disable depth writing
  37550. * @param enable defines the state to set
  37551. */
  37552. setDepthWrite(enable: boolean): void;
  37553. /**
  37554. * Gets a boolean indicating if stencil buffer is enabled
  37555. * @returns the current stencil buffer state
  37556. */
  37557. getStencilBuffer(): boolean;
  37558. /**
  37559. * Enable or disable the stencil buffer
  37560. * @param enable defines if the stencil buffer must be enabled or disabled
  37561. */
  37562. setStencilBuffer(enable: boolean): void;
  37563. /**
  37564. * Gets the current stencil mask
  37565. * @returns a number defining the new stencil mask to use
  37566. */
  37567. getStencilMask(): number;
  37568. /**
  37569. * Sets the current stencil mask
  37570. * @param mask defines the new stencil mask to use
  37571. */
  37572. setStencilMask(mask: number): void;
  37573. /**
  37574. * Gets the current stencil function
  37575. * @returns a number defining the stencil function to use
  37576. */
  37577. getStencilFunction(): number;
  37578. /**
  37579. * Gets the current stencil reference value
  37580. * @returns a number defining the stencil reference value to use
  37581. */
  37582. getStencilFunctionReference(): number;
  37583. /**
  37584. * Gets the current stencil mask
  37585. * @returns a number defining the stencil mask to use
  37586. */
  37587. getStencilFunctionMask(): number;
  37588. /**
  37589. * Sets the current stencil function
  37590. * @param stencilFunc defines the new stencil function to use
  37591. */
  37592. setStencilFunction(stencilFunc: number): void;
  37593. /**
  37594. * Sets the current stencil reference
  37595. * @param reference defines the new stencil reference to use
  37596. */
  37597. setStencilFunctionReference(reference: number): void;
  37598. /**
  37599. * Sets the current stencil mask
  37600. * @param mask defines the new stencil mask to use
  37601. */
  37602. setStencilFunctionMask(mask: number): void;
  37603. /**
  37604. * Gets the current stencil operation when stencil fails
  37605. * @returns a number defining stencil operation to use when stencil fails
  37606. */
  37607. getStencilOperationFail(): number;
  37608. /**
  37609. * Gets the current stencil operation when depth fails
  37610. * @returns a number defining stencil operation to use when depth fails
  37611. */
  37612. getStencilOperationDepthFail(): number;
  37613. /**
  37614. * Gets the current stencil operation when stencil passes
  37615. * @returns a number defining stencil operation to use when stencil passes
  37616. */
  37617. getStencilOperationPass(): number;
  37618. /**
  37619. * Sets the stencil operation to use when stencil fails
  37620. * @param operation defines the stencil operation to use when stencil fails
  37621. */
  37622. setStencilOperationFail(operation: number): void;
  37623. /**
  37624. * Sets the stencil operation to use when depth fails
  37625. * @param operation defines the stencil operation to use when depth fails
  37626. */
  37627. setStencilOperationDepthFail(operation: number): void;
  37628. /**
  37629. * Sets the stencil operation to use when stencil passes
  37630. * @param operation defines the stencil operation to use when stencil passes
  37631. */
  37632. setStencilOperationPass(operation: number): void;
  37633. /**
  37634. * Sets a boolean indicating if the dithering state is enabled or disabled
  37635. * @param value defines the dithering state
  37636. */
  37637. setDitheringState(value: boolean): void;
  37638. /**
  37639. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37640. * @param value defines the rasterizer state
  37641. */
  37642. setRasterizerState(value: boolean): void;
  37643. /**
  37644. * Gets the current depth function
  37645. * @returns a number defining the depth function
  37646. */
  37647. getDepthFunction(): Nullable<number>;
  37648. /**
  37649. * Sets the current depth function
  37650. * @param depthFunc defines the function to use
  37651. */
  37652. setDepthFunction(depthFunc: number): void;
  37653. /**
  37654. * Sets the current depth function to GREATER
  37655. */
  37656. setDepthFunctionToGreater(): void;
  37657. /**
  37658. * Sets the current depth function to GEQUAL
  37659. */
  37660. setDepthFunctionToGreaterOrEqual(): void;
  37661. /**
  37662. * Sets the current depth function to LESS
  37663. */
  37664. setDepthFunctionToLess(): void;
  37665. /**
  37666. * Sets the current depth function to LEQUAL
  37667. */
  37668. setDepthFunctionToLessOrEqual(): void;
  37669. private _cachedStencilBuffer;
  37670. private _cachedStencilFunction;
  37671. private _cachedStencilMask;
  37672. private _cachedStencilOperationPass;
  37673. private _cachedStencilOperationFail;
  37674. private _cachedStencilOperationDepthFail;
  37675. private _cachedStencilReference;
  37676. /**
  37677. * Caches the the state of the stencil buffer
  37678. */
  37679. cacheStencilState(): void;
  37680. /**
  37681. * Restores the state of the stencil buffer
  37682. */
  37683. restoreStencilState(): void;
  37684. /**
  37685. * Directly set the WebGL Viewport
  37686. * @param x defines the x coordinate of the viewport (in screen space)
  37687. * @param y defines the y coordinate of the viewport (in screen space)
  37688. * @param width defines the width of the viewport (in screen space)
  37689. * @param height defines the height of the viewport (in screen space)
  37690. * @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
  37691. */
  37692. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37693. /**
  37694. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37695. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37696. * @param y defines the y-coordinate of the corner of the clear rectangle
  37697. * @param width defines the width of the clear rectangle
  37698. * @param height defines the height of the clear rectangle
  37699. * @param clearColor defines the clear color
  37700. */
  37701. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37702. /**
  37703. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37704. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37705. * @param y defines the y-coordinate of the corner of the clear rectangle
  37706. * @param width defines the width of the clear rectangle
  37707. * @param height defines the height of the clear rectangle
  37708. */
  37709. enableScissor(x: number, y: number, width: number, height: number): void;
  37710. /**
  37711. * Disable previously set scissor test rectangle
  37712. */
  37713. disableScissor(): void;
  37714. protected _reportDrawCall(): void;
  37715. /**
  37716. * Initializes a webVR display and starts listening to display change events
  37717. * The onVRDisplayChangedObservable will be notified upon these changes
  37718. * @returns The onVRDisplayChangedObservable
  37719. */
  37720. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37721. /** @hidden */
  37722. _prepareVRComponent(): void;
  37723. /** @hidden */
  37724. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37725. /** @hidden */
  37726. _submitVRFrame(): void;
  37727. /**
  37728. * Call this function to leave webVR mode
  37729. * Will do nothing if webVR is not supported or if there is no webVR device
  37730. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37731. */
  37732. disableVR(): void;
  37733. /**
  37734. * Gets a boolean indicating that the system is in VR mode and is presenting
  37735. * @returns true if VR mode is engaged
  37736. */
  37737. isVRPresenting(): boolean;
  37738. /** @hidden */
  37739. _requestVRFrame(): void;
  37740. /** @hidden */
  37741. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37742. /**
  37743. * Gets the source code of the vertex shader associated with a specific webGL program
  37744. * @param program defines the program to use
  37745. * @returns a string containing the source code of the vertex shader associated with the program
  37746. */
  37747. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37748. /**
  37749. * Gets the source code of the fragment shader associated with a specific webGL program
  37750. * @param program defines the program to use
  37751. * @returns a string containing the source code of the fragment shader associated with the program
  37752. */
  37753. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37754. /**
  37755. * Sets a depth stencil texture from a render target to the according uniform.
  37756. * @param channel The texture channel
  37757. * @param uniform The uniform to set
  37758. * @param texture The render target texture containing the depth stencil texture to apply
  37759. */
  37760. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37761. /**
  37762. * Sets a texture to the webGL context from a postprocess
  37763. * @param channel defines the channel to use
  37764. * @param postProcess defines the source postprocess
  37765. */
  37766. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37767. /**
  37768. * Binds the output of the passed in post process to the texture channel specified
  37769. * @param channel The channel the texture should be bound to
  37770. * @param postProcess The post process which's output should be bound
  37771. */
  37772. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37773. protected _rebuildBuffers(): void;
  37774. /** @hidden */
  37775. _renderFrame(): void;
  37776. _renderLoop(): void;
  37777. /** @hidden */
  37778. _renderViews(): boolean;
  37779. /**
  37780. * Toggle full screen mode
  37781. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37782. */
  37783. switchFullscreen(requestPointerLock: boolean): void;
  37784. /**
  37785. * Enters full screen mode
  37786. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37787. */
  37788. enterFullscreen(requestPointerLock: boolean): void;
  37789. /**
  37790. * Exits full screen mode
  37791. */
  37792. exitFullscreen(): void;
  37793. /**
  37794. * Enters Pointerlock mode
  37795. */
  37796. enterPointerlock(): void;
  37797. /**
  37798. * Exits Pointerlock mode
  37799. */
  37800. exitPointerlock(): void;
  37801. /**
  37802. * Begin a new frame
  37803. */
  37804. beginFrame(): void;
  37805. /**
  37806. * Enf the current frame
  37807. */
  37808. endFrame(): void;
  37809. resize(): void;
  37810. /**
  37811. * Force a specific size of the canvas
  37812. * @param width defines the new canvas' width
  37813. * @param height defines the new canvas' height
  37814. * @returns true if the size was changed
  37815. */
  37816. setSize(width: number, height: number): boolean;
  37817. /**
  37818. * Updates a dynamic vertex buffer.
  37819. * @param vertexBuffer the vertex buffer to update
  37820. * @param data the data used to update the vertex buffer
  37821. * @param byteOffset the byte offset of the data
  37822. * @param byteLength the byte length of the data
  37823. */
  37824. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37825. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37826. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37827. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37828. _releaseTexture(texture: InternalTexture): void;
  37829. /**
  37830. * @hidden
  37831. * Rescales a texture
  37832. * @param source input texutre
  37833. * @param destination destination texture
  37834. * @param scene scene to use to render the resize
  37835. * @param internalFormat format to use when resizing
  37836. * @param onComplete callback to be called when resize has completed
  37837. */
  37838. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37839. /**
  37840. * Gets the current framerate
  37841. * @returns a number representing the framerate
  37842. */
  37843. getFps(): number;
  37844. /**
  37845. * Gets the time spent between current and previous frame
  37846. * @returns a number representing the delta time in ms
  37847. */
  37848. getDeltaTime(): number;
  37849. private _measureFps;
  37850. /** @hidden */
  37851. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37852. /**
  37853. * Update a dynamic index buffer
  37854. * @param indexBuffer defines the target index buffer
  37855. * @param indices defines the data to update
  37856. * @param offset defines the offset in the target index buffer where update should start
  37857. */
  37858. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37859. /**
  37860. * Updates the sample count of a render target texture
  37861. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37862. * @param texture defines the texture to update
  37863. * @param samples defines the sample count to set
  37864. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37865. */
  37866. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37867. /**
  37868. * Updates a depth texture Comparison Mode and Function.
  37869. * If the comparison Function is equal to 0, the mode will be set to none.
  37870. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37871. * @param texture The texture to set the comparison function for
  37872. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37873. */
  37874. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37875. /**
  37876. * Creates a webGL buffer to use with instanciation
  37877. * @param capacity defines the size of the buffer
  37878. * @returns the webGL buffer
  37879. */
  37880. createInstancesBuffer(capacity: number): DataBuffer;
  37881. /**
  37882. * Delete a webGL buffer used with instanciation
  37883. * @param buffer defines the webGL buffer to delete
  37884. */
  37885. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37886. private _clientWaitAsync;
  37887. /** @hidden */
  37888. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37889. dispose(): void;
  37890. private _disableTouchAction;
  37891. /**
  37892. * Display the loading screen
  37893. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37894. */
  37895. displayLoadingUI(): void;
  37896. /**
  37897. * Hide the loading screen
  37898. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37899. */
  37900. hideLoadingUI(): void;
  37901. /**
  37902. * Gets the current loading screen object
  37903. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37904. */
  37905. get loadingScreen(): ILoadingScreen;
  37906. /**
  37907. * Sets the current loading screen object
  37908. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37909. */
  37910. set loadingScreen(loadingScreen: ILoadingScreen);
  37911. /**
  37912. * Sets the current loading screen text
  37913. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37914. */
  37915. set loadingUIText(text: string);
  37916. /**
  37917. * Sets the current loading screen background color
  37918. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37919. */
  37920. set loadingUIBackgroundColor(color: string);
  37921. /** Pointerlock and fullscreen */
  37922. /**
  37923. * Ask the browser to promote the current element to pointerlock mode
  37924. * @param element defines the DOM element to promote
  37925. */
  37926. static _RequestPointerlock(element: HTMLElement): void;
  37927. /**
  37928. * Asks the browser to exit pointerlock mode
  37929. */
  37930. static _ExitPointerlock(): void;
  37931. /**
  37932. * Ask the browser to promote the current element to fullscreen rendering mode
  37933. * @param element defines the DOM element to promote
  37934. */
  37935. static _RequestFullscreen(element: HTMLElement): void;
  37936. /**
  37937. * Asks the browser to exit fullscreen mode
  37938. */
  37939. static _ExitFullscreen(): void;
  37940. }
  37941. }
  37942. declare module BABYLON {
  37943. /**
  37944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37945. * during the life time of the application.
  37946. */
  37947. export class EngineStore {
  37948. /** Gets the list of created engines */
  37949. static Instances: Engine[];
  37950. /** @hidden */
  37951. static _LastCreatedScene: Nullable<Scene>;
  37952. /**
  37953. * Gets the latest created engine
  37954. */
  37955. static get LastCreatedEngine(): Nullable<Engine>;
  37956. /**
  37957. * Gets the latest created scene
  37958. */
  37959. static get LastCreatedScene(): Nullable<Scene>;
  37960. /**
  37961. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37962. * @ignorenaming
  37963. */
  37964. static UseFallbackTexture: boolean;
  37965. /**
  37966. * Texture content used if a texture cannot loaded
  37967. * @ignorenaming
  37968. */
  37969. static FallbackTexture: string;
  37970. }
  37971. }
  37972. declare module BABYLON {
  37973. /**
  37974. * Helper class that provides a small promise polyfill
  37975. */
  37976. export class PromisePolyfill {
  37977. /**
  37978. * Static function used to check if the polyfill is required
  37979. * If this is the case then the function will inject the polyfill to window.Promise
  37980. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37981. */
  37982. static Apply(force?: boolean): void;
  37983. }
  37984. }
  37985. declare module BABYLON {
  37986. /**
  37987. * Interface for screenshot methods with describe argument called `size` as object with options
  37988. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37989. */
  37990. export interface IScreenshotSize {
  37991. /**
  37992. * number in pixels for canvas height
  37993. */
  37994. height?: number;
  37995. /**
  37996. * multiplier allowing render at a higher or lower resolution
  37997. * If value is defined then height and width will be ignored and taken from camera
  37998. */
  37999. precision?: number;
  38000. /**
  38001. * number in pixels for canvas width
  38002. */
  38003. width?: number;
  38004. }
  38005. }
  38006. declare module BABYLON {
  38007. interface IColor4Like {
  38008. r: float;
  38009. g: float;
  38010. b: float;
  38011. a: float;
  38012. }
  38013. /**
  38014. * Class containing a set of static utilities functions
  38015. */
  38016. export class Tools {
  38017. /**
  38018. * Gets or sets the base URL to use to load assets
  38019. */
  38020. static get BaseUrl(): string;
  38021. static set BaseUrl(value: string);
  38022. /**
  38023. * Enable/Disable Custom HTTP Request Headers globally.
  38024. * default = false
  38025. * @see CustomRequestHeaders
  38026. */
  38027. static UseCustomRequestHeaders: boolean;
  38028. /**
  38029. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38030. * i.e. when loading files, where the server/service expects an Authorization header
  38031. */
  38032. static CustomRequestHeaders: {
  38033. [key: string]: string;
  38034. };
  38035. /**
  38036. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38037. */
  38038. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38039. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38040. /**
  38041. * Default behaviour for cors in the application.
  38042. * It can be a string if the expected behavior is identical in the entire app.
  38043. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38044. */
  38045. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38046. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38047. /**
  38048. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38049. * @ignorenaming
  38050. */
  38051. static get UseFallbackTexture(): boolean;
  38052. static set UseFallbackTexture(value: boolean);
  38053. /**
  38054. * Use this object to register external classes like custom textures or material
  38055. * to allow the laoders to instantiate them
  38056. */
  38057. static get RegisteredExternalClasses(): {
  38058. [key: string]: Object;
  38059. };
  38060. static set RegisteredExternalClasses(classes: {
  38061. [key: string]: Object;
  38062. });
  38063. /**
  38064. * Texture content used if a texture cannot loaded
  38065. * @ignorenaming
  38066. */
  38067. static get fallbackTexture(): string;
  38068. static set fallbackTexture(value: string);
  38069. /**
  38070. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38071. * @param u defines the coordinate on X axis
  38072. * @param v defines the coordinate on Y axis
  38073. * @param width defines the width of the source data
  38074. * @param height defines the height of the source data
  38075. * @param pixels defines the source byte array
  38076. * @param color defines the output color
  38077. */
  38078. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38079. /**
  38080. * Interpolates between a and b via alpha
  38081. * @param a The lower value (returned when alpha = 0)
  38082. * @param b The upper value (returned when alpha = 1)
  38083. * @param alpha The interpolation-factor
  38084. * @return The mixed value
  38085. */
  38086. static Mix(a: number, b: number, alpha: number): number;
  38087. /**
  38088. * Tries to instantiate a new object from a given class name
  38089. * @param className defines the class name to instantiate
  38090. * @returns the new object or null if the system was not able to do the instantiation
  38091. */
  38092. static Instantiate(className: string): any;
  38093. /**
  38094. * Provides a slice function that will work even on IE
  38095. * @param data defines the array to slice
  38096. * @param start defines the start of the data (optional)
  38097. * @param end defines the end of the data (optional)
  38098. * @returns the new sliced array
  38099. */
  38100. static Slice<T>(data: T, start?: number, end?: number): T;
  38101. /**
  38102. * Polyfill for setImmediate
  38103. * @param action defines the action to execute after the current execution block
  38104. */
  38105. static SetImmediate(action: () => void): void;
  38106. /**
  38107. * Function indicating if a number is an exponent of 2
  38108. * @param value defines the value to test
  38109. * @returns true if the value is an exponent of 2
  38110. */
  38111. static IsExponentOfTwo(value: number): boolean;
  38112. private static _tmpFloatArray;
  38113. /**
  38114. * Returns the nearest 32-bit single precision float representation of a Number
  38115. * @param value A Number. If the parameter is of a different type, it will get converted
  38116. * to a number or to NaN if it cannot be converted
  38117. * @returns number
  38118. */
  38119. static FloatRound(value: number): number;
  38120. /**
  38121. * Extracts the filename from a path
  38122. * @param path defines the path to use
  38123. * @returns the filename
  38124. */
  38125. static GetFilename(path: string): string;
  38126. /**
  38127. * Extracts the "folder" part of a path (everything before the filename).
  38128. * @param uri The URI to extract the info from
  38129. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38130. * @returns The "folder" part of the path
  38131. */
  38132. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38133. /**
  38134. * Extracts text content from a DOM element hierarchy
  38135. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38136. */
  38137. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38138. /**
  38139. * Convert an angle in radians to degrees
  38140. * @param angle defines the angle to convert
  38141. * @returns the angle in degrees
  38142. */
  38143. static ToDegrees(angle: number): number;
  38144. /**
  38145. * Convert an angle in degrees to radians
  38146. * @param angle defines the angle to convert
  38147. * @returns the angle in radians
  38148. */
  38149. static ToRadians(angle: number): number;
  38150. /**
  38151. * Returns an array if obj is not an array
  38152. * @param obj defines the object to evaluate as an array
  38153. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38154. * @returns either obj directly if obj is an array or a new array containing obj
  38155. */
  38156. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38157. /**
  38158. * Gets the pointer prefix to use
  38159. * @param engine defines the engine we are finding the prefix for
  38160. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38161. */
  38162. static GetPointerPrefix(engine: Engine): string;
  38163. /**
  38164. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38165. * @param url define the url we are trying
  38166. * @param element define the dom element where to configure the cors policy
  38167. */
  38168. static SetCorsBehavior(url: string | string[], element: {
  38169. crossOrigin: string | null;
  38170. }): void;
  38171. /**
  38172. * Removes unwanted characters from an url
  38173. * @param url defines the url to clean
  38174. * @returns the cleaned url
  38175. */
  38176. static CleanUrl(url: string): string;
  38177. /**
  38178. * Gets or sets a function used to pre-process url before using them to load assets
  38179. */
  38180. static get PreprocessUrl(): (url: string) => string;
  38181. static set PreprocessUrl(processor: (url: string) => string);
  38182. /**
  38183. * Loads an image as an HTMLImageElement.
  38184. * @param input url string, ArrayBuffer, or Blob to load
  38185. * @param onLoad callback called when the image successfully loads
  38186. * @param onError callback called when the image fails to load
  38187. * @param offlineProvider offline provider for caching
  38188. * @param mimeType optional mime type
  38189. * @returns the HTMLImageElement of the loaded image
  38190. */
  38191. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38192. /**
  38193. * Loads a file from a url
  38194. * @param url url string, ArrayBuffer, or Blob to load
  38195. * @param onSuccess callback called when the file successfully loads
  38196. * @param onProgress callback called while file is loading (if the server supports this mode)
  38197. * @param offlineProvider defines the offline provider for caching
  38198. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38199. * @param onError callback called when the file fails to load
  38200. * @returns a file request object
  38201. */
  38202. 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;
  38203. /**
  38204. * Loads a file from a url
  38205. * @param url the file url to load
  38206. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38207. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38208. */
  38209. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38210. /**
  38211. * Load a script (identified by an url). When the url returns, the
  38212. * content of this file is added into a new script element, attached to the DOM (body element)
  38213. * @param scriptUrl defines the url of the script to laod
  38214. * @param onSuccess defines the callback called when the script is loaded
  38215. * @param onError defines the callback to call if an error occurs
  38216. * @param scriptId defines the id of the script element
  38217. */
  38218. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38219. /**
  38220. * Load an asynchronous script (identified by an url). When the url returns, the
  38221. * content of this file is added into a new script element, attached to the DOM (body element)
  38222. * @param scriptUrl defines the url of the script to laod
  38223. * @param scriptId defines the id of the script element
  38224. * @returns a promise request object
  38225. */
  38226. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38227. /**
  38228. * Loads a file from a blob
  38229. * @param fileToLoad defines the blob to use
  38230. * @param callback defines the callback to call when data is loaded
  38231. * @param progressCallback defines the callback to call during loading process
  38232. * @returns a file request object
  38233. */
  38234. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38235. /**
  38236. * Reads a file from a File object
  38237. * @param file defines the file to load
  38238. * @param onSuccess defines the callback to call when data is loaded
  38239. * @param onProgress defines the callback to call during loading process
  38240. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38241. * @param onError defines the callback to call when an error occurs
  38242. * @returns a file request object
  38243. */
  38244. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38245. /**
  38246. * Creates a data url from a given string content
  38247. * @param content defines the content to convert
  38248. * @returns the new data url link
  38249. */
  38250. static FileAsURL(content: string): string;
  38251. /**
  38252. * Format the given number to a specific decimal format
  38253. * @param value defines the number to format
  38254. * @param decimals defines the number of decimals to use
  38255. * @returns the formatted string
  38256. */
  38257. static Format(value: number, decimals?: number): string;
  38258. /**
  38259. * Tries to copy an object by duplicating every property
  38260. * @param source defines the source object
  38261. * @param destination defines the target object
  38262. * @param doNotCopyList defines a list of properties to avoid
  38263. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38264. */
  38265. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38266. /**
  38267. * Gets a boolean indicating if the given object has no own property
  38268. * @param obj defines the object to test
  38269. * @returns true if object has no own property
  38270. */
  38271. static IsEmpty(obj: any): boolean;
  38272. /**
  38273. * Function used to register events at window level
  38274. * @param windowElement defines the Window object to use
  38275. * @param events defines the events to register
  38276. */
  38277. static RegisterTopRootEvents(windowElement: Window, events: {
  38278. name: string;
  38279. handler: Nullable<(e: FocusEvent) => any>;
  38280. }[]): void;
  38281. /**
  38282. * Function used to unregister events from window level
  38283. * @param windowElement defines the Window object to use
  38284. * @param events defines the events to unregister
  38285. */
  38286. static UnregisterTopRootEvents(windowElement: Window, events: {
  38287. name: string;
  38288. handler: Nullable<(e: FocusEvent) => any>;
  38289. }[]): void;
  38290. /**
  38291. * @ignore
  38292. */
  38293. static _ScreenshotCanvas: HTMLCanvasElement;
  38294. /**
  38295. * Dumps the current bound framebuffer
  38296. * @param width defines the rendering width
  38297. * @param height defines the rendering height
  38298. * @param engine defines the hosting engine
  38299. * @param successCallback defines the callback triggered once the data are available
  38300. * @param mimeType defines the mime type of the result
  38301. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38302. */
  38303. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38304. /**
  38305. * Converts the canvas data to blob.
  38306. * This acts as a polyfill for browsers not supporting the to blob function.
  38307. * @param canvas Defines the canvas to extract the data from
  38308. * @param successCallback Defines the callback triggered once the data are available
  38309. * @param mimeType Defines the mime type of the result
  38310. */
  38311. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38312. /**
  38313. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38314. * @param successCallback defines the callback triggered once the data are available
  38315. * @param mimeType defines the mime type of the result
  38316. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38317. */
  38318. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38319. /**
  38320. * Downloads a blob in the browser
  38321. * @param blob defines the blob to download
  38322. * @param fileName defines the name of the downloaded file
  38323. */
  38324. static Download(blob: Blob, fileName: string): void;
  38325. /**
  38326. * Captures a screenshot of the current rendering
  38327. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38328. * @param engine defines the rendering engine
  38329. * @param camera defines the source camera
  38330. * @param size This parameter can be set to a single number or to an object with the
  38331. * following (optional) properties: precision, width, height. If a single number is passed,
  38332. * it will be used for both width and height. If an object is passed, the screenshot size
  38333. * will be derived from the parameters. The precision property is a multiplier allowing
  38334. * rendering at a higher or lower resolution
  38335. * @param successCallback defines the callback receives a single parameter which contains the
  38336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38337. * src parameter of an <img> to display it
  38338. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38339. * Check your browser for supported MIME types
  38340. */
  38341. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38342. /**
  38343. * Captures a screenshot of the current rendering
  38344. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38345. * @param engine defines the rendering engine
  38346. * @param camera defines the source camera
  38347. * @param size This parameter can be set to a single number or to an object with the
  38348. * following (optional) properties: precision, width, height. If a single number is passed,
  38349. * it will be used for both width and height. If an object is passed, the screenshot size
  38350. * will be derived from the parameters. The precision property is a multiplier allowing
  38351. * rendering at a higher or lower resolution
  38352. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38353. * Check your browser for supported MIME types
  38354. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38355. * to the src parameter of an <img> to display it
  38356. */
  38357. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38358. /**
  38359. * Generates an image screenshot from the specified camera.
  38360. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38361. * @param engine The engine to use for rendering
  38362. * @param camera The camera to use for rendering
  38363. * @param size This parameter can be set to a single number or to an object with the
  38364. * following (optional) properties: precision, width, height. If a single number is passed,
  38365. * it will be used for both width and height. If an object is passed, the screenshot size
  38366. * will be derived from the parameters. The precision property is a multiplier allowing
  38367. * rendering at a higher or lower resolution
  38368. * @param successCallback The callback receives a single parameter which contains the
  38369. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38370. * src parameter of an <img> to display it
  38371. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38372. * Check your browser for supported MIME types
  38373. * @param samples Texture samples (default: 1)
  38374. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38375. * @param fileName A name for for the downloaded file.
  38376. */
  38377. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38378. /**
  38379. * Generates an image screenshot from the specified camera.
  38380. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38381. * @param engine The engine to use for rendering
  38382. * @param camera The camera to use for rendering
  38383. * @param size This parameter can be set to a single number or to an object with the
  38384. * following (optional) properties: precision, width, height. If a single number is passed,
  38385. * it will be used for both width and height. If an object is passed, the screenshot size
  38386. * will be derived from the parameters. The precision property is a multiplier allowing
  38387. * rendering at a higher or lower resolution
  38388. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38389. * Check your browser for supported MIME types
  38390. * @param samples Texture samples (default: 1)
  38391. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38392. * @param fileName A name for for the downloaded file.
  38393. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38394. * to the src parameter of an <img> to display it
  38395. */
  38396. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38397. /**
  38398. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38399. * Be aware Math.random() could cause collisions, but:
  38400. * "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"
  38401. * @returns a pseudo random id
  38402. */
  38403. static RandomId(): string;
  38404. /**
  38405. * Test if the given uri is a base64 string
  38406. * @param uri The uri to test
  38407. * @return True if the uri is a base64 string or false otherwise
  38408. */
  38409. static IsBase64(uri: string): boolean;
  38410. /**
  38411. * Decode the given base64 uri.
  38412. * @param uri The uri to decode
  38413. * @return The decoded base64 data.
  38414. */
  38415. static DecodeBase64(uri: string): ArrayBuffer;
  38416. /**
  38417. * Gets the absolute url.
  38418. * @param url the input url
  38419. * @return the absolute url
  38420. */
  38421. static GetAbsoluteUrl(url: string): string;
  38422. /**
  38423. * No log
  38424. */
  38425. static readonly NoneLogLevel: number;
  38426. /**
  38427. * Only message logs
  38428. */
  38429. static readonly MessageLogLevel: number;
  38430. /**
  38431. * Only warning logs
  38432. */
  38433. static readonly WarningLogLevel: number;
  38434. /**
  38435. * Only error logs
  38436. */
  38437. static readonly ErrorLogLevel: number;
  38438. /**
  38439. * All logs
  38440. */
  38441. static readonly AllLogLevel: number;
  38442. /**
  38443. * Gets a value indicating the number of loading errors
  38444. * @ignorenaming
  38445. */
  38446. static get errorsCount(): number;
  38447. /**
  38448. * Callback called when a new log is added
  38449. */
  38450. static OnNewCacheEntry: (entry: string) => void;
  38451. /**
  38452. * Log a message to the console
  38453. * @param message defines the message to log
  38454. */
  38455. static Log(message: string): void;
  38456. /**
  38457. * Write a warning message to the console
  38458. * @param message defines the message to log
  38459. */
  38460. static Warn(message: string): void;
  38461. /**
  38462. * Write an error message to the console
  38463. * @param message defines the message to log
  38464. */
  38465. static Error(message: string): void;
  38466. /**
  38467. * Gets current log cache (list of logs)
  38468. */
  38469. static get LogCache(): string;
  38470. /**
  38471. * Clears the log cache
  38472. */
  38473. static ClearLogCache(): void;
  38474. /**
  38475. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38476. */
  38477. static set LogLevels(level: number);
  38478. /**
  38479. * Checks if the window object exists
  38480. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38481. */
  38482. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38483. /**
  38484. * No performance log
  38485. */
  38486. static readonly PerformanceNoneLogLevel: number;
  38487. /**
  38488. * Use user marks to log performance
  38489. */
  38490. static readonly PerformanceUserMarkLogLevel: number;
  38491. /**
  38492. * Log performance to the console
  38493. */
  38494. static readonly PerformanceConsoleLogLevel: number;
  38495. private static _performance;
  38496. /**
  38497. * Sets the current performance log level
  38498. */
  38499. static set PerformanceLogLevel(level: number);
  38500. private static _StartPerformanceCounterDisabled;
  38501. private static _EndPerformanceCounterDisabled;
  38502. private static _StartUserMark;
  38503. private static _EndUserMark;
  38504. private static _StartPerformanceConsole;
  38505. private static _EndPerformanceConsole;
  38506. /**
  38507. * Starts a performance counter
  38508. */
  38509. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38510. /**
  38511. * Ends a specific performance coutner
  38512. */
  38513. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38514. /**
  38515. * Gets either window.performance.now() if supported or Date.now() else
  38516. */
  38517. static get Now(): number;
  38518. /**
  38519. * This method will return the name of the class used to create the instance of the given object.
  38520. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38521. * @param object the object to get the class name from
  38522. * @param isType defines if the object is actually a type
  38523. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38524. */
  38525. static GetClassName(object: any, isType?: boolean): string;
  38526. /**
  38527. * Gets the first element of an array satisfying a given predicate
  38528. * @param array defines the array to browse
  38529. * @param predicate defines the predicate to use
  38530. * @returns null if not found or the element
  38531. */
  38532. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38533. /**
  38534. * This method will return the name of the full name of the class, including its owning module (if any).
  38535. * 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).
  38536. * @param object the object to get the class name from
  38537. * @param isType defines if the object is actually a type
  38538. * @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.
  38539. * @ignorenaming
  38540. */
  38541. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38542. /**
  38543. * Returns a promise that resolves after the given amount of time.
  38544. * @param delay Number of milliseconds to delay
  38545. * @returns Promise that resolves after the given amount of time
  38546. */
  38547. static DelayAsync(delay: number): Promise<void>;
  38548. /**
  38549. * Utility function to detect if the current user agent is Safari
  38550. * @returns whether or not the current user agent is safari
  38551. */
  38552. static IsSafari(): boolean;
  38553. }
  38554. /**
  38555. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38556. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38557. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38558. * @param name The name of the class, case should be preserved
  38559. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38560. */
  38561. export function className(name: string, module?: string): (target: Object) => void;
  38562. /**
  38563. * An implementation of a loop for asynchronous functions.
  38564. */
  38565. export class AsyncLoop {
  38566. /**
  38567. * Defines the number of iterations for the loop
  38568. */
  38569. iterations: number;
  38570. /**
  38571. * Defines the current index of the loop.
  38572. */
  38573. index: number;
  38574. private _done;
  38575. private _fn;
  38576. private _successCallback;
  38577. /**
  38578. * Constructor.
  38579. * @param iterations the number of iterations.
  38580. * @param func the function to run each iteration
  38581. * @param successCallback the callback that will be called upon succesful execution
  38582. * @param offset starting offset.
  38583. */
  38584. constructor(
  38585. /**
  38586. * Defines the number of iterations for the loop
  38587. */
  38588. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38589. /**
  38590. * Execute the next iteration. Must be called after the last iteration was finished.
  38591. */
  38592. executeNext(): void;
  38593. /**
  38594. * Break the loop and run the success callback.
  38595. */
  38596. breakLoop(): void;
  38597. /**
  38598. * Create and run an async loop.
  38599. * @param iterations the number of iterations.
  38600. * @param fn the function to run each iteration
  38601. * @param successCallback the callback that will be called upon succesful execution
  38602. * @param offset starting offset.
  38603. * @returns the created async loop object
  38604. */
  38605. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38606. /**
  38607. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38608. * @param iterations total number of iterations
  38609. * @param syncedIterations number of synchronous iterations in each async iteration.
  38610. * @param fn the function to call each iteration.
  38611. * @param callback a success call back that will be called when iterating stops.
  38612. * @param breakFunction a break condition (optional)
  38613. * @param timeout timeout settings for the setTimeout function. default - 0.
  38614. * @returns the created async loop object
  38615. */
  38616. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38617. }
  38618. }
  38619. declare module BABYLON {
  38620. /**
  38621. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38622. * The underlying implementation relies on an associative array to ensure the best performances.
  38623. * The value can be anything including 'null' but except 'undefined'
  38624. */
  38625. export class StringDictionary<T> {
  38626. /**
  38627. * This will clear this dictionary and copy the content from the 'source' one.
  38628. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38629. * @param source the dictionary to take the content from and copy to this dictionary
  38630. */
  38631. copyFrom(source: StringDictionary<T>): void;
  38632. /**
  38633. * Get a value based from its key
  38634. * @param key the given key to get the matching value from
  38635. * @return the value if found, otherwise undefined is returned
  38636. */
  38637. get(key: string): T | undefined;
  38638. /**
  38639. * Get a value from its key or add it if it doesn't exist.
  38640. * This method will ensure you that a given key/data will be present in the dictionary.
  38641. * @param key the given key to get the matching value from
  38642. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38643. * The factory will only be invoked if there's no data for the given key.
  38644. * @return the value corresponding to the key.
  38645. */
  38646. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38647. /**
  38648. * Get a value from its key if present in the dictionary otherwise add it
  38649. * @param key the key to get the value from
  38650. * @param val if there's no such key/value pair in the dictionary add it with this value
  38651. * @return the value corresponding to the key
  38652. */
  38653. getOrAdd(key: string, val: T): T;
  38654. /**
  38655. * Check if there's a given key in the dictionary
  38656. * @param key the key to check for
  38657. * @return true if the key is present, false otherwise
  38658. */
  38659. contains(key: string): boolean;
  38660. /**
  38661. * Add a new key and its corresponding value
  38662. * @param key the key to add
  38663. * @param value the value corresponding to the key
  38664. * @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
  38665. */
  38666. add(key: string, value: T): boolean;
  38667. /**
  38668. * Update a specific value associated to a key
  38669. * @param key defines the key to use
  38670. * @param value defines the value to store
  38671. * @returns true if the value was updated (or false if the key was not found)
  38672. */
  38673. set(key: string, value: T): boolean;
  38674. /**
  38675. * Get the element of the given key and remove it from the dictionary
  38676. * @param key defines the key to search
  38677. * @returns the value associated with the key or null if not found
  38678. */
  38679. getAndRemove(key: string): Nullable<T>;
  38680. /**
  38681. * Remove a key/value from the dictionary.
  38682. * @param key the key to remove
  38683. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38684. */
  38685. remove(key: string): boolean;
  38686. /**
  38687. * Clear the whole content of the dictionary
  38688. */
  38689. clear(): void;
  38690. /**
  38691. * Gets the current count
  38692. */
  38693. get count(): number;
  38694. /**
  38695. * Execute a callback on each key/val of the dictionary.
  38696. * Note that you can remove any element in this dictionary in the callback implementation
  38697. * @param callback the callback to execute on a given key/value pair
  38698. */
  38699. forEach(callback: (key: string, val: T) => void): void;
  38700. /**
  38701. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38702. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38703. * Note that you can remove any element in this dictionary in the callback implementation
  38704. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38705. * @returns the first item
  38706. */
  38707. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38708. private _count;
  38709. private _data;
  38710. }
  38711. }
  38712. declare module BABYLON {
  38713. /** @hidden */
  38714. export interface ICollisionCoordinator {
  38715. createCollider(): Collider;
  38716. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38717. init(scene: Scene): void;
  38718. }
  38719. /** @hidden */
  38720. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38721. private _scene;
  38722. private _scaledPosition;
  38723. private _scaledVelocity;
  38724. private _finalPosition;
  38725. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38726. createCollider(): Collider;
  38727. init(scene: Scene): void;
  38728. private _collideWithWorld;
  38729. }
  38730. }
  38731. declare module BABYLON {
  38732. /**
  38733. * Class used to manage all inputs for the scene.
  38734. */
  38735. export class InputManager {
  38736. /** The distance in pixel that you have to move to prevent some events */
  38737. static DragMovementThreshold: number;
  38738. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38739. static LongPressDelay: number;
  38740. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38741. static DoubleClickDelay: number;
  38742. /** If you need to check double click without raising a single click at first click, enable this flag */
  38743. static ExclusiveDoubleClickMode: boolean;
  38744. private _wheelEventName;
  38745. private _onPointerMove;
  38746. private _onPointerDown;
  38747. private _onPointerUp;
  38748. private _initClickEvent;
  38749. private _initActionManager;
  38750. private _delayedSimpleClick;
  38751. private _delayedSimpleClickTimeout;
  38752. private _previousDelayedSimpleClickTimeout;
  38753. private _meshPickProceed;
  38754. private _previousButtonPressed;
  38755. private _currentPickResult;
  38756. private _previousPickResult;
  38757. private _totalPointersPressed;
  38758. private _doubleClickOccured;
  38759. private _pointerOverMesh;
  38760. private _pickedDownMesh;
  38761. private _pickedUpMesh;
  38762. private _pointerX;
  38763. private _pointerY;
  38764. private _unTranslatedPointerX;
  38765. private _unTranslatedPointerY;
  38766. private _startingPointerPosition;
  38767. private _previousStartingPointerPosition;
  38768. private _startingPointerTime;
  38769. private _previousStartingPointerTime;
  38770. private _pointerCaptures;
  38771. private _onKeyDown;
  38772. private _onKeyUp;
  38773. private _onCanvasFocusObserver;
  38774. private _onCanvasBlurObserver;
  38775. private _scene;
  38776. /**
  38777. * Creates a new InputManager
  38778. * @param scene defines the hosting scene
  38779. */
  38780. constructor(scene: Scene);
  38781. /**
  38782. * Gets the mesh that is currently under the pointer
  38783. */
  38784. get meshUnderPointer(): Nullable<AbstractMesh>;
  38785. /**
  38786. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38787. */
  38788. get unTranslatedPointer(): Vector2;
  38789. /**
  38790. * Gets or sets the current on-screen X position of the pointer
  38791. */
  38792. get pointerX(): number;
  38793. set pointerX(value: number);
  38794. /**
  38795. * Gets or sets the current on-screen Y position of the pointer
  38796. */
  38797. get pointerY(): number;
  38798. set pointerY(value: number);
  38799. private _updatePointerPosition;
  38800. private _processPointerMove;
  38801. private _setRayOnPointerInfo;
  38802. private _checkPrePointerObservable;
  38803. /**
  38804. * Use this method to simulate a pointer move on a mesh
  38805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38808. */
  38809. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38810. /**
  38811. * Use this method to simulate a pointer down on a mesh
  38812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38815. */
  38816. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38817. private _processPointerDown;
  38818. /** @hidden */
  38819. _isPointerSwiping(): boolean;
  38820. /**
  38821. * Use this method to simulate a pointer up on a mesh
  38822. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38823. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38824. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38825. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38826. */
  38827. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38828. private _processPointerUp;
  38829. /**
  38830. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38831. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38832. * @returns true if the pointer was captured
  38833. */
  38834. isPointerCaptured(pointerId?: number): boolean;
  38835. /**
  38836. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38837. * @param attachUp defines if you want to attach events to pointerup
  38838. * @param attachDown defines if you want to attach events to pointerdown
  38839. * @param attachMove defines if you want to attach events to pointermove
  38840. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38841. */
  38842. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38843. /**
  38844. * Detaches all event handlers
  38845. */
  38846. detachControl(): void;
  38847. /**
  38848. * Force the value of meshUnderPointer
  38849. * @param mesh defines the mesh to use
  38850. */
  38851. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38852. /**
  38853. * Gets the mesh under the pointer
  38854. * @returns a Mesh or null if no mesh is under the pointer
  38855. */
  38856. getPointerOverMesh(): Nullable<AbstractMesh>;
  38857. }
  38858. }
  38859. declare module BABYLON {
  38860. /**
  38861. * This class defines the direct association between an animation and a target
  38862. */
  38863. export class TargetedAnimation {
  38864. /**
  38865. * Animation to perform
  38866. */
  38867. animation: Animation;
  38868. /**
  38869. * Target to animate
  38870. */
  38871. target: any;
  38872. /**
  38873. * Returns the string "TargetedAnimation"
  38874. * @returns "TargetedAnimation"
  38875. */
  38876. getClassName(): string;
  38877. /**
  38878. * Serialize the object
  38879. * @returns the JSON object representing the current entity
  38880. */
  38881. serialize(): any;
  38882. }
  38883. /**
  38884. * Use this class to create coordinated animations on multiple targets
  38885. */
  38886. export class AnimationGroup implements IDisposable {
  38887. /** The name of the animation group */
  38888. name: string;
  38889. private _scene;
  38890. private _targetedAnimations;
  38891. private _animatables;
  38892. private _from;
  38893. private _to;
  38894. private _isStarted;
  38895. private _isPaused;
  38896. private _speedRatio;
  38897. private _loopAnimation;
  38898. private _isAdditive;
  38899. /**
  38900. * Gets or sets the unique id of the node
  38901. */
  38902. uniqueId: number;
  38903. /**
  38904. * This observable will notify when one animation have ended
  38905. */
  38906. onAnimationEndObservable: Observable<TargetedAnimation>;
  38907. /**
  38908. * Observer raised when one animation loops
  38909. */
  38910. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38911. /**
  38912. * Observer raised when all animations have looped
  38913. */
  38914. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38915. /**
  38916. * This observable will notify when all animations have ended.
  38917. */
  38918. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38919. /**
  38920. * This observable will notify when all animations have paused.
  38921. */
  38922. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38923. /**
  38924. * This observable will notify when all animations are playing.
  38925. */
  38926. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38927. /**
  38928. * Gets the first frame
  38929. */
  38930. get from(): number;
  38931. /**
  38932. * Gets the last frame
  38933. */
  38934. get to(): number;
  38935. /**
  38936. * Define if the animations are started
  38937. */
  38938. get isStarted(): boolean;
  38939. /**
  38940. * Gets a value indicating that the current group is playing
  38941. */
  38942. get isPlaying(): boolean;
  38943. /**
  38944. * Gets or sets the speed ratio to use for all animations
  38945. */
  38946. get speedRatio(): number;
  38947. /**
  38948. * Gets or sets the speed ratio to use for all animations
  38949. */
  38950. set speedRatio(value: number);
  38951. /**
  38952. * Gets or sets if all animations should loop or not
  38953. */
  38954. get loopAnimation(): boolean;
  38955. set loopAnimation(value: boolean);
  38956. /**
  38957. * Gets or sets if all animations should be evaluated additively
  38958. */
  38959. get isAdditive(): boolean;
  38960. set isAdditive(value: boolean);
  38961. /**
  38962. * Gets the targeted animations for this animation group
  38963. */
  38964. get targetedAnimations(): Array<TargetedAnimation>;
  38965. /**
  38966. * returning the list of animatables controlled by this animation group.
  38967. */
  38968. get animatables(): Array<Animatable>;
  38969. /**
  38970. * Gets the list of target animations
  38971. */
  38972. get children(): TargetedAnimation[];
  38973. /**
  38974. * Instantiates a new Animation Group.
  38975. * This helps managing several animations at once.
  38976. * @see https://doc.babylonjs.com/how_to/group
  38977. * @param name Defines the name of the group
  38978. * @param scene Defines the scene the group belongs to
  38979. */
  38980. constructor(
  38981. /** The name of the animation group */
  38982. name: string, scene?: Nullable<Scene>);
  38983. /**
  38984. * Add an animation (with its target) in the group
  38985. * @param animation defines the animation we want to add
  38986. * @param target defines the target of the animation
  38987. * @returns the TargetedAnimation object
  38988. */
  38989. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38990. /**
  38991. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38992. * It can add constant keys at begin or end
  38993. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38994. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38995. * @returns the animation group
  38996. */
  38997. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38998. private _animationLoopCount;
  38999. private _animationLoopFlags;
  39000. private _processLoop;
  39001. /**
  39002. * Start all animations on given targets
  39003. * @param loop defines if animations must loop
  39004. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39005. * @param from defines the from key (optional)
  39006. * @param to defines the to key (optional)
  39007. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39008. * @returns the current animation group
  39009. */
  39010. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39011. /**
  39012. * Pause all animations
  39013. * @returns the animation group
  39014. */
  39015. pause(): AnimationGroup;
  39016. /**
  39017. * Play all animations to initial state
  39018. * This function will start() the animations if they were not started or will restart() them if they were paused
  39019. * @param loop defines if animations must loop
  39020. * @returns the animation group
  39021. */
  39022. play(loop?: boolean): AnimationGroup;
  39023. /**
  39024. * Reset all animations to initial state
  39025. * @returns the animation group
  39026. */
  39027. reset(): AnimationGroup;
  39028. /**
  39029. * Restart animations from key 0
  39030. * @returns the animation group
  39031. */
  39032. restart(): AnimationGroup;
  39033. /**
  39034. * Stop all animations
  39035. * @returns the animation group
  39036. */
  39037. stop(): AnimationGroup;
  39038. /**
  39039. * Set animation weight for all animatables
  39040. * @param weight defines the weight to use
  39041. * @return the animationGroup
  39042. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39043. */
  39044. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39045. /**
  39046. * Synchronize and normalize all animatables with a source animatable
  39047. * @param root defines the root animatable to synchronize with
  39048. * @return the animationGroup
  39049. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39050. */
  39051. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39052. /**
  39053. * Goes to a specific frame in this animation group
  39054. * @param frame the frame number to go to
  39055. * @return the animationGroup
  39056. */
  39057. goToFrame(frame: number): AnimationGroup;
  39058. /**
  39059. * Dispose all associated resources
  39060. */
  39061. dispose(): void;
  39062. private _checkAnimationGroupEnded;
  39063. /**
  39064. * Clone the current animation group and returns a copy
  39065. * @param newName defines the name of the new group
  39066. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39067. * @returns the new aniamtion group
  39068. */
  39069. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39070. /**
  39071. * Serializes the animationGroup to an object
  39072. * @returns Serialized object
  39073. */
  39074. serialize(): any;
  39075. /**
  39076. * Returns a new AnimationGroup object parsed from the source provided.
  39077. * @param parsedAnimationGroup defines the source
  39078. * @param scene defines the scene that will receive the animationGroup
  39079. * @returns a new AnimationGroup
  39080. */
  39081. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39082. /**
  39083. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39084. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39085. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39086. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39087. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39088. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39089. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39090. */
  39091. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39092. /**
  39093. * Returns the string "AnimationGroup"
  39094. * @returns "AnimationGroup"
  39095. */
  39096. getClassName(): string;
  39097. /**
  39098. * Creates a detailled string about the object
  39099. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39100. * @returns a string representing the object
  39101. */
  39102. toString(fullDetails?: boolean): string;
  39103. }
  39104. }
  39105. declare module BABYLON {
  39106. /**
  39107. * Define an interface for all classes that will hold resources
  39108. */
  39109. export interface IDisposable {
  39110. /**
  39111. * Releases all held resources
  39112. */
  39113. dispose(): void;
  39114. }
  39115. /** Interface defining initialization parameters for Scene class */
  39116. export interface SceneOptions {
  39117. /**
  39118. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39119. * It will improve performance when the number of geometries becomes important.
  39120. */
  39121. useGeometryUniqueIdsMap?: boolean;
  39122. /**
  39123. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39124. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39125. */
  39126. useMaterialMeshMap?: boolean;
  39127. /**
  39128. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39129. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39130. */
  39131. useClonedMeshMap?: boolean;
  39132. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39133. virtual?: boolean;
  39134. }
  39135. /**
  39136. * Represents a scene to be rendered by the engine.
  39137. * @see https://doc.babylonjs.com/features/scene
  39138. */
  39139. export class Scene extends AbstractScene implements IAnimatable {
  39140. /** The fog is deactivated */
  39141. static readonly FOGMODE_NONE: number;
  39142. /** The fog density is following an exponential function */
  39143. static readonly FOGMODE_EXP: number;
  39144. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39145. static readonly FOGMODE_EXP2: number;
  39146. /** The fog density is following a linear function. */
  39147. static readonly FOGMODE_LINEAR: number;
  39148. /**
  39149. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39151. */
  39152. static MinDeltaTime: number;
  39153. /**
  39154. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39156. */
  39157. static MaxDeltaTime: number;
  39158. /**
  39159. * Factory used to create the default material.
  39160. * @param name The name of the material to create
  39161. * @param scene The scene to create the material for
  39162. * @returns The default material
  39163. */
  39164. static DefaultMaterialFactory(scene: Scene): Material;
  39165. /**
  39166. * Factory used to create the a collision coordinator.
  39167. * @returns The collision coordinator
  39168. */
  39169. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39170. /** @hidden */
  39171. _inputManager: InputManager;
  39172. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39173. cameraToUseForPointers: Nullable<Camera>;
  39174. /** @hidden */
  39175. readonly _isScene: boolean;
  39176. /** @hidden */
  39177. _blockEntityCollection: boolean;
  39178. /**
  39179. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39180. */
  39181. autoClear: boolean;
  39182. /**
  39183. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39184. */
  39185. autoClearDepthAndStencil: boolean;
  39186. /**
  39187. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39188. */
  39189. clearColor: Color4;
  39190. /**
  39191. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39192. */
  39193. ambientColor: Color3;
  39194. /**
  39195. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39196. * It should only be one of the following (if not the default embedded one):
  39197. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39198. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39199. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39200. * The material properties need to be setup according to the type of texture in use.
  39201. */
  39202. environmentBRDFTexture: BaseTexture;
  39203. /** @hidden */
  39204. protected _environmentTexture: Nullable<BaseTexture>;
  39205. /**
  39206. * Texture used in all pbr material as the reflection texture.
  39207. * As in the majority of the scene they are the same (exception for multi room and so on),
  39208. * this is easier to reference from here than from all the materials.
  39209. */
  39210. get environmentTexture(): Nullable<BaseTexture>;
  39211. /**
  39212. * Texture used in all pbr material as the reflection texture.
  39213. * As in the majority of the scene they are the same (exception for multi room and so on),
  39214. * this is easier to set here than in all the materials.
  39215. */
  39216. set environmentTexture(value: Nullable<BaseTexture>);
  39217. /** @hidden */
  39218. protected _environmentIntensity: number;
  39219. /**
  39220. * Intensity of the environment in all pbr material.
  39221. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39222. * As in the majority of the scene they are the same (exception for multi room and so on),
  39223. * this is easier to reference from here than from all the materials.
  39224. */
  39225. get environmentIntensity(): number;
  39226. /**
  39227. * Intensity of the environment in all pbr material.
  39228. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39229. * As in the majority of the scene they are the same (exception for multi room and so on),
  39230. * this is easier to set here than in all the materials.
  39231. */
  39232. set environmentIntensity(value: number);
  39233. /** @hidden */
  39234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39235. /**
  39236. * Default image processing configuration used either in the rendering
  39237. * Forward main pass or through the imageProcessingPostProcess if present.
  39238. * As in the majority of the scene they are the same (exception for multi camera),
  39239. * this is easier to reference from here than from all the materials and post process.
  39240. *
  39241. * No setter as we it is a shared configuration, you can set the values instead.
  39242. */
  39243. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39244. private _forceWireframe;
  39245. /**
  39246. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39247. */
  39248. set forceWireframe(value: boolean);
  39249. get forceWireframe(): boolean;
  39250. private _skipFrustumClipping;
  39251. /**
  39252. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39253. */
  39254. set skipFrustumClipping(value: boolean);
  39255. get skipFrustumClipping(): boolean;
  39256. private _forcePointsCloud;
  39257. /**
  39258. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39259. */
  39260. set forcePointsCloud(value: boolean);
  39261. get forcePointsCloud(): boolean;
  39262. /**
  39263. * Gets or sets the active clipplane 1
  39264. */
  39265. clipPlane: Nullable<Plane>;
  39266. /**
  39267. * Gets or sets the active clipplane 2
  39268. */
  39269. clipPlane2: Nullable<Plane>;
  39270. /**
  39271. * Gets or sets the active clipplane 3
  39272. */
  39273. clipPlane3: Nullable<Plane>;
  39274. /**
  39275. * Gets or sets the active clipplane 4
  39276. */
  39277. clipPlane4: Nullable<Plane>;
  39278. /**
  39279. * Gets or sets the active clipplane 5
  39280. */
  39281. clipPlane5: Nullable<Plane>;
  39282. /**
  39283. * Gets or sets the active clipplane 6
  39284. */
  39285. clipPlane6: Nullable<Plane>;
  39286. /**
  39287. * Gets or sets a boolean indicating if animations are enabled
  39288. */
  39289. animationsEnabled: boolean;
  39290. private _animationPropertiesOverride;
  39291. /**
  39292. * Gets or sets the animation properties override
  39293. */
  39294. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39295. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39296. /**
  39297. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39298. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39299. */
  39300. useConstantAnimationDeltaTime: boolean;
  39301. /**
  39302. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39303. * Please note that it requires to run a ray cast through the scene on every frame
  39304. */
  39305. constantlyUpdateMeshUnderPointer: boolean;
  39306. /**
  39307. * Defines the HTML cursor to use when hovering over interactive elements
  39308. */
  39309. hoverCursor: string;
  39310. /**
  39311. * Defines the HTML default cursor to use (empty by default)
  39312. */
  39313. defaultCursor: string;
  39314. /**
  39315. * Defines whether cursors are handled by the scene.
  39316. */
  39317. doNotHandleCursors: boolean;
  39318. /**
  39319. * This is used to call preventDefault() on pointer down
  39320. * in order to block unwanted artifacts like system double clicks
  39321. */
  39322. preventDefaultOnPointerDown: boolean;
  39323. /**
  39324. * This is used to call preventDefault() on pointer up
  39325. * in order to block unwanted artifacts like system double clicks
  39326. */
  39327. preventDefaultOnPointerUp: boolean;
  39328. /**
  39329. * Gets or sets user defined metadata
  39330. */
  39331. metadata: any;
  39332. /**
  39333. * For internal use only. Please do not use.
  39334. */
  39335. reservedDataStore: any;
  39336. /**
  39337. * Gets the name of the plugin used to load this scene (null by default)
  39338. */
  39339. loadingPluginName: string;
  39340. /**
  39341. * Use this array to add regular expressions used to disable offline support for specific urls
  39342. */
  39343. disableOfflineSupportExceptionRules: RegExp[];
  39344. /**
  39345. * An event triggered when the scene is disposed.
  39346. */
  39347. onDisposeObservable: Observable<Scene>;
  39348. private _onDisposeObserver;
  39349. /** Sets a function to be executed when this scene is disposed. */
  39350. set onDispose(callback: () => void);
  39351. /**
  39352. * An event triggered before rendering the scene (right after animations and physics)
  39353. */
  39354. onBeforeRenderObservable: Observable<Scene>;
  39355. private _onBeforeRenderObserver;
  39356. /** Sets a function to be executed before rendering this scene */
  39357. set beforeRender(callback: Nullable<() => void>);
  39358. /**
  39359. * An event triggered after rendering the scene
  39360. */
  39361. onAfterRenderObservable: Observable<Scene>;
  39362. /**
  39363. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39364. */
  39365. onAfterRenderCameraObservable: Observable<Camera>;
  39366. private _onAfterRenderObserver;
  39367. /** Sets a function to be executed after rendering this scene */
  39368. set afterRender(callback: Nullable<() => void>);
  39369. /**
  39370. * An event triggered before animating the scene
  39371. */
  39372. onBeforeAnimationsObservable: Observable<Scene>;
  39373. /**
  39374. * An event triggered after animations processing
  39375. */
  39376. onAfterAnimationsObservable: Observable<Scene>;
  39377. /**
  39378. * An event triggered before draw calls are ready to be sent
  39379. */
  39380. onBeforeDrawPhaseObservable: Observable<Scene>;
  39381. /**
  39382. * An event triggered after draw calls have been sent
  39383. */
  39384. onAfterDrawPhaseObservable: Observable<Scene>;
  39385. /**
  39386. * An event triggered when the scene is ready
  39387. */
  39388. onReadyObservable: Observable<Scene>;
  39389. /**
  39390. * An event triggered before rendering a camera
  39391. */
  39392. onBeforeCameraRenderObservable: Observable<Camera>;
  39393. private _onBeforeCameraRenderObserver;
  39394. /** Sets a function to be executed before rendering a camera*/
  39395. set beforeCameraRender(callback: () => void);
  39396. /**
  39397. * An event triggered after rendering a camera
  39398. */
  39399. onAfterCameraRenderObservable: Observable<Camera>;
  39400. private _onAfterCameraRenderObserver;
  39401. /** Sets a function to be executed after rendering a camera*/
  39402. set afterCameraRender(callback: () => void);
  39403. /**
  39404. * An event triggered when active meshes evaluation is about to start
  39405. */
  39406. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39407. /**
  39408. * An event triggered when active meshes evaluation is done
  39409. */
  39410. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39411. /**
  39412. * An event triggered when particles rendering is about to start
  39413. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39414. */
  39415. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39416. /**
  39417. * An event triggered when particles rendering is done
  39418. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39419. */
  39420. onAfterParticlesRenderingObservable: Observable<Scene>;
  39421. /**
  39422. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39423. */
  39424. onDataLoadedObservable: Observable<Scene>;
  39425. /**
  39426. * An event triggered when a camera is created
  39427. */
  39428. onNewCameraAddedObservable: Observable<Camera>;
  39429. /**
  39430. * An event triggered when a camera is removed
  39431. */
  39432. onCameraRemovedObservable: Observable<Camera>;
  39433. /**
  39434. * An event triggered when a light is created
  39435. */
  39436. onNewLightAddedObservable: Observable<Light>;
  39437. /**
  39438. * An event triggered when a light is removed
  39439. */
  39440. onLightRemovedObservable: Observable<Light>;
  39441. /**
  39442. * An event triggered when a geometry is created
  39443. */
  39444. onNewGeometryAddedObservable: Observable<Geometry>;
  39445. /**
  39446. * An event triggered when a geometry is removed
  39447. */
  39448. onGeometryRemovedObservable: Observable<Geometry>;
  39449. /**
  39450. * An event triggered when a transform node is created
  39451. */
  39452. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39453. /**
  39454. * An event triggered when a transform node is removed
  39455. */
  39456. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39457. /**
  39458. * An event triggered when a mesh is created
  39459. */
  39460. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39461. /**
  39462. * An event triggered when a mesh is removed
  39463. */
  39464. onMeshRemovedObservable: Observable<AbstractMesh>;
  39465. /**
  39466. * An event triggered when a skeleton is created
  39467. */
  39468. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39469. /**
  39470. * An event triggered when a skeleton is removed
  39471. */
  39472. onSkeletonRemovedObservable: Observable<Skeleton>;
  39473. /**
  39474. * An event triggered when a material is created
  39475. */
  39476. onNewMaterialAddedObservable: Observable<Material>;
  39477. /**
  39478. * An event triggered when a material is removed
  39479. */
  39480. onMaterialRemovedObservable: Observable<Material>;
  39481. /**
  39482. * An event triggered when a texture is created
  39483. */
  39484. onNewTextureAddedObservable: Observable<BaseTexture>;
  39485. /**
  39486. * An event triggered when a texture is removed
  39487. */
  39488. onTextureRemovedObservable: Observable<BaseTexture>;
  39489. /**
  39490. * An event triggered when render targets are about to be rendered
  39491. * Can happen multiple times per frame.
  39492. */
  39493. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39494. /**
  39495. * An event triggered when render targets were rendered.
  39496. * Can happen multiple times per frame.
  39497. */
  39498. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39499. /**
  39500. * An event triggered before calculating deterministic simulation step
  39501. */
  39502. onBeforeStepObservable: Observable<Scene>;
  39503. /**
  39504. * An event triggered after calculating deterministic simulation step
  39505. */
  39506. onAfterStepObservable: Observable<Scene>;
  39507. /**
  39508. * An event triggered when the activeCamera property is updated
  39509. */
  39510. onActiveCameraChanged: Observable<Scene>;
  39511. /**
  39512. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39513. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39514. * 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)
  39515. */
  39516. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39517. /**
  39518. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39519. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39520. * 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)
  39521. */
  39522. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39523. /**
  39524. * This Observable will when a mesh has been imported into the scene.
  39525. */
  39526. onMeshImportedObservable: Observable<AbstractMesh>;
  39527. /**
  39528. * This Observable will when an animation file has been imported into the scene.
  39529. */
  39530. onAnimationFileImportedObservable: Observable<Scene>;
  39531. /**
  39532. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39533. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39534. */
  39535. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39536. /** @hidden */
  39537. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39538. /**
  39539. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39540. */
  39541. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39542. /**
  39543. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39544. */
  39545. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39546. /**
  39547. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39548. */
  39549. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39550. /** Callback called when a pointer move is detected */
  39551. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39552. /** Callback called when a pointer down is detected */
  39553. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39554. /** Callback called when a pointer up is detected */
  39555. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39556. /** Callback called when a pointer pick is detected */
  39557. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39558. /**
  39559. * 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).
  39560. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39561. */
  39562. onPrePointerObservable: Observable<PointerInfoPre>;
  39563. /**
  39564. * Observable event triggered each time an input event is received from the rendering canvas
  39565. */
  39566. onPointerObservable: Observable<PointerInfo>;
  39567. /**
  39568. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39569. */
  39570. get unTranslatedPointer(): Vector2;
  39571. /**
  39572. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39573. */
  39574. static get DragMovementThreshold(): number;
  39575. static set DragMovementThreshold(value: number);
  39576. /**
  39577. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39578. */
  39579. static get LongPressDelay(): number;
  39580. static set LongPressDelay(value: number);
  39581. /**
  39582. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39583. */
  39584. static get DoubleClickDelay(): number;
  39585. static set DoubleClickDelay(value: number);
  39586. /** If you need to check double click without raising a single click at first click, enable this flag */
  39587. static get ExclusiveDoubleClickMode(): boolean;
  39588. static set ExclusiveDoubleClickMode(value: boolean);
  39589. /** @hidden */
  39590. _mirroredCameraPosition: Nullable<Vector3>;
  39591. /**
  39592. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39593. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39594. */
  39595. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39596. /**
  39597. * Observable event triggered each time an keyboard event is received from the hosting window
  39598. */
  39599. onKeyboardObservable: Observable<KeyboardInfo>;
  39600. private _useRightHandedSystem;
  39601. /**
  39602. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39603. */
  39604. set useRightHandedSystem(value: boolean);
  39605. get useRightHandedSystem(): boolean;
  39606. private _timeAccumulator;
  39607. private _currentStepId;
  39608. private _currentInternalStep;
  39609. /**
  39610. * Sets the step Id used by deterministic lock step
  39611. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39612. * @param newStepId defines the step Id
  39613. */
  39614. setStepId(newStepId: number): void;
  39615. /**
  39616. * Gets the step Id used by deterministic lock step
  39617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39618. * @returns the step Id
  39619. */
  39620. getStepId(): number;
  39621. /**
  39622. * Gets the internal step used by deterministic lock step
  39623. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39624. * @returns the internal step
  39625. */
  39626. getInternalStep(): number;
  39627. private _fogEnabled;
  39628. /**
  39629. * Gets or sets a boolean indicating if fog is enabled on this scene
  39630. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39631. * (Default is true)
  39632. */
  39633. set fogEnabled(value: boolean);
  39634. get fogEnabled(): boolean;
  39635. private _fogMode;
  39636. /**
  39637. * Gets or sets the fog mode to use
  39638. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39639. * | mode | value |
  39640. * | --- | --- |
  39641. * | FOGMODE_NONE | 0 |
  39642. * | FOGMODE_EXP | 1 |
  39643. * | FOGMODE_EXP2 | 2 |
  39644. * | FOGMODE_LINEAR | 3 |
  39645. */
  39646. set fogMode(value: number);
  39647. get fogMode(): number;
  39648. /**
  39649. * Gets or sets the fog color to use
  39650. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39651. * (Default is Color3(0.2, 0.2, 0.3))
  39652. */
  39653. fogColor: Color3;
  39654. /**
  39655. * Gets or sets the fog density to use
  39656. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39657. * (Default is 0.1)
  39658. */
  39659. fogDensity: number;
  39660. /**
  39661. * Gets or sets the fog start distance to use
  39662. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39663. * (Default is 0)
  39664. */
  39665. fogStart: number;
  39666. /**
  39667. * Gets or sets the fog end distance to use
  39668. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39669. * (Default is 1000)
  39670. */
  39671. fogEnd: number;
  39672. /**
  39673. * Flag indicating that the frame buffer binding is handled by another component
  39674. */
  39675. prePass: boolean;
  39676. private _shadowsEnabled;
  39677. /**
  39678. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39679. */
  39680. set shadowsEnabled(value: boolean);
  39681. get shadowsEnabled(): boolean;
  39682. private _lightsEnabled;
  39683. /**
  39684. * Gets or sets a boolean indicating if lights are enabled on this scene
  39685. */
  39686. set lightsEnabled(value: boolean);
  39687. get lightsEnabled(): boolean;
  39688. /** All of the active cameras added to this scene. */
  39689. activeCameras: Camera[];
  39690. /** @hidden */
  39691. _activeCamera: Nullable<Camera>;
  39692. /** Gets or sets the current active camera */
  39693. get activeCamera(): Nullable<Camera>;
  39694. set activeCamera(value: Nullable<Camera>);
  39695. private _defaultMaterial;
  39696. /** The default material used on meshes when no material is affected */
  39697. get defaultMaterial(): Material;
  39698. /** The default material used on meshes when no material is affected */
  39699. set defaultMaterial(value: Material);
  39700. private _texturesEnabled;
  39701. /**
  39702. * Gets or sets a boolean indicating if textures are enabled on this scene
  39703. */
  39704. set texturesEnabled(value: boolean);
  39705. get texturesEnabled(): boolean;
  39706. /**
  39707. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39708. */
  39709. physicsEnabled: boolean;
  39710. /**
  39711. * Gets or sets a boolean indicating if particles are enabled on this scene
  39712. */
  39713. particlesEnabled: boolean;
  39714. /**
  39715. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39716. */
  39717. spritesEnabled: boolean;
  39718. private _skeletonsEnabled;
  39719. /**
  39720. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39721. */
  39722. set skeletonsEnabled(value: boolean);
  39723. get skeletonsEnabled(): boolean;
  39724. /**
  39725. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39726. */
  39727. lensFlaresEnabled: boolean;
  39728. /**
  39729. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39730. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39731. */
  39732. collisionsEnabled: boolean;
  39733. private _collisionCoordinator;
  39734. /** @hidden */
  39735. get collisionCoordinator(): ICollisionCoordinator;
  39736. /**
  39737. * Defines the gravity applied to this scene (used only for collisions)
  39738. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39739. */
  39740. gravity: Vector3;
  39741. /**
  39742. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39743. */
  39744. postProcessesEnabled: boolean;
  39745. /**
  39746. * The list of postprocesses added to the scene
  39747. */
  39748. postProcesses: PostProcess[];
  39749. /**
  39750. * Gets the current postprocess manager
  39751. */
  39752. postProcessManager: PostProcessManager;
  39753. /**
  39754. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39755. */
  39756. renderTargetsEnabled: boolean;
  39757. /**
  39758. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39759. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39760. */
  39761. dumpNextRenderTargets: boolean;
  39762. /**
  39763. * The list of user defined render targets added to the scene
  39764. */
  39765. customRenderTargets: RenderTargetTexture[];
  39766. /**
  39767. * Defines if texture loading must be delayed
  39768. * If true, textures will only be loaded when they need to be rendered
  39769. */
  39770. useDelayedTextureLoading: boolean;
  39771. /**
  39772. * Gets the list of meshes imported to the scene through SceneLoader
  39773. */
  39774. importedMeshesFiles: String[];
  39775. /**
  39776. * Gets or sets a boolean indicating if probes are enabled on this scene
  39777. */
  39778. probesEnabled: boolean;
  39779. /**
  39780. * Gets or sets the current offline provider to use to store scene data
  39781. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39782. */
  39783. offlineProvider: IOfflineProvider;
  39784. /**
  39785. * Gets or sets the action manager associated with the scene
  39786. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39787. */
  39788. actionManager: AbstractActionManager;
  39789. private _meshesForIntersections;
  39790. /**
  39791. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39792. */
  39793. proceduralTexturesEnabled: boolean;
  39794. private _engine;
  39795. private _totalVertices;
  39796. /** @hidden */
  39797. _activeIndices: PerfCounter;
  39798. /** @hidden */
  39799. _activeParticles: PerfCounter;
  39800. /** @hidden */
  39801. _activeBones: PerfCounter;
  39802. private _animationRatio;
  39803. /** @hidden */
  39804. _animationTimeLast: number;
  39805. /** @hidden */
  39806. _animationTime: number;
  39807. /**
  39808. * Gets or sets a general scale for animation speed
  39809. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39810. */
  39811. animationTimeScale: number;
  39812. /** @hidden */
  39813. _cachedMaterial: Nullable<Material>;
  39814. /** @hidden */
  39815. _cachedEffect: Nullable<Effect>;
  39816. /** @hidden */
  39817. _cachedVisibility: Nullable<number>;
  39818. private _renderId;
  39819. private _frameId;
  39820. private _executeWhenReadyTimeoutId;
  39821. private _intermediateRendering;
  39822. private _viewUpdateFlag;
  39823. private _projectionUpdateFlag;
  39824. /** @hidden */
  39825. _toBeDisposed: Nullable<IDisposable>[];
  39826. private _activeRequests;
  39827. /** @hidden */
  39828. _pendingData: any[];
  39829. private _isDisposed;
  39830. /**
  39831. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39832. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39833. */
  39834. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39835. private _activeMeshes;
  39836. private _processedMaterials;
  39837. private _renderTargets;
  39838. /** @hidden */
  39839. _activeParticleSystems: SmartArray<IParticleSystem>;
  39840. private _activeSkeletons;
  39841. private _softwareSkinnedMeshes;
  39842. private _renderingManager;
  39843. /** @hidden */
  39844. _activeAnimatables: Animatable[];
  39845. private _transformMatrix;
  39846. private _sceneUbo;
  39847. /** @hidden */
  39848. _viewMatrix: Matrix;
  39849. private _projectionMatrix;
  39850. /** @hidden */
  39851. _forcedViewPosition: Nullable<Vector3>;
  39852. /** @hidden */
  39853. _frustumPlanes: Plane[];
  39854. /**
  39855. * Gets the list of frustum planes (built from the active camera)
  39856. */
  39857. get frustumPlanes(): Plane[];
  39858. /**
  39859. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39860. * This is useful if there are more lights that the maximum simulteanous authorized
  39861. */
  39862. requireLightSorting: boolean;
  39863. /** @hidden */
  39864. readonly useMaterialMeshMap: boolean;
  39865. /** @hidden */
  39866. readonly useClonedMeshMap: boolean;
  39867. private _externalData;
  39868. private _uid;
  39869. /**
  39870. * @hidden
  39871. * Backing store of defined scene components.
  39872. */
  39873. _components: ISceneComponent[];
  39874. /**
  39875. * @hidden
  39876. * Backing store of defined scene components.
  39877. */
  39878. _serializableComponents: ISceneSerializableComponent[];
  39879. /**
  39880. * List of components to register on the next registration step.
  39881. */
  39882. private _transientComponents;
  39883. /**
  39884. * Registers the transient components if needed.
  39885. */
  39886. private _registerTransientComponents;
  39887. /**
  39888. * @hidden
  39889. * Add a component to the scene.
  39890. * Note that the ccomponent could be registered on th next frame if this is called after
  39891. * the register component stage.
  39892. * @param component Defines the component to add to the scene
  39893. */
  39894. _addComponent(component: ISceneComponent): void;
  39895. /**
  39896. * @hidden
  39897. * Gets a component from the scene.
  39898. * @param name defines the name of the component to retrieve
  39899. * @returns the component or null if not present
  39900. */
  39901. _getComponent(name: string): Nullable<ISceneComponent>;
  39902. /**
  39903. * @hidden
  39904. * Defines the actions happening before camera updates.
  39905. */
  39906. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39907. /**
  39908. * @hidden
  39909. * Defines the actions happening before clear the canvas.
  39910. */
  39911. _beforeClearStage: Stage<SimpleStageAction>;
  39912. /**
  39913. * @hidden
  39914. * Defines the actions when collecting render targets for the frame.
  39915. */
  39916. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39917. /**
  39918. * @hidden
  39919. * Defines the actions happening for one camera in the frame.
  39920. */
  39921. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39922. /**
  39923. * @hidden
  39924. * Defines the actions happening during the per mesh ready checks.
  39925. */
  39926. _isReadyForMeshStage: Stage<MeshStageAction>;
  39927. /**
  39928. * @hidden
  39929. * Defines the actions happening before evaluate active mesh checks.
  39930. */
  39931. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39932. /**
  39933. * @hidden
  39934. * Defines the actions happening during the evaluate sub mesh checks.
  39935. */
  39936. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39937. /**
  39938. * @hidden
  39939. * Defines the actions happening during the active mesh stage.
  39940. */
  39941. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39942. /**
  39943. * @hidden
  39944. * Defines the actions happening during the per camera render target step.
  39945. */
  39946. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39947. /**
  39948. * @hidden
  39949. * Defines the actions happening just before the active camera is drawing.
  39950. */
  39951. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39952. /**
  39953. * @hidden
  39954. * Defines the actions happening just before a render target is drawing.
  39955. */
  39956. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39957. /**
  39958. * @hidden
  39959. * Defines the actions happening just before a rendering group is drawing.
  39960. */
  39961. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39962. /**
  39963. * @hidden
  39964. * Defines the actions happening just before a mesh is drawing.
  39965. */
  39966. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39967. /**
  39968. * @hidden
  39969. * Defines the actions happening just after a mesh has been drawn.
  39970. */
  39971. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39972. /**
  39973. * @hidden
  39974. * Defines the actions happening just after a rendering group has been drawn.
  39975. */
  39976. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39977. /**
  39978. * @hidden
  39979. * Defines the actions happening just after the active camera has been drawn.
  39980. */
  39981. _afterCameraDrawStage: Stage<CameraStageAction>;
  39982. /**
  39983. * @hidden
  39984. * Defines the actions happening just after a render target has been drawn.
  39985. */
  39986. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39987. /**
  39988. * @hidden
  39989. * Defines the actions happening just after rendering all cameras and computing intersections.
  39990. */
  39991. _afterRenderStage: Stage<SimpleStageAction>;
  39992. /**
  39993. * @hidden
  39994. * Defines the actions happening when a pointer move event happens.
  39995. */
  39996. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39997. /**
  39998. * @hidden
  39999. * Defines the actions happening when a pointer down event happens.
  40000. */
  40001. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40002. /**
  40003. * @hidden
  40004. * Defines the actions happening when a pointer up event happens.
  40005. */
  40006. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40007. /**
  40008. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40009. */
  40010. private geometriesByUniqueId;
  40011. /**
  40012. * Creates a new Scene
  40013. * @param engine defines the engine to use to render this scene
  40014. * @param options defines the scene options
  40015. */
  40016. constructor(engine: Engine, options?: SceneOptions);
  40017. /**
  40018. * Gets a string idenfifying the name of the class
  40019. * @returns "Scene" string
  40020. */
  40021. getClassName(): string;
  40022. private _defaultMeshCandidates;
  40023. /**
  40024. * @hidden
  40025. */
  40026. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40027. private _defaultSubMeshCandidates;
  40028. /**
  40029. * @hidden
  40030. */
  40031. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40032. /**
  40033. * Sets the default candidate providers for the scene.
  40034. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40035. * and getCollidingSubMeshCandidates to their default function
  40036. */
  40037. setDefaultCandidateProviders(): void;
  40038. /**
  40039. * Gets the mesh that is currently under the pointer
  40040. */
  40041. get meshUnderPointer(): Nullable<AbstractMesh>;
  40042. /**
  40043. * Gets or sets the current on-screen X position of the pointer
  40044. */
  40045. get pointerX(): number;
  40046. set pointerX(value: number);
  40047. /**
  40048. * Gets or sets the current on-screen Y position of the pointer
  40049. */
  40050. get pointerY(): number;
  40051. set pointerY(value: number);
  40052. /**
  40053. * Gets the cached material (ie. the latest rendered one)
  40054. * @returns the cached material
  40055. */
  40056. getCachedMaterial(): Nullable<Material>;
  40057. /**
  40058. * Gets the cached effect (ie. the latest rendered one)
  40059. * @returns the cached effect
  40060. */
  40061. getCachedEffect(): Nullable<Effect>;
  40062. /**
  40063. * Gets the cached visibility state (ie. the latest rendered one)
  40064. * @returns the cached visibility state
  40065. */
  40066. getCachedVisibility(): Nullable<number>;
  40067. /**
  40068. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40069. * @param material defines the current material
  40070. * @param effect defines the current effect
  40071. * @param visibility defines the current visibility state
  40072. * @returns true if one parameter is not cached
  40073. */
  40074. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40075. /**
  40076. * Gets the engine associated with the scene
  40077. * @returns an Engine
  40078. */
  40079. getEngine(): Engine;
  40080. /**
  40081. * Gets the total number of vertices rendered per frame
  40082. * @returns the total number of vertices rendered per frame
  40083. */
  40084. getTotalVertices(): number;
  40085. /**
  40086. * Gets the performance counter for total vertices
  40087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40088. */
  40089. get totalVerticesPerfCounter(): PerfCounter;
  40090. /**
  40091. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40092. * @returns the total number of active indices rendered per frame
  40093. */
  40094. getActiveIndices(): number;
  40095. /**
  40096. * Gets the performance counter for active indices
  40097. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40098. */
  40099. get totalActiveIndicesPerfCounter(): PerfCounter;
  40100. /**
  40101. * Gets the total number of active particles rendered per frame
  40102. * @returns the total number of active particles rendered per frame
  40103. */
  40104. getActiveParticles(): number;
  40105. /**
  40106. * Gets the performance counter for active particles
  40107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40108. */
  40109. get activeParticlesPerfCounter(): PerfCounter;
  40110. /**
  40111. * Gets the total number of active bones rendered per frame
  40112. * @returns the total number of active bones rendered per frame
  40113. */
  40114. getActiveBones(): number;
  40115. /**
  40116. * Gets the performance counter for active bones
  40117. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40118. */
  40119. get activeBonesPerfCounter(): PerfCounter;
  40120. /**
  40121. * Gets the array of active meshes
  40122. * @returns an array of AbstractMesh
  40123. */
  40124. getActiveMeshes(): SmartArray<AbstractMesh>;
  40125. /**
  40126. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40127. * @returns a number
  40128. */
  40129. getAnimationRatio(): number;
  40130. /**
  40131. * Gets an unique Id for the current render phase
  40132. * @returns a number
  40133. */
  40134. getRenderId(): number;
  40135. /**
  40136. * Gets an unique Id for the current frame
  40137. * @returns a number
  40138. */
  40139. getFrameId(): number;
  40140. /** Call this function if you want to manually increment the render Id*/
  40141. incrementRenderId(): void;
  40142. private _createUbo;
  40143. /**
  40144. * Use this method to simulate a pointer move on a mesh
  40145. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40146. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40147. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40148. * @returns the current scene
  40149. */
  40150. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40151. /**
  40152. * Use this method to simulate a pointer down on a mesh
  40153. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40154. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40155. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40156. * @returns the current scene
  40157. */
  40158. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40159. /**
  40160. * Use this method to simulate a pointer up on a mesh
  40161. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40162. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40163. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40164. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40165. * @returns the current scene
  40166. */
  40167. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40168. /**
  40169. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40170. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40171. * @returns true if the pointer was captured
  40172. */
  40173. isPointerCaptured(pointerId?: number): boolean;
  40174. /**
  40175. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40176. * @param attachUp defines if you want to attach events to pointerup
  40177. * @param attachDown defines if you want to attach events to pointerdown
  40178. * @param attachMove defines if you want to attach events to pointermove
  40179. */
  40180. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40181. /** Detaches all event handlers*/
  40182. detachControl(): void;
  40183. /**
  40184. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40185. * Delay loaded resources are not taking in account
  40186. * @return true if all required resources are ready
  40187. */
  40188. isReady(): boolean;
  40189. /** Resets all cached information relative to material (including effect and visibility) */
  40190. resetCachedMaterial(): void;
  40191. /**
  40192. * Registers a function to be called before every frame render
  40193. * @param func defines the function to register
  40194. */
  40195. registerBeforeRender(func: () => void): void;
  40196. /**
  40197. * Unregisters a function called before every frame render
  40198. * @param func defines the function to unregister
  40199. */
  40200. unregisterBeforeRender(func: () => void): void;
  40201. /**
  40202. * Registers a function to be called after every frame render
  40203. * @param func defines the function to register
  40204. */
  40205. registerAfterRender(func: () => void): void;
  40206. /**
  40207. * Unregisters a function called after every frame render
  40208. * @param func defines the function to unregister
  40209. */
  40210. unregisterAfterRender(func: () => void): void;
  40211. private _executeOnceBeforeRender;
  40212. /**
  40213. * The provided function will run before render once and will be disposed afterwards.
  40214. * A timeout delay can be provided so that the function will be executed in N ms.
  40215. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40216. * @param func The function to be executed.
  40217. * @param timeout optional delay in ms
  40218. */
  40219. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40220. /** @hidden */
  40221. _addPendingData(data: any): void;
  40222. /** @hidden */
  40223. _removePendingData(data: any): void;
  40224. /**
  40225. * Returns the number of items waiting to be loaded
  40226. * @returns the number of items waiting to be loaded
  40227. */
  40228. getWaitingItemsCount(): number;
  40229. /**
  40230. * Returns a boolean indicating if the scene is still loading data
  40231. */
  40232. get isLoading(): boolean;
  40233. /**
  40234. * Registers a function to be executed when the scene is ready
  40235. * @param {Function} func - the function to be executed
  40236. */
  40237. executeWhenReady(func: () => void): void;
  40238. /**
  40239. * Returns a promise that resolves when the scene is ready
  40240. * @returns A promise that resolves when the scene is ready
  40241. */
  40242. whenReadyAsync(): Promise<void>;
  40243. /** @hidden */
  40244. _checkIsReady(): void;
  40245. /**
  40246. * Gets all animatable attached to the scene
  40247. */
  40248. get animatables(): Animatable[];
  40249. /**
  40250. * Resets the last animation time frame.
  40251. * Useful to override when animations start running when loading a scene for the first time.
  40252. */
  40253. resetLastAnimationTimeFrame(): void;
  40254. /**
  40255. * Gets the current view matrix
  40256. * @returns a Matrix
  40257. */
  40258. getViewMatrix(): Matrix;
  40259. /**
  40260. * Gets the current projection matrix
  40261. * @returns a Matrix
  40262. */
  40263. getProjectionMatrix(): Matrix;
  40264. /**
  40265. * Gets the current transform matrix
  40266. * @returns a Matrix made of View * Projection
  40267. */
  40268. getTransformMatrix(): Matrix;
  40269. /**
  40270. * Sets the current transform matrix
  40271. * @param viewL defines the View matrix to use
  40272. * @param projectionL defines the Projection matrix to use
  40273. * @param viewR defines the right View matrix to use (if provided)
  40274. * @param projectionR defines the right Projection matrix to use (if provided)
  40275. */
  40276. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40277. /**
  40278. * Gets the uniform buffer used to store scene data
  40279. * @returns a UniformBuffer
  40280. */
  40281. getSceneUniformBuffer(): UniformBuffer;
  40282. /**
  40283. * Gets an unique (relatively to the current scene) Id
  40284. * @returns an unique number for the scene
  40285. */
  40286. getUniqueId(): number;
  40287. /**
  40288. * Add a mesh to the list of scene's meshes
  40289. * @param newMesh defines the mesh to add
  40290. * @param recursive if all child meshes should also be added to the scene
  40291. */
  40292. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40293. /**
  40294. * Remove a mesh for the list of scene's meshes
  40295. * @param toRemove defines the mesh to remove
  40296. * @param recursive if all child meshes should also be removed from the scene
  40297. * @returns the index where the mesh was in the mesh list
  40298. */
  40299. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40300. /**
  40301. * Add a transform node to the list of scene's transform nodes
  40302. * @param newTransformNode defines the transform node to add
  40303. */
  40304. addTransformNode(newTransformNode: TransformNode): void;
  40305. /**
  40306. * Remove a transform node for the list of scene's transform nodes
  40307. * @param toRemove defines the transform node to remove
  40308. * @returns the index where the transform node was in the transform node list
  40309. */
  40310. removeTransformNode(toRemove: TransformNode): number;
  40311. /**
  40312. * Remove a skeleton for the list of scene's skeletons
  40313. * @param toRemove defines the skeleton to remove
  40314. * @returns the index where the skeleton was in the skeleton list
  40315. */
  40316. removeSkeleton(toRemove: Skeleton): number;
  40317. /**
  40318. * Remove a morph target for the list of scene's morph targets
  40319. * @param toRemove defines the morph target to remove
  40320. * @returns the index where the morph target was in the morph target list
  40321. */
  40322. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40323. /**
  40324. * Remove a light for the list of scene's lights
  40325. * @param toRemove defines the light to remove
  40326. * @returns the index where the light was in the light list
  40327. */
  40328. removeLight(toRemove: Light): number;
  40329. /**
  40330. * Remove a camera for the list of scene's cameras
  40331. * @param toRemove defines the camera to remove
  40332. * @returns the index where the camera was in the camera list
  40333. */
  40334. removeCamera(toRemove: Camera): number;
  40335. /**
  40336. * Remove a particle system for the list of scene's particle systems
  40337. * @param toRemove defines the particle system to remove
  40338. * @returns the index where the particle system was in the particle system list
  40339. */
  40340. removeParticleSystem(toRemove: IParticleSystem): number;
  40341. /**
  40342. * Remove a animation for the list of scene's animations
  40343. * @param toRemove defines the animation to remove
  40344. * @returns the index where the animation was in the animation list
  40345. */
  40346. removeAnimation(toRemove: Animation): number;
  40347. /**
  40348. * Will stop the animation of the given target
  40349. * @param target - the target
  40350. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40351. * @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)
  40352. */
  40353. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40354. /**
  40355. * Removes the given animation group from this scene.
  40356. * @param toRemove The animation group to remove
  40357. * @returns The index of the removed animation group
  40358. */
  40359. removeAnimationGroup(toRemove: AnimationGroup): number;
  40360. /**
  40361. * Removes the given multi-material from this scene.
  40362. * @param toRemove The multi-material to remove
  40363. * @returns The index of the removed multi-material
  40364. */
  40365. removeMultiMaterial(toRemove: MultiMaterial): number;
  40366. /**
  40367. * Removes the given material from this scene.
  40368. * @param toRemove The material to remove
  40369. * @returns The index of the removed material
  40370. */
  40371. removeMaterial(toRemove: Material): number;
  40372. /**
  40373. * Removes the given action manager from this scene.
  40374. * @param toRemove The action manager to remove
  40375. * @returns The index of the removed action manager
  40376. */
  40377. removeActionManager(toRemove: AbstractActionManager): number;
  40378. /**
  40379. * Removes the given texture from this scene.
  40380. * @param toRemove The texture to remove
  40381. * @returns The index of the removed texture
  40382. */
  40383. removeTexture(toRemove: BaseTexture): number;
  40384. /**
  40385. * Adds the given light to this scene
  40386. * @param newLight The light to add
  40387. */
  40388. addLight(newLight: Light): void;
  40389. /**
  40390. * Sorts the list list based on light priorities
  40391. */
  40392. sortLightsByPriority(): void;
  40393. /**
  40394. * Adds the given camera to this scene
  40395. * @param newCamera The camera to add
  40396. */
  40397. addCamera(newCamera: Camera): void;
  40398. /**
  40399. * Adds the given skeleton to this scene
  40400. * @param newSkeleton The skeleton to add
  40401. */
  40402. addSkeleton(newSkeleton: Skeleton): void;
  40403. /**
  40404. * Adds the given particle system to this scene
  40405. * @param newParticleSystem The particle system to add
  40406. */
  40407. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40408. /**
  40409. * Adds the given animation to this scene
  40410. * @param newAnimation The animation to add
  40411. */
  40412. addAnimation(newAnimation: Animation): void;
  40413. /**
  40414. * Adds the given animation group to this scene.
  40415. * @param newAnimationGroup The animation group to add
  40416. */
  40417. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40418. /**
  40419. * Adds the given multi-material to this scene
  40420. * @param newMultiMaterial The multi-material to add
  40421. */
  40422. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40423. /**
  40424. * Adds the given material to this scene
  40425. * @param newMaterial The material to add
  40426. */
  40427. addMaterial(newMaterial: Material): void;
  40428. /**
  40429. * Adds the given morph target to this scene
  40430. * @param newMorphTargetManager The morph target to add
  40431. */
  40432. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40433. /**
  40434. * Adds the given geometry to this scene
  40435. * @param newGeometry The geometry to add
  40436. */
  40437. addGeometry(newGeometry: Geometry): void;
  40438. /**
  40439. * Adds the given action manager to this scene
  40440. * @param newActionManager The action manager to add
  40441. */
  40442. addActionManager(newActionManager: AbstractActionManager): void;
  40443. /**
  40444. * Adds the given texture to this scene.
  40445. * @param newTexture The texture to add
  40446. */
  40447. addTexture(newTexture: BaseTexture): void;
  40448. /**
  40449. * Switch active camera
  40450. * @param newCamera defines the new active camera
  40451. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40452. */
  40453. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40454. /**
  40455. * sets the active camera of the scene using its ID
  40456. * @param id defines the camera's ID
  40457. * @return the new active camera or null if none found.
  40458. */
  40459. setActiveCameraByID(id: string): Nullable<Camera>;
  40460. /**
  40461. * sets the active camera of the scene using its name
  40462. * @param name defines the camera's name
  40463. * @returns the new active camera or null if none found.
  40464. */
  40465. setActiveCameraByName(name: string): Nullable<Camera>;
  40466. /**
  40467. * get an animation group using its name
  40468. * @param name defines the material's name
  40469. * @return the animation group or null if none found.
  40470. */
  40471. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40472. /**
  40473. * Get a material using its unique id
  40474. * @param uniqueId defines the material's unique id
  40475. * @return the material or null if none found.
  40476. */
  40477. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40478. /**
  40479. * get a material using its id
  40480. * @param id defines the material's ID
  40481. * @return the material or null if none found.
  40482. */
  40483. getMaterialByID(id: string): Nullable<Material>;
  40484. /**
  40485. * Gets a the last added material using a given id
  40486. * @param id defines the material's ID
  40487. * @return the last material with the given id or null if none found.
  40488. */
  40489. getLastMaterialByID(id: string): Nullable<Material>;
  40490. /**
  40491. * Gets a material using its name
  40492. * @param name defines the material's name
  40493. * @return the material or null if none found.
  40494. */
  40495. getMaterialByName(name: string): Nullable<Material>;
  40496. /**
  40497. * Get a texture using its unique id
  40498. * @param uniqueId defines the texture's unique id
  40499. * @return the texture or null if none found.
  40500. */
  40501. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40502. /**
  40503. * Gets a camera using its id
  40504. * @param id defines the id to look for
  40505. * @returns the camera or null if not found
  40506. */
  40507. getCameraByID(id: string): Nullable<Camera>;
  40508. /**
  40509. * Gets a camera using its unique id
  40510. * @param uniqueId defines the unique id to look for
  40511. * @returns the camera or null if not found
  40512. */
  40513. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40514. /**
  40515. * Gets a camera using its name
  40516. * @param name defines the camera's name
  40517. * @return the camera or null if none found.
  40518. */
  40519. getCameraByName(name: string): Nullable<Camera>;
  40520. /**
  40521. * Gets a bone using its id
  40522. * @param id defines the bone's id
  40523. * @return the bone or null if not found
  40524. */
  40525. getBoneByID(id: string): Nullable<Bone>;
  40526. /**
  40527. * Gets a bone using its id
  40528. * @param name defines the bone's name
  40529. * @return the bone or null if not found
  40530. */
  40531. getBoneByName(name: string): Nullable<Bone>;
  40532. /**
  40533. * Gets a light node using its name
  40534. * @param name defines the the light's name
  40535. * @return the light or null if none found.
  40536. */
  40537. getLightByName(name: string): Nullable<Light>;
  40538. /**
  40539. * Gets a light node using its id
  40540. * @param id defines the light's id
  40541. * @return the light or null if none found.
  40542. */
  40543. getLightByID(id: string): Nullable<Light>;
  40544. /**
  40545. * Gets a light node using its scene-generated unique ID
  40546. * @param uniqueId defines the light's unique id
  40547. * @return the light or null if none found.
  40548. */
  40549. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40550. /**
  40551. * Gets a particle system by id
  40552. * @param id defines the particle system id
  40553. * @return the corresponding system or null if none found
  40554. */
  40555. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40556. /**
  40557. * Gets a geometry using its ID
  40558. * @param id defines the geometry's id
  40559. * @return the geometry or null if none found.
  40560. */
  40561. getGeometryByID(id: string): Nullable<Geometry>;
  40562. private _getGeometryByUniqueID;
  40563. /**
  40564. * Add a new geometry to this scene
  40565. * @param geometry defines the geometry to be added to the scene.
  40566. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40567. * @return a boolean defining if the geometry was added or not
  40568. */
  40569. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40570. /**
  40571. * Removes an existing geometry
  40572. * @param geometry defines the geometry to be removed from the scene
  40573. * @return a boolean defining if the geometry was removed or not
  40574. */
  40575. removeGeometry(geometry: Geometry): boolean;
  40576. /**
  40577. * Gets the list of geometries attached to the scene
  40578. * @returns an array of Geometry
  40579. */
  40580. getGeometries(): Geometry[];
  40581. /**
  40582. * Gets the first added mesh found of a given ID
  40583. * @param id defines the id to search for
  40584. * @return the mesh found or null if not found at all
  40585. */
  40586. getMeshByID(id: string): Nullable<AbstractMesh>;
  40587. /**
  40588. * Gets a list of meshes using their id
  40589. * @param id defines the id to search for
  40590. * @returns a list of meshes
  40591. */
  40592. getMeshesByID(id: string): Array<AbstractMesh>;
  40593. /**
  40594. * Gets the first added transform node found of a given ID
  40595. * @param id defines the id to search for
  40596. * @return the found transform node or null if not found at all.
  40597. */
  40598. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40599. /**
  40600. * Gets a transform node with its auto-generated unique id
  40601. * @param uniqueId efines the unique id to search for
  40602. * @return the found transform node or null if not found at all.
  40603. */
  40604. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40605. /**
  40606. * Gets a list of transform nodes using their id
  40607. * @param id defines the id to search for
  40608. * @returns a list of transform nodes
  40609. */
  40610. getTransformNodesByID(id: string): Array<TransformNode>;
  40611. /**
  40612. * Gets a mesh with its auto-generated unique id
  40613. * @param uniqueId defines the unique id to search for
  40614. * @return the found mesh or null if not found at all.
  40615. */
  40616. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40617. /**
  40618. * Gets a the last added mesh using a given id
  40619. * @param id defines the id to search for
  40620. * @return the found mesh or null if not found at all.
  40621. */
  40622. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40623. /**
  40624. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40625. * @param id defines the id to search for
  40626. * @return the found node or null if not found at all
  40627. */
  40628. getLastEntryByID(id: string): Nullable<Node>;
  40629. /**
  40630. * Gets a node (Mesh, Camera, Light) using a given id
  40631. * @param id defines the id to search for
  40632. * @return the found node or null if not found at all
  40633. */
  40634. getNodeByID(id: string): Nullable<Node>;
  40635. /**
  40636. * Gets a node (Mesh, Camera, Light) using a given name
  40637. * @param name defines the name to search for
  40638. * @return the found node or null if not found at all.
  40639. */
  40640. getNodeByName(name: string): Nullable<Node>;
  40641. /**
  40642. * Gets a mesh using a given name
  40643. * @param name defines the name to search for
  40644. * @return the found mesh or null if not found at all.
  40645. */
  40646. getMeshByName(name: string): Nullable<AbstractMesh>;
  40647. /**
  40648. * Gets a transform node using a given name
  40649. * @param name defines the name to search for
  40650. * @return the found transform node or null if not found at all.
  40651. */
  40652. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40653. /**
  40654. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40655. * @param id defines the id to search for
  40656. * @return the found skeleton or null if not found at all.
  40657. */
  40658. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40659. /**
  40660. * Gets a skeleton using a given auto generated unique id
  40661. * @param uniqueId defines the unique id to search for
  40662. * @return the found skeleton or null if not found at all.
  40663. */
  40664. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40665. /**
  40666. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40667. * @param id defines the id to search for
  40668. * @return the found skeleton or null if not found at all.
  40669. */
  40670. getSkeletonById(id: string): Nullable<Skeleton>;
  40671. /**
  40672. * Gets a skeleton using a given name
  40673. * @param name defines the name to search for
  40674. * @return the found skeleton or null if not found at all.
  40675. */
  40676. getSkeletonByName(name: string): Nullable<Skeleton>;
  40677. /**
  40678. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40679. * @param id defines the id to search for
  40680. * @return the found morph target manager or null if not found at all.
  40681. */
  40682. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40683. /**
  40684. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40685. * @param id defines the id to search for
  40686. * @return the found morph target or null if not found at all.
  40687. */
  40688. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40689. /**
  40690. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40691. * @param name defines the name to search for
  40692. * @return the found morph target or null if not found at all.
  40693. */
  40694. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40695. /**
  40696. * Gets a boolean indicating if the given mesh is active
  40697. * @param mesh defines the mesh to look for
  40698. * @returns true if the mesh is in the active list
  40699. */
  40700. isActiveMesh(mesh: AbstractMesh): boolean;
  40701. /**
  40702. * Return a unique id as a string which can serve as an identifier for the scene
  40703. */
  40704. get uid(): string;
  40705. /**
  40706. * Add an externaly attached data from its key.
  40707. * This method call will fail and return false, if such key already exists.
  40708. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40709. * @param key the unique key that identifies the data
  40710. * @param data the data object to associate to the key for this Engine instance
  40711. * @return true if no such key were already present and the data was added successfully, false otherwise
  40712. */
  40713. addExternalData<T>(key: string, data: T): boolean;
  40714. /**
  40715. * Get an externaly attached data from its key
  40716. * @param key the unique key that identifies the data
  40717. * @return the associated data, if present (can be null), or undefined if not present
  40718. */
  40719. getExternalData<T>(key: string): Nullable<T>;
  40720. /**
  40721. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40722. * @param key the unique key that identifies the data
  40723. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40724. * @return the associated data, can be null if the factory returned null.
  40725. */
  40726. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40727. /**
  40728. * Remove an externaly attached data from the Engine instance
  40729. * @param key the unique key that identifies the data
  40730. * @return true if the data was successfully removed, false if it doesn't exist
  40731. */
  40732. removeExternalData(key: string): boolean;
  40733. private _evaluateSubMesh;
  40734. /**
  40735. * Clear the processed materials smart array preventing retention point in material dispose.
  40736. */
  40737. freeProcessedMaterials(): void;
  40738. private _preventFreeActiveMeshesAndRenderingGroups;
  40739. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40740. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40741. * when disposing several meshes in a row or a hierarchy of meshes.
  40742. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40743. */
  40744. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40745. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40746. /**
  40747. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40748. */
  40749. freeActiveMeshes(): void;
  40750. /**
  40751. * Clear the info related to rendering groups preventing retention points during dispose.
  40752. */
  40753. freeRenderingGroups(): void;
  40754. /** @hidden */
  40755. _isInIntermediateRendering(): boolean;
  40756. /**
  40757. * Lambda returning the list of potentially active meshes.
  40758. */
  40759. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40760. /**
  40761. * Lambda returning the list of potentially active sub meshes.
  40762. */
  40763. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40764. /**
  40765. * Lambda returning the list of potentially intersecting sub meshes.
  40766. */
  40767. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40768. /**
  40769. * Lambda returning the list of potentially colliding sub meshes.
  40770. */
  40771. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40772. private _activeMeshesFrozen;
  40773. private _skipEvaluateActiveMeshesCompletely;
  40774. /**
  40775. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40776. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40777. * @returns the current scene
  40778. */
  40779. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40780. /**
  40781. * Use this function to restart evaluating active meshes on every frame
  40782. * @returns the current scene
  40783. */
  40784. unfreezeActiveMeshes(): Scene;
  40785. private _evaluateActiveMeshes;
  40786. private _activeMesh;
  40787. /**
  40788. * Update the transform matrix to update from the current active camera
  40789. * @param force defines a boolean used to force the update even if cache is up to date
  40790. */
  40791. updateTransformMatrix(force?: boolean): void;
  40792. private _bindFrameBuffer;
  40793. /** @hidden */
  40794. _allowPostProcessClearColor: boolean;
  40795. /** @hidden */
  40796. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40797. private _processSubCameras;
  40798. private _checkIntersections;
  40799. /** @hidden */
  40800. _advancePhysicsEngineStep(step: number): void;
  40801. /**
  40802. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40803. */
  40804. getDeterministicFrameTime: () => number;
  40805. /** @hidden */
  40806. _animate(): void;
  40807. /** Execute all animations (for a frame) */
  40808. animate(): void;
  40809. /**
  40810. * Render the scene
  40811. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40812. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40813. */
  40814. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40815. /**
  40816. * Freeze all materials
  40817. * A frozen material will not be updatable but should be faster to render
  40818. */
  40819. freezeMaterials(): void;
  40820. /**
  40821. * Unfreeze all materials
  40822. * A frozen material will not be updatable but should be faster to render
  40823. */
  40824. unfreezeMaterials(): void;
  40825. /**
  40826. * Releases all held ressources
  40827. */
  40828. dispose(): void;
  40829. /**
  40830. * Gets if the scene is already disposed
  40831. */
  40832. get isDisposed(): boolean;
  40833. /**
  40834. * Call this function to reduce memory footprint of the scene.
  40835. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40836. */
  40837. clearCachedVertexData(): void;
  40838. /**
  40839. * This function will remove the local cached buffer data from texture.
  40840. * It will save memory but will prevent the texture from being rebuilt
  40841. */
  40842. cleanCachedTextureBuffer(): void;
  40843. /**
  40844. * Get the world extend vectors with an optional filter
  40845. *
  40846. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40847. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40848. */
  40849. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40850. min: Vector3;
  40851. max: Vector3;
  40852. };
  40853. /**
  40854. * Creates a ray that can be used to pick in the scene
  40855. * @param x defines the x coordinate of the origin (on-screen)
  40856. * @param y defines the y coordinate of the origin (on-screen)
  40857. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40858. * @param camera defines the camera to use for the picking
  40859. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40860. * @returns a Ray
  40861. */
  40862. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40863. /**
  40864. * Creates a ray that can be used to pick in the scene
  40865. * @param x defines the x coordinate of the origin (on-screen)
  40866. * @param y defines the y coordinate of the origin (on-screen)
  40867. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40868. * @param result defines the ray where to store the picking ray
  40869. * @param camera defines the camera to use for the picking
  40870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40871. * @returns the current scene
  40872. */
  40873. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40874. /**
  40875. * Creates a ray that can be used to pick in the scene
  40876. * @param x defines the x coordinate of the origin (on-screen)
  40877. * @param y defines the y coordinate of the origin (on-screen)
  40878. * @param camera defines the camera to use for the picking
  40879. * @returns a Ray
  40880. */
  40881. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40882. /**
  40883. * Creates a ray that can be used to pick in the scene
  40884. * @param x defines the x coordinate of the origin (on-screen)
  40885. * @param y defines the y coordinate of the origin (on-screen)
  40886. * @param result defines the ray where to store the picking ray
  40887. * @param camera defines the camera to use for the picking
  40888. * @returns the current scene
  40889. */
  40890. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40891. /** Launch a ray to try to pick a mesh in the scene
  40892. * @param x position on screen
  40893. * @param y position on screen
  40894. * @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
  40895. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40896. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40898. * @returns a PickingInfo
  40899. */
  40900. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40901. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40902. * @param x position on screen
  40903. * @param y position on screen
  40904. * @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
  40905. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40906. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40907. * @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)
  40908. */
  40909. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40910. /** Use the given ray to pick a mesh in the scene
  40911. * @param ray The ray to use to pick meshes
  40912. * @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
  40913. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40914. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40915. * @returns a PickingInfo
  40916. */
  40917. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40918. /**
  40919. * Launch a ray to try to pick a mesh in the scene
  40920. * @param x X position on screen
  40921. * @param y Y position on screen
  40922. * @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
  40923. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40924. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40925. * @returns an array of PickingInfo
  40926. */
  40927. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40928. /**
  40929. * Launch a ray to try to pick a mesh in the scene
  40930. * @param ray Ray to use
  40931. * @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
  40932. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40933. * @returns an array of PickingInfo
  40934. */
  40935. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40936. /**
  40937. * Force the value of meshUnderPointer
  40938. * @param mesh defines the mesh to use
  40939. */
  40940. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40941. /**
  40942. * Gets the mesh under the pointer
  40943. * @returns a Mesh or null if no mesh is under the pointer
  40944. */
  40945. getPointerOverMesh(): Nullable<AbstractMesh>;
  40946. /** @hidden */
  40947. _rebuildGeometries(): void;
  40948. /** @hidden */
  40949. _rebuildTextures(): void;
  40950. private _getByTags;
  40951. /**
  40952. * Get a list of meshes by tags
  40953. * @param tagsQuery defines the tags query to use
  40954. * @param forEach defines a predicate used to filter results
  40955. * @returns an array of Mesh
  40956. */
  40957. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40958. /**
  40959. * Get a list of cameras by tags
  40960. * @param tagsQuery defines the tags query to use
  40961. * @param forEach defines a predicate used to filter results
  40962. * @returns an array of Camera
  40963. */
  40964. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40965. /**
  40966. * Get a list of lights by tags
  40967. * @param tagsQuery defines the tags query to use
  40968. * @param forEach defines a predicate used to filter results
  40969. * @returns an array of Light
  40970. */
  40971. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40972. /**
  40973. * Get a list of materials by tags
  40974. * @param tagsQuery defines the tags query to use
  40975. * @param forEach defines a predicate used to filter results
  40976. * @returns an array of Material
  40977. */
  40978. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40979. /**
  40980. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40981. * This allowed control for front to back rendering or reversly depending of the special needs.
  40982. *
  40983. * @param renderingGroupId The rendering group id corresponding to its index
  40984. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40985. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40986. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40987. */
  40988. 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;
  40989. /**
  40990. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40991. *
  40992. * @param renderingGroupId The rendering group id corresponding to its index
  40993. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40994. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40995. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40996. */
  40997. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40998. /**
  40999. * Gets the current auto clear configuration for one rendering group of the rendering
  41000. * manager.
  41001. * @param index the rendering group index to get the information for
  41002. * @returns The auto clear setup for the requested rendering group
  41003. */
  41004. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41005. private _blockMaterialDirtyMechanism;
  41006. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41007. get blockMaterialDirtyMechanism(): boolean;
  41008. set blockMaterialDirtyMechanism(value: boolean);
  41009. /**
  41010. * Will flag all materials as dirty to trigger new shader compilation
  41011. * @param flag defines the flag used to specify which material part must be marked as dirty
  41012. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41013. */
  41014. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41015. /** @hidden */
  41016. _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;
  41017. /** @hidden */
  41018. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41019. /** @hidden */
  41020. _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;
  41021. /** @hidden */
  41022. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41023. /** @hidden */
  41024. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41025. /** @hidden */
  41026. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41027. }
  41028. }
  41029. declare module BABYLON {
  41030. /**
  41031. * Set of assets to keep when moving a scene into an asset container.
  41032. */
  41033. export class KeepAssets extends AbstractScene {
  41034. }
  41035. /**
  41036. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41037. */
  41038. export class InstantiatedEntries {
  41039. /**
  41040. * List of new root nodes (eg. nodes with no parent)
  41041. */
  41042. rootNodes: TransformNode[];
  41043. /**
  41044. * List of new skeletons
  41045. */
  41046. skeletons: Skeleton[];
  41047. /**
  41048. * List of new animation groups
  41049. */
  41050. animationGroups: AnimationGroup[];
  41051. }
  41052. /**
  41053. * Container with a set of assets that can be added or removed from a scene.
  41054. */
  41055. export class AssetContainer extends AbstractScene {
  41056. private _wasAddedToScene;
  41057. /**
  41058. * The scene the AssetContainer belongs to.
  41059. */
  41060. scene: Scene;
  41061. /**
  41062. * Instantiates an AssetContainer.
  41063. * @param scene The scene the AssetContainer belongs to.
  41064. */
  41065. constructor(scene: Scene);
  41066. /**
  41067. * Instantiate or clone all meshes and add the new ones to the scene.
  41068. * Skeletons and animation groups will all be cloned
  41069. * @param nameFunction defines an optional function used to get new names for clones
  41070. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41071. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41072. */
  41073. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41074. /**
  41075. * Adds all the assets from the container to the scene.
  41076. */
  41077. addAllToScene(): void;
  41078. /**
  41079. * Removes all the assets in the container from the scene
  41080. */
  41081. removeAllFromScene(): void;
  41082. /**
  41083. * Disposes all the assets in the container
  41084. */
  41085. dispose(): void;
  41086. private _moveAssets;
  41087. /**
  41088. * Removes all the assets contained in the scene and adds them to the container.
  41089. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41090. */
  41091. moveAllFromScene(keepAssets?: KeepAssets): void;
  41092. /**
  41093. * 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.
  41094. * @returns the root mesh
  41095. */
  41096. createRootMesh(): Mesh;
  41097. /**
  41098. * Merge animations (direct and animation groups) from this asset container into a scene
  41099. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41100. * @param animatables set of animatables to retarget to a node from the scene
  41101. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41102. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41103. */
  41104. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41105. }
  41106. }
  41107. declare module BABYLON {
  41108. /**
  41109. * Defines how the parser contract is defined.
  41110. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41111. */
  41112. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41113. /**
  41114. * Defines how the individual parser contract is defined.
  41115. * These parser can parse an individual asset
  41116. */
  41117. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41118. /**
  41119. * Base class of the scene acting as a container for the different elements composing a scene.
  41120. * This class is dynamically extended by the different components of the scene increasing
  41121. * flexibility and reducing coupling
  41122. */
  41123. export abstract class AbstractScene {
  41124. /**
  41125. * Stores the list of available parsers in the application.
  41126. */
  41127. private static _BabylonFileParsers;
  41128. /**
  41129. * Stores the list of available individual parsers in the application.
  41130. */
  41131. private static _IndividualBabylonFileParsers;
  41132. /**
  41133. * Adds a parser in the list of available ones
  41134. * @param name Defines the name of the parser
  41135. * @param parser Defines the parser to add
  41136. */
  41137. static AddParser(name: string, parser: BabylonFileParser): void;
  41138. /**
  41139. * Gets a general parser from the list of avaialble ones
  41140. * @param name Defines the name of the parser
  41141. * @returns the requested parser or null
  41142. */
  41143. static GetParser(name: string): Nullable<BabylonFileParser>;
  41144. /**
  41145. * Adds n individual parser in the list of available ones
  41146. * @param name Defines the name of the parser
  41147. * @param parser Defines the parser to add
  41148. */
  41149. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41150. /**
  41151. * Gets an individual parser from the list of avaialble ones
  41152. * @param name Defines the name of the parser
  41153. * @returns the requested parser or null
  41154. */
  41155. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41156. /**
  41157. * Parser json data and populate both a scene and its associated container object
  41158. * @param jsonData Defines the data to parse
  41159. * @param scene Defines the scene to parse the data for
  41160. * @param container Defines the container attached to the parsing sequence
  41161. * @param rootUrl Defines the root url of the data
  41162. */
  41163. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41164. /**
  41165. * Gets the list of root nodes (ie. nodes with no parent)
  41166. */
  41167. rootNodes: Node[];
  41168. /** All of the cameras added to this scene
  41169. * @see https://doc.babylonjs.com/babylon101/cameras
  41170. */
  41171. cameras: Camera[];
  41172. /**
  41173. * All of the lights added to this scene
  41174. * @see https://doc.babylonjs.com/babylon101/lights
  41175. */
  41176. lights: Light[];
  41177. /**
  41178. * All of the (abstract) meshes added to this scene
  41179. */
  41180. meshes: AbstractMesh[];
  41181. /**
  41182. * The list of skeletons added to the scene
  41183. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41184. */
  41185. skeletons: Skeleton[];
  41186. /**
  41187. * All of the particle systems added to this scene
  41188. * @see https://doc.babylonjs.com/babylon101/particles
  41189. */
  41190. particleSystems: IParticleSystem[];
  41191. /**
  41192. * Gets a list of Animations associated with the scene
  41193. */
  41194. animations: Animation[];
  41195. /**
  41196. * All of the animation groups added to this scene
  41197. * @see https://doc.babylonjs.com/how_to/group
  41198. */
  41199. animationGroups: AnimationGroup[];
  41200. /**
  41201. * All of the multi-materials added to this scene
  41202. * @see https://doc.babylonjs.com/how_to/multi_materials
  41203. */
  41204. multiMaterials: MultiMaterial[];
  41205. /**
  41206. * All of the materials added to this scene
  41207. * In the context of a Scene, it is not supposed to be modified manually.
  41208. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41209. * Note also that the order of the Material within the array is not significant and might change.
  41210. * @see https://doc.babylonjs.com/babylon101/materials
  41211. */
  41212. materials: Material[];
  41213. /**
  41214. * The list of morph target managers added to the scene
  41215. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41216. */
  41217. morphTargetManagers: MorphTargetManager[];
  41218. /**
  41219. * The list of geometries used in the scene.
  41220. */
  41221. geometries: Geometry[];
  41222. /**
  41223. * All of the tranform nodes added to this scene
  41224. * In the context of a Scene, it is not supposed to be modified manually.
  41225. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41226. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41227. * @see https://doc.babylonjs.com/how_to/transformnode
  41228. */
  41229. transformNodes: TransformNode[];
  41230. /**
  41231. * ActionManagers available on the scene.
  41232. */
  41233. actionManagers: AbstractActionManager[];
  41234. /**
  41235. * Textures to keep.
  41236. */
  41237. textures: BaseTexture[];
  41238. /**
  41239. * Environment texture for the scene
  41240. */
  41241. environmentTexture: Nullable<BaseTexture>;
  41242. /**
  41243. * @returns all meshes, lights, cameras, transformNodes and bones
  41244. */
  41245. getNodes(): Array<Node>;
  41246. }
  41247. }
  41248. declare module BABYLON {
  41249. /**
  41250. * Interface used to define options for Sound class
  41251. */
  41252. export interface ISoundOptions {
  41253. /**
  41254. * Does the sound autoplay once loaded.
  41255. */
  41256. autoplay?: boolean;
  41257. /**
  41258. * Does the sound loop after it finishes playing once.
  41259. */
  41260. loop?: boolean;
  41261. /**
  41262. * Sound's volume
  41263. */
  41264. volume?: number;
  41265. /**
  41266. * Is it a spatial sound?
  41267. */
  41268. spatialSound?: boolean;
  41269. /**
  41270. * Maximum distance to hear that sound
  41271. */
  41272. maxDistance?: number;
  41273. /**
  41274. * Uses user defined attenuation function
  41275. */
  41276. useCustomAttenuation?: boolean;
  41277. /**
  41278. * Define the roll off factor of spatial sounds.
  41279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41280. */
  41281. rolloffFactor?: number;
  41282. /**
  41283. * Define the reference distance the sound should be heard perfectly.
  41284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41285. */
  41286. refDistance?: number;
  41287. /**
  41288. * Define the distance attenuation model the sound will follow.
  41289. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41290. */
  41291. distanceModel?: string;
  41292. /**
  41293. * Defines the playback speed (1 by default)
  41294. */
  41295. playbackRate?: number;
  41296. /**
  41297. * Defines if the sound is from a streaming source
  41298. */
  41299. streaming?: boolean;
  41300. /**
  41301. * Defines an optional length (in seconds) inside the sound file
  41302. */
  41303. length?: number;
  41304. /**
  41305. * Defines an optional offset (in seconds) inside the sound file
  41306. */
  41307. offset?: number;
  41308. /**
  41309. * If true, URLs will not be required to state the audio file codec to use.
  41310. */
  41311. skipCodecCheck?: boolean;
  41312. }
  41313. /**
  41314. * Defines a sound that can be played in the application.
  41315. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41317. */
  41318. export class Sound {
  41319. /**
  41320. * The name of the sound in the scene.
  41321. */
  41322. name: string;
  41323. /**
  41324. * Does the sound autoplay once loaded.
  41325. */
  41326. autoplay: boolean;
  41327. /**
  41328. * Does the sound loop after it finishes playing once.
  41329. */
  41330. loop: boolean;
  41331. /**
  41332. * Does the sound use a custom attenuation curve to simulate the falloff
  41333. * happening when the source gets further away from the camera.
  41334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41335. */
  41336. useCustomAttenuation: boolean;
  41337. /**
  41338. * The sound track id this sound belongs to.
  41339. */
  41340. soundTrackId: number;
  41341. /**
  41342. * Is this sound currently played.
  41343. */
  41344. isPlaying: boolean;
  41345. /**
  41346. * Is this sound currently paused.
  41347. */
  41348. isPaused: boolean;
  41349. /**
  41350. * Does this sound enables spatial sound.
  41351. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41352. */
  41353. spatialSound: boolean;
  41354. /**
  41355. * Define the reference distance the sound should be heard perfectly.
  41356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41357. */
  41358. refDistance: number;
  41359. /**
  41360. * Define the roll off factor of spatial sounds.
  41361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41362. */
  41363. rolloffFactor: number;
  41364. /**
  41365. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41366. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41367. */
  41368. maxDistance: number;
  41369. /**
  41370. * Define the distance attenuation model the sound will follow.
  41371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41372. */
  41373. distanceModel: string;
  41374. /**
  41375. * @hidden
  41376. * Back Compat
  41377. **/
  41378. onended: () => any;
  41379. /**
  41380. * Gets or sets an object used to store user defined information for the sound.
  41381. */
  41382. metadata: any;
  41383. /**
  41384. * Observable event when the current playing sound finishes.
  41385. */
  41386. onEndedObservable: Observable<Sound>;
  41387. private _panningModel;
  41388. private _playbackRate;
  41389. private _streaming;
  41390. private _startTime;
  41391. private _startOffset;
  41392. private _position;
  41393. /** @hidden */
  41394. _positionInEmitterSpace: boolean;
  41395. private _localDirection;
  41396. private _volume;
  41397. private _isReadyToPlay;
  41398. private _isDirectional;
  41399. private _readyToPlayCallback;
  41400. private _audioBuffer;
  41401. private _soundSource;
  41402. private _streamingSource;
  41403. private _soundPanner;
  41404. private _soundGain;
  41405. private _inputAudioNode;
  41406. private _outputAudioNode;
  41407. private _coneInnerAngle;
  41408. private _coneOuterAngle;
  41409. private _coneOuterGain;
  41410. private _scene;
  41411. private _connectedTransformNode;
  41412. private _customAttenuationFunction;
  41413. private _registerFunc;
  41414. private _isOutputConnected;
  41415. private _htmlAudioElement;
  41416. private _urlType;
  41417. private _length?;
  41418. private _offset?;
  41419. /** @hidden */
  41420. static _SceneComponentInitialization: (scene: Scene) => void;
  41421. /**
  41422. * Create a sound and attach it to a scene
  41423. * @param name Name of your sound
  41424. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41425. * @param scene defines the scene the sound belongs to
  41426. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41427. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41428. */
  41429. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41430. /**
  41431. * Release the sound and its associated resources
  41432. */
  41433. dispose(): void;
  41434. /**
  41435. * Gets if the sounds is ready to be played or not.
  41436. * @returns true if ready, otherwise false
  41437. */
  41438. isReady(): boolean;
  41439. private _soundLoaded;
  41440. /**
  41441. * Sets the data of the sound from an audiobuffer
  41442. * @param audioBuffer The audioBuffer containing the data
  41443. */
  41444. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41445. /**
  41446. * Updates the current sounds options such as maxdistance, loop...
  41447. * @param options A JSON object containing values named as the object properties
  41448. */
  41449. updateOptions(options: ISoundOptions): void;
  41450. private _createSpatialParameters;
  41451. private _updateSpatialParameters;
  41452. /**
  41453. * Switch the panning model to HRTF:
  41454. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41456. */
  41457. switchPanningModelToHRTF(): void;
  41458. /**
  41459. * Switch the panning model to Equal Power:
  41460. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41462. */
  41463. switchPanningModelToEqualPower(): void;
  41464. private _switchPanningModel;
  41465. /**
  41466. * Connect this sound to a sound track audio node like gain...
  41467. * @param soundTrackAudioNode the sound track audio node to connect to
  41468. */
  41469. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41470. /**
  41471. * Transform this sound into a directional source
  41472. * @param coneInnerAngle Size of the inner cone in degree
  41473. * @param coneOuterAngle Size of the outer cone in degree
  41474. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41475. */
  41476. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41477. /**
  41478. * Gets or sets the inner angle for the directional cone.
  41479. */
  41480. get directionalConeInnerAngle(): number;
  41481. /**
  41482. * Gets or sets the inner angle for the directional cone.
  41483. */
  41484. set directionalConeInnerAngle(value: number);
  41485. /**
  41486. * Gets or sets the outer angle for the directional cone.
  41487. */
  41488. get directionalConeOuterAngle(): number;
  41489. /**
  41490. * Gets or sets the outer angle for the directional cone.
  41491. */
  41492. set directionalConeOuterAngle(value: number);
  41493. /**
  41494. * Sets the position of the emitter if spatial sound is enabled
  41495. * @param newPosition Defines the new posisiton
  41496. */
  41497. setPosition(newPosition: Vector3): void;
  41498. /**
  41499. * Sets the local direction of the emitter if spatial sound is enabled
  41500. * @param newLocalDirection Defines the new local direction
  41501. */
  41502. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41503. private _updateDirection;
  41504. /** @hidden */
  41505. updateDistanceFromListener(): void;
  41506. /**
  41507. * Sets a new custom attenuation function for the sound.
  41508. * @param callback Defines the function used for the attenuation
  41509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41510. */
  41511. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41512. /**
  41513. * Play the sound
  41514. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41515. * @param offset (optional) Start the sound at a specific time in seconds
  41516. * @param length (optional) Sound duration (in seconds)
  41517. */
  41518. play(time?: number, offset?: number, length?: number): void;
  41519. private _onended;
  41520. /**
  41521. * Stop the sound
  41522. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41523. */
  41524. stop(time?: number): void;
  41525. /**
  41526. * Put the sound in pause
  41527. */
  41528. pause(): void;
  41529. /**
  41530. * Sets a dedicated volume for this sounds
  41531. * @param newVolume Define the new volume of the sound
  41532. * @param time Define time for gradual change to new volume
  41533. */
  41534. setVolume(newVolume: number, time?: number): void;
  41535. /**
  41536. * Set the sound play back rate
  41537. * @param newPlaybackRate Define the playback rate the sound should be played at
  41538. */
  41539. setPlaybackRate(newPlaybackRate: number): void;
  41540. /**
  41541. * Gets the volume of the sound.
  41542. * @returns the volume of the sound
  41543. */
  41544. getVolume(): number;
  41545. /**
  41546. * Attach the sound to a dedicated mesh
  41547. * @param transformNode The transform node to connect the sound with
  41548. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41549. */
  41550. attachToMesh(transformNode: TransformNode): void;
  41551. /**
  41552. * Detach the sound from the previously attached mesh
  41553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41554. */
  41555. detachFromMesh(): void;
  41556. private _onRegisterAfterWorldMatrixUpdate;
  41557. /**
  41558. * Clone the current sound in the scene.
  41559. * @returns the new sound clone
  41560. */
  41561. clone(): Nullable<Sound>;
  41562. /**
  41563. * Gets the current underlying audio buffer containing the data
  41564. * @returns the audio buffer
  41565. */
  41566. getAudioBuffer(): Nullable<AudioBuffer>;
  41567. /**
  41568. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41569. * @returns the source node
  41570. */
  41571. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41572. /**
  41573. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41574. * @returns the gain node
  41575. */
  41576. getSoundGain(): Nullable<GainNode>;
  41577. /**
  41578. * Serializes the Sound in a JSON representation
  41579. * @returns the JSON representation of the sound
  41580. */
  41581. serialize(): any;
  41582. /**
  41583. * Parse a JSON representation of a sound to innstantiate in a given scene
  41584. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41585. * @param scene Define the scene the new parsed sound should be created in
  41586. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41587. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41588. * @returns the newly parsed sound
  41589. */
  41590. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41591. }
  41592. }
  41593. declare module BABYLON {
  41594. /**
  41595. * This defines an action helpful to play a defined sound on a triggered action.
  41596. */
  41597. export class PlaySoundAction extends Action {
  41598. private _sound;
  41599. /**
  41600. * Instantiate the action
  41601. * @param triggerOptions defines the trigger options
  41602. * @param sound defines the sound to play
  41603. * @param condition defines the trigger related conditions
  41604. */
  41605. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41606. /** @hidden */
  41607. _prepare(): void;
  41608. /**
  41609. * Execute the action and play the sound.
  41610. */
  41611. execute(): void;
  41612. /**
  41613. * Serializes the actions and its related information.
  41614. * @param parent defines the object to serialize in
  41615. * @returns the serialized object
  41616. */
  41617. serialize(parent: any): any;
  41618. }
  41619. /**
  41620. * This defines an action helpful to stop a defined sound on a triggered action.
  41621. */
  41622. export class StopSoundAction extends Action {
  41623. private _sound;
  41624. /**
  41625. * Instantiate the action
  41626. * @param triggerOptions defines the trigger options
  41627. * @param sound defines the sound to stop
  41628. * @param condition defines the trigger related conditions
  41629. */
  41630. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41631. /** @hidden */
  41632. _prepare(): void;
  41633. /**
  41634. * Execute the action and stop the sound.
  41635. */
  41636. execute(): void;
  41637. /**
  41638. * Serializes the actions and its related information.
  41639. * @param parent defines the object to serialize in
  41640. * @returns the serialized object
  41641. */
  41642. serialize(parent: any): any;
  41643. }
  41644. }
  41645. declare module BABYLON {
  41646. /**
  41647. * This defines an action responsible to change the value of a property
  41648. * by interpolating between its current value and the newly set one once triggered.
  41649. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41650. */
  41651. export class InterpolateValueAction extends Action {
  41652. /**
  41653. * Defines the path of the property where the value should be interpolated
  41654. */
  41655. propertyPath: string;
  41656. /**
  41657. * Defines the target value at the end of the interpolation.
  41658. */
  41659. value: any;
  41660. /**
  41661. * Defines the time it will take for the property to interpolate to the value.
  41662. */
  41663. duration: number;
  41664. /**
  41665. * Defines if the other scene animations should be stopped when the action has been triggered
  41666. */
  41667. stopOtherAnimations?: boolean;
  41668. /**
  41669. * Defines a callback raised once the interpolation animation has been done.
  41670. */
  41671. onInterpolationDone?: () => void;
  41672. /**
  41673. * Observable triggered once the interpolation animation has been done.
  41674. */
  41675. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41676. private _target;
  41677. private _effectiveTarget;
  41678. private _property;
  41679. /**
  41680. * Instantiate the action
  41681. * @param triggerOptions defines the trigger options
  41682. * @param target defines the object containing the value to interpolate
  41683. * @param propertyPath defines the path to the property in the target object
  41684. * @param value defines the target value at the end of the interpolation
  41685. * @param duration deines the time it will take for the property to interpolate to the value.
  41686. * @param condition defines the trigger related conditions
  41687. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41688. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41689. */
  41690. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41691. /** @hidden */
  41692. _prepare(): void;
  41693. /**
  41694. * Execute the action starts the value interpolation.
  41695. */
  41696. execute(): void;
  41697. /**
  41698. * Serializes the actions and its related information.
  41699. * @param parent defines the object to serialize in
  41700. * @returns the serialized object
  41701. */
  41702. serialize(parent: any): any;
  41703. }
  41704. }
  41705. declare module BABYLON {
  41706. /**
  41707. * Options allowed during the creation of a sound track.
  41708. */
  41709. export interface ISoundTrackOptions {
  41710. /**
  41711. * The volume the sound track should take during creation
  41712. */
  41713. volume?: number;
  41714. /**
  41715. * Define if the sound track is the main sound track of the scene
  41716. */
  41717. mainTrack?: boolean;
  41718. }
  41719. /**
  41720. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41721. * It will be also used in a future release to apply effects on a specific track.
  41722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41723. */
  41724. export class SoundTrack {
  41725. /**
  41726. * The unique identifier of the sound track in the scene.
  41727. */
  41728. id: number;
  41729. /**
  41730. * The list of sounds included in the sound track.
  41731. */
  41732. soundCollection: Array<Sound>;
  41733. private _outputAudioNode;
  41734. private _scene;
  41735. private _connectedAnalyser;
  41736. private _options;
  41737. private _isInitialized;
  41738. /**
  41739. * Creates a new sound track.
  41740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41741. * @param scene Define the scene the sound track belongs to
  41742. * @param options
  41743. */
  41744. constructor(scene: Scene, options?: ISoundTrackOptions);
  41745. private _initializeSoundTrackAudioGraph;
  41746. /**
  41747. * Release the sound track and its associated resources
  41748. */
  41749. dispose(): void;
  41750. /**
  41751. * Adds a sound to this sound track
  41752. * @param sound define the cound to add
  41753. * @ignoreNaming
  41754. */
  41755. AddSound(sound: Sound): void;
  41756. /**
  41757. * Removes a sound to this sound track
  41758. * @param sound define the cound to remove
  41759. * @ignoreNaming
  41760. */
  41761. RemoveSound(sound: Sound): void;
  41762. /**
  41763. * Set a global volume for the full sound track.
  41764. * @param newVolume Define the new volume of the sound track
  41765. */
  41766. setVolume(newVolume: number): void;
  41767. /**
  41768. * Switch the panning model to HRTF:
  41769. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41770. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41771. */
  41772. switchPanningModelToHRTF(): void;
  41773. /**
  41774. * Switch the panning model to Equal Power:
  41775. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41777. */
  41778. switchPanningModelToEqualPower(): void;
  41779. /**
  41780. * Connect the sound track to an audio analyser allowing some amazing
  41781. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41782. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41783. * @param analyser The analyser to connect to the engine
  41784. */
  41785. connectToAnalyser(analyser: Analyser): void;
  41786. }
  41787. }
  41788. declare module BABYLON {
  41789. interface AbstractScene {
  41790. /**
  41791. * The list of sounds used in the scene.
  41792. */
  41793. sounds: Nullable<Array<Sound>>;
  41794. }
  41795. interface Scene {
  41796. /**
  41797. * @hidden
  41798. * Backing field
  41799. */
  41800. _mainSoundTrack: SoundTrack;
  41801. /**
  41802. * The main sound track played by the scene.
  41803. * It cotains your primary collection of sounds.
  41804. */
  41805. mainSoundTrack: SoundTrack;
  41806. /**
  41807. * The list of sound tracks added to the scene
  41808. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41809. */
  41810. soundTracks: Nullable<Array<SoundTrack>>;
  41811. /**
  41812. * Gets a sound using a given name
  41813. * @param name defines the name to search for
  41814. * @return the found sound or null if not found at all.
  41815. */
  41816. getSoundByName(name: string): Nullable<Sound>;
  41817. /**
  41818. * Gets or sets if audio support is enabled
  41819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41820. */
  41821. audioEnabled: boolean;
  41822. /**
  41823. * Gets or sets if audio will be output to headphones
  41824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41825. */
  41826. headphone: boolean;
  41827. /**
  41828. * Gets or sets custom audio listener position provider
  41829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41830. */
  41831. audioListenerPositionProvider: Nullable<() => Vector3>;
  41832. /**
  41833. * Gets or sets a refresh rate when using 3D audio positioning
  41834. */
  41835. audioPositioningRefreshRate: number;
  41836. }
  41837. /**
  41838. * Defines the sound scene component responsible to manage any sounds
  41839. * in a given scene.
  41840. */
  41841. export class AudioSceneComponent implements ISceneSerializableComponent {
  41842. /**
  41843. * The component name helpfull to identify the component in the list of scene components.
  41844. */
  41845. readonly name: string;
  41846. /**
  41847. * The scene the component belongs to.
  41848. */
  41849. scene: Scene;
  41850. private _audioEnabled;
  41851. /**
  41852. * Gets whether audio is enabled or not.
  41853. * Please use related enable/disable method to switch state.
  41854. */
  41855. get audioEnabled(): boolean;
  41856. private _headphone;
  41857. /**
  41858. * Gets whether audio is outputing to headphone or not.
  41859. * Please use the according Switch methods to change output.
  41860. */
  41861. get headphone(): boolean;
  41862. /**
  41863. * Gets or sets a refresh rate when using 3D audio positioning
  41864. */
  41865. audioPositioningRefreshRate: number;
  41866. private _audioListenerPositionProvider;
  41867. /**
  41868. * Gets the current audio listener position provider
  41869. */
  41870. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41871. /**
  41872. * Sets a custom listener position for all sounds in the scene
  41873. * By default, this is the position of the first active camera
  41874. */
  41875. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41876. /**
  41877. * Creates a new instance of the component for the given scene
  41878. * @param scene Defines the scene to register the component in
  41879. */
  41880. constructor(scene: Scene);
  41881. /**
  41882. * Registers the component in a given scene
  41883. */
  41884. register(): void;
  41885. /**
  41886. * Rebuilds the elements related to this component in case of
  41887. * context lost for instance.
  41888. */
  41889. rebuild(): void;
  41890. /**
  41891. * Serializes the component data to the specified json object
  41892. * @param serializationObject The object to serialize to
  41893. */
  41894. serialize(serializationObject: any): void;
  41895. /**
  41896. * Adds all the elements from the container to the scene
  41897. * @param container the container holding the elements
  41898. */
  41899. addFromContainer(container: AbstractScene): void;
  41900. /**
  41901. * Removes all the elements in the container from the scene
  41902. * @param container contains the elements to remove
  41903. * @param dispose if the removed element should be disposed (default: false)
  41904. */
  41905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41906. /**
  41907. * Disposes the component and the associated ressources.
  41908. */
  41909. dispose(): void;
  41910. /**
  41911. * Disables audio in the associated scene.
  41912. */
  41913. disableAudio(): void;
  41914. /**
  41915. * Enables audio in the associated scene.
  41916. */
  41917. enableAudio(): void;
  41918. /**
  41919. * Switch audio to headphone output.
  41920. */
  41921. switchAudioModeForHeadphones(): void;
  41922. /**
  41923. * Switch audio to normal speakers.
  41924. */
  41925. switchAudioModeForNormalSpeakers(): void;
  41926. private _cachedCameraDirection;
  41927. private _cachedCameraPosition;
  41928. private _lastCheck;
  41929. private _afterRender;
  41930. }
  41931. }
  41932. declare module BABYLON {
  41933. /**
  41934. * Wraps one or more Sound objects and selects one with random weight for playback.
  41935. */
  41936. export class WeightedSound {
  41937. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41938. loop: boolean;
  41939. private _coneInnerAngle;
  41940. private _coneOuterAngle;
  41941. private _volume;
  41942. /** A Sound is currently playing. */
  41943. isPlaying: boolean;
  41944. /** A Sound is currently paused. */
  41945. isPaused: boolean;
  41946. private _sounds;
  41947. private _weights;
  41948. private _currentIndex?;
  41949. /**
  41950. * Creates a new WeightedSound from the list of sounds given.
  41951. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41952. * @param sounds Array of Sounds that will be selected from.
  41953. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41954. */
  41955. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41956. /**
  41957. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41958. */
  41959. get directionalConeInnerAngle(): number;
  41960. /**
  41961. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41962. */
  41963. set directionalConeInnerAngle(value: number);
  41964. /**
  41965. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41966. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41967. */
  41968. get directionalConeOuterAngle(): number;
  41969. /**
  41970. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41971. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41972. */
  41973. set directionalConeOuterAngle(value: number);
  41974. /**
  41975. * Playback volume.
  41976. */
  41977. get volume(): number;
  41978. /**
  41979. * Playback volume.
  41980. */
  41981. set volume(value: number);
  41982. private _onended;
  41983. /**
  41984. * Suspend playback
  41985. */
  41986. pause(): void;
  41987. /**
  41988. * Stop playback
  41989. */
  41990. stop(): void;
  41991. /**
  41992. * Start playback.
  41993. * @param startOffset Position the clip head at a specific time in seconds.
  41994. */
  41995. play(startOffset?: number): void;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42001. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42002. */
  42003. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42004. /**
  42005. * Gets the name of the behavior.
  42006. */
  42007. get name(): string;
  42008. /**
  42009. * The easing function used by animations
  42010. */
  42011. static EasingFunction: BackEase;
  42012. /**
  42013. * The easing mode used by animations
  42014. */
  42015. static EasingMode: number;
  42016. /**
  42017. * The duration of the animation, in milliseconds
  42018. */
  42019. transitionDuration: number;
  42020. /**
  42021. * Length of the distance animated by the transition when lower radius is reached
  42022. */
  42023. lowerRadiusTransitionRange: number;
  42024. /**
  42025. * Length of the distance animated by the transition when upper radius is reached
  42026. */
  42027. upperRadiusTransitionRange: number;
  42028. private _autoTransitionRange;
  42029. /**
  42030. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42031. */
  42032. get autoTransitionRange(): boolean;
  42033. /**
  42034. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42035. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42036. */
  42037. set autoTransitionRange(value: boolean);
  42038. private _attachedCamera;
  42039. private _onAfterCheckInputsObserver;
  42040. private _onMeshTargetChangedObserver;
  42041. /**
  42042. * Initializes the behavior.
  42043. */
  42044. init(): void;
  42045. /**
  42046. * Attaches the behavior to its arc rotate camera.
  42047. * @param camera Defines the camera to attach the behavior to
  42048. */
  42049. attach(camera: ArcRotateCamera): void;
  42050. /**
  42051. * Detaches the behavior from its current arc rotate camera.
  42052. */
  42053. detach(): void;
  42054. private _radiusIsAnimating;
  42055. private _radiusBounceTransition;
  42056. private _animatables;
  42057. private _cachedWheelPrecision;
  42058. /**
  42059. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42060. * @param radiusLimit The limit to check against.
  42061. * @return Bool to indicate if at limit.
  42062. */
  42063. private _isRadiusAtLimit;
  42064. /**
  42065. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42066. * @param radiusDelta The delta by which to animate to. Can be negative.
  42067. */
  42068. private _applyBoundRadiusAnimation;
  42069. /**
  42070. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42071. */
  42072. protected _clearAnimationLocks(): void;
  42073. /**
  42074. * Stops and removes all animations that have been applied to the camera
  42075. */
  42076. stopAllAnimations(): void;
  42077. }
  42078. }
  42079. declare module BABYLON {
  42080. /**
  42081. * 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.
  42082. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42083. */
  42084. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42085. /**
  42086. * Gets the name of the behavior.
  42087. */
  42088. get name(): string;
  42089. private _mode;
  42090. private _radiusScale;
  42091. private _positionScale;
  42092. private _defaultElevation;
  42093. private _elevationReturnTime;
  42094. private _elevationReturnWaitTime;
  42095. private _zoomStopsAnimation;
  42096. private _framingTime;
  42097. /**
  42098. * The easing function used by animations
  42099. */
  42100. static EasingFunction: ExponentialEase;
  42101. /**
  42102. * The easing mode used by animations
  42103. */
  42104. static EasingMode: number;
  42105. /**
  42106. * Sets the current mode used by the behavior
  42107. */
  42108. set mode(mode: number);
  42109. /**
  42110. * Gets current mode used by the behavior.
  42111. */
  42112. get mode(): number;
  42113. /**
  42114. * Sets the scale applied to the radius (1 by default)
  42115. */
  42116. set radiusScale(radius: number);
  42117. /**
  42118. * Gets the scale applied to the radius
  42119. */
  42120. get radiusScale(): number;
  42121. /**
  42122. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42123. */
  42124. set positionScale(scale: number);
  42125. /**
  42126. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42127. */
  42128. get positionScale(): number;
  42129. /**
  42130. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42131. * behaviour is triggered, in radians.
  42132. */
  42133. set defaultElevation(elevation: number);
  42134. /**
  42135. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42136. * behaviour is triggered, in radians.
  42137. */
  42138. get defaultElevation(): number;
  42139. /**
  42140. * Sets the time (in milliseconds) taken to return to the default beta position.
  42141. * Negative value indicates camera should not return to default.
  42142. */
  42143. set elevationReturnTime(speed: number);
  42144. /**
  42145. * Gets the time (in milliseconds) taken to return to the default beta position.
  42146. * Negative value indicates camera should not return to default.
  42147. */
  42148. get elevationReturnTime(): number;
  42149. /**
  42150. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42151. */
  42152. set elevationReturnWaitTime(time: number);
  42153. /**
  42154. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42155. */
  42156. get elevationReturnWaitTime(): number;
  42157. /**
  42158. * Sets the flag that indicates if user zooming should stop animation.
  42159. */
  42160. set zoomStopsAnimation(flag: boolean);
  42161. /**
  42162. * Gets the flag that indicates if user zooming should stop animation.
  42163. */
  42164. get zoomStopsAnimation(): boolean;
  42165. /**
  42166. * Sets the transition time when framing the mesh, in milliseconds
  42167. */
  42168. set framingTime(time: number);
  42169. /**
  42170. * Gets the transition time when framing the mesh, in milliseconds
  42171. */
  42172. get framingTime(): number;
  42173. /**
  42174. * Define if the behavior should automatically change the configured
  42175. * camera limits and sensibilities.
  42176. */
  42177. autoCorrectCameraLimitsAndSensibility: boolean;
  42178. private _onPrePointerObservableObserver;
  42179. private _onAfterCheckInputsObserver;
  42180. private _onMeshTargetChangedObserver;
  42181. private _attachedCamera;
  42182. private _isPointerDown;
  42183. private _lastInteractionTime;
  42184. /**
  42185. * Initializes the behavior.
  42186. */
  42187. init(): void;
  42188. /**
  42189. * Attaches the behavior to its arc rotate camera.
  42190. * @param camera Defines the camera to attach the behavior to
  42191. */
  42192. attach(camera: ArcRotateCamera): void;
  42193. /**
  42194. * Detaches the behavior from its current arc rotate camera.
  42195. */
  42196. detach(): void;
  42197. private _animatables;
  42198. private _betaIsAnimating;
  42199. private _betaTransition;
  42200. private _radiusTransition;
  42201. private _vectorTransition;
  42202. /**
  42203. * Targets the given mesh and updates zoom level accordingly.
  42204. * @param mesh The mesh to target.
  42205. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42206. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42207. */
  42208. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42209. /**
  42210. * Targets the given mesh with its children and updates zoom level accordingly.
  42211. * @param mesh The mesh to target.
  42212. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42213. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42214. */
  42215. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42216. /**
  42217. * Targets the given meshes with their children and updates zoom level accordingly.
  42218. * @param meshes The mesh to target.
  42219. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42220. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42221. */
  42222. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42223. /**
  42224. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42225. * @param minimumWorld Determines the smaller position of the bounding box extend
  42226. * @param maximumWorld Determines the bigger position of the bounding box extend
  42227. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42228. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42229. */
  42230. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42231. /**
  42232. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42233. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42234. * frustum width.
  42235. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42236. * to fully enclose the mesh in the viewing frustum.
  42237. */
  42238. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42239. /**
  42240. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42241. * is automatically returned to its default position (expected to be above ground plane).
  42242. */
  42243. private _maintainCameraAboveGround;
  42244. /**
  42245. * Returns the frustum slope based on the canvas ratio and camera FOV
  42246. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42247. */
  42248. private _getFrustumSlope;
  42249. /**
  42250. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42251. */
  42252. private _clearAnimationLocks;
  42253. /**
  42254. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42255. */
  42256. private _applyUserInteraction;
  42257. /**
  42258. * Stops and removes all animations that have been applied to the camera
  42259. */
  42260. stopAllAnimations(): void;
  42261. /**
  42262. * Gets a value indicating if the user is moving the camera
  42263. */
  42264. get isUserIsMoving(): boolean;
  42265. /**
  42266. * The camera can move all the way towards the mesh.
  42267. */
  42268. static IgnoreBoundsSizeMode: number;
  42269. /**
  42270. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42271. */
  42272. static FitFrustumSidesMode: number;
  42273. }
  42274. }
  42275. declare module BABYLON {
  42276. /**
  42277. * Base class for Camera Pointer Inputs.
  42278. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42279. * for example usage.
  42280. */
  42281. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42282. /**
  42283. * Defines the camera the input is attached to.
  42284. */
  42285. abstract camera: Camera;
  42286. /**
  42287. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42288. */
  42289. protected _altKey: boolean;
  42290. protected _ctrlKey: boolean;
  42291. protected _metaKey: boolean;
  42292. protected _shiftKey: boolean;
  42293. /**
  42294. * Which mouse buttons were pressed at time of last mouse event.
  42295. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42296. */
  42297. protected _buttonsPressed: number;
  42298. /**
  42299. * Defines the buttons associated with the input to handle camera move.
  42300. */
  42301. buttons: number[];
  42302. /**
  42303. * Attach the input controls to a specific dom element to get the input from.
  42304. * @param element Defines the element the controls should be listened from
  42305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42306. */
  42307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42308. /**
  42309. * Detach the current controls from the specified dom element.
  42310. * @param element Defines the element to stop listening the inputs from
  42311. */
  42312. detachControl(element: Nullable<HTMLElement>): void;
  42313. /**
  42314. * Gets the class name of the current input.
  42315. * @returns the class name
  42316. */
  42317. getClassName(): string;
  42318. /**
  42319. * Get the friendly name associated with the input class.
  42320. * @returns the input friendly name
  42321. */
  42322. getSimpleName(): string;
  42323. /**
  42324. * Called on pointer POINTERDOUBLETAP event.
  42325. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42326. */
  42327. protected onDoubleTap(type: string): void;
  42328. /**
  42329. * Called on pointer POINTERMOVE event if only a single touch is active.
  42330. * Override this method to provide functionality.
  42331. */
  42332. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42333. /**
  42334. * Called on pointer POINTERMOVE event if multiple touches are active.
  42335. * Override this method to provide functionality.
  42336. */
  42337. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42338. /**
  42339. * Called on JS contextmenu event.
  42340. * Override this method to provide functionality.
  42341. */
  42342. protected onContextMenu(evt: PointerEvent): void;
  42343. /**
  42344. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42345. * press.
  42346. * Override this method to provide functionality.
  42347. */
  42348. protected onButtonDown(evt: PointerEvent): void;
  42349. /**
  42350. * Called each time a new POINTERUP event occurs. Ie, for each button
  42351. * release.
  42352. * Override this method to provide functionality.
  42353. */
  42354. protected onButtonUp(evt: PointerEvent): void;
  42355. /**
  42356. * Called when window becomes inactive.
  42357. * Override this method to provide functionality.
  42358. */
  42359. protected onLostFocus(): void;
  42360. private _pointerInput;
  42361. private _observer;
  42362. private _onLostFocus;
  42363. private pointA;
  42364. private pointB;
  42365. }
  42366. }
  42367. declare module BABYLON {
  42368. /**
  42369. * Manage the pointers inputs to control an arc rotate camera.
  42370. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42371. */
  42372. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42373. /**
  42374. * Defines the camera the input is attached to.
  42375. */
  42376. camera: ArcRotateCamera;
  42377. /**
  42378. * Gets the class name of the current input.
  42379. * @returns the class name
  42380. */
  42381. getClassName(): string;
  42382. /**
  42383. * Defines the buttons associated with the input to handle camera move.
  42384. */
  42385. buttons: number[];
  42386. /**
  42387. * Defines the pointer angular sensibility along the X axis or how fast is
  42388. * the camera rotating.
  42389. */
  42390. angularSensibilityX: number;
  42391. /**
  42392. * Defines the pointer angular sensibility along the Y axis or how fast is
  42393. * the camera rotating.
  42394. */
  42395. angularSensibilityY: number;
  42396. /**
  42397. * Defines the pointer pinch precision or how fast is the camera zooming.
  42398. */
  42399. pinchPrecision: number;
  42400. /**
  42401. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42402. * from 0.
  42403. * It defines the percentage of current camera.radius to use as delta when
  42404. * pinch zoom is used.
  42405. */
  42406. pinchDeltaPercentage: number;
  42407. /**
  42408. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42409. * that any object in the plane at the camera's target point will scale
  42410. * perfectly with finger motion.
  42411. * Overrides pinchDeltaPercentage and pinchPrecision.
  42412. */
  42413. useNaturalPinchZoom: boolean;
  42414. /**
  42415. * Defines the pointer panning sensibility or how fast is the camera moving.
  42416. */
  42417. panningSensibility: number;
  42418. /**
  42419. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42420. */
  42421. multiTouchPanning: boolean;
  42422. /**
  42423. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42424. * zoom (pinch) through multitouch.
  42425. */
  42426. multiTouchPanAndZoom: boolean;
  42427. /**
  42428. * Revers pinch action direction.
  42429. */
  42430. pinchInwards: boolean;
  42431. private _isPanClick;
  42432. private _twoFingerActivityCount;
  42433. private _isPinching;
  42434. /**
  42435. * Called on pointer POINTERMOVE event if only a single touch is active.
  42436. */
  42437. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42438. /**
  42439. * Called on pointer POINTERDOUBLETAP event.
  42440. */
  42441. protected onDoubleTap(type: string): void;
  42442. /**
  42443. * Called on pointer POINTERMOVE event if multiple touches are active.
  42444. */
  42445. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42446. /**
  42447. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42448. * press.
  42449. */
  42450. protected onButtonDown(evt: PointerEvent): void;
  42451. /**
  42452. * Called each time a new POINTERUP event occurs. Ie, for each button
  42453. * release.
  42454. */
  42455. protected onButtonUp(evt: PointerEvent): void;
  42456. /**
  42457. * Called when window becomes inactive.
  42458. */
  42459. protected onLostFocus(): void;
  42460. }
  42461. }
  42462. declare module BABYLON {
  42463. /**
  42464. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42466. */
  42467. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42468. /**
  42469. * Defines the camera the input is attached to.
  42470. */
  42471. camera: ArcRotateCamera;
  42472. /**
  42473. * Defines the list of key codes associated with the up action (increase alpha)
  42474. */
  42475. keysUp: number[];
  42476. /**
  42477. * Defines the list of key codes associated with the down action (decrease alpha)
  42478. */
  42479. keysDown: number[];
  42480. /**
  42481. * Defines the list of key codes associated with the left action (increase beta)
  42482. */
  42483. keysLeft: number[];
  42484. /**
  42485. * Defines the list of key codes associated with the right action (decrease beta)
  42486. */
  42487. keysRight: number[];
  42488. /**
  42489. * Defines the list of key codes associated with the reset action.
  42490. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42491. */
  42492. keysReset: number[];
  42493. /**
  42494. * Defines the panning sensibility of the inputs.
  42495. * (How fast is the camera panning)
  42496. */
  42497. panningSensibility: number;
  42498. /**
  42499. * Defines the zooming sensibility of the inputs.
  42500. * (How fast is the camera zooming)
  42501. */
  42502. zoomingSensibility: number;
  42503. /**
  42504. * Defines whether maintaining the alt key down switch the movement mode from
  42505. * orientation to zoom.
  42506. */
  42507. useAltToZoom: boolean;
  42508. /**
  42509. * Rotation speed of the camera
  42510. */
  42511. angularSpeed: number;
  42512. private _keys;
  42513. private _ctrlPressed;
  42514. private _altPressed;
  42515. private _onCanvasBlurObserver;
  42516. private _onKeyboardObserver;
  42517. private _engine;
  42518. private _scene;
  42519. /**
  42520. * Attach the input controls to a specific dom element to get the input from.
  42521. * @param element Defines the element the controls should be listened from
  42522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42523. */
  42524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42525. /**
  42526. * Detach the current controls from the specified dom element.
  42527. * @param element Defines the element to stop listening the inputs from
  42528. */
  42529. detachControl(element: Nullable<HTMLElement>): void;
  42530. /**
  42531. * Update the current camera state depending on the inputs that have been used this frame.
  42532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42533. */
  42534. checkInputs(): void;
  42535. /**
  42536. * Gets the class name of the current intput.
  42537. * @returns the class name
  42538. */
  42539. getClassName(): string;
  42540. /**
  42541. * Get the friendly name associated with the input class.
  42542. * @returns the input friendly name
  42543. */
  42544. getSimpleName(): string;
  42545. }
  42546. }
  42547. declare module BABYLON {
  42548. /**
  42549. * Manage the mouse wheel inputs to control an arc rotate camera.
  42550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42551. */
  42552. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42553. /**
  42554. * Defines the camera the input is attached to.
  42555. */
  42556. camera: ArcRotateCamera;
  42557. /**
  42558. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42559. */
  42560. wheelPrecision: number;
  42561. /**
  42562. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42563. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42564. */
  42565. wheelDeltaPercentage: number;
  42566. private _wheel;
  42567. private _observer;
  42568. private computeDeltaFromMouseWheelLegacyEvent;
  42569. /**
  42570. * Attach the input controls to a specific dom element to get the input from.
  42571. * @param element Defines the element the controls should be listened from
  42572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42573. */
  42574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42575. /**
  42576. * Detach the current controls from the specified dom element.
  42577. * @param element Defines the element to stop listening the inputs from
  42578. */
  42579. detachControl(element: Nullable<HTMLElement>): void;
  42580. /**
  42581. * Gets the class name of the current intput.
  42582. * @returns the class name
  42583. */
  42584. getClassName(): string;
  42585. /**
  42586. * Get the friendly name associated with the input class.
  42587. * @returns the input friendly name
  42588. */
  42589. getSimpleName(): string;
  42590. }
  42591. }
  42592. declare module BABYLON {
  42593. /**
  42594. * Default Inputs manager for the ArcRotateCamera.
  42595. * It groups all the default supported inputs for ease of use.
  42596. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42597. */
  42598. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42599. /**
  42600. * Instantiates a new ArcRotateCameraInputsManager.
  42601. * @param camera Defines the camera the inputs belong to
  42602. */
  42603. constructor(camera: ArcRotateCamera);
  42604. /**
  42605. * Add mouse wheel input support to the input manager.
  42606. * @returns the current input manager
  42607. */
  42608. addMouseWheel(): ArcRotateCameraInputsManager;
  42609. /**
  42610. * Add pointers input support to the input manager.
  42611. * @returns the current input manager
  42612. */
  42613. addPointers(): ArcRotateCameraInputsManager;
  42614. /**
  42615. * Add keyboard input support to the input manager.
  42616. * @returns the current input manager
  42617. */
  42618. addKeyboard(): ArcRotateCameraInputsManager;
  42619. }
  42620. }
  42621. declare module BABYLON {
  42622. /**
  42623. * This represents an orbital type of camera.
  42624. *
  42625. * 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.
  42626. * 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.
  42627. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42628. */
  42629. export class ArcRotateCamera extends TargetCamera {
  42630. /**
  42631. * Defines the rotation angle of the camera along the longitudinal axis.
  42632. */
  42633. alpha: number;
  42634. /**
  42635. * Defines the rotation angle of the camera along the latitudinal axis.
  42636. */
  42637. beta: number;
  42638. /**
  42639. * Defines the radius of the camera from it s target point.
  42640. */
  42641. radius: number;
  42642. protected _target: Vector3;
  42643. protected _targetHost: Nullable<AbstractMesh>;
  42644. /**
  42645. * Defines the target point of the camera.
  42646. * The camera looks towards it form the radius distance.
  42647. */
  42648. get target(): Vector3;
  42649. set target(value: Vector3);
  42650. /**
  42651. * Define the current local position of the camera in the scene
  42652. */
  42653. get position(): Vector3;
  42654. set position(newPosition: Vector3);
  42655. protected _upVector: Vector3;
  42656. protected _upToYMatrix: Matrix;
  42657. protected _YToUpMatrix: Matrix;
  42658. /**
  42659. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42660. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42661. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42662. */
  42663. set upVector(vec: Vector3);
  42664. get upVector(): Vector3;
  42665. /**
  42666. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42667. */
  42668. setMatUp(): void;
  42669. /**
  42670. * Current inertia value on the longitudinal axis.
  42671. * The bigger this number the longer it will take for the camera to stop.
  42672. */
  42673. inertialAlphaOffset: number;
  42674. /**
  42675. * Current inertia value on the latitudinal axis.
  42676. * The bigger this number the longer it will take for the camera to stop.
  42677. */
  42678. inertialBetaOffset: number;
  42679. /**
  42680. * Current inertia value on the radius axis.
  42681. * The bigger this number the longer it will take for the camera to stop.
  42682. */
  42683. inertialRadiusOffset: number;
  42684. /**
  42685. * Minimum allowed angle on the longitudinal axis.
  42686. * This can help limiting how the Camera is able to move in the scene.
  42687. */
  42688. lowerAlphaLimit: Nullable<number>;
  42689. /**
  42690. * Maximum allowed angle on the longitudinal axis.
  42691. * This can help limiting how the Camera is able to move in the scene.
  42692. */
  42693. upperAlphaLimit: Nullable<number>;
  42694. /**
  42695. * Minimum allowed angle on the latitudinal axis.
  42696. * This can help limiting how the Camera is able to move in the scene.
  42697. */
  42698. lowerBetaLimit: number;
  42699. /**
  42700. * Maximum allowed angle on the latitudinal axis.
  42701. * This can help limiting how the Camera is able to move in the scene.
  42702. */
  42703. upperBetaLimit: number;
  42704. /**
  42705. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42706. * This can help limiting how the Camera is able to move in the scene.
  42707. */
  42708. lowerRadiusLimit: Nullable<number>;
  42709. /**
  42710. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42711. * This can help limiting how the Camera is able to move in the scene.
  42712. */
  42713. upperRadiusLimit: Nullable<number>;
  42714. /**
  42715. * Defines the current inertia value used during panning of the camera along the X axis.
  42716. */
  42717. inertialPanningX: number;
  42718. /**
  42719. * Defines the current inertia value used during panning of the camera along the Y axis.
  42720. */
  42721. inertialPanningY: number;
  42722. /**
  42723. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42724. * Basically if your fingers moves away from more than this distance you will be considered
  42725. * in pinch mode.
  42726. */
  42727. pinchToPanMaxDistance: number;
  42728. /**
  42729. * Defines the maximum distance the camera can pan.
  42730. * This could help keeping the cammera always in your scene.
  42731. */
  42732. panningDistanceLimit: Nullable<number>;
  42733. /**
  42734. * Defines the target of the camera before paning.
  42735. */
  42736. panningOriginTarget: Vector3;
  42737. /**
  42738. * Defines the value of the inertia used during panning.
  42739. * 0 would mean stop inertia and one would mean no decelleration at all.
  42740. */
  42741. panningInertia: number;
  42742. /**
  42743. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42744. */
  42745. get angularSensibilityX(): number;
  42746. set angularSensibilityX(value: number);
  42747. /**
  42748. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42749. */
  42750. get angularSensibilityY(): number;
  42751. set angularSensibilityY(value: number);
  42752. /**
  42753. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42754. */
  42755. get pinchPrecision(): number;
  42756. set pinchPrecision(value: number);
  42757. /**
  42758. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42759. * It will be used instead of pinchDeltaPrecision if different from 0.
  42760. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42761. */
  42762. get pinchDeltaPercentage(): number;
  42763. set pinchDeltaPercentage(value: number);
  42764. /**
  42765. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42766. * and pinch delta percentage.
  42767. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42768. * that any object in the plane at the camera's target point will scale
  42769. * perfectly with finger motion.
  42770. */
  42771. get useNaturalPinchZoom(): boolean;
  42772. set useNaturalPinchZoom(value: boolean);
  42773. /**
  42774. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42775. */
  42776. get panningSensibility(): number;
  42777. set panningSensibility(value: number);
  42778. /**
  42779. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42780. */
  42781. get keysUp(): number[];
  42782. set keysUp(value: number[]);
  42783. /**
  42784. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42785. */
  42786. get keysDown(): number[];
  42787. set keysDown(value: number[]);
  42788. /**
  42789. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42790. */
  42791. get keysLeft(): number[];
  42792. set keysLeft(value: number[]);
  42793. /**
  42794. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42795. */
  42796. get keysRight(): number[];
  42797. set keysRight(value: number[]);
  42798. /**
  42799. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42800. */
  42801. get wheelPrecision(): number;
  42802. set wheelPrecision(value: number);
  42803. /**
  42804. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42805. * It will be used instead of pinchDeltaPrecision if different from 0.
  42806. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42807. */
  42808. get wheelDeltaPercentage(): number;
  42809. set wheelDeltaPercentage(value: number);
  42810. /**
  42811. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42812. */
  42813. zoomOnFactor: number;
  42814. /**
  42815. * Defines a screen offset for the camera position.
  42816. */
  42817. targetScreenOffset: Vector2;
  42818. /**
  42819. * Allows the camera to be completely reversed.
  42820. * If false the camera can not arrive upside down.
  42821. */
  42822. allowUpsideDown: boolean;
  42823. /**
  42824. * Define if double tap/click is used to restore the previously saved state of the camera.
  42825. */
  42826. useInputToRestoreState: boolean;
  42827. /** @hidden */
  42828. _viewMatrix: Matrix;
  42829. /** @hidden */
  42830. _useCtrlForPanning: boolean;
  42831. /** @hidden */
  42832. _panningMouseButton: number;
  42833. /**
  42834. * Defines the input associated to the camera.
  42835. */
  42836. inputs: ArcRotateCameraInputsManager;
  42837. /** @hidden */
  42838. _reset: () => void;
  42839. /**
  42840. * Defines the allowed panning axis.
  42841. */
  42842. panningAxis: Vector3;
  42843. protected _localDirection: Vector3;
  42844. protected _transformedDirection: Vector3;
  42845. private _bouncingBehavior;
  42846. /**
  42847. * Gets the bouncing behavior of the camera if it has been enabled.
  42848. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42849. */
  42850. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42851. /**
  42852. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42853. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42854. */
  42855. get useBouncingBehavior(): boolean;
  42856. set useBouncingBehavior(value: boolean);
  42857. private _framingBehavior;
  42858. /**
  42859. * Gets the framing behavior of the camera if it has been enabled.
  42860. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42861. */
  42862. get framingBehavior(): Nullable<FramingBehavior>;
  42863. /**
  42864. * Defines if the framing behavior of the camera is enabled on the camera.
  42865. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42866. */
  42867. get useFramingBehavior(): boolean;
  42868. set useFramingBehavior(value: boolean);
  42869. private _autoRotationBehavior;
  42870. /**
  42871. * Gets the auto rotation behavior of the camera if it has been enabled.
  42872. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42873. */
  42874. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42875. /**
  42876. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42877. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42878. */
  42879. get useAutoRotationBehavior(): boolean;
  42880. set useAutoRotationBehavior(value: boolean);
  42881. /**
  42882. * Observable triggered when the mesh target has been changed on the camera.
  42883. */
  42884. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42885. /**
  42886. * Event raised when the camera is colliding with a mesh.
  42887. */
  42888. onCollide: (collidedMesh: AbstractMesh) => void;
  42889. /**
  42890. * Defines whether the camera should check collision with the objects oh the scene.
  42891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42892. */
  42893. checkCollisions: boolean;
  42894. /**
  42895. * Defines the collision radius of the camera.
  42896. * This simulates a sphere around the camera.
  42897. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42898. */
  42899. collisionRadius: Vector3;
  42900. protected _collider: Collider;
  42901. protected _previousPosition: Vector3;
  42902. protected _collisionVelocity: Vector3;
  42903. protected _newPosition: Vector3;
  42904. protected _previousAlpha: number;
  42905. protected _previousBeta: number;
  42906. protected _previousRadius: number;
  42907. protected _collisionTriggered: boolean;
  42908. protected _targetBoundingCenter: Nullable<Vector3>;
  42909. private _computationVector;
  42910. /**
  42911. * Instantiates a new ArcRotateCamera in a given scene
  42912. * @param name Defines the name of the camera
  42913. * @param alpha Defines the camera rotation along the logitudinal axis
  42914. * @param beta Defines the camera rotation along the latitudinal axis
  42915. * @param radius Defines the camera distance from its target
  42916. * @param target Defines the camera target
  42917. * @param scene Defines the scene the camera belongs to
  42918. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42919. */
  42920. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42921. /** @hidden */
  42922. _initCache(): void;
  42923. /** @hidden */
  42924. _updateCache(ignoreParentClass?: boolean): void;
  42925. protected _getTargetPosition(): Vector3;
  42926. private _storedAlpha;
  42927. private _storedBeta;
  42928. private _storedRadius;
  42929. private _storedTarget;
  42930. private _storedTargetScreenOffset;
  42931. /**
  42932. * Stores the current state of the camera (alpha, beta, radius and target)
  42933. * @returns the camera itself
  42934. */
  42935. storeState(): Camera;
  42936. /**
  42937. * @hidden
  42938. * Restored camera state. You must call storeState() first
  42939. */
  42940. _restoreStateValues(): boolean;
  42941. /** @hidden */
  42942. _isSynchronizedViewMatrix(): boolean;
  42943. /**
  42944. * Attached controls to the current camera.
  42945. * @param element Defines the element the controls should be listened from
  42946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42947. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42948. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42949. */
  42950. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42951. /**
  42952. * Detach the current controls from the camera.
  42953. * The camera will stop reacting to inputs.
  42954. * @param element Defines the element to stop listening the inputs from
  42955. */
  42956. detachControl(element: HTMLElement): void;
  42957. /** @hidden */
  42958. _checkInputs(): void;
  42959. protected _checkLimits(): void;
  42960. /**
  42961. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42962. */
  42963. rebuildAnglesAndRadius(): void;
  42964. /**
  42965. * Use a position to define the current camera related information like alpha, beta and radius
  42966. * @param position Defines the position to set the camera at
  42967. */
  42968. setPosition(position: Vector3): void;
  42969. /**
  42970. * Defines the target the camera should look at.
  42971. * This will automatically adapt alpha beta and radius to fit within the new target.
  42972. * @param target Defines the new target as a Vector or a mesh
  42973. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42974. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42975. */
  42976. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42977. /** @hidden */
  42978. _getViewMatrix(): Matrix;
  42979. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42980. /**
  42981. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42982. * @param meshes Defines the mesh to zoom on
  42983. * @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)
  42984. */
  42985. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42986. /**
  42987. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42988. * The target will be changed but the radius
  42989. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42990. * @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)
  42991. */
  42992. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42993. min: Vector3;
  42994. max: Vector3;
  42995. distance: number;
  42996. }, doNotUpdateMaxZ?: boolean): void;
  42997. /**
  42998. * @override
  42999. * Override Camera.createRigCamera
  43000. */
  43001. createRigCamera(name: string, cameraIndex: number): Camera;
  43002. /**
  43003. * @hidden
  43004. * @override
  43005. * Override Camera._updateRigCameras
  43006. */
  43007. _updateRigCameras(): void;
  43008. /**
  43009. * Destroy the camera and release the current resources hold by it.
  43010. */
  43011. dispose(): void;
  43012. /**
  43013. * Gets the current object class name.
  43014. * @return the class name
  43015. */
  43016. getClassName(): string;
  43017. }
  43018. }
  43019. declare module BABYLON {
  43020. /**
  43021. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43022. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43023. */
  43024. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43025. /**
  43026. * Gets the name of the behavior.
  43027. */
  43028. get name(): string;
  43029. private _zoomStopsAnimation;
  43030. private _idleRotationSpeed;
  43031. private _idleRotationWaitTime;
  43032. private _idleRotationSpinupTime;
  43033. /**
  43034. * Sets the flag that indicates if user zooming should stop animation.
  43035. */
  43036. set zoomStopsAnimation(flag: boolean);
  43037. /**
  43038. * Gets the flag that indicates if user zooming should stop animation.
  43039. */
  43040. get zoomStopsAnimation(): boolean;
  43041. /**
  43042. * Sets the default speed at which the camera rotates around the model.
  43043. */
  43044. set idleRotationSpeed(speed: number);
  43045. /**
  43046. * Gets the default speed at which the camera rotates around the model.
  43047. */
  43048. get idleRotationSpeed(): number;
  43049. /**
  43050. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43051. */
  43052. set idleRotationWaitTime(time: number);
  43053. /**
  43054. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43055. */
  43056. get idleRotationWaitTime(): number;
  43057. /**
  43058. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43059. */
  43060. set idleRotationSpinupTime(time: number);
  43061. /**
  43062. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43063. */
  43064. get idleRotationSpinupTime(): number;
  43065. /**
  43066. * Gets a value indicating if the camera is currently rotating because of this behavior
  43067. */
  43068. get rotationInProgress(): boolean;
  43069. private _onPrePointerObservableObserver;
  43070. private _onAfterCheckInputsObserver;
  43071. private _attachedCamera;
  43072. private _isPointerDown;
  43073. private _lastFrameTime;
  43074. private _lastInteractionTime;
  43075. private _cameraRotationSpeed;
  43076. /**
  43077. * Initializes the behavior.
  43078. */
  43079. init(): void;
  43080. /**
  43081. * Attaches the behavior to its arc rotate camera.
  43082. * @param camera Defines the camera to attach the behavior to
  43083. */
  43084. attach(camera: ArcRotateCamera): void;
  43085. /**
  43086. * Detaches the behavior from its current arc rotate camera.
  43087. */
  43088. detach(): void;
  43089. /**
  43090. * Returns true if user is scrolling.
  43091. * @return true if user is scrolling.
  43092. */
  43093. private _userIsZooming;
  43094. private _lastFrameRadius;
  43095. private _shouldAnimationStopForInteraction;
  43096. /**
  43097. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43098. */
  43099. private _applyUserInteraction;
  43100. private _userIsMoving;
  43101. }
  43102. }
  43103. declare module BABYLON {
  43104. /**
  43105. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43106. */
  43107. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43108. private ui;
  43109. /**
  43110. * The name of the behavior
  43111. */
  43112. name: string;
  43113. /**
  43114. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43115. */
  43116. distanceAwayFromFace: number;
  43117. /**
  43118. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43119. */
  43120. distanceAwayFromBottomOfFace: number;
  43121. private _faceVectors;
  43122. private _target;
  43123. private _scene;
  43124. private _onRenderObserver;
  43125. private _tmpMatrix;
  43126. private _tmpVector;
  43127. /**
  43128. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43129. * @param ui The transform node that should be attched to the mesh
  43130. */
  43131. constructor(ui: TransformNode);
  43132. /**
  43133. * Initializes the behavior
  43134. */
  43135. init(): void;
  43136. private _closestFace;
  43137. private _zeroVector;
  43138. private _lookAtTmpMatrix;
  43139. private _lookAtToRef;
  43140. /**
  43141. * Attaches the AttachToBoxBehavior to the passed in mesh
  43142. * @param target The mesh that the specified node will be attached to
  43143. */
  43144. attach(target: Mesh): void;
  43145. /**
  43146. * Detaches the behavior from the mesh
  43147. */
  43148. detach(): void;
  43149. }
  43150. }
  43151. declare module BABYLON {
  43152. /**
  43153. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43154. */
  43155. export class FadeInOutBehavior implements Behavior<Mesh> {
  43156. /**
  43157. * Time in milliseconds to delay before fading in (Default: 0)
  43158. */
  43159. delay: number;
  43160. /**
  43161. * Time in milliseconds for the mesh to fade in (Default: 300)
  43162. */
  43163. fadeInTime: number;
  43164. private _millisecondsPerFrame;
  43165. private _hovered;
  43166. private _hoverValue;
  43167. private _ownerNode;
  43168. /**
  43169. * Instatiates the FadeInOutBehavior
  43170. */
  43171. constructor();
  43172. /**
  43173. * The name of the behavior
  43174. */
  43175. get name(): string;
  43176. /**
  43177. * Initializes the behavior
  43178. */
  43179. init(): void;
  43180. /**
  43181. * Attaches the fade behavior on the passed in mesh
  43182. * @param ownerNode The mesh that will be faded in/out once attached
  43183. */
  43184. attach(ownerNode: Mesh): void;
  43185. /**
  43186. * Detaches the behavior from the mesh
  43187. */
  43188. detach(): void;
  43189. /**
  43190. * Triggers the mesh to begin fading in or out
  43191. * @param value if the object should fade in or out (true to fade in)
  43192. */
  43193. fadeIn(value: boolean): void;
  43194. private _update;
  43195. private _setAllVisibility;
  43196. }
  43197. }
  43198. declare module BABYLON {
  43199. /**
  43200. * Class containing a set of static utilities functions for managing Pivots
  43201. * @hidden
  43202. */
  43203. export class PivotTools {
  43204. private static _PivotCached;
  43205. private static _OldPivotPoint;
  43206. private static _PivotTranslation;
  43207. private static _PivotTmpVector;
  43208. /** @hidden */
  43209. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43210. /** @hidden */
  43211. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Class containing static functions to help procedurally build meshes
  43217. */
  43218. export class PlaneBuilder {
  43219. /**
  43220. * Creates a plane mesh
  43221. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43222. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43223. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43225. * * 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
  43226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43227. * @param name defines the name of the mesh
  43228. * @param options defines the options used to create the mesh
  43229. * @param scene defines the hosting scene
  43230. * @returns the plane mesh
  43231. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43232. */
  43233. static CreatePlane(name: string, options: {
  43234. size?: number;
  43235. width?: number;
  43236. height?: number;
  43237. sideOrientation?: number;
  43238. frontUVs?: Vector4;
  43239. backUVs?: Vector4;
  43240. updatable?: boolean;
  43241. sourcePlane?: Plane;
  43242. }, scene?: Nullable<Scene>): Mesh;
  43243. }
  43244. }
  43245. declare module BABYLON {
  43246. /**
  43247. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43248. */
  43249. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43250. private static _AnyMouseID;
  43251. /**
  43252. * Abstract mesh the behavior is set on
  43253. */
  43254. attachedNode: AbstractMesh;
  43255. private _dragPlane;
  43256. private _scene;
  43257. private _pointerObserver;
  43258. private _beforeRenderObserver;
  43259. private static _planeScene;
  43260. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43261. /**
  43262. * 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)
  43263. */
  43264. maxDragAngle: number;
  43265. /**
  43266. * @hidden
  43267. */
  43268. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43269. /**
  43270. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43271. */
  43272. currentDraggingPointerID: number;
  43273. /**
  43274. * The last position where the pointer hit the drag plane in world space
  43275. */
  43276. lastDragPosition: Vector3;
  43277. /**
  43278. * If the behavior is currently in a dragging state
  43279. */
  43280. dragging: boolean;
  43281. /**
  43282. * 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)
  43283. */
  43284. dragDeltaRatio: number;
  43285. /**
  43286. * If the drag plane orientation should be updated during the dragging (Default: true)
  43287. */
  43288. updateDragPlane: boolean;
  43289. private _debugMode;
  43290. private _moving;
  43291. /**
  43292. * Fires each time the attached mesh is dragged with the pointer
  43293. * * delta between last drag position and current drag position in world space
  43294. * * dragDistance along the drag axis
  43295. * * dragPlaneNormal normal of the current drag plane used during the drag
  43296. * * dragPlanePoint in world space where the drag intersects the drag plane
  43297. */
  43298. onDragObservable: Observable<{
  43299. delta: Vector3;
  43300. dragPlanePoint: Vector3;
  43301. dragPlaneNormal: Vector3;
  43302. dragDistance: number;
  43303. pointerId: number;
  43304. }>;
  43305. /**
  43306. * Fires each time a drag begins (eg. mouse down on mesh)
  43307. */
  43308. onDragStartObservable: Observable<{
  43309. dragPlanePoint: Vector3;
  43310. pointerId: number;
  43311. }>;
  43312. /**
  43313. * Fires each time a drag ends (eg. mouse release after drag)
  43314. */
  43315. onDragEndObservable: Observable<{
  43316. dragPlanePoint: Vector3;
  43317. pointerId: number;
  43318. }>;
  43319. /**
  43320. * If the attached mesh should be moved when dragged
  43321. */
  43322. moveAttached: boolean;
  43323. /**
  43324. * If the drag behavior will react to drag events (Default: true)
  43325. */
  43326. enabled: boolean;
  43327. /**
  43328. * If pointer events should start and release the drag (Default: true)
  43329. */
  43330. startAndReleaseDragOnPointerEvents: boolean;
  43331. /**
  43332. * If camera controls should be detached during the drag
  43333. */
  43334. detachCameraControls: boolean;
  43335. /**
  43336. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43337. */
  43338. useObjectOrientationForDragging: boolean;
  43339. private _options;
  43340. /**
  43341. * Gets the options used by the behavior
  43342. */
  43343. get options(): {
  43344. dragAxis?: Vector3;
  43345. dragPlaneNormal?: Vector3;
  43346. };
  43347. /**
  43348. * Sets the options used by the behavior
  43349. */
  43350. set options(options: {
  43351. dragAxis?: Vector3;
  43352. dragPlaneNormal?: Vector3;
  43353. });
  43354. /**
  43355. * Creates a pointer drag behavior that can be attached to a mesh
  43356. * @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)
  43357. */
  43358. constructor(options?: {
  43359. dragAxis?: Vector3;
  43360. dragPlaneNormal?: Vector3;
  43361. });
  43362. /**
  43363. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43364. */
  43365. validateDrag: (targetPosition: Vector3) => boolean;
  43366. /**
  43367. * The name of the behavior
  43368. */
  43369. get name(): string;
  43370. /**
  43371. * Initializes the behavior
  43372. */
  43373. init(): void;
  43374. private _tmpVector;
  43375. private _alternatePickedPoint;
  43376. private _worldDragAxis;
  43377. private _targetPosition;
  43378. private _attachedElement;
  43379. /**
  43380. * Attaches the drag behavior the passed in mesh
  43381. * @param ownerNode The mesh that will be dragged around once attached
  43382. * @param predicate Predicate to use for pick filtering
  43383. */
  43384. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43385. /**
  43386. * Force relase the drag action by code.
  43387. */
  43388. releaseDrag(): void;
  43389. private _startDragRay;
  43390. private _lastPointerRay;
  43391. /**
  43392. * Simulates the start of a pointer drag event on the behavior
  43393. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43394. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43395. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43396. */
  43397. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43398. private _startDrag;
  43399. private _dragDelta;
  43400. private _moveDrag;
  43401. private _pickWithRayOnDragPlane;
  43402. private _pointA;
  43403. private _pointC;
  43404. private _localAxis;
  43405. private _lookAt;
  43406. private _updateDragPlanePosition;
  43407. /**
  43408. * Detaches the behavior from the mesh
  43409. */
  43410. detach(): void;
  43411. }
  43412. }
  43413. declare module BABYLON {
  43414. /**
  43415. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43416. */
  43417. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43418. private _dragBehaviorA;
  43419. private _dragBehaviorB;
  43420. private _startDistance;
  43421. private _initialScale;
  43422. private _targetScale;
  43423. private _ownerNode;
  43424. private _sceneRenderObserver;
  43425. /**
  43426. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43427. */
  43428. constructor();
  43429. /**
  43430. * The name of the behavior
  43431. */
  43432. get name(): string;
  43433. /**
  43434. * Initializes the behavior
  43435. */
  43436. init(): void;
  43437. private _getCurrentDistance;
  43438. /**
  43439. * Attaches the scale behavior the passed in mesh
  43440. * @param ownerNode The mesh that will be scaled around once attached
  43441. */
  43442. attach(ownerNode: Mesh): void;
  43443. /**
  43444. * Detaches the behavior from the mesh
  43445. */
  43446. detach(): void;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /**
  43451. * 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
  43452. */
  43453. export class SixDofDragBehavior implements Behavior<Mesh> {
  43454. private static _virtualScene;
  43455. private _ownerNode;
  43456. private _sceneRenderObserver;
  43457. private _scene;
  43458. private _targetPosition;
  43459. private _virtualOriginMesh;
  43460. private _virtualDragMesh;
  43461. private _pointerObserver;
  43462. private _moving;
  43463. private _startingOrientation;
  43464. private _attachedElement;
  43465. /**
  43466. * 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)
  43467. */
  43468. private zDragFactor;
  43469. /**
  43470. * If the object should rotate to face the drag origin
  43471. */
  43472. rotateDraggedObject: boolean;
  43473. /**
  43474. * If the behavior is currently in a dragging state
  43475. */
  43476. dragging: boolean;
  43477. /**
  43478. * 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)
  43479. */
  43480. dragDeltaRatio: number;
  43481. /**
  43482. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43483. */
  43484. currentDraggingPointerID: number;
  43485. /**
  43486. * If camera controls should be detached during the drag
  43487. */
  43488. detachCameraControls: boolean;
  43489. /**
  43490. * Fires each time a drag starts
  43491. */
  43492. onDragStartObservable: Observable<{}>;
  43493. /**
  43494. * Fires each time a drag ends (eg. mouse release after drag)
  43495. */
  43496. onDragEndObservable: Observable<{}>;
  43497. /**
  43498. * 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
  43499. */
  43500. constructor();
  43501. /**
  43502. * The name of the behavior
  43503. */
  43504. get name(): string;
  43505. /**
  43506. * Initializes the behavior
  43507. */
  43508. init(): void;
  43509. /**
  43510. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43511. */
  43512. private get _pointerCamera();
  43513. /**
  43514. * Attaches the scale behavior the passed in mesh
  43515. * @param ownerNode The mesh that will be scaled around once attached
  43516. */
  43517. attach(ownerNode: Mesh): void;
  43518. /**
  43519. * Detaches the behavior from the mesh
  43520. */
  43521. detach(): void;
  43522. }
  43523. }
  43524. declare module BABYLON {
  43525. /**
  43526. * Class used to apply inverse kinematics to bones
  43527. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43528. */
  43529. export class BoneIKController {
  43530. private static _tmpVecs;
  43531. private static _tmpQuat;
  43532. private static _tmpMats;
  43533. /**
  43534. * Gets or sets the target mesh
  43535. */
  43536. targetMesh: AbstractMesh;
  43537. /** Gets or sets the mesh used as pole */
  43538. poleTargetMesh: AbstractMesh;
  43539. /**
  43540. * Gets or sets the bone used as pole
  43541. */
  43542. poleTargetBone: Nullable<Bone>;
  43543. /**
  43544. * Gets or sets the target position
  43545. */
  43546. targetPosition: Vector3;
  43547. /**
  43548. * Gets or sets the pole target position
  43549. */
  43550. poleTargetPosition: Vector3;
  43551. /**
  43552. * Gets or sets the pole target local offset
  43553. */
  43554. poleTargetLocalOffset: Vector3;
  43555. /**
  43556. * Gets or sets the pole angle
  43557. */
  43558. poleAngle: number;
  43559. /**
  43560. * Gets or sets the mesh associated with the controller
  43561. */
  43562. mesh: AbstractMesh;
  43563. /**
  43564. * 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)
  43565. */
  43566. slerpAmount: number;
  43567. private _bone1Quat;
  43568. private _bone1Mat;
  43569. private _bone2Ang;
  43570. private _bone1;
  43571. private _bone2;
  43572. private _bone1Length;
  43573. private _bone2Length;
  43574. private _maxAngle;
  43575. private _maxReach;
  43576. private _rightHandedSystem;
  43577. private _bendAxis;
  43578. private _slerping;
  43579. private _adjustRoll;
  43580. /**
  43581. * Gets or sets maximum allowed angle
  43582. */
  43583. get maxAngle(): number;
  43584. set maxAngle(value: number);
  43585. /**
  43586. * Creates a new BoneIKController
  43587. * @param mesh defines the mesh to control
  43588. * @param bone defines the bone to control
  43589. * @param options defines options to set up the controller
  43590. */
  43591. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43592. targetMesh?: AbstractMesh;
  43593. poleTargetMesh?: AbstractMesh;
  43594. poleTargetBone?: Bone;
  43595. poleTargetLocalOffset?: Vector3;
  43596. poleAngle?: number;
  43597. bendAxis?: Vector3;
  43598. maxAngle?: number;
  43599. slerpAmount?: number;
  43600. });
  43601. private _setMaxAngle;
  43602. /**
  43603. * Force the controller to update the bones
  43604. */
  43605. update(): void;
  43606. }
  43607. }
  43608. declare module BABYLON {
  43609. /**
  43610. * Class used to make a bone look toward a point in space
  43611. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43612. */
  43613. export class BoneLookController {
  43614. private static _tmpVecs;
  43615. private static _tmpQuat;
  43616. private static _tmpMats;
  43617. /**
  43618. * The target Vector3 that the bone will look at
  43619. */
  43620. target: Vector3;
  43621. /**
  43622. * The mesh that the bone is attached to
  43623. */
  43624. mesh: AbstractMesh;
  43625. /**
  43626. * The bone that will be looking to the target
  43627. */
  43628. bone: Bone;
  43629. /**
  43630. * The up axis of the coordinate system that is used when the bone is rotated
  43631. */
  43632. upAxis: Vector3;
  43633. /**
  43634. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43635. */
  43636. upAxisSpace: Space;
  43637. /**
  43638. * Used to make an adjustment to the yaw of the bone
  43639. */
  43640. adjustYaw: number;
  43641. /**
  43642. * Used to make an adjustment to the pitch of the bone
  43643. */
  43644. adjustPitch: number;
  43645. /**
  43646. * Used to make an adjustment to the roll of the bone
  43647. */
  43648. adjustRoll: number;
  43649. /**
  43650. * 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)
  43651. */
  43652. slerpAmount: number;
  43653. private _minYaw;
  43654. private _maxYaw;
  43655. private _minPitch;
  43656. private _maxPitch;
  43657. private _minYawSin;
  43658. private _minYawCos;
  43659. private _maxYawSin;
  43660. private _maxYawCos;
  43661. private _midYawConstraint;
  43662. private _minPitchTan;
  43663. private _maxPitchTan;
  43664. private _boneQuat;
  43665. private _slerping;
  43666. private _transformYawPitch;
  43667. private _transformYawPitchInv;
  43668. private _firstFrameSkipped;
  43669. private _yawRange;
  43670. private _fowardAxis;
  43671. /**
  43672. * Gets or sets the minimum yaw angle that the bone can look to
  43673. */
  43674. get minYaw(): number;
  43675. set minYaw(value: number);
  43676. /**
  43677. * Gets or sets the maximum yaw angle that the bone can look to
  43678. */
  43679. get maxYaw(): number;
  43680. set maxYaw(value: number);
  43681. /**
  43682. * Gets or sets the minimum pitch angle that the bone can look to
  43683. */
  43684. get minPitch(): number;
  43685. set minPitch(value: number);
  43686. /**
  43687. * Gets or sets the maximum pitch angle that the bone can look to
  43688. */
  43689. get maxPitch(): number;
  43690. set maxPitch(value: number);
  43691. /**
  43692. * Create a BoneLookController
  43693. * @param mesh the mesh that the bone belongs to
  43694. * @param bone the bone that will be looking to the target
  43695. * @param target the target Vector3 to look at
  43696. * @param options optional settings:
  43697. * * maxYaw: the maximum angle the bone will yaw to
  43698. * * minYaw: the minimum angle the bone will yaw to
  43699. * * maxPitch: the maximum angle the bone will pitch to
  43700. * * minPitch: the minimum angle the bone will yaw to
  43701. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43702. * * upAxis: the up axis of the coordinate system
  43703. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43704. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43705. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43706. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43707. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43708. * * adjustRoll: used to make an adjustment to the roll of the bone
  43709. **/
  43710. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43711. maxYaw?: number;
  43712. minYaw?: number;
  43713. maxPitch?: number;
  43714. minPitch?: number;
  43715. slerpAmount?: number;
  43716. upAxis?: Vector3;
  43717. upAxisSpace?: Space;
  43718. yawAxis?: Vector3;
  43719. pitchAxis?: Vector3;
  43720. adjustYaw?: number;
  43721. adjustPitch?: number;
  43722. adjustRoll?: number;
  43723. });
  43724. /**
  43725. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43726. */
  43727. update(): void;
  43728. private _getAngleDiff;
  43729. private _getAngleBetween;
  43730. private _isAngleBetween;
  43731. }
  43732. }
  43733. declare module BABYLON {
  43734. /**
  43735. * Manage the gamepad inputs to control an arc rotate camera.
  43736. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43737. */
  43738. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43739. /**
  43740. * Defines the camera the input is attached to.
  43741. */
  43742. camera: ArcRotateCamera;
  43743. /**
  43744. * Defines the gamepad the input is gathering event from.
  43745. */
  43746. gamepad: Nullable<Gamepad>;
  43747. /**
  43748. * Defines the gamepad rotation sensiblity.
  43749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43750. */
  43751. gamepadRotationSensibility: number;
  43752. /**
  43753. * Defines the gamepad move sensiblity.
  43754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43755. */
  43756. gamepadMoveSensibility: number;
  43757. private _yAxisScale;
  43758. /**
  43759. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43760. */
  43761. get invertYAxis(): boolean;
  43762. set invertYAxis(value: boolean);
  43763. private _onGamepadConnectedObserver;
  43764. private _onGamepadDisconnectedObserver;
  43765. /**
  43766. * Attach the input controls to a specific dom element to get the input from.
  43767. * @param element Defines the element the controls should be listened from
  43768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43769. */
  43770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43771. /**
  43772. * Detach the current controls from the specified dom element.
  43773. * @param element Defines the element to stop listening the inputs from
  43774. */
  43775. detachControl(element: Nullable<HTMLElement>): void;
  43776. /**
  43777. * Update the current camera state depending on the inputs that have been used this frame.
  43778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43779. */
  43780. checkInputs(): void;
  43781. /**
  43782. * Gets the class name of the current intput.
  43783. * @returns the class name
  43784. */
  43785. getClassName(): string;
  43786. /**
  43787. * Get the friendly name associated with the input class.
  43788. * @returns the input friendly name
  43789. */
  43790. getSimpleName(): string;
  43791. }
  43792. }
  43793. declare module BABYLON {
  43794. interface ArcRotateCameraInputsManager {
  43795. /**
  43796. * Add orientation input support to the input manager.
  43797. * @returns the current input manager
  43798. */
  43799. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43800. }
  43801. /**
  43802. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43804. */
  43805. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43806. /**
  43807. * Defines the camera the input is attached to.
  43808. */
  43809. camera: ArcRotateCamera;
  43810. /**
  43811. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43812. */
  43813. alphaCorrection: number;
  43814. /**
  43815. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43816. */
  43817. gammaCorrection: number;
  43818. private _alpha;
  43819. private _gamma;
  43820. private _dirty;
  43821. private _deviceOrientationHandler;
  43822. /**
  43823. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43824. */
  43825. constructor();
  43826. /**
  43827. * Attach the input controls to a specific dom element to get the input from.
  43828. * @param element Defines the element the controls should be listened from
  43829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43830. */
  43831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43832. /** @hidden */
  43833. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43834. /**
  43835. * Update the current camera state depending on the inputs that have been used this frame.
  43836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43837. */
  43838. checkInputs(): void;
  43839. /**
  43840. * Detach the current controls from the specified dom element.
  43841. * @param element Defines the element to stop listening the inputs from
  43842. */
  43843. detachControl(element: Nullable<HTMLElement>): void;
  43844. /**
  43845. * Gets the class name of the current intput.
  43846. * @returns the class name
  43847. */
  43848. getClassName(): string;
  43849. /**
  43850. * Get the friendly name associated with the input class.
  43851. * @returns the input friendly name
  43852. */
  43853. getSimpleName(): string;
  43854. }
  43855. }
  43856. declare module BABYLON {
  43857. /**
  43858. * Listen to mouse events to control the camera.
  43859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43860. */
  43861. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43862. /**
  43863. * Defines the camera the input is attached to.
  43864. */
  43865. camera: FlyCamera;
  43866. /**
  43867. * Defines if touch is enabled. (Default is true.)
  43868. */
  43869. touchEnabled: boolean;
  43870. /**
  43871. * Defines the buttons associated with the input to handle camera rotation.
  43872. */
  43873. buttons: number[];
  43874. /**
  43875. * Assign buttons for Yaw control.
  43876. */
  43877. buttonsYaw: number[];
  43878. /**
  43879. * Assign buttons for Pitch control.
  43880. */
  43881. buttonsPitch: number[];
  43882. /**
  43883. * Assign buttons for Roll control.
  43884. */
  43885. buttonsRoll: number[];
  43886. /**
  43887. * Detect if any button is being pressed while mouse is moved.
  43888. * -1 = Mouse locked.
  43889. * 0 = Left button.
  43890. * 1 = Middle Button.
  43891. * 2 = Right Button.
  43892. */
  43893. activeButton: number;
  43894. /**
  43895. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43896. * Higher values reduce its sensitivity.
  43897. */
  43898. angularSensibility: number;
  43899. private _mousemoveCallback;
  43900. private _observer;
  43901. private _rollObserver;
  43902. private previousPosition;
  43903. private noPreventDefault;
  43904. private element;
  43905. /**
  43906. * Listen to mouse events to control the camera.
  43907. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43909. */
  43910. constructor(touchEnabled?: boolean);
  43911. /**
  43912. * Attach the mouse control to the HTML DOM element.
  43913. * @param element Defines the element that listens to the input events.
  43914. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43915. */
  43916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43917. /**
  43918. * Detach the current controls from the specified dom element.
  43919. * @param element Defines the element to stop listening the inputs from
  43920. */
  43921. detachControl(element: Nullable<HTMLElement>): void;
  43922. /**
  43923. * Gets the class name of the current input.
  43924. * @returns the class name.
  43925. */
  43926. getClassName(): string;
  43927. /**
  43928. * Get the friendly name associated with the input class.
  43929. * @returns the input's friendly name.
  43930. */
  43931. getSimpleName(): string;
  43932. private _pointerInput;
  43933. private _onMouseMove;
  43934. /**
  43935. * Rotate camera by mouse offset.
  43936. */
  43937. private rotateCamera;
  43938. }
  43939. }
  43940. declare module BABYLON {
  43941. /**
  43942. * Default Inputs manager for the FlyCamera.
  43943. * It groups all the default supported inputs for ease of use.
  43944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43945. */
  43946. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43947. /**
  43948. * Instantiates a new FlyCameraInputsManager.
  43949. * @param camera Defines the camera the inputs belong to.
  43950. */
  43951. constructor(camera: FlyCamera);
  43952. /**
  43953. * Add keyboard input support to the input manager.
  43954. * @returns the new FlyCameraKeyboardMoveInput().
  43955. */
  43956. addKeyboard(): FlyCameraInputsManager;
  43957. /**
  43958. * Add mouse input support to the input manager.
  43959. * @param touchEnabled Enable touch screen support.
  43960. * @returns the new FlyCameraMouseInput().
  43961. */
  43962. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. /**
  43967. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43968. * such as in a 3D Space Shooter or a Flight Simulator.
  43969. */
  43970. export class FlyCamera extends TargetCamera {
  43971. /**
  43972. * Define the collision ellipsoid of the camera.
  43973. * This is helpful for simulating a camera body, like a player's body.
  43974. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43975. */
  43976. ellipsoid: Vector3;
  43977. /**
  43978. * Define an offset for the position of the ellipsoid around the camera.
  43979. * This can be helpful if the camera is attached away from the player's body center,
  43980. * such as at its head.
  43981. */
  43982. ellipsoidOffset: Vector3;
  43983. /**
  43984. * Enable or disable collisions of the camera with the rest of the scene objects.
  43985. */
  43986. checkCollisions: boolean;
  43987. /**
  43988. * Enable or disable gravity on the camera.
  43989. */
  43990. applyGravity: boolean;
  43991. /**
  43992. * Define the current direction the camera is moving to.
  43993. */
  43994. cameraDirection: Vector3;
  43995. /**
  43996. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43997. * This overrides and empties cameraRotation.
  43998. */
  43999. rotationQuaternion: Quaternion;
  44000. /**
  44001. * Track Roll to maintain the wanted Rolling when looking around.
  44002. */
  44003. _trackRoll: number;
  44004. /**
  44005. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44006. */
  44007. rollCorrect: number;
  44008. /**
  44009. * Mimic a banked turn, Rolling the camera when Yawing.
  44010. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44011. */
  44012. bankedTurn: boolean;
  44013. /**
  44014. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44015. */
  44016. bankedTurnLimit: number;
  44017. /**
  44018. * Value of 0 disables the banked Roll.
  44019. * Value of 1 is equal to the Yaw angle in radians.
  44020. */
  44021. bankedTurnMultiplier: number;
  44022. /**
  44023. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44024. */
  44025. inputs: FlyCameraInputsManager;
  44026. /**
  44027. * Gets the input sensibility for mouse input.
  44028. * Higher values reduce sensitivity.
  44029. */
  44030. get angularSensibility(): number;
  44031. /**
  44032. * Sets the input sensibility for a mouse input.
  44033. * Higher values reduce sensitivity.
  44034. */
  44035. set angularSensibility(value: number);
  44036. /**
  44037. * Get the keys for camera movement forward.
  44038. */
  44039. get keysForward(): number[];
  44040. /**
  44041. * Set the keys for camera movement forward.
  44042. */
  44043. set keysForward(value: number[]);
  44044. /**
  44045. * Get the keys for camera movement backward.
  44046. */
  44047. get keysBackward(): number[];
  44048. set keysBackward(value: number[]);
  44049. /**
  44050. * Get the keys for camera movement up.
  44051. */
  44052. get keysUp(): number[];
  44053. /**
  44054. * Set the keys for camera movement up.
  44055. */
  44056. set keysUp(value: number[]);
  44057. /**
  44058. * Get the keys for camera movement down.
  44059. */
  44060. get keysDown(): number[];
  44061. /**
  44062. * Set the keys for camera movement down.
  44063. */
  44064. set keysDown(value: number[]);
  44065. /**
  44066. * Get the keys for camera movement left.
  44067. */
  44068. get keysLeft(): number[];
  44069. /**
  44070. * Set the keys for camera movement left.
  44071. */
  44072. set keysLeft(value: number[]);
  44073. /**
  44074. * Set the keys for camera movement right.
  44075. */
  44076. get keysRight(): number[];
  44077. /**
  44078. * Set the keys for camera movement right.
  44079. */
  44080. set keysRight(value: number[]);
  44081. /**
  44082. * Event raised when the camera collides with a mesh in the scene.
  44083. */
  44084. onCollide: (collidedMesh: AbstractMesh) => void;
  44085. private _collider;
  44086. private _needMoveForGravity;
  44087. private _oldPosition;
  44088. private _diffPosition;
  44089. private _newPosition;
  44090. /** @hidden */
  44091. _localDirection: Vector3;
  44092. /** @hidden */
  44093. _transformedDirection: Vector3;
  44094. /**
  44095. * Instantiates a FlyCamera.
  44096. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44097. * such as in a 3D Space Shooter or a Flight Simulator.
  44098. * @param name Define the name of the camera in the scene.
  44099. * @param position Define the starting position of the camera in the scene.
  44100. * @param scene Define the scene the camera belongs to.
  44101. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44102. */
  44103. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44104. /**
  44105. * Attach a control to the HTML DOM element.
  44106. * @param element Defines the element that listens to the input events.
  44107. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44108. */
  44109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44110. /**
  44111. * Detach a control from the HTML DOM element.
  44112. * The camera will stop reacting to that input.
  44113. * @param element Defines the element that listens to the input events.
  44114. */
  44115. detachControl(element: HTMLElement): void;
  44116. private _collisionMask;
  44117. /**
  44118. * Get the mask that the camera ignores in collision events.
  44119. */
  44120. get collisionMask(): number;
  44121. /**
  44122. * Set the mask that the camera ignores in collision events.
  44123. */
  44124. set collisionMask(mask: number);
  44125. /** @hidden */
  44126. _collideWithWorld(displacement: Vector3): void;
  44127. /** @hidden */
  44128. private _onCollisionPositionChange;
  44129. /** @hidden */
  44130. _checkInputs(): void;
  44131. /** @hidden */
  44132. _decideIfNeedsToMove(): boolean;
  44133. /** @hidden */
  44134. _updatePosition(): void;
  44135. /**
  44136. * Restore the Roll to its target value at the rate specified.
  44137. * @param rate - Higher means slower restoring.
  44138. * @hidden
  44139. */
  44140. restoreRoll(rate: number): void;
  44141. /**
  44142. * Destroy the camera and release the current resources held by it.
  44143. */
  44144. dispose(): void;
  44145. /**
  44146. * Get the current object class name.
  44147. * @returns the class name.
  44148. */
  44149. getClassName(): string;
  44150. }
  44151. }
  44152. declare module BABYLON {
  44153. /**
  44154. * Listen to keyboard events to control the camera.
  44155. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44156. */
  44157. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44158. /**
  44159. * Defines the camera the input is attached to.
  44160. */
  44161. camera: FlyCamera;
  44162. /**
  44163. * The list of keyboard keys used to control the forward move of the camera.
  44164. */
  44165. keysForward: number[];
  44166. /**
  44167. * The list of keyboard keys used to control the backward move of the camera.
  44168. */
  44169. keysBackward: number[];
  44170. /**
  44171. * The list of keyboard keys used to control the forward move of the camera.
  44172. */
  44173. keysUp: number[];
  44174. /**
  44175. * The list of keyboard keys used to control the backward move of the camera.
  44176. */
  44177. keysDown: number[];
  44178. /**
  44179. * The list of keyboard keys used to control the right strafe move of the camera.
  44180. */
  44181. keysRight: number[];
  44182. /**
  44183. * The list of keyboard keys used to control the left strafe move of the camera.
  44184. */
  44185. keysLeft: number[];
  44186. private _keys;
  44187. private _onCanvasBlurObserver;
  44188. private _onKeyboardObserver;
  44189. private _engine;
  44190. private _scene;
  44191. /**
  44192. * Attach the input controls to a specific dom element to get the input from.
  44193. * @param element Defines the element the controls should be listened from
  44194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44195. */
  44196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44197. /**
  44198. * Detach the current controls from the specified dom element.
  44199. * @param element Defines the element to stop listening the inputs from
  44200. */
  44201. detachControl(element: Nullable<HTMLElement>): void;
  44202. /**
  44203. * Gets the class name of the current intput.
  44204. * @returns the class name
  44205. */
  44206. getClassName(): string;
  44207. /** @hidden */
  44208. _onLostFocus(e: FocusEvent): void;
  44209. /**
  44210. * Get the friendly name associated with the input class.
  44211. * @returns the input friendly name
  44212. */
  44213. getSimpleName(): string;
  44214. /**
  44215. * Update the current camera state depending on the inputs that have been used this frame.
  44216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44217. */
  44218. checkInputs(): void;
  44219. }
  44220. }
  44221. declare module BABYLON {
  44222. /**
  44223. * Manage the mouse wheel inputs to control a follow camera.
  44224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44225. */
  44226. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44227. /**
  44228. * Defines the camera the input is attached to.
  44229. */
  44230. camera: FollowCamera;
  44231. /**
  44232. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44233. */
  44234. axisControlRadius: boolean;
  44235. /**
  44236. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44237. */
  44238. axisControlHeight: boolean;
  44239. /**
  44240. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44241. */
  44242. axisControlRotation: boolean;
  44243. /**
  44244. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44245. * relation to mouseWheel events.
  44246. */
  44247. wheelPrecision: number;
  44248. /**
  44249. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44250. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44251. */
  44252. wheelDeltaPercentage: number;
  44253. private _wheel;
  44254. private _observer;
  44255. /**
  44256. * Attach the input controls to a specific dom element to get the input from.
  44257. * @param element Defines the element the controls should be listened from
  44258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44259. */
  44260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44261. /**
  44262. * Detach the current controls from the specified dom element.
  44263. * @param element Defines the element to stop listening the inputs from
  44264. */
  44265. detachControl(element: Nullable<HTMLElement>): void;
  44266. /**
  44267. * Gets the class name of the current intput.
  44268. * @returns the class name
  44269. */
  44270. getClassName(): string;
  44271. /**
  44272. * Get the friendly name associated with the input class.
  44273. * @returns the input friendly name
  44274. */
  44275. getSimpleName(): string;
  44276. }
  44277. }
  44278. declare module BABYLON {
  44279. /**
  44280. * Manage the pointers inputs to control an follow camera.
  44281. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44282. */
  44283. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44284. /**
  44285. * Defines the camera the input is attached to.
  44286. */
  44287. camera: FollowCamera;
  44288. /**
  44289. * Gets the class name of the current input.
  44290. * @returns the class name
  44291. */
  44292. getClassName(): string;
  44293. /**
  44294. * Defines the pointer angular sensibility along the X axis or how fast is
  44295. * the camera rotating.
  44296. * A negative number will reverse the axis direction.
  44297. */
  44298. angularSensibilityX: number;
  44299. /**
  44300. * Defines the pointer angular sensibility along the Y axis or how fast is
  44301. * the camera rotating.
  44302. * A negative number will reverse the axis direction.
  44303. */
  44304. angularSensibilityY: number;
  44305. /**
  44306. * Defines the pointer pinch precision or how fast is the camera zooming.
  44307. * A negative number will reverse the axis direction.
  44308. */
  44309. pinchPrecision: number;
  44310. /**
  44311. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44312. * from 0.
  44313. * It defines the percentage of current camera.radius to use as delta when
  44314. * pinch zoom is used.
  44315. */
  44316. pinchDeltaPercentage: number;
  44317. /**
  44318. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44319. */
  44320. axisXControlRadius: boolean;
  44321. /**
  44322. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44323. */
  44324. axisXControlHeight: boolean;
  44325. /**
  44326. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44327. */
  44328. axisXControlRotation: boolean;
  44329. /**
  44330. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44331. */
  44332. axisYControlRadius: boolean;
  44333. /**
  44334. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44335. */
  44336. axisYControlHeight: boolean;
  44337. /**
  44338. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44339. */
  44340. axisYControlRotation: boolean;
  44341. /**
  44342. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44343. */
  44344. axisPinchControlRadius: boolean;
  44345. /**
  44346. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44347. */
  44348. axisPinchControlHeight: boolean;
  44349. /**
  44350. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44351. */
  44352. axisPinchControlRotation: boolean;
  44353. /**
  44354. * Log error messages if basic misconfiguration has occurred.
  44355. */
  44356. warningEnable: boolean;
  44357. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44358. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44359. private _warningCounter;
  44360. private _warning;
  44361. }
  44362. }
  44363. declare module BABYLON {
  44364. /**
  44365. * Default Inputs manager for the FollowCamera.
  44366. * It groups all the default supported inputs for ease of use.
  44367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44368. */
  44369. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44370. /**
  44371. * Instantiates a new FollowCameraInputsManager.
  44372. * @param camera Defines the camera the inputs belong to
  44373. */
  44374. constructor(camera: FollowCamera);
  44375. /**
  44376. * Add keyboard input support to the input manager.
  44377. * @returns the current input manager
  44378. */
  44379. addKeyboard(): FollowCameraInputsManager;
  44380. /**
  44381. * Add mouse wheel input support to the input manager.
  44382. * @returns the current input manager
  44383. */
  44384. addMouseWheel(): FollowCameraInputsManager;
  44385. /**
  44386. * Add pointers input support to the input manager.
  44387. * @returns the current input manager
  44388. */
  44389. addPointers(): FollowCameraInputsManager;
  44390. /**
  44391. * Add orientation input support to the input manager.
  44392. * @returns the current input manager
  44393. */
  44394. addVRDeviceOrientation(): FollowCameraInputsManager;
  44395. }
  44396. }
  44397. declare module BABYLON {
  44398. /**
  44399. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44400. * an arc rotate version arcFollowCamera are available.
  44401. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44402. */
  44403. export class FollowCamera extends TargetCamera {
  44404. /**
  44405. * Distance the follow camera should follow an object at
  44406. */
  44407. radius: number;
  44408. /**
  44409. * Minimum allowed distance of the camera to the axis of rotation
  44410. * (The camera can not get closer).
  44411. * This can help limiting how the Camera is able to move in the scene.
  44412. */
  44413. lowerRadiusLimit: Nullable<number>;
  44414. /**
  44415. * Maximum allowed distance of the camera to the axis of rotation
  44416. * (The camera can not get further).
  44417. * This can help limiting how the Camera is able to move in the scene.
  44418. */
  44419. upperRadiusLimit: Nullable<number>;
  44420. /**
  44421. * Define a rotation offset between the camera and the object it follows
  44422. */
  44423. rotationOffset: number;
  44424. /**
  44425. * Minimum allowed angle to camera position relative to target object.
  44426. * This can help limiting how the Camera is able to move in the scene.
  44427. */
  44428. lowerRotationOffsetLimit: Nullable<number>;
  44429. /**
  44430. * Maximum allowed angle to camera position relative to target object.
  44431. * This can help limiting how the Camera is able to move in the scene.
  44432. */
  44433. upperRotationOffsetLimit: Nullable<number>;
  44434. /**
  44435. * Define a height offset between the camera and the object it follows.
  44436. * It can help following an object from the top (like a car chaing a plane)
  44437. */
  44438. heightOffset: number;
  44439. /**
  44440. * Minimum allowed height of camera position relative to target object.
  44441. * This can help limiting how the Camera is able to move in the scene.
  44442. */
  44443. lowerHeightOffsetLimit: Nullable<number>;
  44444. /**
  44445. * Maximum allowed height of camera position relative to target object.
  44446. * This can help limiting how the Camera is able to move in the scene.
  44447. */
  44448. upperHeightOffsetLimit: Nullable<number>;
  44449. /**
  44450. * Define how fast the camera can accelerate to follow it s target.
  44451. */
  44452. cameraAcceleration: number;
  44453. /**
  44454. * Define the speed limit of the camera following an object.
  44455. */
  44456. maxCameraSpeed: number;
  44457. /**
  44458. * Define the target of the camera.
  44459. */
  44460. lockedTarget: Nullable<AbstractMesh>;
  44461. /**
  44462. * Defines the input associated with the camera.
  44463. */
  44464. inputs: FollowCameraInputsManager;
  44465. /**
  44466. * Instantiates the follow camera.
  44467. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44468. * @param name Define the name of the camera in the scene
  44469. * @param position Define the position of the camera
  44470. * @param scene Define the scene the camera belong to
  44471. * @param lockedTarget Define the target of the camera
  44472. */
  44473. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44474. private _follow;
  44475. /**
  44476. * Attached controls to the current camera.
  44477. * @param element Defines the element the controls should be listened from
  44478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44479. */
  44480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44481. /**
  44482. * Detach the current controls from the camera.
  44483. * The camera will stop reacting to inputs.
  44484. * @param element Defines the element to stop listening the inputs from
  44485. */
  44486. detachControl(element: HTMLElement): void;
  44487. /** @hidden */
  44488. _checkInputs(): void;
  44489. private _checkLimits;
  44490. /**
  44491. * Gets the camera class name.
  44492. * @returns the class name
  44493. */
  44494. getClassName(): string;
  44495. }
  44496. /**
  44497. * Arc Rotate version of the follow camera.
  44498. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44499. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44500. */
  44501. export class ArcFollowCamera extends TargetCamera {
  44502. /** The longitudinal angle of the camera */
  44503. alpha: number;
  44504. /** The latitudinal angle of the camera */
  44505. beta: number;
  44506. /** The radius of the camera from its target */
  44507. radius: number;
  44508. /** Define the camera target (the mesh it should follow) */
  44509. target: Nullable<AbstractMesh>;
  44510. private _cartesianCoordinates;
  44511. /**
  44512. * Instantiates a new ArcFollowCamera
  44513. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44514. * @param name Define the name of the camera
  44515. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44516. * @param beta Define the rotation angle of the camera around the elevation axis
  44517. * @param radius Define the radius of the camera from its target point
  44518. * @param target Define the target of the camera
  44519. * @param scene Define the scene the camera belongs to
  44520. */
  44521. constructor(name: string,
  44522. /** The longitudinal angle of the camera */
  44523. alpha: number,
  44524. /** The latitudinal angle of the camera */
  44525. beta: number,
  44526. /** The radius of the camera from its target */
  44527. radius: number,
  44528. /** Define the camera target (the mesh it should follow) */
  44529. target: Nullable<AbstractMesh>, scene: Scene);
  44530. private _follow;
  44531. /** @hidden */
  44532. _checkInputs(): void;
  44533. /**
  44534. * Returns the class name of the object.
  44535. * It is mostly used internally for serialization purposes.
  44536. */
  44537. getClassName(): string;
  44538. }
  44539. }
  44540. declare module BABYLON {
  44541. /**
  44542. * Manage the keyboard inputs to control the movement of a follow camera.
  44543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44544. */
  44545. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44546. /**
  44547. * Defines the camera the input is attached to.
  44548. */
  44549. camera: FollowCamera;
  44550. /**
  44551. * Defines the list of key codes associated with the up action (increase heightOffset)
  44552. */
  44553. keysHeightOffsetIncr: number[];
  44554. /**
  44555. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44556. */
  44557. keysHeightOffsetDecr: number[];
  44558. /**
  44559. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44560. */
  44561. keysHeightOffsetModifierAlt: boolean;
  44562. /**
  44563. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44564. */
  44565. keysHeightOffsetModifierCtrl: boolean;
  44566. /**
  44567. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44568. */
  44569. keysHeightOffsetModifierShift: boolean;
  44570. /**
  44571. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44572. */
  44573. keysRotationOffsetIncr: number[];
  44574. /**
  44575. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44576. */
  44577. keysRotationOffsetDecr: number[];
  44578. /**
  44579. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44580. */
  44581. keysRotationOffsetModifierAlt: boolean;
  44582. /**
  44583. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44584. */
  44585. keysRotationOffsetModifierCtrl: boolean;
  44586. /**
  44587. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44588. */
  44589. keysRotationOffsetModifierShift: boolean;
  44590. /**
  44591. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44592. */
  44593. keysRadiusIncr: number[];
  44594. /**
  44595. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44596. */
  44597. keysRadiusDecr: number[];
  44598. /**
  44599. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44600. */
  44601. keysRadiusModifierAlt: boolean;
  44602. /**
  44603. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44604. */
  44605. keysRadiusModifierCtrl: boolean;
  44606. /**
  44607. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44608. */
  44609. keysRadiusModifierShift: boolean;
  44610. /**
  44611. * Defines the rate of change of heightOffset.
  44612. */
  44613. heightSensibility: number;
  44614. /**
  44615. * Defines the rate of change of rotationOffset.
  44616. */
  44617. rotationSensibility: number;
  44618. /**
  44619. * Defines the rate of change of radius.
  44620. */
  44621. radiusSensibility: number;
  44622. private _keys;
  44623. private _ctrlPressed;
  44624. private _altPressed;
  44625. private _shiftPressed;
  44626. private _onCanvasBlurObserver;
  44627. private _onKeyboardObserver;
  44628. private _engine;
  44629. private _scene;
  44630. /**
  44631. * Attach the input controls to a specific dom element to get the input from.
  44632. * @param element Defines the element the controls should be listened from
  44633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44634. */
  44635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44636. /**
  44637. * Detach the current controls from the specified dom element.
  44638. * @param element Defines the element to stop listening the inputs from
  44639. */
  44640. detachControl(element: Nullable<HTMLElement>): void;
  44641. /**
  44642. * Update the current camera state depending on the inputs that have been used this frame.
  44643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44644. */
  44645. checkInputs(): void;
  44646. /**
  44647. * Gets the class name of the current input.
  44648. * @returns the class name
  44649. */
  44650. getClassName(): string;
  44651. /**
  44652. * Get the friendly name associated with the input class.
  44653. * @returns the input friendly name
  44654. */
  44655. getSimpleName(): string;
  44656. /**
  44657. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44658. * allow modification of the heightOffset value.
  44659. */
  44660. private _modifierHeightOffset;
  44661. /**
  44662. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44663. * allow modification of the rotationOffset value.
  44664. */
  44665. private _modifierRotationOffset;
  44666. /**
  44667. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44668. * allow modification of the radius value.
  44669. */
  44670. private _modifierRadius;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. interface FreeCameraInputsManager {
  44675. /**
  44676. * @hidden
  44677. */
  44678. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44679. /**
  44680. * Add orientation input support to the input manager.
  44681. * @returns the current input manager
  44682. */
  44683. addDeviceOrientation(): FreeCameraInputsManager;
  44684. }
  44685. /**
  44686. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44687. * Screen rotation is taken into account.
  44688. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44689. */
  44690. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44691. private _camera;
  44692. private _screenOrientationAngle;
  44693. private _constantTranform;
  44694. private _screenQuaternion;
  44695. private _alpha;
  44696. private _beta;
  44697. private _gamma;
  44698. /**
  44699. * Can be used to detect if a device orientation sensor is available on a device
  44700. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44701. * @returns a promise that will resolve on orientation change
  44702. */
  44703. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44704. /**
  44705. * @hidden
  44706. */
  44707. _onDeviceOrientationChangedObservable: Observable<void>;
  44708. /**
  44709. * Instantiates a new input
  44710. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44711. */
  44712. constructor();
  44713. /**
  44714. * Define the camera controlled by the input.
  44715. */
  44716. get camera(): FreeCamera;
  44717. set camera(camera: FreeCamera);
  44718. /**
  44719. * Attach the input controls to a specific dom element to get the input from.
  44720. * @param element Defines the element the controls should be listened from
  44721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44722. */
  44723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44724. private _orientationChanged;
  44725. private _deviceOrientation;
  44726. /**
  44727. * Detach the current controls from the specified dom element.
  44728. * @param element Defines the element to stop listening the inputs from
  44729. */
  44730. detachControl(element: Nullable<HTMLElement>): void;
  44731. /**
  44732. * Update the current camera state depending on the inputs that have been used this frame.
  44733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44734. */
  44735. checkInputs(): void;
  44736. /**
  44737. * Gets the class name of the current intput.
  44738. * @returns the class name
  44739. */
  44740. getClassName(): string;
  44741. /**
  44742. * Get the friendly name associated with the input class.
  44743. * @returns the input friendly name
  44744. */
  44745. getSimpleName(): string;
  44746. }
  44747. }
  44748. declare module BABYLON {
  44749. /**
  44750. * Manage the gamepad inputs to control a free camera.
  44751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44752. */
  44753. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44754. /**
  44755. * Define the camera the input is attached to.
  44756. */
  44757. camera: FreeCamera;
  44758. /**
  44759. * Define the Gamepad controlling the input
  44760. */
  44761. gamepad: Nullable<Gamepad>;
  44762. /**
  44763. * Defines the gamepad rotation sensiblity.
  44764. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44765. */
  44766. gamepadAngularSensibility: number;
  44767. /**
  44768. * Defines the gamepad move sensiblity.
  44769. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44770. */
  44771. gamepadMoveSensibility: number;
  44772. private _yAxisScale;
  44773. /**
  44774. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44775. */
  44776. get invertYAxis(): boolean;
  44777. set invertYAxis(value: boolean);
  44778. private _onGamepadConnectedObserver;
  44779. private _onGamepadDisconnectedObserver;
  44780. private _cameraTransform;
  44781. private _deltaTransform;
  44782. private _vector3;
  44783. private _vector2;
  44784. /**
  44785. * Attach the input controls to a specific dom element to get the input from.
  44786. * @param element Defines the element the controls should be listened from
  44787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44788. */
  44789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44790. /**
  44791. * Detach the current controls from the specified dom element.
  44792. * @param element Defines the element to stop listening the inputs from
  44793. */
  44794. detachControl(element: Nullable<HTMLElement>): void;
  44795. /**
  44796. * Update the current camera state depending on the inputs that have been used this frame.
  44797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44798. */
  44799. checkInputs(): void;
  44800. /**
  44801. * Gets the class name of the current intput.
  44802. * @returns the class name
  44803. */
  44804. getClassName(): string;
  44805. /**
  44806. * Get the friendly name associated with the input class.
  44807. * @returns the input friendly name
  44808. */
  44809. getSimpleName(): string;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * Defines the potential axis of a Joystick
  44815. */
  44816. export enum JoystickAxis {
  44817. /** X axis */
  44818. X = 0,
  44819. /** Y axis */
  44820. Y = 1,
  44821. /** Z axis */
  44822. Z = 2
  44823. }
  44824. /**
  44825. * Represents the different customization options available
  44826. * for VirtualJoystick
  44827. */
  44828. interface VirtualJoystickCustomizations {
  44829. /**
  44830. * Size of the joystick's puck
  44831. */
  44832. puckSize: number;
  44833. /**
  44834. * Size of the joystick's container
  44835. */
  44836. containerSize: number;
  44837. /**
  44838. * Color of the joystick && puck
  44839. */
  44840. color: string;
  44841. /**
  44842. * Image URL for the joystick's puck
  44843. */
  44844. puckImage?: string;
  44845. /**
  44846. * Image URL for the joystick's container
  44847. */
  44848. containerImage?: string;
  44849. /**
  44850. * Defines the unmoving position of the joystick container
  44851. */
  44852. position?: {
  44853. x: number;
  44854. y: number;
  44855. };
  44856. /**
  44857. * Defines whether or not the joystick container is always visible
  44858. */
  44859. alwaysVisible: boolean;
  44860. /**
  44861. * Defines whether or not to limit the movement of the puck to the joystick's container
  44862. */
  44863. limitToContainer: boolean;
  44864. }
  44865. /**
  44866. * Class used to define virtual joystick (used in touch mode)
  44867. */
  44868. export class VirtualJoystick {
  44869. /**
  44870. * Gets or sets a boolean indicating that left and right values must be inverted
  44871. */
  44872. reverseLeftRight: boolean;
  44873. /**
  44874. * Gets or sets a boolean indicating that up and down values must be inverted
  44875. */
  44876. reverseUpDown: boolean;
  44877. /**
  44878. * Gets the offset value for the position (ie. the change of the position value)
  44879. */
  44880. deltaPosition: Vector3;
  44881. /**
  44882. * Gets a boolean indicating if the virtual joystick was pressed
  44883. */
  44884. pressed: boolean;
  44885. /**
  44886. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44887. */
  44888. static Canvas: Nullable<HTMLCanvasElement>;
  44889. /**
  44890. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44891. */
  44892. limitToContainer: boolean;
  44893. private static _globalJoystickIndex;
  44894. private static _alwaysVisibleSticks;
  44895. private static vjCanvasContext;
  44896. private static vjCanvasWidth;
  44897. private static vjCanvasHeight;
  44898. private static halfWidth;
  44899. private static _GetDefaultOptions;
  44900. private _action;
  44901. private _axisTargetedByLeftAndRight;
  44902. private _axisTargetedByUpAndDown;
  44903. private _joystickSensibility;
  44904. private _inversedSensibility;
  44905. private _joystickPointerID;
  44906. private _joystickColor;
  44907. private _joystickPointerPos;
  44908. private _joystickPreviousPointerPos;
  44909. private _joystickPointerStartPos;
  44910. private _deltaJoystickVector;
  44911. private _leftJoystick;
  44912. private _touches;
  44913. private _joystickPosition;
  44914. private _alwaysVisible;
  44915. private _puckImage;
  44916. private _containerImage;
  44917. private _joystickPuckSize;
  44918. private _joystickContainerSize;
  44919. private _clearPuckSize;
  44920. private _clearContainerSize;
  44921. private _clearPuckSizeOffset;
  44922. private _clearContainerSizeOffset;
  44923. private _onPointerDownHandlerRef;
  44924. private _onPointerMoveHandlerRef;
  44925. private _onPointerUpHandlerRef;
  44926. private _onResize;
  44927. /**
  44928. * Creates a new virtual joystick
  44929. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44930. * @param customizations Defines the options we want to customize the VirtualJoystick
  44931. */
  44932. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44933. /**
  44934. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44935. * @param newJoystickSensibility defines the new sensibility
  44936. */
  44937. setJoystickSensibility(newJoystickSensibility: number): void;
  44938. private _onPointerDown;
  44939. private _onPointerMove;
  44940. private _onPointerUp;
  44941. /**
  44942. * Change the color of the virtual joystick
  44943. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44944. */
  44945. setJoystickColor(newColor: string): void;
  44946. /**
  44947. * Size of the joystick's container
  44948. */
  44949. set containerSize(newSize: number);
  44950. get containerSize(): number;
  44951. /**
  44952. * Size of the joystick's puck
  44953. */
  44954. set puckSize(newSize: number);
  44955. get puckSize(): number;
  44956. /**
  44957. * Clears the set position of the joystick
  44958. */
  44959. clearPosition(): void;
  44960. /**
  44961. * Defines whether or not the joystick container is always visible
  44962. */
  44963. set alwaysVisible(value: boolean);
  44964. get alwaysVisible(): boolean;
  44965. /**
  44966. * Sets the constant position of the Joystick container
  44967. * @param x X axis coordinate
  44968. * @param y Y axis coordinate
  44969. */
  44970. setPosition(x: number, y: number): void;
  44971. /**
  44972. * Defines a callback to call when the joystick is touched
  44973. * @param action defines the callback
  44974. */
  44975. setActionOnTouch(action: () => any): void;
  44976. /**
  44977. * Defines which axis you'd like to control for left & right
  44978. * @param axis defines the axis to use
  44979. */
  44980. setAxisForLeftRight(axis: JoystickAxis): void;
  44981. /**
  44982. * Defines which axis you'd like to control for up & down
  44983. * @param axis defines the axis to use
  44984. */
  44985. setAxisForUpDown(axis: JoystickAxis): void;
  44986. /**
  44987. * Clears the canvas from the previous puck / container draw
  44988. */
  44989. private _clearPreviousDraw;
  44990. /**
  44991. * Loads `urlPath` to be used for the container's image
  44992. * @param urlPath defines the urlPath of an image to use
  44993. */
  44994. setContainerImage(urlPath: string): void;
  44995. /**
  44996. * Loads `urlPath` to be used for the puck's image
  44997. * @param urlPath defines the urlPath of an image to use
  44998. */
  44999. setPuckImage(urlPath: string): void;
  45000. /**
  45001. * Draws the Virtual Joystick's container
  45002. */
  45003. private _drawContainer;
  45004. /**
  45005. * Draws the Virtual Joystick's puck
  45006. */
  45007. private _drawPuck;
  45008. private _drawVirtualJoystick;
  45009. /**
  45010. * Release internal HTML canvas
  45011. */
  45012. releaseCanvas(): void;
  45013. }
  45014. }
  45015. declare module BABYLON {
  45016. interface FreeCameraInputsManager {
  45017. /**
  45018. * Add virtual joystick input support to the input manager.
  45019. * @returns the current input manager
  45020. */
  45021. addVirtualJoystick(): FreeCameraInputsManager;
  45022. }
  45023. /**
  45024. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45026. */
  45027. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45028. /**
  45029. * Defines the camera the input is attached to.
  45030. */
  45031. camera: FreeCamera;
  45032. private _leftjoystick;
  45033. private _rightjoystick;
  45034. /**
  45035. * Gets the left stick of the virtual joystick.
  45036. * @returns The virtual Joystick
  45037. */
  45038. getLeftJoystick(): VirtualJoystick;
  45039. /**
  45040. * Gets the right stick of the virtual joystick.
  45041. * @returns The virtual Joystick
  45042. */
  45043. getRightJoystick(): VirtualJoystick;
  45044. /**
  45045. * Update the current camera state depending on the inputs that have been used this frame.
  45046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45047. */
  45048. checkInputs(): void;
  45049. /**
  45050. * Attach the input controls to a specific dom element to get the input from.
  45051. * @param element Defines the element the controls should be listened from
  45052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45053. */
  45054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45055. /**
  45056. * Detach the current controls from the specified dom element.
  45057. * @param element Defines the element to stop listening the inputs from
  45058. */
  45059. detachControl(element: Nullable<HTMLElement>): void;
  45060. /**
  45061. * Gets the class name of the current intput.
  45062. * @returns the class name
  45063. */
  45064. getClassName(): string;
  45065. /**
  45066. * Get the friendly name associated with the input class.
  45067. * @returns the input friendly name
  45068. */
  45069. getSimpleName(): string;
  45070. }
  45071. }
  45072. declare module BABYLON {
  45073. /**
  45074. * This represents a FPS type of camera controlled by touch.
  45075. * This is like a universal camera minus the Gamepad controls.
  45076. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45077. */
  45078. export class TouchCamera extends FreeCamera {
  45079. /**
  45080. * Defines the touch sensibility for rotation.
  45081. * The higher the faster.
  45082. */
  45083. get touchAngularSensibility(): number;
  45084. set touchAngularSensibility(value: number);
  45085. /**
  45086. * Defines the touch sensibility for move.
  45087. * The higher the faster.
  45088. */
  45089. get touchMoveSensibility(): number;
  45090. set touchMoveSensibility(value: number);
  45091. /**
  45092. * Instantiates a new touch camera.
  45093. * This represents a FPS type of camera controlled by touch.
  45094. * This is like a universal camera minus the Gamepad controls.
  45095. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45096. * @param name Define the name of the camera in the scene
  45097. * @param position Define the start position of the camera in the scene
  45098. * @param scene Define the scene the camera belongs to
  45099. */
  45100. constructor(name: string, position: Vector3, scene: Scene);
  45101. /**
  45102. * Gets the current object class name.
  45103. * @return the class name
  45104. */
  45105. getClassName(): string;
  45106. /** @hidden */
  45107. _setupInputs(): void;
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. /**
  45112. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45113. * being tilted forward or back and left or right.
  45114. */
  45115. export class DeviceOrientationCamera extends FreeCamera {
  45116. private _initialQuaternion;
  45117. private _quaternionCache;
  45118. private _tmpDragQuaternion;
  45119. private _disablePointerInputWhenUsingDeviceOrientation;
  45120. /**
  45121. * Creates a new device orientation camera
  45122. * @param name The name of the camera
  45123. * @param position The start position camera
  45124. * @param scene The scene the camera belongs to
  45125. */
  45126. constructor(name: string, position: Vector3, scene: Scene);
  45127. /**
  45128. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45129. */
  45130. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45131. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45132. private _dragFactor;
  45133. /**
  45134. * Enabled turning on the y axis when the orientation sensor is active
  45135. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45136. */
  45137. enableHorizontalDragging(dragFactor?: number): void;
  45138. /**
  45139. * Gets the current instance class name ("DeviceOrientationCamera").
  45140. * This helps avoiding instanceof at run time.
  45141. * @returns the class name
  45142. */
  45143. getClassName(): string;
  45144. /**
  45145. * @hidden
  45146. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45147. */
  45148. _checkInputs(): void;
  45149. /**
  45150. * Reset the camera to its default orientation on the specified axis only.
  45151. * @param axis The axis to reset
  45152. */
  45153. resetToCurrentRotation(axis?: Axis): void;
  45154. }
  45155. }
  45156. declare module BABYLON {
  45157. /**
  45158. * Defines supported buttons for XBox360 compatible gamepads
  45159. */
  45160. export enum Xbox360Button {
  45161. /** A */
  45162. A = 0,
  45163. /** B */
  45164. B = 1,
  45165. /** X */
  45166. X = 2,
  45167. /** Y */
  45168. Y = 3,
  45169. /** Left button */
  45170. LB = 4,
  45171. /** Right button */
  45172. RB = 5,
  45173. /** Back */
  45174. Back = 8,
  45175. /** Start */
  45176. Start = 9,
  45177. /** Left stick */
  45178. LeftStick = 10,
  45179. /** Right stick */
  45180. RightStick = 11
  45181. }
  45182. /** Defines values for XBox360 DPad */
  45183. export enum Xbox360Dpad {
  45184. /** Up */
  45185. Up = 12,
  45186. /** Down */
  45187. Down = 13,
  45188. /** Left */
  45189. Left = 14,
  45190. /** Right */
  45191. Right = 15
  45192. }
  45193. /**
  45194. * Defines a XBox360 gamepad
  45195. */
  45196. export class Xbox360Pad extends Gamepad {
  45197. private _leftTrigger;
  45198. private _rightTrigger;
  45199. private _onlefttriggerchanged;
  45200. private _onrighttriggerchanged;
  45201. private _onbuttondown;
  45202. private _onbuttonup;
  45203. private _ondpaddown;
  45204. private _ondpadup;
  45205. /** Observable raised when a button is pressed */
  45206. onButtonDownObservable: Observable<Xbox360Button>;
  45207. /** Observable raised when a button is released */
  45208. onButtonUpObservable: Observable<Xbox360Button>;
  45209. /** Observable raised when a pad is pressed */
  45210. onPadDownObservable: Observable<Xbox360Dpad>;
  45211. /** Observable raised when a pad is released */
  45212. onPadUpObservable: Observable<Xbox360Dpad>;
  45213. private _buttonA;
  45214. private _buttonB;
  45215. private _buttonX;
  45216. private _buttonY;
  45217. private _buttonBack;
  45218. private _buttonStart;
  45219. private _buttonLB;
  45220. private _buttonRB;
  45221. private _buttonLeftStick;
  45222. private _buttonRightStick;
  45223. private _dPadUp;
  45224. private _dPadDown;
  45225. private _dPadLeft;
  45226. private _dPadRight;
  45227. private _isXboxOnePad;
  45228. /**
  45229. * Creates a new XBox360 gamepad object
  45230. * @param id defines the id of this gamepad
  45231. * @param index defines its index
  45232. * @param gamepad defines the internal HTML gamepad object
  45233. * @param xboxOne defines if it is a XBox One gamepad
  45234. */
  45235. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45236. /**
  45237. * Defines the callback to call when left trigger is pressed
  45238. * @param callback defines the callback to use
  45239. */
  45240. onlefttriggerchanged(callback: (value: number) => void): void;
  45241. /**
  45242. * Defines the callback to call when right trigger is pressed
  45243. * @param callback defines the callback to use
  45244. */
  45245. onrighttriggerchanged(callback: (value: number) => void): void;
  45246. /**
  45247. * Gets the left trigger value
  45248. */
  45249. get leftTrigger(): number;
  45250. /**
  45251. * Sets the left trigger value
  45252. */
  45253. set leftTrigger(newValue: number);
  45254. /**
  45255. * Gets the right trigger value
  45256. */
  45257. get rightTrigger(): number;
  45258. /**
  45259. * Sets the right trigger value
  45260. */
  45261. set rightTrigger(newValue: number);
  45262. /**
  45263. * Defines the callback to call when a button is pressed
  45264. * @param callback defines the callback to use
  45265. */
  45266. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45267. /**
  45268. * Defines the callback to call when a button is released
  45269. * @param callback defines the callback to use
  45270. */
  45271. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45272. /**
  45273. * Defines the callback to call when a pad is pressed
  45274. * @param callback defines the callback to use
  45275. */
  45276. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45277. /**
  45278. * Defines the callback to call when a pad is released
  45279. * @param callback defines the callback to use
  45280. */
  45281. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45282. private _setButtonValue;
  45283. private _setDPadValue;
  45284. /**
  45285. * Gets the value of the `A` button
  45286. */
  45287. get buttonA(): number;
  45288. /**
  45289. * Sets the value of the `A` button
  45290. */
  45291. set buttonA(value: number);
  45292. /**
  45293. * Gets the value of the `B` button
  45294. */
  45295. get buttonB(): number;
  45296. /**
  45297. * Sets the value of the `B` button
  45298. */
  45299. set buttonB(value: number);
  45300. /**
  45301. * Gets the value of the `X` button
  45302. */
  45303. get buttonX(): number;
  45304. /**
  45305. * Sets the value of the `X` button
  45306. */
  45307. set buttonX(value: number);
  45308. /**
  45309. * Gets the value of the `Y` button
  45310. */
  45311. get buttonY(): number;
  45312. /**
  45313. * Sets the value of the `Y` button
  45314. */
  45315. set buttonY(value: number);
  45316. /**
  45317. * Gets the value of the `Start` button
  45318. */
  45319. get buttonStart(): number;
  45320. /**
  45321. * Sets the value of the `Start` button
  45322. */
  45323. set buttonStart(value: number);
  45324. /**
  45325. * Gets the value of the `Back` button
  45326. */
  45327. get buttonBack(): number;
  45328. /**
  45329. * Sets the value of the `Back` button
  45330. */
  45331. set buttonBack(value: number);
  45332. /**
  45333. * Gets the value of the `Left` button
  45334. */
  45335. get buttonLB(): number;
  45336. /**
  45337. * Sets the value of the `Left` button
  45338. */
  45339. set buttonLB(value: number);
  45340. /**
  45341. * Gets the value of the `Right` button
  45342. */
  45343. get buttonRB(): number;
  45344. /**
  45345. * Sets the value of the `Right` button
  45346. */
  45347. set buttonRB(value: number);
  45348. /**
  45349. * Gets the value of the Left joystick
  45350. */
  45351. get buttonLeftStick(): number;
  45352. /**
  45353. * Sets the value of the Left joystick
  45354. */
  45355. set buttonLeftStick(value: number);
  45356. /**
  45357. * Gets the value of the Right joystick
  45358. */
  45359. get buttonRightStick(): number;
  45360. /**
  45361. * Sets the value of the Right joystick
  45362. */
  45363. set buttonRightStick(value: number);
  45364. /**
  45365. * Gets the value of D-pad up
  45366. */
  45367. get dPadUp(): number;
  45368. /**
  45369. * Sets the value of D-pad up
  45370. */
  45371. set dPadUp(value: number);
  45372. /**
  45373. * Gets the value of D-pad down
  45374. */
  45375. get dPadDown(): number;
  45376. /**
  45377. * Sets the value of D-pad down
  45378. */
  45379. set dPadDown(value: number);
  45380. /**
  45381. * Gets the value of D-pad left
  45382. */
  45383. get dPadLeft(): number;
  45384. /**
  45385. * Sets the value of D-pad left
  45386. */
  45387. set dPadLeft(value: number);
  45388. /**
  45389. * Gets the value of D-pad right
  45390. */
  45391. get dPadRight(): number;
  45392. /**
  45393. * Sets the value of D-pad right
  45394. */
  45395. set dPadRight(value: number);
  45396. /**
  45397. * Force the gamepad to synchronize with device values
  45398. */
  45399. update(): void;
  45400. /**
  45401. * Disposes the gamepad
  45402. */
  45403. dispose(): void;
  45404. }
  45405. }
  45406. declare module BABYLON {
  45407. /**
  45408. * Defines supported buttons for DualShock compatible gamepads
  45409. */
  45410. export enum DualShockButton {
  45411. /** Cross */
  45412. Cross = 0,
  45413. /** Circle */
  45414. Circle = 1,
  45415. /** Square */
  45416. Square = 2,
  45417. /** Triangle */
  45418. Triangle = 3,
  45419. /** L1 */
  45420. L1 = 4,
  45421. /** R1 */
  45422. R1 = 5,
  45423. /** Share */
  45424. Share = 8,
  45425. /** Options */
  45426. Options = 9,
  45427. /** Left stick */
  45428. LeftStick = 10,
  45429. /** Right stick */
  45430. RightStick = 11
  45431. }
  45432. /** Defines values for DualShock DPad */
  45433. export enum DualShockDpad {
  45434. /** Up */
  45435. Up = 12,
  45436. /** Down */
  45437. Down = 13,
  45438. /** Left */
  45439. Left = 14,
  45440. /** Right */
  45441. Right = 15
  45442. }
  45443. /**
  45444. * Defines a DualShock gamepad
  45445. */
  45446. export class DualShockPad extends Gamepad {
  45447. private _leftTrigger;
  45448. private _rightTrigger;
  45449. private _onlefttriggerchanged;
  45450. private _onrighttriggerchanged;
  45451. private _onbuttondown;
  45452. private _onbuttonup;
  45453. private _ondpaddown;
  45454. private _ondpadup;
  45455. /** Observable raised when a button is pressed */
  45456. onButtonDownObservable: Observable<DualShockButton>;
  45457. /** Observable raised when a button is released */
  45458. onButtonUpObservable: Observable<DualShockButton>;
  45459. /** Observable raised when a pad is pressed */
  45460. onPadDownObservable: Observable<DualShockDpad>;
  45461. /** Observable raised when a pad is released */
  45462. onPadUpObservable: Observable<DualShockDpad>;
  45463. private _buttonCross;
  45464. private _buttonCircle;
  45465. private _buttonSquare;
  45466. private _buttonTriangle;
  45467. private _buttonShare;
  45468. private _buttonOptions;
  45469. private _buttonL1;
  45470. private _buttonR1;
  45471. private _buttonLeftStick;
  45472. private _buttonRightStick;
  45473. private _dPadUp;
  45474. private _dPadDown;
  45475. private _dPadLeft;
  45476. private _dPadRight;
  45477. /**
  45478. * Creates a new DualShock gamepad object
  45479. * @param id defines the id of this gamepad
  45480. * @param index defines its index
  45481. * @param gamepad defines the internal HTML gamepad object
  45482. */
  45483. constructor(id: string, index: number, gamepad: any);
  45484. /**
  45485. * Defines the callback to call when left trigger is pressed
  45486. * @param callback defines the callback to use
  45487. */
  45488. onlefttriggerchanged(callback: (value: number) => void): void;
  45489. /**
  45490. * Defines the callback to call when right trigger is pressed
  45491. * @param callback defines the callback to use
  45492. */
  45493. onrighttriggerchanged(callback: (value: number) => void): void;
  45494. /**
  45495. * Gets the left trigger value
  45496. */
  45497. get leftTrigger(): number;
  45498. /**
  45499. * Sets the left trigger value
  45500. */
  45501. set leftTrigger(newValue: number);
  45502. /**
  45503. * Gets the right trigger value
  45504. */
  45505. get rightTrigger(): number;
  45506. /**
  45507. * Sets the right trigger value
  45508. */
  45509. set rightTrigger(newValue: number);
  45510. /**
  45511. * Defines the callback to call when a button is pressed
  45512. * @param callback defines the callback to use
  45513. */
  45514. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45515. /**
  45516. * Defines the callback to call when a button is released
  45517. * @param callback defines the callback to use
  45518. */
  45519. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45520. /**
  45521. * Defines the callback to call when a pad is pressed
  45522. * @param callback defines the callback to use
  45523. */
  45524. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45525. /**
  45526. * Defines the callback to call when a pad is released
  45527. * @param callback defines the callback to use
  45528. */
  45529. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45530. private _setButtonValue;
  45531. private _setDPadValue;
  45532. /**
  45533. * Gets the value of the `Cross` button
  45534. */
  45535. get buttonCross(): number;
  45536. /**
  45537. * Sets the value of the `Cross` button
  45538. */
  45539. set buttonCross(value: number);
  45540. /**
  45541. * Gets the value of the `Circle` button
  45542. */
  45543. get buttonCircle(): number;
  45544. /**
  45545. * Sets the value of the `Circle` button
  45546. */
  45547. set buttonCircle(value: number);
  45548. /**
  45549. * Gets the value of the `Square` button
  45550. */
  45551. get buttonSquare(): number;
  45552. /**
  45553. * Sets the value of the `Square` button
  45554. */
  45555. set buttonSquare(value: number);
  45556. /**
  45557. * Gets the value of the `Triangle` button
  45558. */
  45559. get buttonTriangle(): number;
  45560. /**
  45561. * Sets the value of the `Triangle` button
  45562. */
  45563. set buttonTriangle(value: number);
  45564. /**
  45565. * Gets the value of the `Options` button
  45566. */
  45567. get buttonOptions(): number;
  45568. /**
  45569. * Sets the value of the `Options` button
  45570. */
  45571. set buttonOptions(value: number);
  45572. /**
  45573. * Gets the value of the `Share` button
  45574. */
  45575. get buttonShare(): number;
  45576. /**
  45577. * Sets the value of the `Share` button
  45578. */
  45579. set buttonShare(value: number);
  45580. /**
  45581. * Gets the value of the `L1` button
  45582. */
  45583. get buttonL1(): number;
  45584. /**
  45585. * Sets the value of the `L1` button
  45586. */
  45587. set buttonL1(value: number);
  45588. /**
  45589. * Gets the value of the `R1` button
  45590. */
  45591. get buttonR1(): number;
  45592. /**
  45593. * Sets the value of the `R1` button
  45594. */
  45595. set buttonR1(value: number);
  45596. /**
  45597. * Gets the value of the Left joystick
  45598. */
  45599. get buttonLeftStick(): number;
  45600. /**
  45601. * Sets the value of the Left joystick
  45602. */
  45603. set buttonLeftStick(value: number);
  45604. /**
  45605. * Gets the value of the Right joystick
  45606. */
  45607. get buttonRightStick(): number;
  45608. /**
  45609. * Sets the value of the Right joystick
  45610. */
  45611. set buttonRightStick(value: number);
  45612. /**
  45613. * Gets the value of D-pad up
  45614. */
  45615. get dPadUp(): number;
  45616. /**
  45617. * Sets the value of D-pad up
  45618. */
  45619. set dPadUp(value: number);
  45620. /**
  45621. * Gets the value of D-pad down
  45622. */
  45623. get dPadDown(): number;
  45624. /**
  45625. * Sets the value of D-pad down
  45626. */
  45627. set dPadDown(value: number);
  45628. /**
  45629. * Gets the value of D-pad left
  45630. */
  45631. get dPadLeft(): number;
  45632. /**
  45633. * Sets the value of D-pad left
  45634. */
  45635. set dPadLeft(value: number);
  45636. /**
  45637. * Gets the value of D-pad right
  45638. */
  45639. get dPadRight(): number;
  45640. /**
  45641. * Sets the value of D-pad right
  45642. */
  45643. set dPadRight(value: number);
  45644. /**
  45645. * Force the gamepad to synchronize with device values
  45646. */
  45647. update(): void;
  45648. /**
  45649. * Disposes the gamepad
  45650. */
  45651. dispose(): void;
  45652. }
  45653. }
  45654. declare module BABYLON {
  45655. /**
  45656. * Manager for handling gamepads
  45657. */
  45658. export class GamepadManager {
  45659. private _scene?;
  45660. private _babylonGamepads;
  45661. private _oneGamepadConnected;
  45662. /** @hidden */
  45663. _isMonitoring: boolean;
  45664. private _gamepadEventSupported;
  45665. private _gamepadSupport?;
  45666. /**
  45667. * observable to be triggered when the gamepad controller has been connected
  45668. */
  45669. onGamepadConnectedObservable: Observable<Gamepad>;
  45670. /**
  45671. * observable to be triggered when the gamepad controller has been disconnected
  45672. */
  45673. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45674. private _onGamepadConnectedEvent;
  45675. private _onGamepadDisconnectedEvent;
  45676. /**
  45677. * Initializes the gamepad manager
  45678. * @param _scene BabylonJS scene
  45679. */
  45680. constructor(_scene?: Scene | undefined);
  45681. /**
  45682. * The gamepads in the game pad manager
  45683. */
  45684. get gamepads(): Gamepad[];
  45685. /**
  45686. * Get the gamepad controllers based on type
  45687. * @param type The type of gamepad controller
  45688. * @returns Nullable gamepad
  45689. */
  45690. getGamepadByType(type?: number): Nullable<Gamepad>;
  45691. /**
  45692. * Disposes the gamepad manager
  45693. */
  45694. dispose(): void;
  45695. private _addNewGamepad;
  45696. private _startMonitoringGamepads;
  45697. private _stopMonitoringGamepads;
  45698. /** @hidden */
  45699. _checkGamepadsStatus(): void;
  45700. private _updateGamepadObjects;
  45701. }
  45702. }
  45703. declare module BABYLON {
  45704. interface Scene {
  45705. /** @hidden */
  45706. _gamepadManager: Nullable<GamepadManager>;
  45707. /**
  45708. * Gets the gamepad manager associated with the scene
  45709. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45710. */
  45711. gamepadManager: GamepadManager;
  45712. }
  45713. /**
  45714. * Interface representing a free camera inputs manager
  45715. */
  45716. interface FreeCameraInputsManager {
  45717. /**
  45718. * Adds gamepad input support to the FreeCameraInputsManager.
  45719. * @returns the FreeCameraInputsManager
  45720. */
  45721. addGamepad(): FreeCameraInputsManager;
  45722. }
  45723. /**
  45724. * Interface representing an arc rotate camera inputs manager
  45725. */
  45726. interface ArcRotateCameraInputsManager {
  45727. /**
  45728. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45729. * @returns the camera inputs manager
  45730. */
  45731. addGamepad(): ArcRotateCameraInputsManager;
  45732. }
  45733. /**
  45734. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45735. */
  45736. export class GamepadSystemSceneComponent implements ISceneComponent {
  45737. /**
  45738. * The component name helpfull to identify the component in the list of scene components.
  45739. */
  45740. readonly name: string;
  45741. /**
  45742. * The scene the component belongs to.
  45743. */
  45744. scene: Scene;
  45745. /**
  45746. * Creates a new instance of the component for the given scene
  45747. * @param scene Defines the scene to register the component in
  45748. */
  45749. constructor(scene: Scene);
  45750. /**
  45751. * Registers the component in a given scene
  45752. */
  45753. register(): void;
  45754. /**
  45755. * Rebuilds the elements related to this component in case of
  45756. * context lost for instance.
  45757. */
  45758. rebuild(): void;
  45759. /**
  45760. * Disposes the component and the associated ressources
  45761. */
  45762. dispose(): void;
  45763. private _beforeCameraUpdate;
  45764. }
  45765. }
  45766. declare module BABYLON {
  45767. /**
  45768. * 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,
  45769. * which still works and will still be found in many Playgrounds.
  45770. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45771. */
  45772. export class UniversalCamera extends TouchCamera {
  45773. /**
  45774. * Defines the gamepad rotation sensiblity.
  45775. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45776. */
  45777. get gamepadAngularSensibility(): number;
  45778. set gamepadAngularSensibility(value: number);
  45779. /**
  45780. * Defines the gamepad move sensiblity.
  45781. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45782. */
  45783. get gamepadMoveSensibility(): number;
  45784. set gamepadMoveSensibility(value: number);
  45785. /**
  45786. * 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,
  45787. * which still works and will still be found in many Playgrounds.
  45788. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45789. * @param name Define the name of the camera in the scene
  45790. * @param position Define the start position of the camera in the scene
  45791. * @param scene Define the scene the camera belongs to
  45792. */
  45793. constructor(name: string, position: Vector3, scene: Scene);
  45794. /**
  45795. * Gets the current object class name.
  45796. * @return the class name
  45797. */
  45798. getClassName(): string;
  45799. }
  45800. }
  45801. declare module BABYLON {
  45802. /**
  45803. * This represents a FPS type of camera. This is only here for back compat purpose.
  45804. * Please use the UniversalCamera instead as both are identical.
  45805. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45806. */
  45807. export class GamepadCamera extends UniversalCamera {
  45808. /**
  45809. * Instantiates a new Gamepad Camera
  45810. * This represents a FPS type of camera. This is only here for back compat purpose.
  45811. * Please use the UniversalCamera instead as both are identical.
  45812. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45813. * @param name Define the name of the camera in the scene
  45814. * @param position Define the start position of the camera in the scene
  45815. * @param scene Define the scene the camera belongs to
  45816. */
  45817. constructor(name: string, position: Vector3, scene: Scene);
  45818. /**
  45819. * Gets the current object class name.
  45820. * @return the class name
  45821. */
  45822. getClassName(): string;
  45823. }
  45824. }
  45825. declare module BABYLON {
  45826. /** @hidden */
  45827. export var passPixelShader: {
  45828. name: string;
  45829. shader: string;
  45830. };
  45831. }
  45832. declare module BABYLON {
  45833. /** @hidden */
  45834. export var passCubePixelShader: {
  45835. name: string;
  45836. shader: string;
  45837. };
  45838. }
  45839. declare module BABYLON {
  45840. /**
  45841. * PassPostProcess which produces an output the same as it's input
  45842. */
  45843. export class PassPostProcess extends PostProcess {
  45844. /**
  45845. * Creates the PassPostProcess
  45846. * @param name The name of the effect.
  45847. * @param options The required width/height ratio to downsize to before computing the render pass.
  45848. * @param camera The camera to apply the render pass to.
  45849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45850. * @param engine The engine which the post process will be applied. (default: current engine)
  45851. * @param reusable If the post process can be reused on the same frame. (default: false)
  45852. * @param textureType The type of texture to be used when performing the post processing.
  45853. * @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)
  45854. */
  45855. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45856. }
  45857. /**
  45858. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45859. */
  45860. export class PassCubePostProcess extends PostProcess {
  45861. private _face;
  45862. /**
  45863. * Gets or sets the cube face to display.
  45864. * * 0 is +X
  45865. * * 1 is -X
  45866. * * 2 is +Y
  45867. * * 3 is -Y
  45868. * * 4 is +Z
  45869. * * 5 is -Z
  45870. */
  45871. get face(): number;
  45872. set face(value: number);
  45873. /**
  45874. * Creates the PassCubePostProcess
  45875. * @param name The name of the effect.
  45876. * @param options The required width/height ratio to downsize to before computing the render pass.
  45877. * @param camera The camera to apply the render pass to.
  45878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45879. * @param engine The engine which the post process will be applied. (default: current engine)
  45880. * @param reusable If the post process can be reused on the same frame. (default: false)
  45881. * @param textureType The type of texture to be used when performing the post processing.
  45882. * @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)
  45883. */
  45884. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45885. }
  45886. }
  45887. declare module BABYLON {
  45888. /** @hidden */
  45889. export var anaglyphPixelShader: {
  45890. name: string;
  45891. shader: string;
  45892. };
  45893. }
  45894. declare module BABYLON {
  45895. /**
  45896. * Postprocess used to generate anaglyphic rendering
  45897. */
  45898. export class AnaglyphPostProcess extends PostProcess {
  45899. private _passedProcess;
  45900. /**
  45901. * Creates a new AnaglyphPostProcess
  45902. * @param name defines postprocess name
  45903. * @param options defines creation options or target ratio scale
  45904. * @param rigCameras defines cameras using this postprocess
  45905. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45906. * @param engine defines hosting engine
  45907. * @param reusable defines if the postprocess will be reused multiple times per frame
  45908. */
  45909. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45910. }
  45911. }
  45912. declare module BABYLON {
  45913. /**
  45914. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45915. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45916. */
  45917. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45918. /**
  45919. * Creates a new AnaglyphArcRotateCamera
  45920. * @param name defines camera name
  45921. * @param alpha defines alpha angle (in radians)
  45922. * @param beta defines beta angle (in radians)
  45923. * @param radius defines radius
  45924. * @param target defines camera target
  45925. * @param interaxialDistance defines distance between each color axis
  45926. * @param scene defines the hosting scene
  45927. */
  45928. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45929. /**
  45930. * Gets camera class name
  45931. * @returns AnaglyphArcRotateCamera
  45932. */
  45933. getClassName(): string;
  45934. }
  45935. }
  45936. declare module BABYLON {
  45937. /**
  45938. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45939. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45940. */
  45941. export class AnaglyphFreeCamera extends FreeCamera {
  45942. /**
  45943. * Creates a new AnaglyphFreeCamera
  45944. * @param name defines camera name
  45945. * @param position defines initial position
  45946. * @param interaxialDistance defines distance between each color axis
  45947. * @param scene defines the hosting scene
  45948. */
  45949. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45950. /**
  45951. * Gets camera class name
  45952. * @returns AnaglyphFreeCamera
  45953. */
  45954. getClassName(): string;
  45955. }
  45956. }
  45957. declare module BABYLON {
  45958. /**
  45959. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45960. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45961. */
  45962. export class AnaglyphGamepadCamera extends GamepadCamera {
  45963. /**
  45964. * Creates a new AnaglyphGamepadCamera
  45965. * @param name defines camera name
  45966. * @param position defines initial position
  45967. * @param interaxialDistance defines distance between each color axis
  45968. * @param scene defines the hosting scene
  45969. */
  45970. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45971. /**
  45972. * Gets camera class name
  45973. * @returns AnaglyphGamepadCamera
  45974. */
  45975. getClassName(): string;
  45976. }
  45977. }
  45978. declare module BABYLON {
  45979. /**
  45980. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45982. */
  45983. export class AnaglyphUniversalCamera extends UniversalCamera {
  45984. /**
  45985. * Creates a new AnaglyphUniversalCamera
  45986. * @param name defines camera name
  45987. * @param position defines initial position
  45988. * @param interaxialDistance defines distance between each color axis
  45989. * @param scene defines the hosting scene
  45990. */
  45991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45992. /**
  45993. * Gets camera class name
  45994. * @returns AnaglyphUniversalCamera
  45995. */
  45996. getClassName(): string;
  45997. }
  45998. }
  45999. declare module BABYLON {
  46000. /**
  46001. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46002. * @see https://doc.babylonjs.com/features/cameras
  46003. */
  46004. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46005. /**
  46006. * Creates a new StereoscopicArcRotateCamera
  46007. * @param name defines camera name
  46008. * @param alpha defines alpha angle (in radians)
  46009. * @param beta defines beta angle (in radians)
  46010. * @param radius defines radius
  46011. * @param target defines camera target
  46012. * @param interaxialDistance defines distance between each color axis
  46013. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46014. * @param scene defines the hosting scene
  46015. */
  46016. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46017. /**
  46018. * Gets camera class name
  46019. * @returns StereoscopicArcRotateCamera
  46020. */
  46021. getClassName(): string;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /**
  46026. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46027. * @see https://doc.babylonjs.com/features/cameras
  46028. */
  46029. export class StereoscopicFreeCamera extends FreeCamera {
  46030. /**
  46031. * Creates a new StereoscopicFreeCamera
  46032. * @param name defines camera name
  46033. * @param position defines initial position
  46034. * @param interaxialDistance defines distance between each color axis
  46035. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46036. * @param scene defines the hosting scene
  46037. */
  46038. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46039. /**
  46040. * Gets camera class name
  46041. * @returns StereoscopicFreeCamera
  46042. */
  46043. getClassName(): string;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46049. * @see https://doc.babylonjs.com/features/cameras
  46050. */
  46051. export class StereoscopicGamepadCamera extends GamepadCamera {
  46052. /**
  46053. * Creates a new StereoscopicGamepadCamera
  46054. * @param name defines camera name
  46055. * @param position defines initial position
  46056. * @param interaxialDistance defines distance between each color axis
  46057. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46058. * @param scene defines the hosting scene
  46059. */
  46060. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46061. /**
  46062. * Gets camera class name
  46063. * @returns StereoscopicGamepadCamera
  46064. */
  46065. getClassName(): string;
  46066. }
  46067. }
  46068. declare module BABYLON {
  46069. /**
  46070. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46071. * @see https://doc.babylonjs.com/features/cameras
  46072. */
  46073. export class StereoscopicUniversalCamera extends UniversalCamera {
  46074. /**
  46075. * Creates a new StereoscopicUniversalCamera
  46076. * @param name defines camera name
  46077. * @param position defines initial position
  46078. * @param interaxialDistance defines distance between each color axis
  46079. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46080. * @param scene defines the hosting scene
  46081. */
  46082. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46083. /**
  46084. * Gets camera class name
  46085. * @returns StereoscopicUniversalCamera
  46086. */
  46087. getClassName(): string;
  46088. }
  46089. }
  46090. declare module BABYLON {
  46091. /**
  46092. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46093. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46094. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46095. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46096. */
  46097. export class VirtualJoysticksCamera extends FreeCamera {
  46098. /**
  46099. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46100. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46101. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46102. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46103. * @param name Define the name of the camera in the scene
  46104. * @param position Define the start position of the camera in the scene
  46105. * @param scene Define the scene the camera belongs to
  46106. */
  46107. constructor(name: string, position: Vector3, scene: Scene);
  46108. /**
  46109. * Gets the current object class name.
  46110. * @return the class name
  46111. */
  46112. getClassName(): string;
  46113. }
  46114. }
  46115. declare module BABYLON {
  46116. /**
  46117. * This represents all the required metrics to create a VR camera.
  46118. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46119. */
  46120. export class VRCameraMetrics {
  46121. /**
  46122. * Define the horizontal resolution off the screen.
  46123. */
  46124. hResolution: number;
  46125. /**
  46126. * Define the vertical resolution off the screen.
  46127. */
  46128. vResolution: number;
  46129. /**
  46130. * Define the horizontal screen size.
  46131. */
  46132. hScreenSize: number;
  46133. /**
  46134. * Define the vertical screen size.
  46135. */
  46136. vScreenSize: number;
  46137. /**
  46138. * Define the vertical screen center position.
  46139. */
  46140. vScreenCenter: number;
  46141. /**
  46142. * Define the distance of the eyes to the screen.
  46143. */
  46144. eyeToScreenDistance: number;
  46145. /**
  46146. * Define the distance between both lenses
  46147. */
  46148. lensSeparationDistance: number;
  46149. /**
  46150. * Define the distance between both viewer's eyes.
  46151. */
  46152. interpupillaryDistance: number;
  46153. /**
  46154. * Define the distortion factor of the VR postprocess.
  46155. * Please, touch with care.
  46156. */
  46157. distortionK: number[];
  46158. /**
  46159. * Define the chromatic aberration correction factors for the VR post process.
  46160. */
  46161. chromaAbCorrection: number[];
  46162. /**
  46163. * Define the scale factor of the post process.
  46164. * The smaller the better but the slower.
  46165. */
  46166. postProcessScaleFactor: number;
  46167. /**
  46168. * Define an offset for the lens center.
  46169. */
  46170. lensCenterOffset: number;
  46171. /**
  46172. * Define if the current vr camera should compensate the distortion of the lense or not.
  46173. */
  46174. compensateDistortion: boolean;
  46175. /**
  46176. * Defines if multiview should be enabled when rendering (Default: false)
  46177. */
  46178. multiviewEnabled: boolean;
  46179. /**
  46180. * Gets the rendering aspect ratio based on the provided resolutions.
  46181. */
  46182. get aspectRatio(): number;
  46183. /**
  46184. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46185. */
  46186. get aspectRatioFov(): number;
  46187. /**
  46188. * @hidden
  46189. */
  46190. get leftHMatrix(): Matrix;
  46191. /**
  46192. * @hidden
  46193. */
  46194. get rightHMatrix(): Matrix;
  46195. /**
  46196. * @hidden
  46197. */
  46198. get leftPreViewMatrix(): Matrix;
  46199. /**
  46200. * @hidden
  46201. */
  46202. get rightPreViewMatrix(): Matrix;
  46203. /**
  46204. * Get the default VRMetrics based on the most generic setup.
  46205. * @returns the default vr metrics
  46206. */
  46207. static GetDefault(): VRCameraMetrics;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /** @hidden */
  46212. export var vrDistortionCorrectionPixelShader: {
  46213. name: string;
  46214. shader: string;
  46215. };
  46216. }
  46217. declare module BABYLON {
  46218. /**
  46219. * VRDistortionCorrectionPostProcess used for mobile VR
  46220. */
  46221. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46222. private _isRightEye;
  46223. private _distortionFactors;
  46224. private _postProcessScaleFactor;
  46225. private _lensCenterOffset;
  46226. private _scaleIn;
  46227. private _scaleFactor;
  46228. private _lensCenter;
  46229. /**
  46230. * Initializes the VRDistortionCorrectionPostProcess
  46231. * @param name The name of the effect.
  46232. * @param camera The camera to apply the render pass to.
  46233. * @param isRightEye If this is for the right eye distortion
  46234. * @param vrMetrics All the required metrics for the VR camera
  46235. */
  46236. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46237. }
  46238. }
  46239. declare module BABYLON {
  46240. /**
  46241. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46242. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46243. */
  46244. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46245. /**
  46246. * Creates a new VRDeviceOrientationArcRotateCamera
  46247. * @param name defines camera name
  46248. * @param alpha defines the camera rotation along the logitudinal axis
  46249. * @param beta defines the camera rotation along the latitudinal axis
  46250. * @param radius defines the camera distance from its target
  46251. * @param target defines the camera target
  46252. * @param scene defines the scene the camera belongs to
  46253. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46254. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46255. */
  46256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46257. /**
  46258. * Gets camera class name
  46259. * @returns VRDeviceOrientationArcRotateCamera
  46260. */
  46261. getClassName(): string;
  46262. }
  46263. }
  46264. declare module BABYLON {
  46265. /**
  46266. * Camera used to simulate VR rendering (based on FreeCamera)
  46267. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46268. */
  46269. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46270. /**
  46271. * Creates a new VRDeviceOrientationFreeCamera
  46272. * @param name defines camera name
  46273. * @param position defines the start position of the camera
  46274. * @param scene defines the scene the camera belongs to
  46275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46277. */
  46278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46279. /**
  46280. * Gets camera class name
  46281. * @returns VRDeviceOrientationFreeCamera
  46282. */
  46283. getClassName(): string;
  46284. }
  46285. }
  46286. declare module BABYLON {
  46287. /**
  46288. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46289. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46290. */
  46291. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46292. /**
  46293. * Creates a new VRDeviceOrientationGamepadCamera
  46294. * @param name defines camera name
  46295. * @param position defines the start position of the camera
  46296. * @param scene defines the scene the camera belongs to
  46297. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46298. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46299. */
  46300. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46301. /**
  46302. * Gets camera class name
  46303. * @returns VRDeviceOrientationGamepadCamera
  46304. */
  46305. getClassName(): string;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * A class extending Texture allowing drawing on a texture
  46311. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46312. */
  46313. export class DynamicTexture extends Texture {
  46314. private _generateMipMaps;
  46315. private _canvas;
  46316. private _context;
  46317. /**
  46318. * Creates a DynamicTexture
  46319. * @param name defines the name of the texture
  46320. * @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
  46321. * @param scene defines the scene where you want the texture
  46322. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46323. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46324. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46325. */
  46326. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46327. /**
  46328. * Get the current class name of the texture useful for serialization or dynamic coding.
  46329. * @returns "DynamicTexture"
  46330. */
  46331. getClassName(): string;
  46332. /**
  46333. * Gets the current state of canRescale
  46334. */
  46335. get canRescale(): boolean;
  46336. private _recreate;
  46337. /**
  46338. * Scales the texture
  46339. * @param ratio the scale factor to apply to both width and height
  46340. */
  46341. scale(ratio: number): void;
  46342. /**
  46343. * Resizes the texture
  46344. * @param width the new width
  46345. * @param height the new height
  46346. */
  46347. scaleTo(width: number, height: number): void;
  46348. /**
  46349. * Gets the context of the canvas used by the texture
  46350. * @returns the canvas context of the dynamic texture
  46351. */
  46352. getContext(): CanvasRenderingContext2D;
  46353. /**
  46354. * Clears the texture
  46355. */
  46356. clear(): void;
  46357. /**
  46358. * Updates the texture
  46359. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46360. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46361. */
  46362. update(invertY?: boolean, premulAlpha?: boolean): void;
  46363. /**
  46364. * Draws text onto the texture
  46365. * @param text defines the text to be drawn
  46366. * @param x defines the placement of the text from the left
  46367. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46368. * @param font defines the font to be used with font-style, font-size, font-name
  46369. * @param color defines the color used for the text
  46370. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46372. * @param update defines whether texture is immediately update (default is true)
  46373. */
  46374. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46375. /**
  46376. * Clones the texture
  46377. * @returns the clone of the texture.
  46378. */
  46379. clone(): DynamicTexture;
  46380. /**
  46381. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46382. * @returns a serialized dynamic texture object
  46383. */
  46384. serialize(): any;
  46385. private _IsCanvasElement;
  46386. /** @hidden */
  46387. _rebuild(): void;
  46388. }
  46389. }
  46390. declare module BABYLON {
  46391. /**
  46392. * Class containing static functions to help procedurally build meshes
  46393. */
  46394. export class GroundBuilder {
  46395. /**
  46396. * Creates a ground mesh
  46397. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46398. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46400. * @param name defines the name of the mesh
  46401. * @param options defines the options used to create the mesh
  46402. * @param scene defines the hosting scene
  46403. * @returns the ground mesh
  46404. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46405. */
  46406. static CreateGround(name: string, options: {
  46407. width?: number;
  46408. height?: number;
  46409. subdivisions?: number;
  46410. subdivisionsX?: number;
  46411. subdivisionsY?: number;
  46412. updatable?: boolean;
  46413. }, scene: any): Mesh;
  46414. /**
  46415. * Creates a tiled ground mesh
  46416. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46417. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46418. * * 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
  46419. * * 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
  46420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46421. * @param name defines the name of the mesh
  46422. * @param options defines the options used to create the mesh
  46423. * @param scene defines the hosting scene
  46424. * @returns the tiled ground mesh
  46425. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46426. */
  46427. static CreateTiledGround(name: string, options: {
  46428. xmin: number;
  46429. zmin: number;
  46430. xmax: number;
  46431. zmax: number;
  46432. subdivisions?: {
  46433. w: number;
  46434. h: number;
  46435. };
  46436. precision?: {
  46437. w: number;
  46438. h: number;
  46439. };
  46440. updatable?: boolean;
  46441. }, scene?: Nullable<Scene>): Mesh;
  46442. /**
  46443. * Creates a ground mesh from a height map
  46444. * * The parameter `url` sets the URL of the height map image resource.
  46445. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46446. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46447. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46448. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46449. * * 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.
  46450. * * 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).
  46451. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46453. * @param name defines the name of the mesh
  46454. * @param url defines the url to the height map
  46455. * @param options defines the options used to create the mesh
  46456. * @param scene defines the hosting scene
  46457. * @returns the ground mesh
  46458. * @see https://doc.babylonjs.com/babylon101/height_map
  46459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46460. */
  46461. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46462. width?: number;
  46463. height?: number;
  46464. subdivisions?: number;
  46465. minHeight?: number;
  46466. maxHeight?: number;
  46467. colorFilter?: Color3;
  46468. alphaFilter?: number;
  46469. updatable?: boolean;
  46470. onReady?: (mesh: GroundMesh) => void;
  46471. }, scene?: Nullable<Scene>): GroundMesh;
  46472. }
  46473. }
  46474. declare module BABYLON {
  46475. /**
  46476. * Class containing static functions to help procedurally build meshes
  46477. */
  46478. export class TorusBuilder {
  46479. /**
  46480. * Creates a torus mesh
  46481. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46482. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46483. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46485. * * 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
  46486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46487. * @param name defines the name of the mesh
  46488. * @param options defines the options used to create the mesh
  46489. * @param scene defines the hosting scene
  46490. * @returns the torus mesh
  46491. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46492. */
  46493. static CreateTorus(name: string, options: {
  46494. diameter?: number;
  46495. thickness?: number;
  46496. tessellation?: number;
  46497. updatable?: boolean;
  46498. sideOrientation?: number;
  46499. frontUVs?: Vector4;
  46500. backUVs?: Vector4;
  46501. }, scene: any): Mesh;
  46502. }
  46503. }
  46504. declare module BABYLON {
  46505. /**
  46506. * Class containing static functions to help procedurally build meshes
  46507. */
  46508. export class CylinderBuilder {
  46509. /**
  46510. * Creates a cylinder or a cone mesh
  46511. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46512. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46513. * * 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.
  46514. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46515. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46516. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46517. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46518. * * 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).
  46519. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46520. * * 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).
  46521. * * 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
  46522. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46523. * * 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
  46524. * * 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.
  46525. * * If `enclose` is false, a ring surface is one element.
  46526. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46527. * * 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
  46528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46529. * * 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
  46530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46531. * @param name defines the name of the mesh
  46532. * @param options defines the options used to create the mesh
  46533. * @param scene defines the hosting scene
  46534. * @returns the cylinder mesh
  46535. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46536. */
  46537. static CreateCylinder(name: string, options: {
  46538. height?: number;
  46539. diameterTop?: number;
  46540. diameterBottom?: number;
  46541. diameter?: number;
  46542. tessellation?: number;
  46543. subdivisions?: number;
  46544. arc?: number;
  46545. faceColors?: Color4[];
  46546. faceUV?: Vector4[];
  46547. updatable?: boolean;
  46548. hasRings?: boolean;
  46549. enclose?: boolean;
  46550. cap?: number;
  46551. sideOrientation?: number;
  46552. frontUVs?: Vector4;
  46553. backUVs?: Vector4;
  46554. }, scene: any): Mesh;
  46555. }
  46556. }
  46557. declare module BABYLON {
  46558. /**
  46559. * States of the webXR experience
  46560. */
  46561. export enum WebXRState {
  46562. /**
  46563. * Transitioning to being in XR mode
  46564. */
  46565. ENTERING_XR = 0,
  46566. /**
  46567. * Transitioning to non XR mode
  46568. */
  46569. EXITING_XR = 1,
  46570. /**
  46571. * In XR mode and presenting
  46572. */
  46573. IN_XR = 2,
  46574. /**
  46575. * Not entered XR mode
  46576. */
  46577. NOT_IN_XR = 3
  46578. }
  46579. /**
  46580. * Abstraction of the XR render target
  46581. */
  46582. export interface WebXRRenderTarget extends IDisposable {
  46583. /**
  46584. * xrpresent context of the canvas which can be used to display/mirror xr content
  46585. */
  46586. canvasContext: WebGLRenderingContext;
  46587. /**
  46588. * xr layer for the canvas
  46589. */
  46590. xrLayer: Nullable<XRWebGLLayer>;
  46591. /**
  46592. * Initializes the xr layer for the session
  46593. * @param xrSession xr session
  46594. * @returns a promise that will resolve once the XR Layer has been created
  46595. */
  46596. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46597. }
  46598. }
  46599. declare module BABYLON {
  46600. /**
  46601. * COnfiguration object for WebXR output canvas
  46602. */
  46603. export class WebXRManagedOutputCanvasOptions {
  46604. /**
  46605. * An optional canvas in case you wish to create it yourself and provide it here.
  46606. * If not provided, a new canvas will be created
  46607. */
  46608. canvasElement?: HTMLCanvasElement;
  46609. /**
  46610. * Options for this XR Layer output
  46611. */
  46612. canvasOptions?: XRWebGLLayerOptions;
  46613. /**
  46614. * CSS styling for a newly created canvas (if not provided)
  46615. */
  46616. newCanvasCssStyle?: string;
  46617. /**
  46618. * Get the default values of the configuration object
  46619. * @returns default values of this configuration object
  46620. */
  46621. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46622. }
  46623. /**
  46624. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46625. */
  46626. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46627. private _options;
  46628. private _canvas;
  46629. private _engine;
  46630. private _originalCanvasSize;
  46631. /**
  46632. * Rendering context of the canvas which can be used to display/mirror xr content
  46633. */
  46634. canvasContext: WebGLRenderingContext;
  46635. /**
  46636. * xr layer for the canvas
  46637. */
  46638. xrLayer: Nullable<XRWebGLLayer>;
  46639. /**
  46640. * Obseervers registered here will be triggered when the xr layer was initialized
  46641. */
  46642. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46643. /**
  46644. * Initializes the canvas to be added/removed upon entering/exiting xr
  46645. * @param _xrSessionManager The XR Session manager
  46646. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46647. */
  46648. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46649. /**
  46650. * Disposes of the object
  46651. */
  46652. dispose(): void;
  46653. /**
  46654. * Initializes the xr layer for the session
  46655. * @param xrSession xr session
  46656. * @returns a promise that will resolve once the XR Layer has been created
  46657. */
  46658. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46659. private _addCanvas;
  46660. private _removeCanvas;
  46661. private _setCanvasSize;
  46662. private _setManagedOutputCanvas;
  46663. }
  46664. }
  46665. declare module BABYLON {
  46666. /**
  46667. * Manages an XRSession to work with Babylon's engine
  46668. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46669. */
  46670. export class WebXRSessionManager implements IDisposable {
  46671. /** The scene which the session should be created for */
  46672. scene: Scene;
  46673. private _referenceSpace;
  46674. private _rttProvider;
  46675. private _sessionEnded;
  46676. private _xrNavigator;
  46677. private baseLayer;
  46678. /**
  46679. * The base reference space from which the session started. good if you want to reset your
  46680. * reference space
  46681. */
  46682. baseReferenceSpace: XRReferenceSpace;
  46683. /**
  46684. * Current XR frame
  46685. */
  46686. currentFrame: Nullable<XRFrame>;
  46687. /** WebXR timestamp updated every frame */
  46688. currentTimestamp: number;
  46689. /**
  46690. * Used just in case of a failure to initialize an immersive session.
  46691. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46692. */
  46693. defaultHeightCompensation: number;
  46694. /**
  46695. * Fires every time a new xrFrame arrives which can be used to update the camera
  46696. */
  46697. onXRFrameObservable: Observable<XRFrame>;
  46698. /**
  46699. * Fires when the reference space changed
  46700. */
  46701. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46702. /**
  46703. * Fires when the xr session is ended either by the device or manually done
  46704. */
  46705. onXRSessionEnded: Observable<any>;
  46706. /**
  46707. * Fires when the xr session is ended either by the device or manually done
  46708. */
  46709. onXRSessionInit: Observable<XRSession>;
  46710. /**
  46711. * Underlying xr session
  46712. */
  46713. session: XRSession;
  46714. /**
  46715. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46716. * or get the offset the player is currently at.
  46717. */
  46718. viewerReferenceSpace: XRReferenceSpace;
  46719. /**
  46720. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46721. * @param scene The scene which the session should be created for
  46722. */
  46723. constructor(
  46724. /** The scene which the session should be created for */
  46725. scene: Scene);
  46726. /**
  46727. * The current reference space used in this session. This reference space can constantly change!
  46728. * It is mainly used to offset the camera's position.
  46729. */
  46730. get referenceSpace(): XRReferenceSpace;
  46731. /**
  46732. * Set a new reference space and triggers the observable
  46733. */
  46734. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46735. /**
  46736. * Disposes of the session manager
  46737. */
  46738. dispose(): void;
  46739. /**
  46740. * Stops the xrSession and restores the render loop
  46741. * @returns Promise which resolves after it exits XR
  46742. */
  46743. exitXRAsync(): Promise<void>;
  46744. /**
  46745. * Gets the correct render target texture to be rendered this frame for this eye
  46746. * @param eye the eye for which to get the render target
  46747. * @returns the render target for the specified eye
  46748. */
  46749. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46750. /**
  46751. * Creates a WebXRRenderTarget object for the XR session
  46752. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46753. * @param options optional options to provide when creating a new render target
  46754. * @returns a WebXR render target to which the session can render
  46755. */
  46756. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46757. /**
  46758. * Initializes the manager
  46759. * After initialization enterXR can be called to start an XR session
  46760. * @returns Promise which resolves after it is initialized
  46761. */
  46762. initializeAsync(): Promise<void>;
  46763. /**
  46764. * Initializes an xr session
  46765. * @param xrSessionMode mode to initialize
  46766. * @param xrSessionInit defines optional and required values to pass to the session builder
  46767. * @returns a promise which will resolve once the session has been initialized
  46768. */
  46769. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46770. /**
  46771. * Checks if a session would be supported for the creation options specified
  46772. * @param sessionMode session mode to check if supported eg. immersive-vr
  46773. * @returns A Promise that resolves to true if supported and false if not
  46774. */
  46775. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46776. /**
  46777. * Resets the reference space to the one started the session
  46778. */
  46779. resetReferenceSpace(): void;
  46780. /**
  46781. * Starts rendering to the xr layer
  46782. */
  46783. runXRRenderLoop(): void;
  46784. /**
  46785. * Sets the reference space on the xr session
  46786. * @param referenceSpaceType space to set
  46787. * @returns a promise that will resolve once the reference space has been set
  46788. */
  46789. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46790. /**
  46791. * Updates the render state of the session
  46792. * @param state state to set
  46793. * @returns a promise that resolves once the render state has been updated
  46794. */
  46795. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46796. /**
  46797. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46798. * @param sessionMode defines the session to test
  46799. * @returns a promise with boolean as final value
  46800. */
  46801. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46802. private _createRenderTargetTexture;
  46803. }
  46804. }
  46805. declare module BABYLON {
  46806. /**
  46807. * WebXR Camera which holds the views for the xrSession
  46808. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46809. */
  46810. export class WebXRCamera extends FreeCamera {
  46811. private _xrSessionManager;
  46812. private _firstFrame;
  46813. private _referenceQuaternion;
  46814. private _referencedPosition;
  46815. private _xrInvPositionCache;
  46816. private _xrInvQuaternionCache;
  46817. /**
  46818. * Should position compensation execute on first frame.
  46819. * This is used when copying the position from a native (non XR) camera
  46820. */
  46821. compensateOnFirstFrame: boolean;
  46822. /**
  46823. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46824. * @param name the name of the camera
  46825. * @param scene the scene to add the camera to
  46826. * @param _xrSessionManager a constructed xr session manager
  46827. */
  46828. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46829. /**
  46830. * Return the user's height, unrelated to the current ground.
  46831. * This will be the y position of this camera, when ground level is 0.
  46832. */
  46833. get realWorldHeight(): number;
  46834. /** @hidden */
  46835. _updateForDualEyeDebugging(): void;
  46836. /**
  46837. * Sets this camera's transformation based on a non-vr camera
  46838. * @param otherCamera the non-vr camera to copy the transformation from
  46839. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46840. */
  46841. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46842. /**
  46843. * Gets the current instance class name ("WebXRCamera").
  46844. * @returns the class name
  46845. */
  46846. getClassName(): string;
  46847. private _rotate180;
  46848. private _updateFromXRSession;
  46849. private _updateNumberOfRigCameras;
  46850. private _updateReferenceSpace;
  46851. private _updateReferenceSpaceOffset;
  46852. }
  46853. }
  46854. declare module BABYLON {
  46855. /**
  46856. * Defining the interface required for a (webxr) feature
  46857. */
  46858. export interface IWebXRFeature extends IDisposable {
  46859. /**
  46860. * Is this feature attached
  46861. */
  46862. attached: boolean;
  46863. /**
  46864. * Should auto-attach be disabled?
  46865. */
  46866. disableAutoAttach: boolean;
  46867. /**
  46868. * Attach the feature to the session
  46869. * Will usually be called by the features manager
  46870. *
  46871. * @param force should attachment be forced (even when already attached)
  46872. * @returns true if successful.
  46873. */
  46874. attach(force?: boolean): boolean;
  46875. /**
  46876. * Detach the feature from the session
  46877. * Will usually be called by the features manager
  46878. *
  46879. * @returns true if successful.
  46880. */
  46881. detach(): boolean;
  46882. /**
  46883. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46884. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46885. *
  46886. * @returns whether or not the feature is compatible in this environment
  46887. */
  46888. isCompatible(): boolean;
  46889. /**
  46890. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46891. */
  46892. xrNativeFeatureName?: string;
  46893. }
  46894. /**
  46895. * A list of the currently available features without referencing them
  46896. */
  46897. export class WebXRFeatureName {
  46898. /**
  46899. * The name of the anchor system feature
  46900. */
  46901. static ANCHOR_SYSTEM: string;
  46902. /**
  46903. * The name of the background remover feature
  46904. */
  46905. static BACKGROUND_REMOVER: string;
  46906. /**
  46907. * The name of the hit test feature
  46908. */
  46909. static HIT_TEST: string;
  46910. /**
  46911. * physics impostors for xr controllers feature
  46912. */
  46913. static PHYSICS_CONTROLLERS: string;
  46914. /**
  46915. * The name of the plane detection feature
  46916. */
  46917. static PLANE_DETECTION: string;
  46918. /**
  46919. * The name of the pointer selection feature
  46920. */
  46921. static POINTER_SELECTION: string;
  46922. /**
  46923. * The name of the teleportation feature
  46924. */
  46925. static TELEPORTATION: string;
  46926. }
  46927. /**
  46928. * Defining the constructor of a feature. Used to register the modules.
  46929. */
  46930. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46931. /**
  46932. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46933. * It is mainly used in AR sessions.
  46934. *
  46935. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46936. */
  46937. export class WebXRFeaturesManager implements IDisposable {
  46938. private _xrSessionManager;
  46939. private static readonly _AvailableFeatures;
  46940. private _features;
  46941. /**
  46942. * constructs a new features manages.
  46943. *
  46944. * @param _xrSessionManager an instance of WebXRSessionManager
  46945. */
  46946. constructor(_xrSessionManager: WebXRSessionManager);
  46947. /**
  46948. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46949. * Mainly used internally.
  46950. *
  46951. * @param featureName the name of the feature to register
  46952. * @param constructorFunction the function used to construct the module
  46953. * @param version the (babylon) version of the module
  46954. * @param stable is that a stable version of this module
  46955. */
  46956. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46957. /**
  46958. * Returns a constructor of a specific feature.
  46959. *
  46960. * @param featureName the name of the feature to construct
  46961. * @param version the version of the feature to load
  46962. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46963. * @param options optional options provided to the module.
  46964. * @returns a function that, when called, will return a new instance of this feature
  46965. */
  46966. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46967. /**
  46968. * Can be used to return the list of features currently registered
  46969. *
  46970. * @returns an Array of available features
  46971. */
  46972. static GetAvailableFeatures(): string[];
  46973. /**
  46974. * Gets the versions available for a specific feature
  46975. * @param featureName the name of the feature
  46976. * @returns an array with the available versions
  46977. */
  46978. static GetAvailableVersions(featureName: string): string[];
  46979. /**
  46980. * Return the latest unstable version of this feature
  46981. * @param featureName the name of the feature to search
  46982. * @returns the version number. if not found will return -1
  46983. */
  46984. static GetLatestVersionOfFeature(featureName: string): number;
  46985. /**
  46986. * Return the latest stable version of this feature
  46987. * @param featureName the name of the feature to search
  46988. * @returns the version number. if not found will return -1
  46989. */
  46990. static GetStableVersionOfFeature(featureName: string): number;
  46991. /**
  46992. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46993. * Can be used during a session to start a feature
  46994. * @param featureName the name of feature to attach
  46995. */
  46996. attachFeature(featureName: string): void;
  46997. /**
  46998. * Can be used inside a session or when the session ends to detach a specific feature
  46999. * @param featureName the name of the feature to detach
  47000. */
  47001. detachFeature(featureName: string): void;
  47002. /**
  47003. * Used to disable an already-enabled feature
  47004. * The feature will be disposed and will be recreated once enabled.
  47005. * @param featureName the feature to disable
  47006. * @returns true if disable was successful
  47007. */
  47008. disableFeature(featureName: string | {
  47009. Name: string;
  47010. }): boolean;
  47011. /**
  47012. * dispose this features manager
  47013. */
  47014. dispose(): void;
  47015. /**
  47016. * 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.
  47017. * 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.
  47018. *
  47019. * @param featureName the name of the feature to load or the class of the feature
  47020. * @param version optional version to load. if not provided the latest version will be enabled
  47021. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47022. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47023. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47024. * @returns a new constructed feature or throws an error if feature not found.
  47025. */
  47026. enableFeature(featureName: string | {
  47027. Name: string;
  47028. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47029. /**
  47030. * get the implementation of an enabled feature.
  47031. * @param featureName the name of the feature to load
  47032. * @returns the feature class, if found
  47033. */
  47034. getEnabledFeature(featureName: string): IWebXRFeature;
  47035. /**
  47036. * Get the list of enabled features
  47037. * @returns an array of enabled features
  47038. */
  47039. getEnabledFeatures(): string[];
  47040. /**
  47041. * This function will exten the session creation configuration object with enabled features.
  47042. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47043. * according to the defined "required" variable, provided during enableFeature call
  47044. * @param xrSessionInit the xr Session init object to extend
  47045. *
  47046. * @returns an extended XRSessionInit object
  47047. */
  47048. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47054. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47055. */
  47056. export class WebXRExperienceHelper implements IDisposable {
  47057. private scene;
  47058. private _nonVRCamera;
  47059. private _originalSceneAutoClear;
  47060. private _supported;
  47061. /**
  47062. * Camera used to render xr content
  47063. */
  47064. camera: WebXRCamera;
  47065. /** A features manager for this xr session */
  47066. featuresManager: WebXRFeaturesManager;
  47067. /**
  47068. * Observers registered here will be triggered after the camera's initial transformation is set
  47069. * This can be used to set a different ground level or an extra rotation.
  47070. *
  47071. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47072. * to the position set after this observable is done executing.
  47073. */
  47074. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47075. /**
  47076. * Fires when the state of the experience helper has changed
  47077. */
  47078. onStateChangedObservable: Observable<WebXRState>;
  47079. /** Session manager used to keep track of xr session */
  47080. sessionManager: WebXRSessionManager;
  47081. /**
  47082. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47083. */
  47084. state: WebXRState;
  47085. /**
  47086. * Creates a WebXRExperienceHelper
  47087. * @param scene The scene the helper should be created in
  47088. */
  47089. private constructor();
  47090. /**
  47091. * Creates the experience helper
  47092. * @param scene the scene to attach the experience helper to
  47093. * @returns a promise for the experience helper
  47094. */
  47095. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47096. /**
  47097. * Disposes of the experience helper
  47098. */
  47099. dispose(): void;
  47100. /**
  47101. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47102. * @param sessionMode options for the XR session
  47103. * @param referenceSpaceType frame of reference of the XR session
  47104. * @param renderTarget the output canvas that will be used to enter XR mode
  47105. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47106. * @returns promise that resolves after xr mode has entered
  47107. */
  47108. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47109. /**
  47110. * Exits XR mode and returns the scene to its original state
  47111. * @returns promise that resolves after xr mode has exited
  47112. */
  47113. exitXRAsync(): Promise<void>;
  47114. private _nonXRToXRCamera;
  47115. private _setState;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. /**
  47120. * X-Y values for axes in WebXR
  47121. */
  47122. export interface IWebXRMotionControllerAxesValue {
  47123. /**
  47124. * The value of the x axis
  47125. */
  47126. x: number;
  47127. /**
  47128. * The value of the y-axis
  47129. */
  47130. y: number;
  47131. }
  47132. /**
  47133. * changed / previous values for the values of this component
  47134. */
  47135. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47136. /**
  47137. * current (this frame) value
  47138. */
  47139. current: T;
  47140. /**
  47141. * previous (last change) value
  47142. */
  47143. previous: T;
  47144. }
  47145. /**
  47146. * Represents changes in the component between current frame and last values recorded
  47147. */
  47148. export interface IWebXRMotionControllerComponentChanges {
  47149. /**
  47150. * will be populated with previous and current values if axes changed
  47151. */
  47152. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47153. /**
  47154. * will be populated with previous and current values if pressed changed
  47155. */
  47156. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47157. /**
  47158. * will be populated with previous and current values if touched changed
  47159. */
  47160. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47161. /**
  47162. * will be populated with previous and current values if value changed
  47163. */
  47164. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47165. }
  47166. /**
  47167. * This class represents a single component (for example button or thumbstick) of a motion controller
  47168. */
  47169. export class WebXRControllerComponent implements IDisposable {
  47170. /**
  47171. * the id of this component
  47172. */
  47173. id: string;
  47174. /**
  47175. * the type of the component
  47176. */
  47177. type: MotionControllerComponentType;
  47178. private _buttonIndex;
  47179. private _axesIndices;
  47180. private _axes;
  47181. private _changes;
  47182. private _currentValue;
  47183. private _hasChanges;
  47184. private _pressed;
  47185. private _touched;
  47186. /**
  47187. * button component type
  47188. */
  47189. static BUTTON_TYPE: MotionControllerComponentType;
  47190. /**
  47191. * squeeze component type
  47192. */
  47193. static SQUEEZE_TYPE: MotionControllerComponentType;
  47194. /**
  47195. * Thumbstick component type
  47196. */
  47197. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47198. /**
  47199. * Touchpad component type
  47200. */
  47201. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47202. /**
  47203. * trigger component type
  47204. */
  47205. static TRIGGER_TYPE: MotionControllerComponentType;
  47206. /**
  47207. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47208. * the axes data changes
  47209. */
  47210. onAxisValueChangedObservable: Observable<{
  47211. x: number;
  47212. y: number;
  47213. }>;
  47214. /**
  47215. * Observers registered here will be triggered when the state of a button changes
  47216. * State change is either pressed / touched / value
  47217. */
  47218. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47219. /**
  47220. * Creates a new component for a motion controller.
  47221. * It is created by the motion controller itself
  47222. *
  47223. * @param id the id of this component
  47224. * @param type the type of the component
  47225. * @param _buttonIndex index in the buttons array of the gamepad
  47226. * @param _axesIndices indices of the values in the axes array of the gamepad
  47227. */
  47228. constructor(
  47229. /**
  47230. * the id of this component
  47231. */
  47232. id: string,
  47233. /**
  47234. * the type of the component
  47235. */
  47236. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47237. /**
  47238. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47239. */
  47240. get axes(): IWebXRMotionControllerAxesValue;
  47241. /**
  47242. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47243. */
  47244. get changes(): IWebXRMotionControllerComponentChanges;
  47245. /**
  47246. * Return whether or not the component changed the last frame
  47247. */
  47248. get hasChanges(): boolean;
  47249. /**
  47250. * is the button currently pressed
  47251. */
  47252. get pressed(): boolean;
  47253. /**
  47254. * is the button currently touched
  47255. */
  47256. get touched(): boolean;
  47257. /**
  47258. * Get the current value of this component
  47259. */
  47260. get value(): number;
  47261. /**
  47262. * Dispose this component
  47263. */
  47264. dispose(): void;
  47265. /**
  47266. * Are there axes correlating to this component
  47267. * @return true is axes data is available
  47268. */
  47269. isAxes(): boolean;
  47270. /**
  47271. * Is this component a button (hence - pressable)
  47272. * @returns true if can be pressed
  47273. */
  47274. isButton(): boolean;
  47275. /**
  47276. * update this component using the gamepad object it is in. Called on every frame
  47277. * @param nativeController the native gamepad controller object
  47278. */
  47279. update(nativeController: IMinimalMotionControllerObject): void;
  47280. }
  47281. }
  47282. declare module BABYLON {
  47283. /**
  47284. * Interface used to represent data loading progression
  47285. */
  47286. export interface ISceneLoaderProgressEvent {
  47287. /**
  47288. * Defines if data length to load can be evaluated
  47289. */
  47290. readonly lengthComputable: boolean;
  47291. /**
  47292. * Defines the loaded data length
  47293. */
  47294. readonly loaded: number;
  47295. /**
  47296. * Defines the data length to load
  47297. */
  47298. readonly total: number;
  47299. }
  47300. /**
  47301. * Interface used by SceneLoader plugins to define supported file extensions
  47302. */
  47303. export interface ISceneLoaderPluginExtensions {
  47304. /**
  47305. * Defines the list of supported extensions
  47306. */
  47307. [extension: string]: {
  47308. isBinary: boolean;
  47309. };
  47310. }
  47311. /**
  47312. * Interface used by SceneLoader plugin factory
  47313. */
  47314. export interface ISceneLoaderPluginFactory {
  47315. /**
  47316. * Defines the name of the factory
  47317. */
  47318. name: string;
  47319. /**
  47320. * Function called to create a new plugin
  47321. * @return the new plugin
  47322. */
  47323. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47324. /**
  47325. * The callback that returns true if the data can be directly loaded.
  47326. * @param data string containing the file data
  47327. * @returns if the data can be loaded directly
  47328. */
  47329. canDirectLoad?(data: string): boolean;
  47330. }
  47331. /**
  47332. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47333. */
  47334. export interface ISceneLoaderPluginBase {
  47335. /**
  47336. * The friendly name of this plugin.
  47337. */
  47338. name: string;
  47339. /**
  47340. * The file extensions supported by this plugin.
  47341. */
  47342. extensions: string | ISceneLoaderPluginExtensions;
  47343. /**
  47344. * The callback called when loading from a url.
  47345. * @param scene scene loading this url
  47346. * @param url url to load
  47347. * @param onSuccess callback called when the file successfully loads
  47348. * @param onProgress callback called while file is loading (if the server supports this mode)
  47349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47350. * @param onError callback called when the file fails to load
  47351. * @returns a file request object
  47352. */
  47353. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47354. /**
  47355. * The callback called when loading from a file object.
  47356. * @param scene scene loading this file
  47357. * @param file defines the file to load
  47358. * @param onSuccess defines the callback to call when data is loaded
  47359. * @param onProgress defines the callback to call during loading process
  47360. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47361. * @param onError defines the callback to call when an error occurs
  47362. * @returns a file request object
  47363. */
  47364. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47365. /**
  47366. * The callback that returns true if the data can be directly loaded.
  47367. * @param data string containing the file data
  47368. * @returns if the data can be loaded directly
  47369. */
  47370. canDirectLoad?(data: string): boolean;
  47371. /**
  47372. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47373. * @param scene scene loading this data
  47374. * @param data string containing the data
  47375. * @returns data to pass to the plugin
  47376. */
  47377. directLoad?(scene: Scene, data: string): any;
  47378. /**
  47379. * The callback that allows custom handling of the root url based on the response url.
  47380. * @param rootUrl the original root url
  47381. * @param responseURL the response url if available
  47382. * @returns the new root url
  47383. */
  47384. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47385. }
  47386. /**
  47387. * Interface used to define a SceneLoader plugin
  47388. */
  47389. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47390. /**
  47391. * Import meshes into a scene.
  47392. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47393. * @param scene The scene to import into
  47394. * @param data The data to import
  47395. * @param rootUrl The root url for scene and resources
  47396. * @param meshes The meshes array to import into
  47397. * @param particleSystems The particle systems array to import into
  47398. * @param skeletons The skeletons array to import into
  47399. * @param onError The callback when import fails
  47400. * @returns True if successful or false otherwise
  47401. */
  47402. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47403. /**
  47404. * Load into a scene.
  47405. * @param scene The scene to load into
  47406. * @param data The data to import
  47407. * @param rootUrl The root url for scene and resources
  47408. * @param onError The callback when import fails
  47409. * @returns True if successful or false otherwise
  47410. */
  47411. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47412. /**
  47413. * Load into an asset container.
  47414. * @param scene The scene to load into
  47415. * @param data The data to import
  47416. * @param rootUrl The root url for scene and resources
  47417. * @param onError The callback when import fails
  47418. * @returns The loaded asset container
  47419. */
  47420. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47421. }
  47422. /**
  47423. * Interface used to define an async SceneLoader plugin
  47424. */
  47425. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47426. /**
  47427. * Import meshes into a scene.
  47428. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47429. * @param scene The scene to import into
  47430. * @param data The data to import
  47431. * @param rootUrl The root url for scene and resources
  47432. * @param onProgress The callback when the load progresses
  47433. * @param fileName Defines the name of the file to load
  47434. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47435. */
  47436. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47437. meshes: AbstractMesh[];
  47438. particleSystems: IParticleSystem[];
  47439. skeletons: Skeleton[];
  47440. animationGroups: AnimationGroup[];
  47441. }>;
  47442. /**
  47443. * Load into a scene.
  47444. * @param scene The scene to load into
  47445. * @param data The data to import
  47446. * @param rootUrl The root url for scene and resources
  47447. * @param onProgress The callback when the load progresses
  47448. * @param fileName Defines the name of the file to load
  47449. * @returns Nothing
  47450. */
  47451. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47452. /**
  47453. * Load into an asset container.
  47454. * @param scene The scene to load into
  47455. * @param data The data to import
  47456. * @param rootUrl The root url for scene and resources
  47457. * @param onProgress The callback when the load progresses
  47458. * @param fileName Defines the name of the file to load
  47459. * @returns The loaded asset container
  47460. */
  47461. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47462. }
  47463. /**
  47464. * Mode that determines how to handle old animation groups before loading new ones.
  47465. */
  47466. export enum SceneLoaderAnimationGroupLoadingMode {
  47467. /**
  47468. * Reset all old animations to initial state then dispose them.
  47469. */
  47470. Clean = 0,
  47471. /**
  47472. * Stop all old animations.
  47473. */
  47474. Stop = 1,
  47475. /**
  47476. * Restart old animations from first frame.
  47477. */
  47478. Sync = 2,
  47479. /**
  47480. * Old animations remains untouched.
  47481. */
  47482. NoSync = 3
  47483. }
  47484. /**
  47485. * Defines a plugin registered by the SceneLoader
  47486. */
  47487. interface IRegisteredPlugin {
  47488. /**
  47489. * Defines the plugin to use
  47490. */
  47491. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47492. /**
  47493. * Defines if the plugin supports binary data
  47494. */
  47495. isBinary: boolean;
  47496. }
  47497. /**
  47498. * Class used to load scene from various file formats using registered plugins
  47499. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47500. */
  47501. export class SceneLoader {
  47502. /**
  47503. * No logging while loading
  47504. */
  47505. static readonly NO_LOGGING: number;
  47506. /**
  47507. * Minimal logging while loading
  47508. */
  47509. static readonly MINIMAL_LOGGING: number;
  47510. /**
  47511. * Summary logging while loading
  47512. */
  47513. static readonly SUMMARY_LOGGING: number;
  47514. /**
  47515. * Detailled logging while loading
  47516. */
  47517. static readonly DETAILED_LOGGING: number;
  47518. /**
  47519. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47520. */
  47521. static get ForceFullSceneLoadingForIncremental(): boolean;
  47522. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47523. /**
  47524. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47525. */
  47526. static get ShowLoadingScreen(): boolean;
  47527. static set ShowLoadingScreen(value: boolean);
  47528. /**
  47529. * Defines the current logging level (while loading the scene)
  47530. * @ignorenaming
  47531. */
  47532. static get loggingLevel(): number;
  47533. static set loggingLevel(value: number);
  47534. /**
  47535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47536. */
  47537. static get CleanBoneMatrixWeights(): boolean;
  47538. static set CleanBoneMatrixWeights(value: boolean);
  47539. /**
  47540. * Event raised when a plugin is used to load a scene
  47541. */
  47542. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47543. private static _registeredPlugins;
  47544. private static _showingLoadingScreen;
  47545. /**
  47546. * Gets the default plugin (used to load Babylon files)
  47547. * @returns the .babylon plugin
  47548. */
  47549. static GetDefaultPlugin(): IRegisteredPlugin;
  47550. private static _GetPluginForExtension;
  47551. private static _GetPluginForDirectLoad;
  47552. private static _GetPluginForFilename;
  47553. private static _GetDirectLoad;
  47554. private static _LoadData;
  47555. private static _GetFileInfo;
  47556. /**
  47557. * Gets a plugin that can load the given extension
  47558. * @param extension defines the extension to load
  47559. * @returns a plugin or null if none works
  47560. */
  47561. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47562. /**
  47563. * Gets a boolean indicating that the given extension can be loaded
  47564. * @param extension defines the extension to load
  47565. * @returns true if the extension is supported
  47566. */
  47567. static IsPluginForExtensionAvailable(extension: string): boolean;
  47568. /**
  47569. * Adds a new plugin to the list of registered plugins
  47570. * @param plugin defines the plugin to add
  47571. */
  47572. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47573. /**
  47574. * Import meshes into a scene
  47575. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47576. * @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)
  47577. * @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)
  47578. * @param scene the instance of BABYLON.Scene to append to
  47579. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47580. * @param onProgress a callback with a progress event for each file being loaded
  47581. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47582. * @param pluginExtension the extension used to determine the plugin
  47583. * @returns The loaded plugin
  47584. */
  47585. 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>;
  47586. /**
  47587. * Import meshes into a scene
  47588. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47589. * @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)
  47590. * @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)
  47591. * @param scene the instance of BABYLON.Scene to append to
  47592. * @param onProgress a callback with a progress event for each file being loaded
  47593. * @param pluginExtension the extension used to determine the plugin
  47594. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47595. */
  47596. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47597. meshes: AbstractMesh[];
  47598. particleSystems: IParticleSystem[];
  47599. skeletons: Skeleton[];
  47600. animationGroups: AnimationGroup[];
  47601. }>;
  47602. /**
  47603. * Load a scene
  47604. * @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)
  47605. * @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)
  47606. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47607. * @param onSuccess a callback with the scene when import succeeds
  47608. * @param onProgress a callback with a progress event for each file being loaded
  47609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47610. * @param pluginExtension the extension used to determine the plugin
  47611. * @returns The loaded plugin
  47612. */
  47613. 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>;
  47614. /**
  47615. * Load a scene
  47616. * @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)
  47617. * @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)
  47618. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47619. * @param onProgress a callback with a progress event for each file being loaded
  47620. * @param pluginExtension the extension used to determine the plugin
  47621. * @returns The loaded scene
  47622. */
  47623. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47624. /**
  47625. * Append a scene
  47626. * @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)
  47627. * @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)
  47628. * @param scene is the instance of BABYLON.Scene to append to
  47629. * @param onSuccess a callback with the scene when import succeeds
  47630. * @param onProgress a callback with a progress event for each file being loaded
  47631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47632. * @param pluginExtension the extension used to determine the plugin
  47633. * @returns The loaded plugin
  47634. */
  47635. 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>;
  47636. /**
  47637. * Append a scene
  47638. * @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)
  47639. * @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)
  47640. * @param scene is the instance of BABYLON.Scene to append to
  47641. * @param onProgress a callback with a progress event for each file being loaded
  47642. * @param pluginExtension the extension used to determine the plugin
  47643. * @returns The given scene
  47644. */
  47645. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47646. /**
  47647. * Load a scene into an asset container
  47648. * @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)
  47649. * @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)
  47650. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47651. * @param onSuccess a callback with the scene when import succeeds
  47652. * @param onProgress a callback with a progress event for each file being loaded
  47653. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47654. * @param pluginExtension the extension used to determine the plugin
  47655. * @returns The loaded plugin
  47656. */
  47657. 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>;
  47658. /**
  47659. * Load a scene into an asset container
  47660. * @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)
  47661. * @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)
  47662. * @param scene is the instance of Scene to append to
  47663. * @param onProgress a callback with a progress event for each file being loaded
  47664. * @param pluginExtension the extension used to determine the plugin
  47665. * @returns The loaded asset container
  47666. */
  47667. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47668. /**
  47669. * Import animations from a file into a scene
  47670. * @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)
  47671. * @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)
  47672. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47673. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47674. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47675. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47676. * @param onSuccess a callback with the scene when import succeeds
  47677. * @param onProgress a callback with a progress event for each file being loaded
  47678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47679. * @param pluginExtension the extension used to determine the plugin
  47680. */
  47681. 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;
  47682. /**
  47683. * Import animations from a file into a scene
  47684. * @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)
  47685. * @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)
  47686. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47687. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47688. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47689. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47690. * @param onSuccess a callback with the scene when import succeeds
  47691. * @param onProgress a callback with a progress event for each file being loaded
  47692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47693. * @param pluginExtension the extension used to determine the plugin
  47694. * @returns the updated scene with imported animations
  47695. */
  47696. 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>;
  47697. }
  47698. }
  47699. declare module BABYLON {
  47700. /**
  47701. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47702. */
  47703. export type MotionControllerHandedness = "none" | "left" | "right";
  47704. /**
  47705. * The type of components available in motion controllers.
  47706. * This is not the name of the component.
  47707. */
  47708. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47709. /**
  47710. * The state of a controller component
  47711. */
  47712. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47713. /**
  47714. * The schema of motion controller layout.
  47715. * No object will be initialized using this interface
  47716. * This is used just to define the profile.
  47717. */
  47718. export interface IMotionControllerLayout {
  47719. /**
  47720. * Path to load the assets. Usually relative to the base path
  47721. */
  47722. assetPath: string;
  47723. /**
  47724. * Available components (unsorted)
  47725. */
  47726. components: {
  47727. /**
  47728. * A map of component Ids
  47729. */
  47730. [componentId: string]: {
  47731. /**
  47732. * The type of input the component outputs
  47733. */
  47734. type: MotionControllerComponentType;
  47735. /**
  47736. * The indices of this component in the gamepad object
  47737. */
  47738. gamepadIndices: {
  47739. /**
  47740. * Index of button
  47741. */
  47742. button?: number;
  47743. /**
  47744. * If available, index of x-axis
  47745. */
  47746. xAxis?: number;
  47747. /**
  47748. * If available, index of y-axis
  47749. */
  47750. yAxis?: number;
  47751. };
  47752. /**
  47753. * The mesh's root node name
  47754. */
  47755. rootNodeName: string;
  47756. /**
  47757. * Animation definitions for this model
  47758. */
  47759. visualResponses: {
  47760. [stateKey: string]: {
  47761. /**
  47762. * What property will be animated
  47763. */
  47764. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47765. /**
  47766. * What states influence this visual response
  47767. */
  47768. states: MotionControllerComponentStateType[];
  47769. /**
  47770. * Type of animation - movement or visibility
  47771. */
  47772. valueNodeProperty: "transform" | "visibility";
  47773. /**
  47774. * Base node name to move. Its position will be calculated according to the min and max nodes
  47775. */
  47776. valueNodeName?: string;
  47777. /**
  47778. * Minimum movement node
  47779. */
  47780. minNodeName?: string;
  47781. /**
  47782. * Max movement node
  47783. */
  47784. maxNodeName?: string;
  47785. };
  47786. };
  47787. /**
  47788. * If touch enabled, what is the name of node to display user feedback
  47789. */
  47790. touchPointNodeName?: string;
  47791. };
  47792. };
  47793. /**
  47794. * Is it xr standard mapping or not
  47795. */
  47796. gamepadMapping: "" | "xr-standard";
  47797. /**
  47798. * Base root node of this entire model
  47799. */
  47800. rootNodeName: string;
  47801. /**
  47802. * Defines the main button component id
  47803. */
  47804. selectComponentId: string;
  47805. }
  47806. /**
  47807. * A definition for the layout map in the input profile
  47808. */
  47809. export interface IMotionControllerLayoutMap {
  47810. /**
  47811. * Layouts with handedness type as a key
  47812. */
  47813. [handedness: string]: IMotionControllerLayout;
  47814. }
  47815. /**
  47816. * The XR Input profile schema
  47817. * Profiles can be found here:
  47818. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47819. */
  47820. export interface IMotionControllerProfile {
  47821. /**
  47822. * fallback profiles for this profileId
  47823. */
  47824. fallbackProfileIds: string[];
  47825. /**
  47826. * The layout map, with handedness as key
  47827. */
  47828. layouts: IMotionControllerLayoutMap;
  47829. /**
  47830. * The id of this profile
  47831. * correlates to the profile(s) in the xrInput.profiles array
  47832. */
  47833. profileId: string;
  47834. }
  47835. /**
  47836. * A helper-interface for the 3 meshes needed for controller button animation
  47837. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47838. */
  47839. export interface IMotionControllerButtonMeshMap {
  47840. /**
  47841. * the mesh that defines the pressed value mesh position.
  47842. * This is used to find the max-position of this button
  47843. */
  47844. pressedMesh: AbstractMesh;
  47845. /**
  47846. * the mesh that defines the unpressed value mesh position.
  47847. * This is used to find the min (or initial) position of this button
  47848. */
  47849. unpressedMesh: AbstractMesh;
  47850. /**
  47851. * The mesh that will be changed when value changes
  47852. */
  47853. valueMesh: AbstractMesh;
  47854. }
  47855. /**
  47856. * A helper-interface for the 3 meshes needed for controller axis animation.
  47857. * This will be expanded when touchpad animations are fully supported
  47858. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47859. */
  47860. export interface IMotionControllerMeshMap {
  47861. /**
  47862. * the mesh that defines the maximum value mesh position.
  47863. */
  47864. maxMesh?: AbstractMesh;
  47865. /**
  47866. * the mesh that defines the minimum value mesh position.
  47867. */
  47868. minMesh?: AbstractMesh;
  47869. /**
  47870. * The mesh that will be changed when axis value changes
  47871. */
  47872. valueMesh: AbstractMesh;
  47873. }
  47874. /**
  47875. * The elements needed for change-detection of the gamepad objects in motion controllers
  47876. */
  47877. export interface IMinimalMotionControllerObject {
  47878. /**
  47879. * Available axes of this controller
  47880. */
  47881. axes: number[];
  47882. /**
  47883. * An array of available buttons
  47884. */
  47885. buttons: Array<{
  47886. /**
  47887. * Value of the button/trigger
  47888. */
  47889. value: number;
  47890. /**
  47891. * If the button/trigger is currently touched
  47892. */
  47893. touched: boolean;
  47894. /**
  47895. * If the button/trigger is currently pressed
  47896. */
  47897. pressed: boolean;
  47898. }>;
  47899. /**
  47900. * EXPERIMENTAL haptic support.
  47901. */
  47902. hapticActuators?: Array<{
  47903. pulse: (value: number, duration: number) => Promise<boolean>;
  47904. }>;
  47905. }
  47906. /**
  47907. * An Abstract Motion controller
  47908. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47909. * Each component has an observable to check for changes in value and state
  47910. */
  47911. export abstract class WebXRAbstractMotionController implements IDisposable {
  47912. protected scene: Scene;
  47913. protected layout: IMotionControllerLayout;
  47914. /**
  47915. * The gamepad object correlating to this controller
  47916. */
  47917. gamepadObject: IMinimalMotionControllerObject;
  47918. /**
  47919. * handedness (left/right/none) of this controller
  47920. */
  47921. handedness: MotionControllerHandedness;
  47922. private _initComponent;
  47923. private _modelReady;
  47924. /**
  47925. * A map of components (WebXRControllerComponent) in this motion controller
  47926. * Components have a ComponentType and can also have both button and axis definitions
  47927. */
  47928. readonly components: {
  47929. [id: string]: WebXRControllerComponent;
  47930. };
  47931. /**
  47932. * Disable the model's animation. Can be set at any time.
  47933. */
  47934. disableAnimation: boolean;
  47935. /**
  47936. * Observers registered here will be triggered when the model of this controller is done loading
  47937. */
  47938. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47939. /**
  47940. * The profile id of this motion controller
  47941. */
  47942. abstract profileId: string;
  47943. /**
  47944. * The root mesh of the model. It is null if the model was not yet initialized
  47945. */
  47946. rootMesh: Nullable<AbstractMesh>;
  47947. /**
  47948. * constructs a new abstract motion controller
  47949. * @param scene the scene to which the model of the controller will be added
  47950. * @param layout The profile layout to load
  47951. * @param gamepadObject The gamepad object correlating to this controller
  47952. * @param handedness handedness (left/right/none) of this controller
  47953. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47954. */
  47955. constructor(scene: Scene, layout: IMotionControllerLayout,
  47956. /**
  47957. * The gamepad object correlating to this controller
  47958. */
  47959. gamepadObject: IMinimalMotionControllerObject,
  47960. /**
  47961. * handedness (left/right/none) of this controller
  47962. */
  47963. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47964. /**
  47965. * Dispose this controller, the model mesh and all its components
  47966. */
  47967. dispose(): void;
  47968. /**
  47969. * Returns all components of specific type
  47970. * @param type the type to search for
  47971. * @return an array of components with this type
  47972. */
  47973. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47974. /**
  47975. * get a component based an its component id as defined in layout.components
  47976. * @param id the id of the component
  47977. * @returns the component correlates to the id or undefined if not found
  47978. */
  47979. getComponent(id: string): WebXRControllerComponent;
  47980. /**
  47981. * Get the list of components available in this motion controller
  47982. * @returns an array of strings correlating to available components
  47983. */
  47984. getComponentIds(): string[];
  47985. /**
  47986. * Get the first component of specific type
  47987. * @param type type of component to find
  47988. * @return a controller component or null if not found
  47989. */
  47990. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47991. /**
  47992. * Get the main (Select) component of this controller as defined in the layout
  47993. * @returns the main component of this controller
  47994. */
  47995. getMainComponent(): WebXRControllerComponent;
  47996. /**
  47997. * Loads the model correlating to this controller
  47998. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47999. * @returns A promise fulfilled with the result of the model loading
  48000. */
  48001. loadModel(): Promise<boolean>;
  48002. /**
  48003. * Update this model using the current XRFrame
  48004. * @param xrFrame the current xr frame to use and update the model
  48005. */
  48006. updateFromXRFrame(xrFrame: XRFrame): void;
  48007. /**
  48008. * Backwards compatibility due to a deeply-integrated typo
  48009. */
  48010. get handness(): XREye;
  48011. /**
  48012. * Pulse (vibrate) this controller
  48013. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48014. * Consecutive calls to this function will cancel the last pulse call
  48015. *
  48016. * @param value the strength of the pulse in 0.0...1.0 range
  48017. * @param duration Duration of the pulse in milliseconds
  48018. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48019. * @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
  48020. */
  48021. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48022. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48023. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48024. /**
  48025. * Moves the axis on the controller mesh based on its current state
  48026. * @param axis the index of the axis
  48027. * @param axisValue the value of the axis which determines the meshes new position
  48028. * @hidden
  48029. */
  48030. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48031. /**
  48032. * Update the model itself with the current frame data
  48033. * @param xrFrame the frame to use for updating the model mesh
  48034. */
  48035. protected updateModel(xrFrame: XRFrame): void;
  48036. /**
  48037. * Get the filename and path for this controller's model
  48038. * @returns a map of filename and path
  48039. */
  48040. protected abstract _getFilenameAndPath(): {
  48041. filename: string;
  48042. path: string;
  48043. };
  48044. /**
  48045. * This function is called before the mesh is loaded. It checks for loading constraints.
  48046. * For example, this function can check if the GLB loader is available
  48047. * If this function returns false, the generic controller will be loaded instead
  48048. * @returns Is the client ready to load the mesh
  48049. */
  48050. protected abstract _getModelLoadingConstraints(): boolean;
  48051. /**
  48052. * This function will be called after the model was successfully loaded and can be used
  48053. * for mesh transformations before it is available for the user
  48054. * @param meshes the loaded meshes
  48055. */
  48056. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48057. /**
  48058. * Set the root mesh for this controller. Important for the WebXR controller class
  48059. * @param meshes the loaded meshes
  48060. */
  48061. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48062. /**
  48063. * A function executed each frame that updates the mesh (if needed)
  48064. * @param xrFrame the current xrFrame
  48065. */
  48066. protected abstract _updateModel(xrFrame: XRFrame): void;
  48067. private _getGenericFilenameAndPath;
  48068. private _getGenericParentMesh;
  48069. }
  48070. }
  48071. declare module BABYLON {
  48072. /**
  48073. * A generic trigger-only motion controller for WebXR
  48074. */
  48075. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48076. /**
  48077. * Static version of the profile id of this controller
  48078. */
  48079. static ProfileId: string;
  48080. profileId: string;
  48081. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48082. protected _getFilenameAndPath(): {
  48083. filename: string;
  48084. path: string;
  48085. };
  48086. protected _getModelLoadingConstraints(): boolean;
  48087. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48089. protected _updateModel(): void;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * Class containing static functions to help procedurally build meshes
  48095. */
  48096. export class SphereBuilder {
  48097. /**
  48098. * Creates a sphere mesh
  48099. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48100. * * 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`)
  48101. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48102. * * 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
  48103. * * 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)
  48104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48105. * * 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
  48106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48107. * @param name defines the name of the mesh
  48108. * @param options defines the options used to create the mesh
  48109. * @param scene defines the hosting scene
  48110. * @returns the sphere mesh
  48111. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48112. */
  48113. static CreateSphere(name: string, options: {
  48114. segments?: number;
  48115. diameter?: number;
  48116. diameterX?: number;
  48117. diameterY?: number;
  48118. diameterZ?: number;
  48119. arc?: number;
  48120. slice?: number;
  48121. sideOrientation?: number;
  48122. frontUVs?: Vector4;
  48123. backUVs?: Vector4;
  48124. updatable?: boolean;
  48125. }, scene?: Nullable<Scene>): Mesh;
  48126. }
  48127. }
  48128. declare module BABYLON {
  48129. /**
  48130. * A profiled motion controller has its profile loaded from an online repository.
  48131. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48132. */
  48133. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48134. private _repositoryUrl;
  48135. private _buttonMeshMapping;
  48136. private _touchDots;
  48137. /**
  48138. * The profile ID of this controller. Will be populated when the controller initializes.
  48139. */
  48140. profileId: string;
  48141. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48142. dispose(): void;
  48143. protected _getFilenameAndPath(): {
  48144. filename: string;
  48145. path: string;
  48146. };
  48147. protected _getModelLoadingConstraints(): boolean;
  48148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48150. protected _updateModel(_xrFrame: XRFrame): void;
  48151. }
  48152. }
  48153. declare module BABYLON {
  48154. /**
  48155. * A construction function type to create a new controller based on an xrInput object
  48156. */
  48157. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48158. /**
  48159. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48160. *
  48161. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48162. * it should be replaced with auto-loaded controllers.
  48163. *
  48164. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48165. */
  48166. export class WebXRMotionControllerManager {
  48167. private static _AvailableControllers;
  48168. private static _Fallbacks;
  48169. private static _ProfileLoadingPromises;
  48170. private static _ProfilesList;
  48171. /**
  48172. * The base URL of the online controller repository. Can be changed at any time.
  48173. */
  48174. static BaseRepositoryUrl: string;
  48175. /**
  48176. * Which repository gets priority - local or online
  48177. */
  48178. static PrioritizeOnlineRepository: boolean;
  48179. /**
  48180. * Use the online repository, or use only locally-defined controllers
  48181. */
  48182. static UseOnlineRepository: boolean;
  48183. /**
  48184. * Clear the cache used for profile loading and reload when requested again
  48185. */
  48186. static ClearProfilesCache(): void;
  48187. /**
  48188. * Register the default fallbacks.
  48189. * This function is called automatically when this file is imported.
  48190. */
  48191. static DefaultFallbacks(): void;
  48192. /**
  48193. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48194. * @param profileId the profile to which a fallback needs to be found
  48195. * @return an array with corresponding fallback profiles
  48196. */
  48197. static FindFallbackWithProfileId(profileId: string): string[];
  48198. /**
  48199. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48200. * The order of search:
  48201. *
  48202. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48203. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48204. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48205. * 4) return the generic trigger controller if none were found
  48206. *
  48207. * @param xrInput the xrInput to which a new controller is initialized
  48208. * @param scene the scene to which the model will be added
  48209. * @param forceProfile force a certain profile for this controller
  48210. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48211. */
  48212. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48213. /**
  48214. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48215. *
  48216. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48217. *
  48218. * @param type the profile type to register
  48219. * @param constructFunction the function to be called when loading this profile
  48220. */
  48221. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48222. /**
  48223. * Register a fallback to a specific profile.
  48224. * @param profileId the profileId that will receive the fallbacks
  48225. * @param fallbacks A list of fallback profiles
  48226. */
  48227. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48228. /**
  48229. * Will update the list of profiles available in the repository
  48230. * @return a promise that resolves to a map of profiles available online
  48231. */
  48232. static UpdateProfilesList(): Promise<{
  48233. [profile: string]: string;
  48234. }>;
  48235. private static _LoadProfileFromRepository;
  48236. private static _LoadProfilesFromAvailableControllers;
  48237. }
  48238. }
  48239. declare module BABYLON {
  48240. /**
  48241. * Configuration options for the WebXR controller creation
  48242. */
  48243. export interface IWebXRControllerOptions {
  48244. /**
  48245. * Should the controller mesh be animated when a user interacts with it
  48246. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48247. */
  48248. disableMotionControllerAnimation?: boolean;
  48249. /**
  48250. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48251. */
  48252. doNotLoadControllerMesh?: boolean;
  48253. /**
  48254. * Force a specific controller type for this controller.
  48255. * This can be used when creating your own profile or when testing different controllers
  48256. */
  48257. forceControllerProfile?: string;
  48258. /**
  48259. * Defines a rendering group ID for meshes that will be loaded.
  48260. * This is for the default controllers only.
  48261. */
  48262. renderingGroupId?: number;
  48263. }
  48264. /**
  48265. * Represents an XR controller
  48266. */
  48267. export class WebXRInputSource {
  48268. private _scene;
  48269. /** The underlying input source for the controller */
  48270. inputSource: XRInputSource;
  48271. private _options;
  48272. private _tmpVector;
  48273. private _uniqueId;
  48274. /**
  48275. * 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
  48276. */
  48277. grip?: AbstractMesh;
  48278. /**
  48279. * If available, this is the gamepad object related to this controller.
  48280. * Using this object it is possible to get click events and trackpad changes of the
  48281. * webxr controller that is currently being used.
  48282. */
  48283. motionController?: WebXRAbstractMotionController;
  48284. /**
  48285. * Event that fires when the controller is removed/disposed.
  48286. * The object provided as event data is this controller, after associated assets were disposed.
  48287. * uniqueId is still available.
  48288. */
  48289. onDisposeObservable: Observable<WebXRInputSource>;
  48290. /**
  48291. * Will be triggered when the mesh associated with the motion controller is done loading.
  48292. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48293. * A shortened version of controller -> motion controller -> on mesh loaded.
  48294. */
  48295. onMeshLoadedObservable: Observable<AbstractMesh>;
  48296. /**
  48297. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48298. */
  48299. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48300. /**
  48301. * Pointer which can be used to select objects or attach a visible laser to
  48302. */
  48303. pointer: AbstractMesh;
  48304. /**
  48305. * Creates the input source object
  48306. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48307. * @param _scene the scene which the controller should be associated to
  48308. * @param inputSource the underlying input source for the controller
  48309. * @param _options options for this controller creation
  48310. */
  48311. constructor(_scene: Scene,
  48312. /** The underlying input source for the controller */
  48313. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48314. /**
  48315. * Get this controllers unique id
  48316. */
  48317. get uniqueId(): string;
  48318. /**
  48319. * Disposes of the object
  48320. */
  48321. dispose(): void;
  48322. /**
  48323. * Gets a world space ray coming from the pointer or grip
  48324. * @param result the resulting ray
  48325. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48326. */
  48327. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48328. /**
  48329. * Updates the controller pose based on the given XRFrame
  48330. * @param xrFrame xr frame to update the pose with
  48331. * @param referenceSpace reference space to use
  48332. */
  48333. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48334. }
  48335. }
  48336. declare module BABYLON {
  48337. /**
  48338. * The schema for initialization options of the XR Input class
  48339. */
  48340. export interface IWebXRInputOptions {
  48341. /**
  48342. * If set to true no model will be automatically loaded
  48343. */
  48344. doNotLoadControllerMeshes?: boolean;
  48345. /**
  48346. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48347. * If not found, the xr input profile data will be used.
  48348. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48349. */
  48350. forceInputProfile?: string;
  48351. /**
  48352. * Do not send a request to the controller repository to load the profile.
  48353. *
  48354. * Instead, use the controllers available in babylon itself.
  48355. */
  48356. disableOnlineControllerRepository?: boolean;
  48357. /**
  48358. * A custom URL for the controllers repository
  48359. */
  48360. customControllersRepositoryURL?: string;
  48361. /**
  48362. * Should the controller model's components not move according to the user input
  48363. */
  48364. disableControllerAnimation?: boolean;
  48365. /**
  48366. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48367. */
  48368. controllerOptions?: IWebXRControllerOptions;
  48369. }
  48370. /**
  48371. * XR input used to track XR inputs such as controllers/rays
  48372. */
  48373. export class WebXRInput implements IDisposable {
  48374. /**
  48375. * the xr session manager for this session
  48376. */
  48377. xrSessionManager: WebXRSessionManager;
  48378. /**
  48379. * the WebXR camera for this session. Mainly used for teleportation
  48380. */
  48381. xrCamera: WebXRCamera;
  48382. private readonly options;
  48383. /**
  48384. * XR controllers being tracked
  48385. */
  48386. controllers: Array<WebXRInputSource>;
  48387. private _frameObserver;
  48388. private _sessionEndedObserver;
  48389. private _sessionInitObserver;
  48390. /**
  48391. * Event when a controller has been connected/added
  48392. */
  48393. onControllerAddedObservable: Observable<WebXRInputSource>;
  48394. /**
  48395. * Event when a controller has been removed/disconnected
  48396. */
  48397. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48398. /**
  48399. * Initializes the WebXRInput
  48400. * @param xrSessionManager the xr session manager for this session
  48401. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48402. * @param options = initialization options for this xr input
  48403. */
  48404. constructor(
  48405. /**
  48406. * the xr session manager for this session
  48407. */
  48408. xrSessionManager: WebXRSessionManager,
  48409. /**
  48410. * the WebXR camera for this session. Mainly used for teleportation
  48411. */
  48412. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48413. private _onInputSourcesChange;
  48414. private _addAndRemoveControllers;
  48415. /**
  48416. * Disposes of the object
  48417. */
  48418. dispose(): void;
  48419. }
  48420. }
  48421. declare module BABYLON {
  48422. /**
  48423. * This is the base class for all WebXR features.
  48424. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48425. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48426. */
  48427. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48428. protected _xrSessionManager: WebXRSessionManager;
  48429. private _attached;
  48430. private _removeOnDetach;
  48431. /**
  48432. * Should auto-attach be disabled?
  48433. */
  48434. disableAutoAttach: boolean;
  48435. /**
  48436. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48437. */
  48438. xrNativeFeatureName: string;
  48439. /**
  48440. * Construct a new (abstract) WebXR feature
  48441. * @param _xrSessionManager the xr session manager for this feature
  48442. */
  48443. constructor(_xrSessionManager: WebXRSessionManager);
  48444. /**
  48445. * Is this feature attached
  48446. */
  48447. get attached(): boolean;
  48448. /**
  48449. * attach this feature
  48450. *
  48451. * @param force should attachment be forced (even when already attached)
  48452. * @returns true if successful, false is failed or already attached
  48453. */
  48454. attach(force?: boolean): boolean;
  48455. /**
  48456. * detach this feature.
  48457. *
  48458. * @returns true if successful, false if failed or already detached
  48459. */
  48460. detach(): boolean;
  48461. /**
  48462. * Dispose this feature and all of the resources attached
  48463. */
  48464. dispose(): void;
  48465. /**
  48466. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48467. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48468. *
  48469. * @returns whether or not the feature is compatible in this environment
  48470. */
  48471. isCompatible(): boolean;
  48472. /**
  48473. * This is used to register callbacks that will automatically be removed when detach is called.
  48474. * @param observable the observable to which the observer will be attached
  48475. * @param callback the callback to register
  48476. */
  48477. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48478. /**
  48479. * Code in this function will be executed on each xrFrame received from the browser.
  48480. * This function will not execute after the feature is detached.
  48481. * @param _xrFrame the current frame
  48482. */
  48483. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48484. }
  48485. }
  48486. declare module BABYLON {
  48487. /**
  48488. * Renders a layer on top of an existing scene
  48489. */
  48490. export class UtilityLayerRenderer implements IDisposable {
  48491. /** the original scene that will be rendered on top of */
  48492. originalScene: Scene;
  48493. private _pointerCaptures;
  48494. private _lastPointerEvents;
  48495. private static _DefaultUtilityLayer;
  48496. private static _DefaultKeepDepthUtilityLayer;
  48497. private _sharedGizmoLight;
  48498. private _renderCamera;
  48499. /**
  48500. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48501. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48502. * @returns the camera that is used when rendering the utility layer
  48503. */
  48504. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48505. /**
  48506. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48507. * @param cam the camera that should be used when rendering the utility layer
  48508. */
  48509. setRenderCamera(cam: Nullable<Camera>): void;
  48510. /**
  48511. * @hidden
  48512. * Light which used by gizmos to get light shading
  48513. */
  48514. _getSharedGizmoLight(): HemisphericLight;
  48515. /**
  48516. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48517. */
  48518. pickUtilitySceneFirst: boolean;
  48519. /**
  48520. * 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)
  48521. */
  48522. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48523. /**
  48524. * 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)
  48525. */
  48526. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48527. /**
  48528. * The scene that is rendered on top of the original scene
  48529. */
  48530. utilityLayerScene: Scene;
  48531. /**
  48532. * If the utility layer should automatically be rendered on top of existing scene
  48533. */
  48534. shouldRender: boolean;
  48535. /**
  48536. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48537. */
  48538. onlyCheckPointerDownEvents: boolean;
  48539. /**
  48540. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48541. */
  48542. processAllEvents: boolean;
  48543. /**
  48544. * Observable raised when the pointer move from the utility layer scene to the main scene
  48545. */
  48546. onPointerOutObservable: Observable<number>;
  48547. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48548. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48549. private _afterRenderObserver;
  48550. private _sceneDisposeObserver;
  48551. private _originalPointerObserver;
  48552. /**
  48553. * Instantiates a UtilityLayerRenderer
  48554. * @param originalScene the original scene that will be rendered on top of
  48555. * @param handleEvents boolean indicating if the utility layer should handle events
  48556. */
  48557. constructor(
  48558. /** the original scene that will be rendered on top of */
  48559. originalScene: Scene, handleEvents?: boolean);
  48560. private _notifyObservers;
  48561. /**
  48562. * Renders the utility layers scene on top of the original scene
  48563. */
  48564. render(): void;
  48565. /**
  48566. * Disposes of the renderer
  48567. */
  48568. dispose(): void;
  48569. private _updateCamera;
  48570. }
  48571. }
  48572. declare module BABYLON {
  48573. /**
  48574. * Options interface for the pointer selection module
  48575. */
  48576. export interface IWebXRControllerPointerSelectionOptions {
  48577. /**
  48578. * if provided, this scene will be used to render meshes.
  48579. */
  48580. customUtilityLayerScene?: Scene;
  48581. /**
  48582. * 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)
  48583. * If not disabled, the last picked point will be used to execute a pointer up event
  48584. * If disabled, pointer up event will be triggered right after the pointer down event.
  48585. * Used in screen and gaze target ray mode only
  48586. */
  48587. disablePointerUpOnTouchOut: boolean;
  48588. /**
  48589. * For gaze mode (time to select instead of press)
  48590. */
  48591. forceGazeMode: boolean;
  48592. /**
  48593. * 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
  48594. * to start a new countdown to the pointer down event.
  48595. * Defaults to 1.
  48596. */
  48597. gazeModePointerMovedFactor?: number;
  48598. /**
  48599. * Different button type to use instead of the main component
  48600. */
  48601. overrideButtonId?: string;
  48602. /**
  48603. * use this rendering group id for the meshes (optional)
  48604. */
  48605. renderingGroupId?: number;
  48606. /**
  48607. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48608. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48609. * 3000 means 3 seconds between pointing at something and selecting it
  48610. */
  48611. timeToSelect?: number;
  48612. /**
  48613. * Should meshes created here be added to a utility layer or the main scene
  48614. */
  48615. useUtilityLayer?: boolean;
  48616. /**
  48617. * the xr input to use with this pointer selection
  48618. */
  48619. xrInput: WebXRInput;
  48620. }
  48621. /**
  48622. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48623. */
  48624. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48625. private readonly _options;
  48626. private static _idCounter;
  48627. private _attachController;
  48628. private _controllers;
  48629. private _scene;
  48630. private _tmpVectorForPickCompare;
  48631. /**
  48632. * The module's name
  48633. */
  48634. static readonly Name: string;
  48635. /**
  48636. * The (Babylon) version of this module.
  48637. * This is an integer representing the implementation version.
  48638. * This number does not correspond to the WebXR specs version
  48639. */
  48640. static readonly Version: number;
  48641. /**
  48642. * Disable lighting on the laser pointer (so it will always be visible)
  48643. */
  48644. disablePointerLighting: boolean;
  48645. /**
  48646. * Disable lighting on the selection mesh (so it will always be visible)
  48647. */
  48648. disableSelectionMeshLighting: boolean;
  48649. /**
  48650. * Should the laser pointer be displayed
  48651. */
  48652. displayLaserPointer: boolean;
  48653. /**
  48654. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48655. */
  48656. displaySelectionMesh: boolean;
  48657. /**
  48658. * This color will be set to the laser pointer when selection is triggered
  48659. */
  48660. laserPointerPickedColor: Color3;
  48661. /**
  48662. * Default color of the laser pointer
  48663. */
  48664. laserPointerDefaultColor: Color3;
  48665. /**
  48666. * default color of the selection ring
  48667. */
  48668. selectionMeshDefaultColor: Color3;
  48669. /**
  48670. * This color will be applied to the selection ring when selection is triggered
  48671. */
  48672. selectionMeshPickedColor: Color3;
  48673. /**
  48674. * Optional filter to be used for ray selection. This predicate shares behavior with
  48675. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48676. */
  48677. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48678. /**
  48679. * constructs a new background remover module
  48680. * @param _xrSessionManager the session manager for this module
  48681. * @param _options read-only options to be used in this module
  48682. */
  48683. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48684. /**
  48685. * attach this feature
  48686. * Will usually be called by the features manager
  48687. *
  48688. * @returns true if successful.
  48689. */
  48690. attach(): boolean;
  48691. /**
  48692. * detach this feature.
  48693. * Will usually be called by the features manager
  48694. *
  48695. * @returns true if successful.
  48696. */
  48697. detach(): boolean;
  48698. /**
  48699. * Will get the mesh under a specific pointer.
  48700. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48701. * @param controllerId the controllerId to check
  48702. * @returns The mesh under pointer or null if no mesh is under the pointer
  48703. */
  48704. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48705. /**
  48706. * Get the xr controller that correlates to the pointer id in the pointer event
  48707. *
  48708. * @param id the pointer id to search for
  48709. * @returns the controller that correlates to this id or null if not found
  48710. */
  48711. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48712. protected _onXRFrame(_xrFrame: XRFrame): void;
  48713. private _attachGazeMode;
  48714. private _attachScreenRayMode;
  48715. private _attachTrackedPointerRayMode;
  48716. private _convertNormalToDirectionOfRay;
  48717. private _detachController;
  48718. private _generateNewMeshPair;
  48719. private _pickingMoved;
  48720. private _updatePointerDistance;
  48721. /** @hidden */
  48722. get lasterPointerDefaultColor(): Color3;
  48723. }
  48724. }
  48725. declare module BABYLON {
  48726. /**
  48727. * Button which can be used to enter a different mode of XR
  48728. */
  48729. export class WebXREnterExitUIButton {
  48730. /** button element */
  48731. element: HTMLElement;
  48732. /** XR initialization options for the button */
  48733. sessionMode: XRSessionMode;
  48734. /** Reference space type */
  48735. referenceSpaceType: XRReferenceSpaceType;
  48736. /**
  48737. * Creates a WebXREnterExitUIButton
  48738. * @param element button element
  48739. * @param sessionMode XR initialization session mode
  48740. * @param referenceSpaceType the type of reference space to be used
  48741. */
  48742. constructor(
  48743. /** button element */
  48744. element: HTMLElement,
  48745. /** XR initialization options for the button */
  48746. sessionMode: XRSessionMode,
  48747. /** Reference space type */
  48748. referenceSpaceType: XRReferenceSpaceType);
  48749. /**
  48750. * Extendable function which can be used to update the button's visuals when the state changes
  48751. * @param activeButton the current active button in the UI
  48752. */
  48753. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48754. }
  48755. /**
  48756. * Options to create the webXR UI
  48757. */
  48758. export class WebXREnterExitUIOptions {
  48759. /**
  48760. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48761. */
  48762. customButtons?: Array<WebXREnterExitUIButton>;
  48763. /**
  48764. * A reference space type to use when creating the default button.
  48765. * Default is local-floor
  48766. */
  48767. referenceSpaceType?: XRReferenceSpaceType;
  48768. /**
  48769. * Context to enter xr with
  48770. */
  48771. renderTarget?: Nullable<WebXRRenderTarget>;
  48772. /**
  48773. * A session mode to use when creating the default button.
  48774. * Default is immersive-vr
  48775. */
  48776. sessionMode?: XRSessionMode;
  48777. /**
  48778. * A list of optional features to init the session with
  48779. */
  48780. optionalFeatures?: string[];
  48781. /**
  48782. * A list of optional features to init the session with
  48783. */
  48784. requiredFeatures?: string[];
  48785. }
  48786. /**
  48787. * UI to allow the user to enter/exit XR mode
  48788. */
  48789. export class WebXREnterExitUI implements IDisposable {
  48790. private scene;
  48791. /** version of the options passed to this UI */
  48792. options: WebXREnterExitUIOptions;
  48793. private _activeButton;
  48794. private _buttons;
  48795. private _overlay;
  48796. /**
  48797. * Fired every time the active button is changed.
  48798. *
  48799. * When xr is entered via a button that launches xr that button will be the callback parameter
  48800. *
  48801. * When exiting xr the callback parameter will be null)
  48802. */
  48803. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48804. /**
  48805. *
  48806. * @param scene babylon scene object to use
  48807. * @param options (read-only) version of the options passed to this UI
  48808. */
  48809. private constructor();
  48810. /**
  48811. * Creates UI to allow the user to enter/exit XR mode
  48812. * @param scene the scene to add the ui to
  48813. * @param helper the xr experience helper to enter/exit xr with
  48814. * @param options options to configure the UI
  48815. * @returns the created ui
  48816. */
  48817. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48818. /**
  48819. * Disposes of the XR UI component
  48820. */
  48821. dispose(): void;
  48822. private _updateButtons;
  48823. }
  48824. }
  48825. declare module BABYLON {
  48826. /**
  48827. * Class containing static functions to help procedurally build meshes
  48828. */
  48829. export class LinesBuilder {
  48830. /**
  48831. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48832. * * 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
  48833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48834. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48835. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48836. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48837. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48838. * * 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
  48839. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48842. * @param name defines the name of the new line system
  48843. * @param options defines the options used to create the line system
  48844. * @param scene defines the hosting scene
  48845. * @returns a new line system mesh
  48846. */
  48847. static CreateLineSystem(name: string, options: {
  48848. lines: Vector3[][];
  48849. updatable?: boolean;
  48850. instance?: Nullable<LinesMesh>;
  48851. colors?: Nullable<Color4[][]>;
  48852. useVertexAlpha?: boolean;
  48853. }, scene: Nullable<Scene>): LinesMesh;
  48854. /**
  48855. * Creates a line mesh
  48856. * 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
  48857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48858. * * The parameter `points` is an array successive Vector3
  48859. * * 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
  48860. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48862. * * When updating an instance, remember that only point positions can change, not the number of points
  48863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48865. * @param name defines the name of the new line system
  48866. * @param options defines the options used to create the line system
  48867. * @param scene defines the hosting scene
  48868. * @returns a new line mesh
  48869. */
  48870. static CreateLines(name: string, options: {
  48871. points: Vector3[];
  48872. updatable?: boolean;
  48873. instance?: Nullable<LinesMesh>;
  48874. colors?: Color4[];
  48875. useVertexAlpha?: boolean;
  48876. }, scene?: Nullable<Scene>): LinesMesh;
  48877. /**
  48878. * Creates a dashed line mesh
  48879. * * 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
  48880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48881. * * The parameter `points` is an array successive Vector3
  48882. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48883. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48884. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48885. * * 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
  48886. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48887. * * When updating an instance, remember that only point positions can change, not the number of points
  48888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48889. * @param name defines the name of the mesh
  48890. * @param options defines the options used to create the mesh
  48891. * @param scene defines the hosting scene
  48892. * @returns the dashed line mesh
  48893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48894. */
  48895. static CreateDashedLines(name: string, options: {
  48896. points: Vector3[];
  48897. dashSize?: number;
  48898. gapSize?: number;
  48899. dashNb?: number;
  48900. updatable?: boolean;
  48901. instance?: LinesMesh;
  48902. useVertexAlpha?: boolean;
  48903. }, scene?: Nullable<Scene>): LinesMesh;
  48904. }
  48905. }
  48906. declare module BABYLON {
  48907. /**
  48908. * Construction options for a timer
  48909. */
  48910. export interface ITimerOptions<T> {
  48911. /**
  48912. * Time-to-end
  48913. */
  48914. timeout: number;
  48915. /**
  48916. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48917. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48918. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48919. */
  48920. contextObservable: Observable<T>;
  48921. /**
  48922. * Optional parameters when adding an observer to the observable
  48923. */
  48924. observableParameters?: {
  48925. mask?: number;
  48926. insertFirst?: boolean;
  48927. scope?: any;
  48928. };
  48929. /**
  48930. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48931. */
  48932. breakCondition?: (data?: ITimerData<T>) => boolean;
  48933. /**
  48934. * Will be triggered when the time condition has met
  48935. */
  48936. onEnded?: (data: ITimerData<any>) => void;
  48937. /**
  48938. * Will be triggered when the break condition has met (prematurely ended)
  48939. */
  48940. onAborted?: (data: ITimerData<any>) => void;
  48941. /**
  48942. * Optional function to execute on each tick (or count)
  48943. */
  48944. onTick?: (data: ITimerData<any>) => void;
  48945. }
  48946. /**
  48947. * An interface defining the data sent by the timer
  48948. */
  48949. export interface ITimerData<T> {
  48950. /**
  48951. * When did it start
  48952. */
  48953. startTime: number;
  48954. /**
  48955. * Time now
  48956. */
  48957. currentTime: number;
  48958. /**
  48959. * Time passed since started
  48960. */
  48961. deltaTime: number;
  48962. /**
  48963. * How much is completed, in [0.0...1.0].
  48964. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48965. */
  48966. completeRate: number;
  48967. /**
  48968. * What the registered observable sent in the last count
  48969. */
  48970. payload: T;
  48971. }
  48972. /**
  48973. * The current state of the timer
  48974. */
  48975. export enum TimerState {
  48976. /**
  48977. * Timer initialized, not yet started
  48978. */
  48979. INIT = 0,
  48980. /**
  48981. * Timer started and counting
  48982. */
  48983. STARTED = 1,
  48984. /**
  48985. * Timer ended (whether aborted or time reached)
  48986. */
  48987. ENDED = 2
  48988. }
  48989. /**
  48990. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48991. *
  48992. * @param options options with which to initialize this timer
  48993. */
  48994. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48995. /**
  48996. * An advanced implementation of a timer class
  48997. */
  48998. export class AdvancedTimer<T = any> implements IDisposable {
  48999. /**
  49000. * Will notify each time the timer calculates the remaining time
  49001. */
  49002. onEachCountObservable: Observable<ITimerData<T>>;
  49003. /**
  49004. * Will trigger when the timer was aborted due to the break condition
  49005. */
  49006. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49007. /**
  49008. * Will trigger when the timer ended successfully
  49009. */
  49010. onTimerEndedObservable: Observable<ITimerData<T>>;
  49011. /**
  49012. * Will trigger when the timer state has changed
  49013. */
  49014. onStateChangedObservable: Observable<TimerState>;
  49015. private _observer;
  49016. private _contextObservable;
  49017. private _observableParameters;
  49018. private _startTime;
  49019. private _timer;
  49020. private _state;
  49021. private _breakCondition;
  49022. private _timeToEnd;
  49023. private _breakOnNextTick;
  49024. /**
  49025. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49026. * @param options construction options for this advanced timer
  49027. */
  49028. constructor(options: ITimerOptions<T>);
  49029. /**
  49030. * set a breaking condition for this timer. Default is to never break during count
  49031. * @param predicate the new break condition. Returns true to break, false otherwise
  49032. */
  49033. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49034. /**
  49035. * Reset ALL associated observables in this advanced timer
  49036. */
  49037. clearObservables(): void;
  49038. /**
  49039. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49040. *
  49041. * @param timeToEnd how much time to measure until timer ended
  49042. */
  49043. start(timeToEnd?: number): void;
  49044. /**
  49045. * Will force a stop on the next tick.
  49046. */
  49047. stop(): void;
  49048. /**
  49049. * Dispose this timer, clearing all resources
  49050. */
  49051. dispose(): void;
  49052. private _setState;
  49053. private _tick;
  49054. private _stop;
  49055. }
  49056. }
  49057. declare module BABYLON {
  49058. /**
  49059. * The options container for the teleportation module
  49060. */
  49061. export interface IWebXRTeleportationOptions {
  49062. /**
  49063. * if provided, this scene will be used to render meshes.
  49064. */
  49065. customUtilityLayerScene?: Scene;
  49066. /**
  49067. * Values to configure the default target mesh
  49068. */
  49069. defaultTargetMeshOptions?: {
  49070. /**
  49071. * Fill color of the teleportation area
  49072. */
  49073. teleportationFillColor?: string;
  49074. /**
  49075. * Border color for the teleportation area
  49076. */
  49077. teleportationBorderColor?: string;
  49078. /**
  49079. * Disable the mesh's animation sequence
  49080. */
  49081. disableAnimation?: boolean;
  49082. /**
  49083. * Disable lighting on the material or the ring and arrow
  49084. */
  49085. disableLighting?: boolean;
  49086. /**
  49087. * Override the default material of the torus and arrow
  49088. */
  49089. torusArrowMaterial?: Material;
  49090. };
  49091. /**
  49092. * A list of meshes to use as floor meshes.
  49093. * Meshes can be added and removed after initializing the feature using the
  49094. * addFloorMesh and removeFloorMesh functions
  49095. * If empty, rotation will still work
  49096. */
  49097. floorMeshes?: AbstractMesh[];
  49098. /**
  49099. * use this rendering group id for the meshes (optional)
  49100. */
  49101. renderingGroupId?: number;
  49102. /**
  49103. * Should teleportation move only to snap points
  49104. */
  49105. snapPointsOnly?: boolean;
  49106. /**
  49107. * An array of points to which the teleportation will snap to.
  49108. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49109. */
  49110. snapPositions?: Vector3[];
  49111. /**
  49112. * How close should the teleportation ray be in order to snap to position.
  49113. * Default to 0.8 units (meters)
  49114. */
  49115. snapToPositionRadius?: number;
  49116. /**
  49117. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49118. * If you want to support rotation, make sure your mesh has a direction indicator.
  49119. *
  49120. * When left untouched, the default mesh will be initialized.
  49121. */
  49122. teleportationTargetMesh?: AbstractMesh;
  49123. /**
  49124. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49125. */
  49126. timeToTeleport?: number;
  49127. /**
  49128. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49129. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49130. */
  49131. useMainComponentOnly?: boolean;
  49132. /**
  49133. * Should meshes created here be added to a utility layer or the main scene
  49134. */
  49135. useUtilityLayer?: boolean;
  49136. /**
  49137. * Babylon XR Input class for controller
  49138. */
  49139. xrInput: WebXRInput;
  49140. }
  49141. /**
  49142. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49143. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49144. * the input of the attached controllers.
  49145. */
  49146. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49147. private _options;
  49148. private _controllers;
  49149. private _currentTeleportationControllerId;
  49150. private _floorMeshes;
  49151. private _quadraticBezierCurve;
  49152. private _selectionFeature;
  49153. private _snapToPositions;
  49154. private _snappedToPoint;
  49155. private _teleportationRingMaterial?;
  49156. private _tmpRay;
  49157. private _tmpVector;
  49158. /**
  49159. * The module's name
  49160. */
  49161. static readonly Name: string;
  49162. /**
  49163. * The (Babylon) version of this module.
  49164. * This is an integer representing the implementation version.
  49165. * This number does not correspond to the webxr specs version
  49166. */
  49167. static readonly Version: number;
  49168. /**
  49169. * Is movement backwards enabled
  49170. */
  49171. backwardsMovementEnabled: boolean;
  49172. /**
  49173. * Distance to travel when moving backwards
  49174. */
  49175. backwardsTeleportationDistance: number;
  49176. /**
  49177. * The distance from the user to the inspection point in the direction of the controller
  49178. * A higher number will allow the user to move further
  49179. * defaults to 5 (meters, in xr units)
  49180. */
  49181. parabolicCheckRadius: number;
  49182. /**
  49183. * Should the module support parabolic ray on top of direct ray
  49184. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49185. * Very helpful when moving between floors / different heights
  49186. */
  49187. parabolicRayEnabled: boolean;
  49188. /**
  49189. * How much rotation should be applied when rotating right and left
  49190. */
  49191. rotationAngle: number;
  49192. /**
  49193. * Is rotation enabled when moving forward?
  49194. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49195. */
  49196. rotationEnabled: boolean;
  49197. /**
  49198. * constructs a new anchor system
  49199. * @param _xrSessionManager an instance of WebXRSessionManager
  49200. * @param _options configuration object for this feature
  49201. */
  49202. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49203. /**
  49204. * Get the snapPointsOnly flag
  49205. */
  49206. get snapPointsOnly(): boolean;
  49207. /**
  49208. * Sets the snapPointsOnly flag
  49209. * @param snapToPoints should teleportation be exclusively to snap points
  49210. */
  49211. set snapPointsOnly(snapToPoints: boolean);
  49212. /**
  49213. * Add a new mesh to the floor meshes array
  49214. * @param mesh the mesh to use as floor mesh
  49215. */
  49216. addFloorMesh(mesh: AbstractMesh): void;
  49217. /**
  49218. * Add a new snap-to point to fix teleportation to this position
  49219. * @param newSnapPoint The new Snap-To point
  49220. */
  49221. addSnapPoint(newSnapPoint: Vector3): void;
  49222. attach(): boolean;
  49223. detach(): boolean;
  49224. dispose(): void;
  49225. /**
  49226. * Remove a mesh from the floor meshes array
  49227. * @param mesh the mesh to remove
  49228. */
  49229. removeFloorMesh(mesh: AbstractMesh): void;
  49230. /**
  49231. * Remove a mesh from the floor meshes array using its name
  49232. * @param name the mesh name to remove
  49233. */
  49234. removeFloorMeshByName(name: string): void;
  49235. /**
  49236. * 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
  49237. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49238. * @returns was the point found and removed or not
  49239. */
  49240. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49241. /**
  49242. * This function sets a selection feature that will be disabled when
  49243. * the forward ray is shown and will be reattached when hidden.
  49244. * This is used to remove the selection rays when moving.
  49245. * @param selectionFeature the feature to disable when forward movement is enabled
  49246. */
  49247. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49248. protected _onXRFrame(_xrFrame: XRFrame): void;
  49249. private _attachController;
  49250. private _createDefaultTargetMesh;
  49251. private _detachController;
  49252. private _findClosestSnapPointWithRadius;
  49253. private _setTargetMeshPosition;
  49254. private _setTargetMeshVisibility;
  49255. private _showParabolicPath;
  49256. private _teleportForward;
  49257. }
  49258. }
  49259. declare module BABYLON {
  49260. /**
  49261. * Options for the default xr helper
  49262. */
  49263. export class WebXRDefaultExperienceOptions {
  49264. /**
  49265. * Enable or disable default UI to enter XR
  49266. */
  49267. disableDefaultUI?: boolean;
  49268. /**
  49269. * Should teleportation not initialize. defaults to false.
  49270. */
  49271. disableTeleportation?: boolean;
  49272. /**
  49273. * Floor meshes that will be used for teleport
  49274. */
  49275. floorMeshes?: Array<AbstractMesh>;
  49276. /**
  49277. * If set to true, the first frame will not be used to reset position
  49278. * The first frame is mainly used when copying transformation from the old camera
  49279. * Mainly used in AR
  49280. */
  49281. ignoreNativeCameraTransformation?: boolean;
  49282. /**
  49283. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49284. */
  49285. inputOptions?: IWebXRInputOptions;
  49286. /**
  49287. * optional configuration for the output canvas
  49288. */
  49289. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49290. /**
  49291. * optional UI options. This can be used among other to change session mode and reference space type
  49292. */
  49293. uiOptions?: WebXREnterExitUIOptions;
  49294. /**
  49295. * When loading teleportation and pointer select, use stable versions instead of latest.
  49296. */
  49297. useStablePlugins?: boolean;
  49298. /**
  49299. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49300. */
  49301. renderingGroupId?: number;
  49302. /**
  49303. * A list of optional features to init the session with
  49304. * If set to true, all features we support will be added
  49305. */
  49306. optionalFeatures?: boolean | string[];
  49307. }
  49308. /**
  49309. * Default experience which provides a similar setup to the previous webVRExperience
  49310. */
  49311. export class WebXRDefaultExperience {
  49312. /**
  49313. * Base experience
  49314. */
  49315. baseExperience: WebXRExperienceHelper;
  49316. /**
  49317. * Enables ui for entering/exiting xr
  49318. */
  49319. enterExitUI: WebXREnterExitUI;
  49320. /**
  49321. * Input experience extension
  49322. */
  49323. input: WebXRInput;
  49324. /**
  49325. * Enables laser pointer and selection
  49326. */
  49327. pointerSelection: WebXRControllerPointerSelection;
  49328. /**
  49329. * Default target xr should render to
  49330. */
  49331. renderTarget: WebXRRenderTarget;
  49332. /**
  49333. * Enables teleportation
  49334. */
  49335. teleportation: WebXRMotionControllerTeleportation;
  49336. private constructor();
  49337. /**
  49338. * Creates the default xr experience
  49339. * @param scene scene
  49340. * @param options options for basic configuration
  49341. * @returns resulting WebXRDefaultExperience
  49342. */
  49343. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49344. /**
  49345. * DIsposes of the experience helper
  49346. */
  49347. dispose(): void;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * Options to modify the vr teleportation behavior.
  49353. */
  49354. export interface VRTeleportationOptions {
  49355. /**
  49356. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49357. */
  49358. floorMeshName?: string;
  49359. /**
  49360. * A list of meshes to be used as the teleportation floor. (default: empty)
  49361. */
  49362. floorMeshes?: Mesh[];
  49363. /**
  49364. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49365. */
  49366. teleportationMode?: number;
  49367. /**
  49368. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49369. */
  49370. teleportationTime?: number;
  49371. /**
  49372. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49373. */
  49374. teleportationSpeed?: number;
  49375. /**
  49376. * The easing function used in the animation or null for Linear. (default CircleEase)
  49377. */
  49378. easingFunction?: EasingFunction;
  49379. }
  49380. /**
  49381. * Options to modify the vr experience helper's behavior.
  49382. */
  49383. export interface VRExperienceHelperOptions extends WebVROptions {
  49384. /**
  49385. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49386. */
  49387. createDeviceOrientationCamera?: boolean;
  49388. /**
  49389. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49390. */
  49391. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49392. /**
  49393. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49394. */
  49395. laserToggle?: boolean;
  49396. /**
  49397. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49398. */
  49399. floorMeshes?: Mesh[];
  49400. /**
  49401. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49402. */
  49403. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49404. /**
  49405. * Defines if WebXR should be used instead of WebVR (if available)
  49406. */
  49407. useXR?: boolean;
  49408. }
  49409. /**
  49410. * Event containing information after VR has been entered
  49411. */
  49412. export class OnAfterEnteringVRObservableEvent {
  49413. /**
  49414. * If entering vr was successful
  49415. */
  49416. success: boolean;
  49417. }
  49418. /**
  49419. * Helps to quickly add VR support to an existing scene.
  49420. * See https://doc.babylonjs.com/how_to/webvr_helper
  49421. */
  49422. export class VRExperienceHelper {
  49423. /** Options to modify the vr experience helper's behavior. */
  49424. webVROptions: VRExperienceHelperOptions;
  49425. private _scene;
  49426. private _position;
  49427. private _btnVR;
  49428. private _btnVRDisplayed;
  49429. private _webVRsupported;
  49430. private _webVRready;
  49431. private _webVRrequesting;
  49432. private _webVRpresenting;
  49433. private _hasEnteredVR;
  49434. private _fullscreenVRpresenting;
  49435. private _inputElement;
  49436. private _webVRCamera;
  49437. private _vrDeviceOrientationCamera;
  49438. private _deviceOrientationCamera;
  49439. private _existingCamera;
  49440. private _onKeyDown;
  49441. private _onVrDisplayPresentChange;
  49442. private _onVRDisplayChanged;
  49443. private _onVRRequestPresentStart;
  49444. private _onVRRequestPresentComplete;
  49445. /**
  49446. * 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)
  49447. */
  49448. enableGazeEvenWhenNoPointerLock: boolean;
  49449. /**
  49450. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49451. */
  49452. exitVROnDoubleTap: boolean;
  49453. /**
  49454. * Observable raised right before entering VR.
  49455. */
  49456. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49457. /**
  49458. * Observable raised when entering VR has completed.
  49459. */
  49460. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49461. /**
  49462. * Observable raised when exiting VR.
  49463. */
  49464. onExitingVRObservable: Observable<VRExperienceHelper>;
  49465. /**
  49466. * Observable raised when controller mesh is loaded.
  49467. */
  49468. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49469. /** Return this.onEnteringVRObservable
  49470. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49471. */
  49472. get onEnteringVR(): Observable<VRExperienceHelper>;
  49473. /** Return this.onExitingVRObservable
  49474. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49475. */
  49476. get onExitingVR(): Observable<VRExperienceHelper>;
  49477. /** Return this.onControllerMeshLoadedObservable
  49478. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49479. */
  49480. get onControllerMeshLoaded(): Observable<WebVRController>;
  49481. private _rayLength;
  49482. private _useCustomVRButton;
  49483. private _teleportationRequested;
  49484. private _teleportActive;
  49485. private _floorMeshName;
  49486. private _floorMeshesCollection;
  49487. private _teleportationMode;
  49488. private _teleportationTime;
  49489. private _teleportationSpeed;
  49490. private _teleportationEasing;
  49491. private _rotationAllowed;
  49492. private _teleportBackwardsVector;
  49493. private _teleportationTarget;
  49494. private _isDefaultTeleportationTarget;
  49495. private _postProcessMove;
  49496. private _teleportationFillColor;
  49497. private _teleportationBorderColor;
  49498. private _rotationAngle;
  49499. private _haloCenter;
  49500. private _cameraGazer;
  49501. private _padSensibilityUp;
  49502. private _padSensibilityDown;
  49503. private _leftController;
  49504. private _rightController;
  49505. private _gazeColor;
  49506. private _laserColor;
  49507. private _pickedLaserColor;
  49508. private _pickedGazeColor;
  49509. /**
  49510. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49511. */
  49512. onNewMeshSelected: Observable<AbstractMesh>;
  49513. /**
  49514. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49515. * This observable will provide the mesh and the controller used to select the mesh
  49516. */
  49517. onMeshSelectedWithController: Observable<{
  49518. mesh: AbstractMesh;
  49519. controller: WebVRController;
  49520. }>;
  49521. /**
  49522. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49523. */
  49524. onNewMeshPicked: Observable<PickingInfo>;
  49525. private _circleEase;
  49526. /**
  49527. * Observable raised before camera teleportation
  49528. */
  49529. onBeforeCameraTeleport: Observable<Vector3>;
  49530. /**
  49531. * Observable raised after camera teleportation
  49532. */
  49533. onAfterCameraTeleport: Observable<Vector3>;
  49534. /**
  49535. * Observable raised when current selected mesh gets unselected
  49536. */
  49537. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49538. private _raySelectionPredicate;
  49539. /**
  49540. * To be optionaly changed by user to define custom ray selection
  49541. */
  49542. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49543. /**
  49544. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49545. */
  49546. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49547. /**
  49548. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49549. */
  49550. teleportationEnabled: boolean;
  49551. private _defaultHeight;
  49552. private _teleportationInitialized;
  49553. private _interactionsEnabled;
  49554. private _interactionsRequested;
  49555. private _displayGaze;
  49556. private _displayLaserPointer;
  49557. /**
  49558. * The mesh used to display where the user is going to teleport.
  49559. */
  49560. get teleportationTarget(): Mesh;
  49561. /**
  49562. * Sets the mesh to be used to display where the user is going to teleport.
  49563. */
  49564. set teleportationTarget(value: Mesh);
  49565. /**
  49566. * 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
  49567. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49568. * See https://doc.babylonjs.com/resources/baking_transformations
  49569. */
  49570. get gazeTrackerMesh(): Mesh;
  49571. set gazeTrackerMesh(value: Mesh);
  49572. /**
  49573. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49574. */
  49575. updateGazeTrackerScale: boolean;
  49576. /**
  49577. * If the gaze trackers color should be updated when selecting meshes
  49578. */
  49579. updateGazeTrackerColor: boolean;
  49580. /**
  49581. * If the controller laser color should be updated when selecting meshes
  49582. */
  49583. updateControllerLaserColor: boolean;
  49584. /**
  49585. * The gaze tracking mesh corresponding to the left controller
  49586. */
  49587. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49588. /**
  49589. * The gaze tracking mesh corresponding to the right controller
  49590. */
  49591. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49592. /**
  49593. * If the ray of the gaze should be displayed.
  49594. */
  49595. get displayGaze(): boolean;
  49596. /**
  49597. * Sets if the ray of the gaze should be displayed.
  49598. */
  49599. set displayGaze(value: boolean);
  49600. /**
  49601. * If the ray of the LaserPointer should be displayed.
  49602. */
  49603. get displayLaserPointer(): boolean;
  49604. /**
  49605. * Sets if the ray of the LaserPointer should be displayed.
  49606. */
  49607. set displayLaserPointer(value: boolean);
  49608. /**
  49609. * The deviceOrientationCamera used as the camera when not in VR.
  49610. */
  49611. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49612. /**
  49613. * Based on the current WebVR support, returns the current VR camera used.
  49614. */
  49615. get currentVRCamera(): Nullable<Camera>;
  49616. /**
  49617. * The webVRCamera which is used when in VR.
  49618. */
  49619. get webVRCamera(): WebVRFreeCamera;
  49620. /**
  49621. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49622. */
  49623. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49624. /**
  49625. * The html button that is used to trigger entering into VR.
  49626. */
  49627. get vrButton(): Nullable<HTMLButtonElement>;
  49628. private get _teleportationRequestInitiated();
  49629. /**
  49630. * Defines whether or not Pointer lock should be requested when switching to
  49631. * full screen.
  49632. */
  49633. requestPointerLockOnFullScreen: boolean;
  49634. /**
  49635. * If asking to force XR, this will be populated with the default xr experience
  49636. */
  49637. xr: WebXRDefaultExperience;
  49638. /**
  49639. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49640. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49641. */
  49642. xrTestDone: boolean;
  49643. /**
  49644. * Instantiates a VRExperienceHelper.
  49645. * Helps to quickly add VR support to an existing scene.
  49646. * @param scene The scene the VRExperienceHelper belongs to.
  49647. * @param webVROptions Options to modify the vr experience helper's behavior.
  49648. */
  49649. constructor(scene: Scene,
  49650. /** Options to modify the vr experience helper's behavior. */
  49651. webVROptions?: VRExperienceHelperOptions);
  49652. private completeVRInit;
  49653. private _onDefaultMeshLoaded;
  49654. private _onResize;
  49655. private _onFullscreenChange;
  49656. /**
  49657. * Gets a value indicating if we are currently in VR mode.
  49658. */
  49659. get isInVRMode(): boolean;
  49660. private onVrDisplayPresentChange;
  49661. private onVRDisplayChanged;
  49662. private moveButtonToBottomRight;
  49663. private displayVRButton;
  49664. private updateButtonVisibility;
  49665. private _cachedAngularSensibility;
  49666. /**
  49667. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49668. * Otherwise, will use the fullscreen API.
  49669. */
  49670. enterVR(): void;
  49671. /**
  49672. * Attempt to exit VR, or fullscreen.
  49673. */
  49674. exitVR(): void;
  49675. /**
  49676. * The position of the vr experience helper.
  49677. */
  49678. get position(): Vector3;
  49679. /**
  49680. * Sets the position of the vr experience helper.
  49681. */
  49682. set position(value: Vector3);
  49683. /**
  49684. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49685. */
  49686. enableInteractions(): void;
  49687. private get _noControllerIsActive();
  49688. private beforeRender;
  49689. private _isTeleportationFloor;
  49690. /**
  49691. * Adds a floor mesh to be used for teleportation.
  49692. * @param floorMesh the mesh to be used for teleportation.
  49693. */
  49694. addFloorMesh(floorMesh: Mesh): void;
  49695. /**
  49696. * Removes a floor mesh from being used for teleportation.
  49697. * @param floorMesh the mesh to be removed.
  49698. */
  49699. removeFloorMesh(floorMesh: Mesh): void;
  49700. /**
  49701. * Enables interactions and teleportation using the VR controllers and gaze.
  49702. * @param vrTeleportationOptions options to modify teleportation behavior.
  49703. */
  49704. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49705. private _onNewGamepadConnected;
  49706. private _tryEnableInteractionOnController;
  49707. private _onNewGamepadDisconnected;
  49708. private _enableInteractionOnController;
  49709. private _checkTeleportWithRay;
  49710. private _checkRotate;
  49711. private _checkTeleportBackwards;
  49712. private _enableTeleportationOnController;
  49713. private _createTeleportationCircles;
  49714. private _displayTeleportationTarget;
  49715. private _hideTeleportationTarget;
  49716. private _rotateCamera;
  49717. private _moveTeleportationSelectorTo;
  49718. private _workingVector;
  49719. private _workingQuaternion;
  49720. private _workingMatrix;
  49721. /**
  49722. * Time Constant Teleportation Mode
  49723. */
  49724. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49725. /**
  49726. * Speed Constant Teleportation Mode
  49727. */
  49728. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49729. /**
  49730. * Teleports the users feet to the desired location
  49731. * @param location The location where the user's feet should be placed
  49732. */
  49733. teleportCamera(location: Vector3): void;
  49734. private _convertNormalToDirectionOfRay;
  49735. private _castRayAndSelectObject;
  49736. private _notifySelectedMeshUnselected;
  49737. /**
  49738. * Permanently set new colors for the laser pointer
  49739. * @param color the new laser color
  49740. * @param pickedColor the new laser color when picked mesh detected
  49741. */
  49742. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49743. /**
  49744. * Set lighting enabled / disabled on the laser pointer of both controllers
  49745. * @param enabled should the lighting be enabled on the laser pointer
  49746. */
  49747. setLaserLightingState(enabled?: boolean): void;
  49748. /**
  49749. * Permanently set new colors for the gaze pointer
  49750. * @param color the new gaze color
  49751. * @param pickedColor the new gaze color when picked mesh detected
  49752. */
  49753. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49754. /**
  49755. * Sets the color of the laser ray from the vr controllers.
  49756. * @param color new color for the ray.
  49757. */
  49758. changeLaserColor(color: Color3): void;
  49759. /**
  49760. * Sets the color of the ray from the vr headsets gaze.
  49761. * @param color new color for the ray.
  49762. */
  49763. changeGazeColor(color: Color3): void;
  49764. /**
  49765. * Exits VR and disposes of the vr experience helper
  49766. */
  49767. dispose(): void;
  49768. /**
  49769. * Gets the name of the VRExperienceHelper class
  49770. * @returns "VRExperienceHelper"
  49771. */
  49772. getClassName(): string;
  49773. }
  49774. }
  49775. declare module BABYLON {
  49776. /**
  49777. * Contains an array of blocks representing the octree
  49778. */
  49779. export interface IOctreeContainer<T> {
  49780. /**
  49781. * Blocks within the octree
  49782. */
  49783. blocks: Array<OctreeBlock<T>>;
  49784. }
  49785. /**
  49786. * Class used to store a cell in an octree
  49787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49788. */
  49789. export class OctreeBlock<T> {
  49790. /**
  49791. * Gets the content of the current block
  49792. */
  49793. entries: T[];
  49794. /**
  49795. * Gets the list of block children
  49796. */
  49797. blocks: Array<OctreeBlock<T>>;
  49798. private _depth;
  49799. private _maxDepth;
  49800. private _capacity;
  49801. private _minPoint;
  49802. private _maxPoint;
  49803. private _boundingVectors;
  49804. private _creationFunc;
  49805. /**
  49806. * Creates a new block
  49807. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49808. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49809. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49810. * @param depth defines the current depth of this block in the octree
  49811. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49812. * @param creationFunc defines a callback to call when an element is added to the block
  49813. */
  49814. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49815. /**
  49816. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49817. */
  49818. get capacity(): number;
  49819. /**
  49820. * Gets the minimum vector (in world space) of the block's bounding box
  49821. */
  49822. get minPoint(): Vector3;
  49823. /**
  49824. * Gets the maximum vector (in world space) of the block's bounding box
  49825. */
  49826. get maxPoint(): Vector3;
  49827. /**
  49828. * Add a new element to this block
  49829. * @param entry defines the element to add
  49830. */
  49831. addEntry(entry: T): void;
  49832. /**
  49833. * Remove an element from this block
  49834. * @param entry defines the element to remove
  49835. */
  49836. removeEntry(entry: T): void;
  49837. /**
  49838. * Add an array of elements to this block
  49839. * @param entries defines the array of elements to add
  49840. */
  49841. addEntries(entries: T[]): void;
  49842. /**
  49843. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49844. * @param frustumPlanes defines the frustum planes to test
  49845. * @param selection defines the array to store current content if selection is positive
  49846. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49847. */
  49848. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49849. /**
  49850. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49851. * @param sphereCenter defines the bounding sphere center
  49852. * @param sphereRadius defines the bounding sphere radius
  49853. * @param selection defines the array to store current content if selection is positive
  49854. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49855. */
  49856. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49857. /**
  49858. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49859. * @param ray defines the ray to test with
  49860. * @param selection defines the array to store current content if selection is positive
  49861. */
  49862. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49863. /**
  49864. * Subdivide the content into child blocks (this block will then be empty)
  49865. */
  49866. createInnerBlocks(): void;
  49867. /**
  49868. * @hidden
  49869. */
  49870. 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;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49876. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49877. */
  49878. export class Octree<T> {
  49879. /** 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.) */
  49880. maxDepth: number;
  49881. /**
  49882. * Blocks within the octree containing objects
  49883. */
  49884. blocks: Array<OctreeBlock<T>>;
  49885. /**
  49886. * Content stored in the octree
  49887. */
  49888. dynamicContent: T[];
  49889. private _maxBlockCapacity;
  49890. private _selectionContent;
  49891. private _creationFunc;
  49892. /**
  49893. * Creates a octree
  49894. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49895. * @param creationFunc function to be used to instatiate the octree
  49896. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49897. * @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.)
  49898. */
  49899. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49900. /** 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.) */
  49901. maxDepth?: number);
  49902. /**
  49903. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49904. * @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);
  49905. * @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);
  49906. * @param entries meshes to be added to the octree blocks
  49907. */
  49908. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49909. /**
  49910. * Adds a mesh to the octree
  49911. * @param entry Mesh to add to the octree
  49912. */
  49913. addMesh(entry: T): void;
  49914. /**
  49915. * Remove an element from the octree
  49916. * @param entry defines the element to remove
  49917. */
  49918. removeMesh(entry: T): void;
  49919. /**
  49920. * Selects an array of meshes within the frustum
  49921. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49922. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49923. * @returns array of meshes within the frustum
  49924. */
  49925. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49926. /**
  49927. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49928. * @param sphereCenter defines the bounding sphere center
  49929. * @param sphereRadius defines the bounding sphere radius
  49930. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49931. * @returns an array of objects that intersect the sphere
  49932. */
  49933. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49934. /**
  49935. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49936. * @param ray defines the ray to test with
  49937. * @returns array of intersected objects
  49938. */
  49939. intersectsRay(ray: Ray): SmartArray<T>;
  49940. /**
  49941. * Adds a mesh into the octree block if it intersects the block
  49942. */
  49943. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49944. /**
  49945. * Adds a submesh into the octree block if it intersects the block
  49946. */
  49947. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49948. }
  49949. }
  49950. declare module BABYLON {
  49951. interface Scene {
  49952. /**
  49953. * @hidden
  49954. * Backing Filed
  49955. */
  49956. _selectionOctree: Octree<AbstractMesh>;
  49957. /**
  49958. * Gets the octree used to boost mesh selection (picking)
  49959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49960. */
  49961. selectionOctree: Octree<AbstractMesh>;
  49962. /**
  49963. * Creates or updates the octree used to boost selection (picking)
  49964. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49965. * @param maxCapacity defines the maximum capacity per leaf
  49966. * @param maxDepth defines the maximum depth of the octree
  49967. * @returns an octree of AbstractMesh
  49968. */
  49969. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49970. }
  49971. interface AbstractMesh {
  49972. /**
  49973. * @hidden
  49974. * Backing Field
  49975. */
  49976. _submeshesOctree: Octree<SubMesh>;
  49977. /**
  49978. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49979. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49980. * @param maxCapacity defines the maximum size of each block (64 by default)
  49981. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49982. * @returns the new octree
  49983. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49984. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49985. */
  49986. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49987. }
  49988. /**
  49989. * Defines the octree scene component responsible to manage any octrees
  49990. * in a given scene.
  49991. */
  49992. export class OctreeSceneComponent {
  49993. /**
  49994. * The component name help to identify the component in the list of scene components.
  49995. */
  49996. readonly name: string;
  49997. /**
  49998. * The scene the component belongs to.
  49999. */
  50000. scene: Scene;
  50001. /**
  50002. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50003. */
  50004. readonly checksIsEnabled: boolean;
  50005. /**
  50006. * Creates a new instance of the component for the given scene
  50007. * @param scene Defines the scene to register the component in
  50008. */
  50009. constructor(scene: Scene);
  50010. /**
  50011. * Registers the component in a given scene
  50012. */
  50013. register(): void;
  50014. /**
  50015. * Return the list of active meshes
  50016. * @returns the list of active meshes
  50017. */
  50018. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50019. /**
  50020. * Return the list of active sub meshes
  50021. * @param mesh The mesh to get the candidates sub meshes from
  50022. * @returns the list of active sub meshes
  50023. */
  50024. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50025. private _tempRay;
  50026. /**
  50027. * Return the list of sub meshes intersecting with a given local ray
  50028. * @param mesh defines the mesh to find the submesh for
  50029. * @param localRay defines the ray in local space
  50030. * @returns the list of intersecting sub meshes
  50031. */
  50032. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50033. /**
  50034. * Return the list of sub meshes colliding with a collider
  50035. * @param mesh defines the mesh to find the submesh for
  50036. * @param collider defines the collider to evaluate the collision against
  50037. * @returns the list of colliding sub meshes
  50038. */
  50039. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50040. /**
  50041. * Rebuilds the elements related to this component in case of
  50042. * context lost for instance.
  50043. */
  50044. rebuild(): void;
  50045. /**
  50046. * Disposes the component and the associated ressources.
  50047. */
  50048. dispose(): void;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50054. */
  50055. export class Gizmo implements IDisposable {
  50056. /** The utility layer the gizmo will be added to */
  50057. gizmoLayer: UtilityLayerRenderer;
  50058. /**
  50059. * The root mesh of the gizmo
  50060. */
  50061. _rootMesh: Mesh;
  50062. private _attachedMesh;
  50063. private _attachedNode;
  50064. /**
  50065. * Ratio for the scale of the gizmo (Default: 1)
  50066. */
  50067. scaleRatio: number;
  50068. /**
  50069. * If a custom mesh has been set (Default: false)
  50070. */
  50071. protected _customMeshSet: boolean;
  50072. /**
  50073. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50074. * * When set, interactions will be enabled
  50075. */
  50076. get attachedMesh(): Nullable<AbstractMesh>;
  50077. set attachedMesh(value: Nullable<AbstractMesh>);
  50078. /**
  50079. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50080. * * When set, interactions will be enabled
  50081. */
  50082. get attachedNode(): Nullable<Node>;
  50083. set attachedNode(value: Nullable<Node>);
  50084. /**
  50085. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50086. * @param mesh The mesh to replace the default mesh of the gizmo
  50087. */
  50088. setCustomMesh(mesh: Mesh): void;
  50089. /**
  50090. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50091. */
  50092. updateGizmoRotationToMatchAttachedMesh: boolean;
  50093. /**
  50094. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50095. */
  50096. updateGizmoPositionToMatchAttachedMesh: boolean;
  50097. /**
  50098. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50099. */
  50100. updateScale: boolean;
  50101. protected _interactionsEnabled: boolean;
  50102. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50103. private _beforeRenderObserver;
  50104. private _tempVector;
  50105. /**
  50106. * Creates a gizmo
  50107. * @param gizmoLayer The utility layer the gizmo will be added to
  50108. */
  50109. constructor(
  50110. /** The utility layer the gizmo will be added to */
  50111. gizmoLayer?: UtilityLayerRenderer);
  50112. /**
  50113. * Updates the gizmo to match the attached mesh's position/rotation
  50114. */
  50115. protected _update(): void;
  50116. /**
  50117. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50118. * @param value Node, TransformNode or mesh
  50119. */
  50120. protected _matrixChanged(): void;
  50121. /**
  50122. * Disposes of the gizmo
  50123. */
  50124. dispose(): void;
  50125. }
  50126. }
  50127. declare module BABYLON {
  50128. /**
  50129. * Single plane drag gizmo
  50130. */
  50131. export class PlaneDragGizmo extends Gizmo {
  50132. /**
  50133. * Drag behavior responsible for the gizmos dragging interactions
  50134. */
  50135. dragBehavior: PointerDragBehavior;
  50136. private _pointerObserver;
  50137. /**
  50138. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50139. */
  50140. snapDistance: number;
  50141. /**
  50142. * Event that fires each time the gizmo snaps to a new location.
  50143. * * snapDistance is the the change in distance
  50144. */
  50145. onSnapObservable: Observable<{
  50146. snapDistance: number;
  50147. }>;
  50148. private _plane;
  50149. private _coloredMaterial;
  50150. private _hoverMaterial;
  50151. private _isEnabled;
  50152. private _parent;
  50153. /** @hidden */
  50154. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50155. /** @hidden */
  50156. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50157. /**
  50158. * Creates a PlaneDragGizmo
  50159. * @param gizmoLayer The utility layer the gizmo will be added to
  50160. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50161. * @param color The color of the gizmo
  50162. */
  50163. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50164. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50165. /**
  50166. * If the gizmo is enabled
  50167. */
  50168. set isEnabled(value: boolean);
  50169. get isEnabled(): boolean;
  50170. /**
  50171. * Disposes of the gizmo
  50172. */
  50173. dispose(): void;
  50174. }
  50175. }
  50176. declare module BABYLON {
  50177. /**
  50178. * Gizmo that enables dragging a mesh along 3 axis
  50179. */
  50180. export class PositionGizmo extends Gizmo {
  50181. /**
  50182. * Internal gizmo used for interactions on the x axis
  50183. */
  50184. xGizmo: AxisDragGizmo;
  50185. /**
  50186. * Internal gizmo used for interactions on the y axis
  50187. */
  50188. yGizmo: AxisDragGizmo;
  50189. /**
  50190. * Internal gizmo used for interactions on the z axis
  50191. */
  50192. zGizmo: AxisDragGizmo;
  50193. /**
  50194. * Internal gizmo used for interactions on the yz plane
  50195. */
  50196. xPlaneGizmo: PlaneDragGizmo;
  50197. /**
  50198. * Internal gizmo used for interactions on the xz plane
  50199. */
  50200. yPlaneGizmo: PlaneDragGizmo;
  50201. /**
  50202. * Internal gizmo used for interactions on the xy plane
  50203. */
  50204. zPlaneGizmo: PlaneDragGizmo;
  50205. /**
  50206. * private variables
  50207. */
  50208. private _meshAttached;
  50209. private _nodeAttached;
  50210. private _updateGizmoRotationToMatchAttachedMesh;
  50211. private _snapDistance;
  50212. private _scaleRatio;
  50213. /** Fires an event when any of it's sub gizmos are dragged */
  50214. onDragStartObservable: Observable<unknown>;
  50215. /** Fires an event when any of it's sub gizmos are released from dragging */
  50216. onDragEndObservable: Observable<unknown>;
  50217. /**
  50218. * If set to true, planar drag is enabled
  50219. */
  50220. private _planarGizmoEnabled;
  50221. get attachedMesh(): Nullable<AbstractMesh>;
  50222. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50223. get attachedNode(): Nullable<Node>;
  50224. set attachedNode(node: Nullable<Node>);
  50225. /**
  50226. * Creates a PositionGizmo
  50227. * @param gizmoLayer The utility layer the gizmo will be added to
  50228. @param thickness display gizmo axis thickness
  50229. */
  50230. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50231. /**
  50232. * If the planar drag gizmo is enabled
  50233. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50234. */
  50235. set planarGizmoEnabled(value: boolean);
  50236. get planarGizmoEnabled(): boolean;
  50237. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50238. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50239. /**
  50240. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50241. */
  50242. set snapDistance(value: number);
  50243. get snapDistance(): number;
  50244. /**
  50245. * Ratio for the scale of the gizmo (Default: 1)
  50246. */
  50247. set scaleRatio(value: number);
  50248. get scaleRatio(): number;
  50249. /**
  50250. * Disposes of the gizmo
  50251. */
  50252. dispose(): void;
  50253. /**
  50254. * CustomMeshes are not supported by this gizmo
  50255. * @param mesh The mesh to replace the default mesh of the gizmo
  50256. */
  50257. setCustomMesh(mesh: Mesh): void;
  50258. }
  50259. }
  50260. declare module BABYLON {
  50261. /**
  50262. * Single axis drag gizmo
  50263. */
  50264. export class AxisDragGizmo extends Gizmo {
  50265. /**
  50266. * Drag behavior responsible for the gizmos dragging interactions
  50267. */
  50268. dragBehavior: PointerDragBehavior;
  50269. private _pointerObserver;
  50270. /**
  50271. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50272. */
  50273. snapDistance: number;
  50274. /**
  50275. * Event that fires each time the gizmo snaps to a new location.
  50276. * * snapDistance is the the change in distance
  50277. */
  50278. onSnapObservable: Observable<{
  50279. snapDistance: number;
  50280. }>;
  50281. private _isEnabled;
  50282. private _parent;
  50283. private _arrow;
  50284. private _coloredMaterial;
  50285. private _hoverMaterial;
  50286. /** @hidden */
  50287. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50288. /** @hidden */
  50289. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50290. /**
  50291. * Creates an AxisDragGizmo
  50292. * @param gizmoLayer The utility layer the gizmo will be added to
  50293. * @param dragAxis The axis which the gizmo will be able to drag on
  50294. * @param color The color of the gizmo
  50295. * @param thickness display gizmo axis thickness
  50296. */
  50297. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50298. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50299. /**
  50300. * If the gizmo is enabled
  50301. */
  50302. set isEnabled(value: boolean);
  50303. get isEnabled(): boolean;
  50304. /**
  50305. * Disposes of the gizmo
  50306. */
  50307. dispose(): void;
  50308. }
  50309. }
  50310. declare module BABYLON.Debug {
  50311. /**
  50312. * The Axes viewer will show 3 axes in a specific point in space
  50313. */
  50314. export class AxesViewer {
  50315. private _xAxis;
  50316. private _yAxis;
  50317. private _zAxis;
  50318. private _scaleLinesFactor;
  50319. private _instanced;
  50320. /**
  50321. * Gets the hosting scene
  50322. */
  50323. scene: Scene;
  50324. /**
  50325. * Gets or sets a number used to scale line length
  50326. */
  50327. scaleLines: number;
  50328. /** Gets the node hierarchy used to render x-axis */
  50329. get xAxis(): TransformNode;
  50330. /** Gets the node hierarchy used to render y-axis */
  50331. get yAxis(): TransformNode;
  50332. /** Gets the node hierarchy used to render z-axis */
  50333. get zAxis(): TransformNode;
  50334. /**
  50335. * Creates a new AxesViewer
  50336. * @param scene defines the hosting scene
  50337. * @param scaleLines defines a number used to scale line length (1 by default)
  50338. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50339. * @param xAxis defines the node hierarchy used to render the x-axis
  50340. * @param yAxis defines the node hierarchy used to render the y-axis
  50341. * @param zAxis defines the node hierarchy used to render the z-axis
  50342. */
  50343. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50344. /**
  50345. * Force the viewer to update
  50346. * @param position defines the position of the viewer
  50347. * @param xaxis defines the x axis of the viewer
  50348. * @param yaxis defines the y axis of the viewer
  50349. * @param zaxis defines the z axis of the viewer
  50350. */
  50351. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50352. /**
  50353. * Creates an instance of this axes viewer.
  50354. * @returns a new axes viewer with instanced meshes
  50355. */
  50356. createInstance(): AxesViewer;
  50357. /** Releases resources */
  50358. dispose(): void;
  50359. private static _SetRenderingGroupId;
  50360. }
  50361. }
  50362. declare module BABYLON.Debug {
  50363. /**
  50364. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50365. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50366. */
  50367. export class BoneAxesViewer extends AxesViewer {
  50368. /**
  50369. * Gets or sets the target mesh where to display the axes viewer
  50370. */
  50371. mesh: Nullable<Mesh>;
  50372. /**
  50373. * Gets or sets the target bone where to display the axes viewer
  50374. */
  50375. bone: Nullable<Bone>;
  50376. /** Gets current position */
  50377. pos: Vector3;
  50378. /** Gets direction of X axis */
  50379. xaxis: Vector3;
  50380. /** Gets direction of Y axis */
  50381. yaxis: Vector3;
  50382. /** Gets direction of Z axis */
  50383. zaxis: Vector3;
  50384. /**
  50385. * Creates a new BoneAxesViewer
  50386. * @param scene defines the hosting scene
  50387. * @param bone defines the target bone
  50388. * @param mesh defines the target mesh
  50389. * @param scaleLines defines a scaling factor for line length (1 by default)
  50390. */
  50391. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50392. /**
  50393. * Force the viewer to update
  50394. */
  50395. update(): void;
  50396. /** Releases resources */
  50397. dispose(): void;
  50398. }
  50399. }
  50400. declare module BABYLON {
  50401. /**
  50402. * Interface used to define scene explorer extensibility option
  50403. */
  50404. export interface IExplorerExtensibilityOption {
  50405. /**
  50406. * Define the option label
  50407. */
  50408. label: string;
  50409. /**
  50410. * Defines the action to execute on click
  50411. */
  50412. action: (entity: any) => void;
  50413. }
  50414. /**
  50415. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50416. */
  50417. export interface IExplorerExtensibilityGroup {
  50418. /**
  50419. * Defines a predicate to test if a given type mut be extended
  50420. */
  50421. predicate: (entity: any) => boolean;
  50422. /**
  50423. * Gets the list of options added to a type
  50424. */
  50425. entries: IExplorerExtensibilityOption[];
  50426. }
  50427. /**
  50428. * Interface used to define the options to use to create the Inspector
  50429. */
  50430. export interface IInspectorOptions {
  50431. /**
  50432. * Display in overlay mode (default: false)
  50433. */
  50434. overlay?: boolean;
  50435. /**
  50436. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50437. */
  50438. globalRoot?: HTMLElement;
  50439. /**
  50440. * Display the Scene explorer
  50441. */
  50442. showExplorer?: boolean;
  50443. /**
  50444. * Display the property inspector
  50445. */
  50446. showInspector?: boolean;
  50447. /**
  50448. * Display in embed mode (both panes on the right)
  50449. */
  50450. embedMode?: boolean;
  50451. /**
  50452. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50453. */
  50454. handleResize?: boolean;
  50455. /**
  50456. * Allow the panes to popup (default: true)
  50457. */
  50458. enablePopup?: boolean;
  50459. /**
  50460. * Allow the panes to be closed by users (default: true)
  50461. */
  50462. enableClose?: boolean;
  50463. /**
  50464. * Optional list of extensibility entries
  50465. */
  50466. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50467. /**
  50468. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50469. */
  50470. inspectorURL?: string;
  50471. /**
  50472. * Optional initial tab (default to DebugLayerTab.Properties)
  50473. */
  50474. initialTab?: DebugLayerTab;
  50475. }
  50476. interface Scene {
  50477. /**
  50478. * @hidden
  50479. * Backing field
  50480. */
  50481. _debugLayer: DebugLayer;
  50482. /**
  50483. * Gets the debug layer (aka Inspector) associated with the scene
  50484. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50485. */
  50486. debugLayer: DebugLayer;
  50487. }
  50488. /**
  50489. * Enum of inspector action tab
  50490. */
  50491. export enum DebugLayerTab {
  50492. /**
  50493. * Properties tag (default)
  50494. */
  50495. Properties = 0,
  50496. /**
  50497. * Debug tab
  50498. */
  50499. Debug = 1,
  50500. /**
  50501. * Statistics tab
  50502. */
  50503. Statistics = 2,
  50504. /**
  50505. * Tools tab
  50506. */
  50507. Tools = 3,
  50508. /**
  50509. * Settings tab
  50510. */
  50511. Settings = 4
  50512. }
  50513. /**
  50514. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50515. * what is happening in your scene
  50516. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50517. */
  50518. export class DebugLayer {
  50519. /**
  50520. * Define the url to get the inspector script from.
  50521. * By default it uses the babylonjs CDN.
  50522. * @ignoreNaming
  50523. */
  50524. static InspectorURL: string;
  50525. private _scene;
  50526. private BJSINSPECTOR;
  50527. private _onPropertyChangedObservable?;
  50528. /**
  50529. * Observable triggered when a property is changed through the inspector.
  50530. */
  50531. get onPropertyChangedObservable(): any;
  50532. /**
  50533. * Instantiates a new debug layer.
  50534. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50535. * what is happening in your scene
  50536. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50537. * @param scene Defines the scene to inspect
  50538. */
  50539. constructor(scene: Scene);
  50540. /** Creates the inspector window. */
  50541. private _createInspector;
  50542. /**
  50543. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50544. * @param entity defines the entity to select
  50545. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50546. */
  50547. select(entity: any, lineContainerTitles?: string | string[]): void;
  50548. /** Get the inspector from bundle or global */
  50549. private _getGlobalInspector;
  50550. /**
  50551. * Get if the inspector is visible or not.
  50552. * @returns true if visible otherwise, false
  50553. */
  50554. isVisible(): boolean;
  50555. /**
  50556. * Hide the inspector and close its window.
  50557. */
  50558. hide(): void;
  50559. /**
  50560. * Update the scene in the inspector
  50561. */
  50562. setAsActiveScene(): void;
  50563. /**
  50564. * Launch the debugLayer.
  50565. * @param config Define the configuration of the inspector
  50566. * @return a promise fulfilled when the debug layer is visible
  50567. */
  50568. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * Class containing static functions to help procedurally build meshes
  50574. */
  50575. export class BoxBuilder {
  50576. /**
  50577. * Creates a box mesh
  50578. * * The parameter `size` sets the size (float) of each box side (default 1)
  50579. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50580. * * 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)
  50581. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50583. * * 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
  50584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50585. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50586. * @param name defines the name of the mesh
  50587. * @param options defines the options used to create the mesh
  50588. * @param scene defines the hosting scene
  50589. * @returns the box mesh
  50590. */
  50591. static CreateBox(name: string, options: {
  50592. size?: number;
  50593. width?: number;
  50594. height?: number;
  50595. depth?: number;
  50596. faceUV?: Vector4[];
  50597. faceColors?: Color4[];
  50598. sideOrientation?: number;
  50599. frontUVs?: Vector4;
  50600. backUVs?: Vector4;
  50601. wrap?: boolean;
  50602. topBaseAt?: number;
  50603. bottomBaseAt?: number;
  50604. updatable?: boolean;
  50605. }, scene?: Nullable<Scene>): Mesh;
  50606. }
  50607. }
  50608. declare module BABYLON.Debug {
  50609. /**
  50610. * Used to show the physics impostor around the specific mesh
  50611. */
  50612. export class PhysicsViewer {
  50613. /** @hidden */
  50614. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50615. /** @hidden */
  50616. protected _meshes: Array<Nullable<AbstractMesh>>;
  50617. /** @hidden */
  50618. protected _scene: Nullable<Scene>;
  50619. /** @hidden */
  50620. protected _numMeshes: number;
  50621. /** @hidden */
  50622. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50623. private _renderFunction;
  50624. private _utilityLayer;
  50625. private _debugBoxMesh;
  50626. private _debugSphereMesh;
  50627. private _debugCylinderMesh;
  50628. private _debugMaterial;
  50629. private _debugMeshMeshes;
  50630. /**
  50631. * Creates a new PhysicsViewer
  50632. * @param scene defines the hosting scene
  50633. */
  50634. constructor(scene: Scene);
  50635. /** @hidden */
  50636. protected _updateDebugMeshes(): void;
  50637. /**
  50638. * Renders a specified physic impostor
  50639. * @param impostor defines the impostor to render
  50640. * @param targetMesh defines the mesh represented by the impostor
  50641. * @returns the new debug mesh used to render the impostor
  50642. */
  50643. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50644. /**
  50645. * Hides a specified physic impostor
  50646. * @param impostor defines the impostor to hide
  50647. */
  50648. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50649. private _getDebugMaterial;
  50650. private _getDebugBoxMesh;
  50651. private _getDebugSphereMesh;
  50652. private _getDebugCylinderMesh;
  50653. private _getDebugMeshMesh;
  50654. private _getDebugMesh;
  50655. /** Releases all resources */
  50656. dispose(): void;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50662. * in order to better appreciate the issue one might have.
  50663. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50664. */
  50665. export class RayHelper {
  50666. /**
  50667. * Defines the ray we are currently tryin to visualize.
  50668. */
  50669. ray: Nullable<Ray>;
  50670. private _renderPoints;
  50671. private _renderLine;
  50672. private _renderFunction;
  50673. private _scene;
  50674. private _updateToMeshFunction;
  50675. private _attachedToMesh;
  50676. private _meshSpaceDirection;
  50677. private _meshSpaceOrigin;
  50678. /**
  50679. * Helper function to create a colored helper in a scene in one line.
  50680. * @param ray Defines the ray we are currently tryin to visualize
  50681. * @param scene Defines the scene the ray is used in
  50682. * @param color Defines the color we want to see the ray in
  50683. * @returns The newly created ray helper.
  50684. */
  50685. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50686. /**
  50687. * Instantiate a new ray helper.
  50688. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50689. * in order to better appreciate the issue one might have.
  50690. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50691. * @param ray Defines the ray we are currently tryin to visualize
  50692. */
  50693. constructor(ray: Ray);
  50694. /**
  50695. * Shows the ray we are willing to debug.
  50696. * @param scene Defines the scene the ray needs to be rendered in
  50697. * @param color Defines the color the ray needs to be rendered in
  50698. */
  50699. show(scene: Scene, color?: Color3): void;
  50700. /**
  50701. * Hides the ray we are debugging.
  50702. */
  50703. hide(): void;
  50704. private _render;
  50705. /**
  50706. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50707. * @param mesh Defines the mesh we want the helper attached to
  50708. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50709. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50710. * @param length Defines the length of the ray
  50711. */
  50712. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50713. /**
  50714. * Detach the ray helper from the mesh it has previously been attached to.
  50715. */
  50716. detachFromMesh(): void;
  50717. private _updateToMesh;
  50718. /**
  50719. * Dispose the helper and release its associated resources.
  50720. */
  50721. dispose(): void;
  50722. }
  50723. }
  50724. declare module BABYLON.Debug {
  50725. /**
  50726. * Class used to render a debug view of a given skeleton
  50727. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50728. */
  50729. export class SkeletonViewer {
  50730. /** defines the skeleton to render */
  50731. skeleton: Skeleton;
  50732. /** defines the mesh attached to the skeleton */
  50733. mesh: AbstractMesh;
  50734. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50735. autoUpdateBonesMatrices: boolean;
  50736. /** defines the rendering group id to use with the viewer */
  50737. renderingGroupId: number;
  50738. /** Gets or sets the color used to render the skeleton */
  50739. color: Color3;
  50740. private _scene;
  50741. private _debugLines;
  50742. private _debugMesh;
  50743. private _isEnabled;
  50744. private _renderFunction;
  50745. private _utilityLayer;
  50746. /**
  50747. * Returns the mesh used to render the bones
  50748. */
  50749. get debugMesh(): Nullable<LinesMesh>;
  50750. /**
  50751. * Creates a new SkeletonViewer
  50752. * @param skeleton defines the skeleton to render
  50753. * @param mesh defines the mesh attached to the skeleton
  50754. * @param scene defines the hosting scene
  50755. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50756. * @param renderingGroupId defines the rendering group id to use with the viewer
  50757. */
  50758. constructor(
  50759. /** defines the skeleton to render */
  50760. skeleton: Skeleton,
  50761. /** defines the mesh attached to the skeleton */
  50762. mesh: AbstractMesh, scene: Scene,
  50763. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50764. autoUpdateBonesMatrices?: boolean,
  50765. /** defines the rendering group id to use with the viewer */
  50766. renderingGroupId?: number);
  50767. /** Gets or sets a boolean indicating if the viewer is enabled */
  50768. set isEnabled(value: boolean);
  50769. get isEnabled(): boolean;
  50770. private _getBonePosition;
  50771. private _getLinesForBonesWithLength;
  50772. private _getLinesForBonesNoLength;
  50773. /** Update the viewer to sync with current skeleton state */
  50774. update(): void;
  50775. /** Release associated resources */
  50776. dispose(): void;
  50777. }
  50778. }
  50779. declare module BABYLON {
  50780. /**
  50781. * Enum for Device Types
  50782. */
  50783. export enum DeviceType {
  50784. /** Generic */
  50785. Generic = 0,
  50786. /** Keyboard */
  50787. Keyboard = 1,
  50788. /** Mouse */
  50789. Mouse = 2,
  50790. /** Touch Pointers */
  50791. Touch = 3,
  50792. /** PS4 Dual Shock */
  50793. DualShock = 4,
  50794. /** Xbox */
  50795. Xbox = 5,
  50796. /** Switch Controller */
  50797. Switch = 6
  50798. }
  50799. /**
  50800. * Enum for All Pointers (Touch/Mouse)
  50801. */
  50802. export enum PointerInput {
  50803. /** Horizontal Axis */
  50804. Horizontal = 0,
  50805. /** Vertical Axis */
  50806. Vertical = 1,
  50807. /** Left Click or Touch */
  50808. LeftClick = 2,
  50809. /** Middle Click */
  50810. MiddleClick = 3,
  50811. /** Right Click */
  50812. RightClick = 4,
  50813. /** Browser Back */
  50814. BrowserBack = 5,
  50815. /** Browser Forward */
  50816. BrowserForward = 6
  50817. }
  50818. /**
  50819. * Enum for Dual Shock Gamepad
  50820. */
  50821. export enum DualShockInput {
  50822. /** Cross */
  50823. Cross = 0,
  50824. /** Circle */
  50825. Circle = 1,
  50826. /** Square */
  50827. Square = 2,
  50828. /** Triangle */
  50829. Triangle = 3,
  50830. /** L1 */
  50831. L1 = 4,
  50832. /** R1 */
  50833. R1 = 5,
  50834. /** L2 */
  50835. L2 = 6,
  50836. /** R2 */
  50837. R2 = 7,
  50838. /** Share */
  50839. Share = 8,
  50840. /** Options */
  50841. Options = 9,
  50842. /** L3 */
  50843. L3 = 10,
  50844. /** R3 */
  50845. R3 = 11,
  50846. /** DPadUp */
  50847. DPadUp = 12,
  50848. /** DPadDown */
  50849. DPadDown = 13,
  50850. /** DPadLeft */
  50851. DPadLeft = 14,
  50852. /** DRight */
  50853. DPadRight = 15,
  50854. /** Home */
  50855. Home = 16,
  50856. /** TouchPad */
  50857. TouchPad = 17,
  50858. /** LStickXAxis */
  50859. LStickXAxis = 18,
  50860. /** LStickYAxis */
  50861. LStickYAxis = 19,
  50862. /** RStickXAxis */
  50863. RStickXAxis = 20,
  50864. /** RStickYAxis */
  50865. RStickYAxis = 21
  50866. }
  50867. /**
  50868. * Enum for Xbox Gamepad
  50869. */
  50870. export enum XboxInput {
  50871. /** A */
  50872. A = 0,
  50873. /** B */
  50874. B = 1,
  50875. /** X */
  50876. X = 2,
  50877. /** Y */
  50878. Y = 3,
  50879. /** LB */
  50880. LB = 4,
  50881. /** RB */
  50882. RB = 5,
  50883. /** LT */
  50884. LT = 6,
  50885. /** RT */
  50886. RT = 7,
  50887. /** Back */
  50888. Back = 8,
  50889. /** Start */
  50890. Start = 9,
  50891. /** LS */
  50892. LS = 10,
  50893. /** RS */
  50894. RS = 11,
  50895. /** DPadUp */
  50896. DPadUp = 12,
  50897. /** DPadDown */
  50898. DPadDown = 13,
  50899. /** DPadLeft */
  50900. DPadLeft = 14,
  50901. /** DRight */
  50902. DPadRight = 15,
  50903. /** Home */
  50904. Home = 16,
  50905. /** LStickXAxis */
  50906. LStickXAxis = 17,
  50907. /** LStickYAxis */
  50908. LStickYAxis = 18,
  50909. /** RStickXAxis */
  50910. RStickXAxis = 19,
  50911. /** RStickYAxis */
  50912. RStickYAxis = 20
  50913. }
  50914. /**
  50915. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50916. */
  50917. export enum SwitchInput {
  50918. /** B */
  50919. B = 0,
  50920. /** A */
  50921. A = 1,
  50922. /** Y */
  50923. Y = 2,
  50924. /** X */
  50925. X = 3,
  50926. /** L */
  50927. L = 4,
  50928. /** R */
  50929. R = 5,
  50930. /** ZL */
  50931. ZL = 6,
  50932. /** ZR */
  50933. ZR = 7,
  50934. /** Minus */
  50935. Minus = 8,
  50936. /** Plus */
  50937. Plus = 9,
  50938. /** LS */
  50939. LS = 10,
  50940. /** RS */
  50941. RS = 11,
  50942. /** DPadUp */
  50943. DPadUp = 12,
  50944. /** DPadDown */
  50945. DPadDown = 13,
  50946. /** DPadLeft */
  50947. DPadLeft = 14,
  50948. /** DRight */
  50949. DPadRight = 15,
  50950. /** Home */
  50951. Home = 16,
  50952. /** Capture */
  50953. Capture = 17,
  50954. /** LStickXAxis */
  50955. LStickXAxis = 18,
  50956. /** LStickYAxis */
  50957. LStickYAxis = 19,
  50958. /** RStickXAxis */
  50959. RStickXAxis = 20,
  50960. /** RStickYAxis */
  50961. RStickYAxis = 21
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * This class will take all inputs from Keyboard, Pointer, and
  50967. * any Gamepads and provide a polling system that all devices
  50968. * will use. This class assumes that there will only be one
  50969. * pointer device and one keyboard.
  50970. */
  50971. export class DeviceInputSystem implements IDisposable {
  50972. /**
  50973. * Callback to be triggered when a device is connected
  50974. */
  50975. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50976. /**
  50977. * Callback to be triggered when a device is disconnected
  50978. */
  50979. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50980. /**
  50981. * Callback to be triggered when event driven input is updated
  50982. */
  50983. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50984. private _inputs;
  50985. private _gamepads;
  50986. private _keyboardActive;
  50987. private _pointerActive;
  50988. private _elementToAttachTo;
  50989. private _keyboardDownEvent;
  50990. private _keyboardUpEvent;
  50991. private _pointerMoveEvent;
  50992. private _pointerDownEvent;
  50993. private _pointerUpEvent;
  50994. private _gamepadConnectedEvent;
  50995. private _gamepadDisconnectedEvent;
  50996. private static _MAX_KEYCODES;
  50997. private static _MAX_POINTER_INPUTS;
  50998. private constructor();
  50999. /**
  51000. * Creates a new DeviceInputSystem instance
  51001. * @param engine Engine to pull input element from
  51002. * @returns The new instance
  51003. */
  51004. static Create(engine: Engine): DeviceInputSystem;
  51005. /**
  51006. * Checks for current device input value, given an id and input index
  51007. * @param deviceName Id of connected device
  51008. * @param inputIndex Index of device input
  51009. * @returns Current value of input
  51010. */
  51011. /**
  51012. * Checks for current device input value, given an id and input index
  51013. * @param deviceType Enum specifiying device type
  51014. * @param deviceSlot "Slot" or index that device is referenced in
  51015. * @param inputIndex Id of input to be checked
  51016. * @returns Current value of input
  51017. */
  51018. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51019. /**
  51020. * Dispose of all the eventlisteners
  51021. */
  51022. dispose(): void;
  51023. /**
  51024. * Add device and inputs to device array
  51025. * @param deviceType Enum specifiying device type
  51026. * @param deviceSlot "Slot" or index that device is referenced in
  51027. * @param numberOfInputs Number of input entries to create for given device
  51028. */
  51029. private _registerDevice;
  51030. /**
  51031. * Given a specific device name, remove that device from the device map
  51032. * @param deviceType Enum specifiying device type
  51033. * @param deviceSlot "Slot" or index that device is referenced in
  51034. */
  51035. private _unregisterDevice;
  51036. /**
  51037. * Handle all actions that come from keyboard interaction
  51038. */
  51039. private _handleKeyActions;
  51040. /**
  51041. * Handle all actions that come from pointer interaction
  51042. */
  51043. private _handlePointerActions;
  51044. /**
  51045. * Handle all actions that come from gamepad interaction
  51046. */
  51047. private _handleGamepadActions;
  51048. /**
  51049. * Update all non-event based devices with each frame
  51050. * @param deviceType Enum specifiying device type
  51051. * @param deviceSlot "Slot" or index that device is referenced in
  51052. * @param inputIndex Id of input to be checked
  51053. */
  51054. private _updateDevice;
  51055. /**
  51056. * Gets DeviceType from the device name
  51057. * @param deviceName Name of Device from DeviceInputSystem
  51058. * @returns DeviceType enum value
  51059. */
  51060. private _getGamepadDeviceType;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /**
  51065. * Type to handle enforcement of inputs
  51066. */
  51067. 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;
  51068. }
  51069. declare module BABYLON {
  51070. /**
  51071. * Class that handles all input for a specific device
  51072. */
  51073. export class DeviceSource<T extends DeviceType> {
  51074. /** Type of device */
  51075. readonly deviceType: DeviceType;
  51076. /** "Slot" or index that device is referenced in */
  51077. readonly deviceSlot: number;
  51078. /**
  51079. * Observable to handle device input changes per device
  51080. */
  51081. readonly onInputChangedObservable: Observable<{
  51082. inputIndex: DeviceInput<T>;
  51083. previousState: Nullable<number>;
  51084. currentState: Nullable<number>;
  51085. }>;
  51086. private readonly _deviceInputSystem;
  51087. /**
  51088. * Default Constructor
  51089. * @param deviceInputSystem Reference to DeviceInputSystem
  51090. * @param deviceType Type of device
  51091. * @param deviceSlot "Slot" or index that device is referenced in
  51092. */
  51093. constructor(deviceInputSystem: DeviceInputSystem,
  51094. /** Type of device */
  51095. deviceType: DeviceType,
  51096. /** "Slot" or index that device is referenced in */
  51097. deviceSlot?: number);
  51098. /**
  51099. * Get input for specific input
  51100. * @param inputIndex index of specific input on device
  51101. * @returns Input value from DeviceInputSystem
  51102. */
  51103. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51104. }
  51105. /**
  51106. * Class to keep track of devices
  51107. */
  51108. export class DeviceSourceManager implements IDisposable {
  51109. /**
  51110. * Observable to be triggered when before a device is connected
  51111. */
  51112. readonly onBeforeDeviceConnectedObservable: Observable<{
  51113. deviceType: DeviceType;
  51114. deviceSlot: number;
  51115. }>;
  51116. /**
  51117. * Observable to be triggered when before a device is disconnected
  51118. */
  51119. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51120. deviceType: DeviceType;
  51121. deviceSlot: number;
  51122. }>;
  51123. /**
  51124. * Observable to be triggered when after a device is connected
  51125. */
  51126. readonly onAfterDeviceConnectedObservable: Observable<{
  51127. deviceType: DeviceType;
  51128. deviceSlot: number;
  51129. }>;
  51130. /**
  51131. * Observable to be triggered when after a device is disconnected
  51132. */
  51133. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51134. deviceType: DeviceType;
  51135. deviceSlot: number;
  51136. }>;
  51137. private readonly _devices;
  51138. private readonly _firstDevice;
  51139. private readonly _deviceInputSystem;
  51140. /**
  51141. * Default Constructor
  51142. * @param engine engine to pull input element from
  51143. */
  51144. constructor(engine: Engine);
  51145. /**
  51146. * Gets a DeviceSource, given a type and slot
  51147. * @param deviceType Enum specifying device type
  51148. * @param deviceSlot "Slot" or index that device is referenced in
  51149. * @returns DeviceSource object
  51150. */
  51151. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51152. /**
  51153. * Gets an array of DeviceSource objects for a given device type
  51154. * @param deviceType Enum specifying device type
  51155. * @returns Array of DeviceSource objects
  51156. */
  51157. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51158. /**
  51159. * Dispose of DeviceInputSystem and other parts
  51160. */
  51161. dispose(): void;
  51162. /**
  51163. * Function to add device name to device list
  51164. * @param deviceType Enum specifying device type
  51165. * @param deviceSlot "Slot" or index that device is referenced in
  51166. */
  51167. private _addDevice;
  51168. /**
  51169. * Function to remove device name to device list
  51170. * @param deviceType Enum specifying device type
  51171. * @param deviceSlot "Slot" or index that device is referenced in
  51172. */
  51173. private _removeDevice;
  51174. /**
  51175. * Updates array storing first connected device of each type
  51176. * @param type Type of Device
  51177. */
  51178. private _updateFirstDevices;
  51179. }
  51180. }
  51181. declare module BABYLON {
  51182. /**
  51183. * Options to create the null engine
  51184. */
  51185. export class NullEngineOptions {
  51186. /**
  51187. * Render width (Default: 512)
  51188. */
  51189. renderWidth: number;
  51190. /**
  51191. * Render height (Default: 256)
  51192. */
  51193. renderHeight: number;
  51194. /**
  51195. * Texture size (Default: 512)
  51196. */
  51197. textureSize: number;
  51198. /**
  51199. * If delta time between frames should be constant
  51200. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51201. */
  51202. deterministicLockstep: boolean;
  51203. /**
  51204. * Maximum about of steps between frames (Default: 4)
  51205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51206. */
  51207. lockstepMaxSteps: number;
  51208. /**
  51209. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51210. */
  51211. useHighPrecisionMatrix?: boolean;
  51212. }
  51213. /**
  51214. * The null engine class provides support for headless version of babylon.js.
  51215. * This can be used in server side scenario or for testing purposes
  51216. */
  51217. export class NullEngine extends Engine {
  51218. private _options;
  51219. /**
  51220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51222. * @returns true if engine is in deterministic lock step mode
  51223. */
  51224. isDeterministicLockStep(): boolean;
  51225. /**
  51226. * Gets the max steps when engine is running in deterministic lock step
  51227. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51228. * @returns the max steps
  51229. */
  51230. getLockstepMaxSteps(): number;
  51231. /**
  51232. * Gets the current hardware scaling level.
  51233. * By default the hardware scaling level is computed from the window device ratio.
  51234. * 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.
  51235. * @returns a number indicating the current hardware scaling level
  51236. */
  51237. getHardwareScalingLevel(): number;
  51238. constructor(options?: NullEngineOptions);
  51239. /**
  51240. * Creates a vertex buffer
  51241. * @param vertices the data for the vertex buffer
  51242. * @returns the new WebGL static buffer
  51243. */
  51244. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51245. /**
  51246. * Creates a new index buffer
  51247. * @param indices defines the content of the index buffer
  51248. * @param updatable defines if the index buffer must be updatable
  51249. * @returns a new webGL buffer
  51250. */
  51251. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51252. /**
  51253. * Clear the current render buffer or the current render target (if any is set up)
  51254. * @param color defines the color to use
  51255. * @param backBuffer defines if the back buffer must be cleared
  51256. * @param depth defines if the depth buffer must be cleared
  51257. * @param stencil defines if the stencil buffer must be cleared
  51258. */
  51259. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51260. /**
  51261. * Gets the current render width
  51262. * @param useScreen defines if screen size must be used (or the current render target if any)
  51263. * @returns a number defining the current render width
  51264. */
  51265. getRenderWidth(useScreen?: boolean): number;
  51266. /**
  51267. * Gets the current render height
  51268. * @param useScreen defines if screen size must be used (or the current render target if any)
  51269. * @returns a number defining the current render height
  51270. */
  51271. getRenderHeight(useScreen?: boolean): number;
  51272. /**
  51273. * Set the WebGL's viewport
  51274. * @param viewport defines the viewport element to be used
  51275. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51276. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51277. */
  51278. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51279. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51280. /**
  51281. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51282. * @param pipelineContext defines the pipeline context to use
  51283. * @param uniformsNames defines the list of uniform names
  51284. * @returns an array of webGL uniform locations
  51285. */
  51286. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51287. /**
  51288. * Gets the lsit of active attributes for a given webGL program
  51289. * @param pipelineContext defines the pipeline context to use
  51290. * @param attributesNames defines the list of attribute names to get
  51291. * @returns an array of indices indicating the offset of each attribute
  51292. */
  51293. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51294. /**
  51295. * Binds an effect to the webGL context
  51296. * @param effect defines the effect to bind
  51297. */
  51298. bindSamplers(effect: Effect): void;
  51299. /**
  51300. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51301. * @param effect defines the effect to activate
  51302. */
  51303. enableEffect(effect: Effect): void;
  51304. /**
  51305. * Set various states to the webGL context
  51306. * @param culling defines backface culling state
  51307. * @param zOffset defines the value to apply to zOffset (0 by default)
  51308. * @param force defines if states must be applied even if cache is up to date
  51309. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51310. */
  51311. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51312. /**
  51313. * Set the value of an uniform to an array of int32
  51314. * @param uniform defines the webGL uniform location where to store the value
  51315. * @param array defines the array of int32 to store
  51316. */
  51317. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51318. /**
  51319. * Set the value of an uniform to an array of int32 (stored as vec2)
  51320. * @param uniform defines the webGL uniform location where to store the value
  51321. * @param array defines the array of int32 to store
  51322. */
  51323. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51324. /**
  51325. * Set the value of an uniform to an array of int32 (stored as vec3)
  51326. * @param uniform defines the webGL uniform location where to store the value
  51327. * @param array defines the array of int32 to store
  51328. */
  51329. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51330. /**
  51331. * Set the value of an uniform to an array of int32 (stored as vec4)
  51332. * @param uniform defines the webGL uniform location where to store the value
  51333. * @param array defines the array of int32 to store
  51334. */
  51335. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51336. /**
  51337. * Set the value of an uniform to an array of float32
  51338. * @param uniform defines the webGL uniform location where to store the value
  51339. * @param array defines the array of float32 to store
  51340. */
  51341. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51342. /**
  51343. * Set the value of an uniform to an array of float32 (stored as vec2)
  51344. * @param uniform defines the webGL uniform location where to store the value
  51345. * @param array defines the array of float32 to store
  51346. */
  51347. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51348. /**
  51349. * Set the value of an uniform to an array of float32 (stored as vec3)
  51350. * @param uniform defines the webGL uniform location where to store the value
  51351. * @param array defines the array of float32 to store
  51352. */
  51353. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51354. /**
  51355. * Set the value of an uniform to an array of float32 (stored as vec4)
  51356. * @param uniform defines the webGL uniform location where to store the value
  51357. * @param array defines the array of float32 to store
  51358. */
  51359. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51360. /**
  51361. * Set the value of an uniform to an array of number
  51362. * @param uniform defines the webGL uniform location where to store the value
  51363. * @param array defines the array of number to store
  51364. */
  51365. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51366. /**
  51367. * Set the value of an uniform to an array of number (stored as vec2)
  51368. * @param uniform defines the webGL uniform location where to store the value
  51369. * @param array defines the array of number to store
  51370. */
  51371. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51372. /**
  51373. * Set the value of an uniform to an array of number (stored as vec3)
  51374. * @param uniform defines the webGL uniform location where to store the value
  51375. * @param array defines the array of number to store
  51376. */
  51377. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51378. /**
  51379. * Set the value of an uniform to an array of number (stored as vec4)
  51380. * @param uniform defines the webGL uniform location where to store the value
  51381. * @param array defines the array of number to store
  51382. */
  51383. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51384. /**
  51385. * Set the value of an uniform to an array of float32 (stored as matrices)
  51386. * @param uniform defines the webGL uniform location where to store the value
  51387. * @param matrices defines the array of float32 to store
  51388. */
  51389. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51390. /**
  51391. * Set the value of an uniform to a matrix (3x3)
  51392. * @param uniform defines the webGL uniform location where to store the value
  51393. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51394. */
  51395. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51396. /**
  51397. * Set the value of an uniform to a matrix (2x2)
  51398. * @param uniform defines the webGL uniform location where to store the value
  51399. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51400. */
  51401. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51402. /**
  51403. * Set the value of an uniform to a number (float)
  51404. * @param uniform defines the webGL uniform location where to store the value
  51405. * @param value defines the float number to store
  51406. */
  51407. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51408. /**
  51409. * Set the value of an uniform to a vec2
  51410. * @param uniform defines the webGL uniform location where to store the value
  51411. * @param x defines the 1st component of the value
  51412. * @param y defines the 2nd component of the value
  51413. */
  51414. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51415. /**
  51416. * Set the value of an uniform to a vec3
  51417. * @param uniform defines the webGL uniform location where to store the value
  51418. * @param x defines the 1st component of the value
  51419. * @param y defines the 2nd component of the value
  51420. * @param z defines the 3rd component of the value
  51421. */
  51422. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51423. /**
  51424. * Set the value of an uniform to a boolean
  51425. * @param uniform defines the webGL uniform location where to store the value
  51426. * @param bool defines the boolean to store
  51427. */
  51428. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51429. /**
  51430. * Set the value of an uniform to a vec4
  51431. * @param uniform defines the webGL uniform location where to store the value
  51432. * @param x defines the 1st component of the value
  51433. * @param y defines the 2nd component of the value
  51434. * @param z defines the 3rd component of the value
  51435. * @param w defines the 4th component of the value
  51436. */
  51437. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51438. /**
  51439. * Sets the current alpha mode
  51440. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51441. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51442. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51443. */
  51444. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51445. /**
  51446. * Bind webGl buffers directly to the webGL context
  51447. * @param vertexBuffers defines the vertex buffer to bind
  51448. * @param indexBuffer defines the index buffer to bind
  51449. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51450. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51451. * @param effect defines the effect associated with the vertex buffer
  51452. */
  51453. bindBuffers(vertexBuffers: {
  51454. [key: string]: VertexBuffer;
  51455. }, indexBuffer: DataBuffer, effect: Effect): void;
  51456. /**
  51457. * Force the entire cache to be cleared
  51458. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51459. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51460. */
  51461. wipeCaches(bruteForce?: boolean): void;
  51462. /**
  51463. * Send a draw order
  51464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51465. * @param indexStart defines the starting index
  51466. * @param indexCount defines the number of index to draw
  51467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51468. */
  51469. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51470. /**
  51471. * Draw a list of indexed primitives
  51472. * @param fillMode defines the primitive to use
  51473. * @param indexStart defines the starting index
  51474. * @param indexCount defines the number of index to draw
  51475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51476. */
  51477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51478. /**
  51479. * Draw a list of unindexed primitives
  51480. * @param fillMode defines the primitive to use
  51481. * @param verticesStart defines the index of first vertex to draw
  51482. * @param verticesCount defines the count of vertices to draw
  51483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51484. */
  51485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51486. /** @hidden */
  51487. _createTexture(): WebGLTexture;
  51488. /** @hidden */
  51489. _releaseTexture(texture: InternalTexture): void;
  51490. /**
  51491. * Usually called from Texture.ts.
  51492. * Passed information to create a WebGLTexture
  51493. * @param urlArg defines a value which contains one of the following:
  51494. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51495. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51496. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51498. * @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)
  51499. * @param scene needed for loading to the correct scene
  51500. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51501. * @param onLoad optional callback to be called upon successful completion
  51502. * @param onError optional callback to be called upon failure
  51503. * @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
  51504. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51505. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51506. * @param forcedExtension defines the extension to use to pick the right loader
  51507. * @param mimeType defines an optional mime type
  51508. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51509. */
  51510. 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;
  51511. /**
  51512. * Creates a new render target texture
  51513. * @param size defines the size of the texture
  51514. * @param options defines the options used to create the texture
  51515. * @returns a new render target texture stored in an InternalTexture
  51516. */
  51517. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51518. /**
  51519. * Update the sampling mode of a given texture
  51520. * @param samplingMode defines the required sampling mode
  51521. * @param texture defines the texture to update
  51522. */
  51523. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51524. /**
  51525. * Binds the frame buffer to the specified texture.
  51526. * @param texture The texture to render to or null for the default canvas
  51527. * @param faceIndex The face of the texture to render to in case of cube texture
  51528. * @param requiredWidth The width of the target to render to
  51529. * @param requiredHeight The height of the target to render to
  51530. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51531. * @param lodLevel defines le lod level to bind to the frame buffer
  51532. */
  51533. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51534. /**
  51535. * Unbind the current render target texture from the webGL context
  51536. * @param texture defines the render target texture to unbind
  51537. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51538. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51539. */
  51540. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51541. /**
  51542. * Creates a dynamic vertex buffer
  51543. * @param vertices the data for the dynamic vertex buffer
  51544. * @returns the new WebGL dynamic buffer
  51545. */
  51546. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51547. /**
  51548. * Update the content of a dynamic texture
  51549. * @param texture defines the texture to update
  51550. * @param canvas defines the canvas containing the source
  51551. * @param invertY defines if data must be stored with Y axis inverted
  51552. * @param premulAlpha defines if alpha is stored as premultiplied
  51553. * @param format defines the format of the data
  51554. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51555. */
  51556. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51557. /**
  51558. * Gets a boolean indicating if all created effects are ready
  51559. * @returns true if all effects are ready
  51560. */
  51561. areAllEffectsReady(): boolean;
  51562. /**
  51563. * @hidden
  51564. * Get the current error code of the webGL context
  51565. * @returns the error code
  51566. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51567. */
  51568. getError(): number;
  51569. /** @hidden */
  51570. _getUnpackAlignement(): number;
  51571. /** @hidden */
  51572. _unpackFlipY(value: boolean): void;
  51573. /**
  51574. * Update a dynamic index buffer
  51575. * @param indexBuffer defines the target index buffer
  51576. * @param indices defines the data to update
  51577. * @param offset defines the offset in the target index buffer where update should start
  51578. */
  51579. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51580. /**
  51581. * Updates a dynamic vertex buffer.
  51582. * @param vertexBuffer the vertex buffer to update
  51583. * @param vertices the data used to update the vertex buffer
  51584. * @param byteOffset the byte offset of the data (optional)
  51585. * @param byteLength the byte length of the data (optional)
  51586. */
  51587. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51588. /** @hidden */
  51589. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51590. /** @hidden */
  51591. _bindTexture(channel: number, texture: InternalTexture): void;
  51592. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51593. /**
  51594. * 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
  51595. */
  51596. releaseEffects(): void;
  51597. displayLoadingUI(): void;
  51598. hideLoadingUI(): void;
  51599. /** @hidden */
  51600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51601. /** @hidden */
  51602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51603. /** @hidden */
  51604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51605. /** @hidden */
  51606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51607. }
  51608. }
  51609. declare module BABYLON {
  51610. /**
  51611. * @hidden
  51612. **/
  51613. export class _TimeToken {
  51614. _startTimeQuery: Nullable<WebGLQuery>;
  51615. _endTimeQuery: Nullable<WebGLQuery>;
  51616. _timeElapsedQuery: Nullable<WebGLQuery>;
  51617. _timeElapsedQueryEnded: boolean;
  51618. }
  51619. }
  51620. declare module BABYLON {
  51621. /** @hidden */
  51622. export class _OcclusionDataStorage {
  51623. /** @hidden */
  51624. occlusionInternalRetryCounter: number;
  51625. /** @hidden */
  51626. isOcclusionQueryInProgress: boolean;
  51627. /** @hidden */
  51628. isOccluded: boolean;
  51629. /** @hidden */
  51630. occlusionRetryCount: number;
  51631. /** @hidden */
  51632. occlusionType: number;
  51633. /** @hidden */
  51634. occlusionQueryAlgorithmType: number;
  51635. }
  51636. interface Engine {
  51637. /**
  51638. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51639. * @return the new query
  51640. */
  51641. createQuery(): WebGLQuery;
  51642. /**
  51643. * Delete and release a webGL query
  51644. * @param query defines the query to delete
  51645. * @return the current engine
  51646. */
  51647. deleteQuery(query: WebGLQuery): Engine;
  51648. /**
  51649. * Check if a given query has resolved and got its value
  51650. * @param query defines the query to check
  51651. * @returns true if the query got its value
  51652. */
  51653. isQueryResultAvailable(query: WebGLQuery): boolean;
  51654. /**
  51655. * Gets the value of a given query
  51656. * @param query defines the query to check
  51657. * @returns the value of the query
  51658. */
  51659. getQueryResult(query: WebGLQuery): number;
  51660. /**
  51661. * Initiates an occlusion query
  51662. * @param algorithmType defines the algorithm to use
  51663. * @param query defines the query to use
  51664. * @returns the current engine
  51665. * @see https://doc.babylonjs.com/features/occlusionquery
  51666. */
  51667. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51668. /**
  51669. * Ends an occlusion query
  51670. * @see https://doc.babylonjs.com/features/occlusionquery
  51671. * @param algorithmType defines the algorithm to use
  51672. * @returns the current engine
  51673. */
  51674. endOcclusionQuery(algorithmType: number): Engine;
  51675. /**
  51676. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51677. * Please note that only one query can be issued at a time
  51678. * @returns a time token used to track the time span
  51679. */
  51680. startTimeQuery(): Nullable<_TimeToken>;
  51681. /**
  51682. * Ends a time query
  51683. * @param token defines the token used to measure the time span
  51684. * @returns the time spent (in ns)
  51685. */
  51686. endTimeQuery(token: _TimeToken): int;
  51687. /** @hidden */
  51688. _currentNonTimestampToken: Nullable<_TimeToken>;
  51689. /** @hidden */
  51690. _createTimeQuery(): WebGLQuery;
  51691. /** @hidden */
  51692. _deleteTimeQuery(query: WebGLQuery): void;
  51693. /** @hidden */
  51694. _getGlAlgorithmType(algorithmType: number): number;
  51695. /** @hidden */
  51696. _getTimeQueryResult(query: WebGLQuery): any;
  51697. /** @hidden */
  51698. _getTimeQueryAvailability(query: WebGLQuery): any;
  51699. }
  51700. interface AbstractMesh {
  51701. /**
  51702. * Backing filed
  51703. * @hidden
  51704. */
  51705. __occlusionDataStorage: _OcclusionDataStorage;
  51706. /**
  51707. * Access property
  51708. * @hidden
  51709. */
  51710. _occlusionDataStorage: _OcclusionDataStorage;
  51711. /**
  51712. * 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.
  51713. * The default value is -1 which means don't break the query and wait till the result
  51714. * @see https://doc.babylonjs.com/features/occlusionquery
  51715. */
  51716. occlusionRetryCount: number;
  51717. /**
  51718. * 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:
  51719. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51720. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51721. * * 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.
  51722. * @see https://doc.babylonjs.com/features/occlusionquery
  51723. */
  51724. occlusionType: number;
  51725. /**
  51726. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51727. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51728. * * 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.
  51729. * @see https://doc.babylonjs.com/features/occlusionquery
  51730. */
  51731. occlusionQueryAlgorithmType: number;
  51732. /**
  51733. * 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
  51734. * @see https://doc.babylonjs.com/features/occlusionquery
  51735. */
  51736. isOccluded: boolean;
  51737. /**
  51738. * Flag to check the progress status of the query
  51739. * @see https://doc.babylonjs.com/features/occlusionquery
  51740. */
  51741. isOcclusionQueryInProgress: boolean;
  51742. }
  51743. }
  51744. declare module BABYLON {
  51745. /** @hidden */
  51746. export var _forceTransformFeedbackToBundle: boolean;
  51747. interface Engine {
  51748. /**
  51749. * Creates a webGL transform feedback object
  51750. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51751. * @returns the webGL transform feedback object
  51752. */
  51753. createTransformFeedback(): WebGLTransformFeedback;
  51754. /**
  51755. * Delete a webGL transform feedback object
  51756. * @param value defines the webGL transform feedback object to delete
  51757. */
  51758. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51759. /**
  51760. * Bind a webGL transform feedback object to the webgl context
  51761. * @param value defines the webGL transform feedback object to bind
  51762. */
  51763. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51764. /**
  51765. * Begins a transform feedback operation
  51766. * @param usePoints defines if points or triangles must be used
  51767. */
  51768. beginTransformFeedback(usePoints: boolean): void;
  51769. /**
  51770. * Ends a transform feedback operation
  51771. */
  51772. endTransformFeedback(): void;
  51773. /**
  51774. * Specify the varyings to use with transform feedback
  51775. * @param program defines the associated webGL program
  51776. * @param value defines the list of strings representing the varying names
  51777. */
  51778. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51779. /**
  51780. * Bind a webGL buffer for a transform feedback operation
  51781. * @param value defines the webGL buffer to bind
  51782. */
  51783. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51784. }
  51785. }
  51786. declare module BABYLON {
  51787. /**
  51788. * Class used to define an additional view for the engine
  51789. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51790. */
  51791. export class EngineView {
  51792. /** Defines the canvas where to render the view */
  51793. target: HTMLCanvasElement;
  51794. /** Defines an optional camera used to render the view (will use active camera else) */
  51795. camera?: Camera;
  51796. }
  51797. interface Engine {
  51798. /**
  51799. * Gets or sets the HTML element to use for attaching events
  51800. */
  51801. inputElement: Nullable<HTMLElement>;
  51802. /**
  51803. * Gets the current engine view
  51804. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51805. */
  51806. activeView: Nullable<EngineView>;
  51807. /** Gets or sets the list of views */
  51808. views: EngineView[];
  51809. /**
  51810. * Register a new child canvas
  51811. * @param canvas defines the canvas to register
  51812. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51813. * @returns the associated view
  51814. */
  51815. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51816. /**
  51817. * Remove a registered child canvas
  51818. * @param canvas defines the canvas to remove
  51819. * @returns the current engine
  51820. */
  51821. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51822. }
  51823. }
  51824. declare module BABYLON {
  51825. interface Engine {
  51826. /** @hidden */
  51827. _excludedCompressedTextures: string[];
  51828. /** @hidden */
  51829. _textureFormatInUse: string;
  51830. /**
  51831. * Gets the list of texture formats supported
  51832. */
  51833. readonly texturesSupported: Array<string>;
  51834. /**
  51835. * Gets the texture format in use
  51836. */
  51837. readonly textureFormatInUse: Nullable<string>;
  51838. /**
  51839. * Set the compressed texture extensions or file names to skip.
  51840. *
  51841. * @param skippedFiles defines the list of those texture files you want to skip
  51842. * Example: [".dds", ".env", "myfile.png"]
  51843. */
  51844. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51845. /**
  51846. * Set the compressed texture format to use, based on the formats you have, and the formats
  51847. * supported by the hardware / browser.
  51848. *
  51849. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51850. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51851. * to API arguments needed to compressed textures. This puts the burden on the container
  51852. * generator to house the arcane code for determining these for current & future formats.
  51853. *
  51854. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51855. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51856. *
  51857. * Note: The result of this call is not taken into account when a texture is base64.
  51858. *
  51859. * @param formatsAvailable defines the list of those format families you have created
  51860. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51861. *
  51862. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51863. * @returns The extension selected.
  51864. */
  51865. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51866. }
  51867. }
  51868. declare module BABYLON {
  51869. /**
  51870. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51871. */
  51872. export interface CubeMapInfo {
  51873. /**
  51874. * The pixel array for the front face.
  51875. * This is stored in format, left to right, up to down format.
  51876. */
  51877. front: Nullable<ArrayBufferView>;
  51878. /**
  51879. * The pixel array for the back face.
  51880. * This is stored in format, left to right, up to down format.
  51881. */
  51882. back: Nullable<ArrayBufferView>;
  51883. /**
  51884. * The pixel array for the left face.
  51885. * This is stored in format, left to right, up to down format.
  51886. */
  51887. left: Nullable<ArrayBufferView>;
  51888. /**
  51889. * The pixel array for the right face.
  51890. * This is stored in format, left to right, up to down format.
  51891. */
  51892. right: Nullable<ArrayBufferView>;
  51893. /**
  51894. * The pixel array for the up face.
  51895. * This is stored in format, left to right, up to down format.
  51896. */
  51897. up: Nullable<ArrayBufferView>;
  51898. /**
  51899. * The pixel array for the down face.
  51900. * This is stored in format, left to right, up to down format.
  51901. */
  51902. down: Nullable<ArrayBufferView>;
  51903. /**
  51904. * The size of the cubemap stored.
  51905. *
  51906. * Each faces will be size * size pixels.
  51907. */
  51908. size: number;
  51909. /**
  51910. * The format of the texture.
  51911. *
  51912. * RGBA, RGB.
  51913. */
  51914. format: number;
  51915. /**
  51916. * The type of the texture data.
  51917. *
  51918. * UNSIGNED_INT, FLOAT.
  51919. */
  51920. type: number;
  51921. /**
  51922. * Specifies whether the texture is in gamma space.
  51923. */
  51924. gammaSpace: boolean;
  51925. }
  51926. /**
  51927. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51928. */
  51929. export class PanoramaToCubeMapTools {
  51930. private static FACE_LEFT;
  51931. private static FACE_RIGHT;
  51932. private static FACE_FRONT;
  51933. private static FACE_BACK;
  51934. private static FACE_DOWN;
  51935. private static FACE_UP;
  51936. /**
  51937. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51938. *
  51939. * @param float32Array The source data.
  51940. * @param inputWidth The width of the input panorama.
  51941. * @param inputHeight The height of the input panorama.
  51942. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51943. * @return The cubemap data
  51944. */
  51945. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51946. private static CreateCubemapTexture;
  51947. private static CalcProjectionSpherical;
  51948. }
  51949. }
  51950. declare module BABYLON {
  51951. /**
  51952. * Helper class dealing with the extraction of spherical polynomial dataArray
  51953. * from a cube map.
  51954. */
  51955. export class CubeMapToSphericalPolynomialTools {
  51956. private static FileFaces;
  51957. /**
  51958. * Converts a texture to the according Spherical Polynomial data.
  51959. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51960. *
  51961. * @param texture The texture to extract the information from.
  51962. * @return The Spherical Polynomial data.
  51963. */
  51964. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51965. /**
  51966. * Converts a cubemap to the according Spherical Polynomial data.
  51967. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51968. *
  51969. * @param cubeInfo The Cube map to extract the information from.
  51970. * @return The Spherical Polynomial data.
  51971. */
  51972. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51973. }
  51974. }
  51975. declare module BABYLON {
  51976. interface BaseTexture {
  51977. /**
  51978. * Get the polynomial representation of the texture data.
  51979. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51980. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51981. */
  51982. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51983. }
  51984. }
  51985. declare module BABYLON {
  51986. /** @hidden */
  51987. export var rgbdEncodePixelShader: {
  51988. name: string;
  51989. shader: string;
  51990. };
  51991. }
  51992. declare module BABYLON {
  51993. /** @hidden */
  51994. export var rgbdDecodePixelShader: {
  51995. name: string;
  51996. shader: string;
  51997. };
  51998. }
  51999. declare module BABYLON {
  52000. /**
  52001. * Raw texture data and descriptor sufficient for WebGL texture upload
  52002. */
  52003. export interface EnvironmentTextureInfo {
  52004. /**
  52005. * Version of the environment map
  52006. */
  52007. version: number;
  52008. /**
  52009. * Width of image
  52010. */
  52011. width: number;
  52012. /**
  52013. * Irradiance information stored in the file.
  52014. */
  52015. irradiance: any;
  52016. /**
  52017. * Specular information stored in the file.
  52018. */
  52019. specular: any;
  52020. }
  52021. /**
  52022. * Defines One Image in the file. It requires only the position in the file
  52023. * as well as the length.
  52024. */
  52025. interface BufferImageData {
  52026. /**
  52027. * Length of the image data.
  52028. */
  52029. length: number;
  52030. /**
  52031. * Position of the data from the null terminator delimiting the end of the JSON.
  52032. */
  52033. position: number;
  52034. }
  52035. /**
  52036. * Defines the specular data enclosed in the file.
  52037. * This corresponds to the version 1 of the data.
  52038. */
  52039. export interface EnvironmentTextureSpecularInfoV1 {
  52040. /**
  52041. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52042. */
  52043. specularDataPosition?: number;
  52044. /**
  52045. * This contains all the images data needed to reconstruct the cubemap.
  52046. */
  52047. mipmaps: Array<BufferImageData>;
  52048. /**
  52049. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52050. */
  52051. lodGenerationScale: number;
  52052. }
  52053. /**
  52054. * Sets of helpers addressing the serialization and deserialization of environment texture
  52055. * stored in a BabylonJS env file.
  52056. * Those files are usually stored as .env files.
  52057. */
  52058. export class EnvironmentTextureTools {
  52059. /**
  52060. * Magic number identifying the env file.
  52061. */
  52062. private static _MagicBytes;
  52063. /**
  52064. * Gets the environment info from an env file.
  52065. * @param data The array buffer containing the .env bytes.
  52066. * @returns the environment file info (the json header) if successfully parsed.
  52067. */
  52068. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52069. /**
  52070. * Creates an environment texture from a loaded cube texture.
  52071. * @param texture defines the cube texture to convert in env file
  52072. * @return a promise containing the environment data if succesfull.
  52073. */
  52074. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52075. /**
  52076. * Creates a JSON representation of the spherical data.
  52077. * @param texture defines the texture containing the polynomials
  52078. * @return the JSON representation of the spherical info
  52079. */
  52080. private static _CreateEnvTextureIrradiance;
  52081. /**
  52082. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52083. * @param data the image data
  52084. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52085. * @return the views described by info providing access to the underlying buffer
  52086. */
  52087. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52088. /**
  52089. * Uploads the texture info contained in the env file to the GPU.
  52090. * @param texture defines the internal texture to upload to
  52091. * @param data defines the data to load
  52092. * @param info defines the texture info retrieved through the GetEnvInfo method
  52093. * @returns a promise
  52094. */
  52095. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52096. private static _OnImageReadyAsync;
  52097. /**
  52098. * Uploads the levels of image data to the GPU.
  52099. * @param texture defines the internal texture to upload to
  52100. * @param imageData defines the array buffer views of image data [mipmap][face]
  52101. * @returns a promise
  52102. */
  52103. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52104. /**
  52105. * Uploads spherical polynomials information to the texture.
  52106. * @param texture defines the texture we are trying to upload the information to
  52107. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52108. */
  52109. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52110. /** @hidden */
  52111. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52112. }
  52113. }
  52114. declare module BABYLON {
  52115. /**
  52116. * Class used to inline functions in shader code
  52117. */
  52118. export class ShaderCodeInliner {
  52119. private static readonly _RegexpFindFunctionNameAndType;
  52120. private _sourceCode;
  52121. private _functionDescr;
  52122. private _numMaxIterations;
  52123. /** Gets or sets the token used to mark the functions to inline */
  52124. inlineToken: string;
  52125. /** Gets or sets the debug mode */
  52126. debug: boolean;
  52127. /** Gets the code after the inlining process */
  52128. get code(): string;
  52129. /**
  52130. * Initializes the inliner
  52131. * @param sourceCode shader code source to inline
  52132. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52133. */
  52134. constructor(sourceCode: string, numMaxIterations?: number);
  52135. /**
  52136. * Start the processing of the shader code
  52137. */
  52138. processCode(): void;
  52139. private _collectFunctions;
  52140. private _processInlining;
  52141. private _extractBetweenMarkers;
  52142. private _skipWhitespaces;
  52143. private _removeComments;
  52144. private _replaceFunctionCallsByCode;
  52145. private _findBackward;
  52146. private _escapeRegExp;
  52147. private _replaceNames;
  52148. }
  52149. }
  52150. declare module BABYLON {
  52151. /**
  52152. * Container for accessors for natively-stored mesh data buffers.
  52153. */
  52154. class NativeDataBuffer extends DataBuffer {
  52155. /**
  52156. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52157. */
  52158. nativeIndexBuffer?: any;
  52159. /**
  52160. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52161. */
  52162. nativeVertexBuffer?: any;
  52163. }
  52164. /** @hidden */
  52165. class NativeTexture extends InternalTexture {
  52166. getInternalTexture(): InternalTexture;
  52167. getViewCount(): number;
  52168. }
  52169. /** @hidden */
  52170. export class NativeEngine extends Engine {
  52171. private readonly _native;
  52172. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52173. private readonly INVALID_HANDLE;
  52174. getHardwareScalingLevel(): number;
  52175. constructor();
  52176. dispose(): void;
  52177. /**
  52178. * Can be used to override the current requestAnimationFrame requester.
  52179. * @hidden
  52180. */
  52181. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52182. /**
  52183. * Override default engine behavior.
  52184. * @param color
  52185. * @param backBuffer
  52186. * @param depth
  52187. * @param stencil
  52188. */
  52189. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52190. /**
  52191. * Gets host document
  52192. * @returns the host document object
  52193. */
  52194. getHostDocument(): Nullable<Document>;
  52195. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52196. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52197. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52198. recordVertexArrayObject(vertexBuffers: {
  52199. [key: string]: VertexBuffer;
  52200. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52201. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52202. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52203. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52204. /**
  52205. * Draw a list of indexed primitives
  52206. * @param fillMode defines the primitive to use
  52207. * @param indexStart defines the starting index
  52208. * @param indexCount defines the number of index to draw
  52209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52210. */
  52211. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52212. /**
  52213. * Draw a list of unindexed primitives
  52214. * @param fillMode defines the primitive to use
  52215. * @param verticesStart defines the index of first vertex to draw
  52216. * @param verticesCount defines the count of vertices to draw
  52217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52218. */
  52219. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52220. createPipelineContext(): IPipelineContext;
  52221. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52222. /** @hidden */
  52223. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52224. /** @hidden */
  52225. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52226. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52227. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52228. protected _setProgram(program: WebGLProgram): void;
  52229. _releaseEffect(effect: Effect): void;
  52230. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52231. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52233. bindSamplers(effect: Effect): void;
  52234. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52235. getRenderWidth(useScreen?: boolean): number;
  52236. getRenderHeight(useScreen?: boolean): number;
  52237. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52238. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52239. /**
  52240. * Set the z offset to apply to current rendering
  52241. * @param value defines the offset to apply
  52242. */
  52243. setZOffset(value: number): void;
  52244. /**
  52245. * Gets the current value of the zOffset
  52246. * @returns the current zOffset state
  52247. */
  52248. getZOffset(): number;
  52249. /**
  52250. * Enable or disable depth buffering
  52251. * @param enable defines the state to set
  52252. */
  52253. setDepthBuffer(enable: boolean): void;
  52254. /**
  52255. * Gets a boolean indicating if depth writing is enabled
  52256. * @returns the current depth writing state
  52257. */
  52258. getDepthWrite(): boolean;
  52259. /**
  52260. * Enable or disable depth writing
  52261. * @param enable defines the state to set
  52262. */
  52263. setDepthWrite(enable: boolean): void;
  52264. /**
  52265. * Enable or disable color writing
  52266. * @param enable defines the state to set
  52267. */
  52268. setColorWrite(enable: boolean): void;
  52269. /**
  52270. * Gets a boolean indicating if color writing is enabled
  52271. * @returns the current color writing state
  52272. */
  52273. getColorWrite(): boolean;
  52274. /**
  52275. * Sets alpha constants used by some alpha blending modes
  52276. * @param r defines the red component
  52277. * @param g defines the green component
  52278. * @param b defines the blue component
  52279. * @param a defines the alpha component
  52280. */
  52281. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52282. /**
  52283. * Sets the current alpha mode
  52284. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52286. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52287. */
  52288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52289. /**
  52290. * Gets the current alpha mode
  52291. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52292. * @returns the current alpha mode
  52293. */
  52294. getAlphaMode(): number;
  52295. setInt(uniform: WebGLUniformLocation, int: number): void;
  52296. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52297. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52298. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52299. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52300. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52301. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52302. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52303. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52304. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52305. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52306. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52307. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52309. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52310. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52311. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52312. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52313. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52314. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52315. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52316. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52317. wipeCaches(bruteForce?: boolean): void;
  52318. _createTexture(): WebGLTexture;
  52319. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52320. /**
  52321. * Usually called from Texture.ts.
  52322. * Passed information to create a WebGLTexture
  52323. * @param url defines a value which contains one of the following:
  52324. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52325. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52326. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52328. * @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)
  52329. * @param scene needed for loading to the correct scene
  52330. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52331. * @param onLoad optional callback to be called upon successful completion
  52332. * @param onError optional callback to be called upon failure
  52333. * @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
  52334. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52335. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52336. * @param forcedExtension defines the extension to use to pick the right loader
  52337. * @param mimeType defines an optional mime type
  52338. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52339. */
  52340. 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;
  52341. /**
  52342. * Creates a cube texture
  52343. * @param rootUrl defines the url where the files to load is located
  52344. * @param scene defines the current scene
  52345. * @param files defines the list of files to load (1 per face)
  52346. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52347. * @param onLoad defines an optional callback raised when the texture is loaded
  52348. * @param onError defines an optional callback raised if there is an issue to load the texture
  52349. * @param format defines the format of the data
  52350. * @param forcedExtension defines the extension to use to pick the right loader
  52351. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52352. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52353. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52354. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52355. * @returns the cube texture as an InternalTexture
  52356. */
  52357. 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;
  52358. private _getSamplingFilter;
  52359. private static _GetNativeTextureFormat;
  52360. createRenderTargetTexture(size: number | {
  52361. width: number;
  52362. height: number;
  52363. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52364. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52365. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52366. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52367. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52368. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52369. /**
  52370. * Updates a dynamic vertex buffer.
  52371. * @param vertexBuffer the vertex buffer to update
  52372. * @param data the data used to update the vertex buffer
  52373. * @param byteOffset the byte offset of the data (optional)
  52374. * @param byteLength the byte length of the data (optional)
  52375. */
  52376. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52377. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52378. private _updateAnisotropicLevel;
  52379. private _getAddressMode;
  52380. /** @hidden */
  52381. _bindTexture(channel: number, texture: InternalTexture): void;
  52382. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52383. releaseEffects(): void;
  52384. /** @hidden */
  52385. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52386. /** @hidden */
  52387. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52388. /** @hidden */
  52389. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52390. /** @hidden */
  52391. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52392. }
  52393. }
  52394. declare module BABYLON {
  52395. /**
  52396. * Gather the list of clipboard event types as constants.
  52397. */
  52398. export class ClipboardEventTypes {
  52399. /**
  52400. * The clipboard event is fired when a copy command is active (pressed).
  52401. */
  52402. static readonly COPY: number;
  52403. /**
  52404. * The clipboard event is fired when a cut command is active (pressed).
  52405. */
  52406. static readonly CUT: number;
  52407. /**
  52408. * The clipboard event is fired when a paste command is active (pressed).
  52409. */
  52410. static readonly PASTE: number;
  52411. }
  52412. /**
  52413. * This class is used to store clipboard related info for the onClipboardObservable event.
  52414. */
  52415. export class ClipboardInfo {
  52416. /**
  52417. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52418. */
  52419. type: number;
  52420. /**
  52421. * Defines the related dom event
  52422. */
  52423. event: ClipboardEvent;
  52424. /**
  52425. *Creates an instance of ClipboardInfo.
  52426. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52427. * @param event Defines the related dom event
  52428. */
  52429. constructor(
  52430. /**
  52431. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52432. */
  52433. type: number,
  52434. /**
  52435. * Defines the related dom event
  52436. */
  52437. event: ClipboardEvent);
  52438. /**
  52439. * Get the clipboard event's type from the keycode.
  52440. * @param keyCode Defines the keyCode for the current keyboard event.
  52441. * @return {number}
  52442. */
  52443. static GetTypeFromCharacter(keyCode: number): number;
  52444. }
  52445. }
  52446. declare module BABYLON {
  52447. /**
  52448. * Google Daydream controller
  52449. */
  52450. export class DaydreamController extends WebVRController {
  52451. /**
  52452. * Base Url for the controller model.
  52453. */
  52454. static MODEL_BASE_URL: string;
  52455. /**
  52456. * File name for the controller model.
  52457. */
  52458. static MODEL_FILENAME: string;
  52459. /**
  52460. * Gamepad Id prefix used to identify Daydream Controller.
  52461. */
  52462. static readonly GAMEPAD_ID_PREFIX: string;
  52463. /**
  52464. * Creates a new DaydreamController from a gamepad
  52465. * @param vrGamepad the gamepad that the controller should be created from
  52466. */
  52467. constructor(vrGamepad: any);
  52468. /**
  52469. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52470. * @param scene scene in which to add meshes
  52471. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52472. */
  52473. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52474. /**
  52475. * Called once for each button that changed state since the last frame
  52476. * @param buttonIdx Which button index changed
  52477. * @param state New state of the button
  52478. * @param changes Which properties on the state changed since last frame
  52479. */
  52480. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52481. }
  52482. }
  52483. declare module BABYLON {
  52484. /**
  52485. * Gear VR Controller
  52486. */
  52487. export class GearVRController extends WebVRController {
  52488. /**
  52489. * Base Url for the controller model.
  52490. */
  52491. static MODEL_BASE_URL: string;
  52492. /**
  52493. * File name for the controller model.
  52494. */
  52495. static MODEL_FILENAME: string;
  52496. /**
  52497. * Gamepad Id prefix used to identify this controller.
  52498. */
  52499. static readonly GAMEPAD_ID_PREFIX: string;
  52500. private readonly _buttonIndexToObservableNameMap;
  52501. /**
  52502. * Creates a new GearVRController from a gamepad
  52503. * @param vrGamepad the gamepad that the controller should be created from
  52504. */
  52505. constructor(vrGamepad: any);
  52506. /**
  52507. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52508. * @param scene scene in which to add meshes
  52509. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52510. */
  52511. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52512. /**
  52513. * Called once for each button that changed state since the last frame
  52514. * @param buttonIdx Which button index changed
  52515. * @param state New state of the button
  52516. * @param changes Which properties on the state changed since last frame
  52517. */
  52518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52519. }
  52520. }
  52521. declare module BABYLON {
  52522. /**
  52523. * Generic Controller
  52524. */
  52525. export class GenericController extends WebVRController {
  52526. /**
  52527. * Base Url for the controller model.
  52528. */
  52529. static readonly MODEL_BASE_URL: string;
  52530. /**
  52531. * File name for the controller model.
  52532. */
  52533. static readonly MODEL_FILENAME: string;
  52534. /**
  52535. * Creates a new GenericController from a gamepad
  52536. * @param vrGamepad the gamepad that the controller should be created from
  52537. */
  52538. constructor(vrGamepad: any);
  52539. /**
  52540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52541. * @param scene scene in which to add meshes
  52542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52543. */
  52544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52545. /**
  52546. * Called once for each button that changed state since the last frame
  52547. * @param buttonIdx Which button index changed
  52548. * @param state New state of the button
  52549. * @param changes Which properties on the state changed since last frame
  52550. */
  52551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52552. }
  52553. }
  52554. declare module BABYLON {
  52555. /**
  52556. * Oculus Touch Controller
  52557. */
  52558. export class OculusTouchController extends WebVRController {
  52559. /**
  52560. * Base Url for the controller model.
  52561. */
  52562. static MODEL_BASE_URL: string;
  52563. /**
  52564. * File name for the left controller model.
  52565. */
  52566. static MODEL_LEFT_FILENAME: string;
  52567. /**
  52568. * File name for the right controller model.
  52569. */
  52570. static MODEL_RIGHT_FILENAME: string;
  52571. /**
  52572. * Base Url for the Quest controller model.
  52573. */
  52574. static QUEST_MODEL_BASE_URL: string;
  52575. /**
  52576. * @hidden
  52577. * If the controllers are running on a device that needs the updated Quest controller models
  52578. */
  52579. static _IsQuest: boolean;
  52580. /**
  52581. * Fired when the secondary trigger on this controller is modified
  52582. */
  52583. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52584. /**
  52585. * Fired when the thumb rest on this controller is modified
  52586. */
  52587. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52588. /**
  52589. * Creates a new OculusTouchController from a gamepad
  52590. * @param vrGamepad the gamepad that the controller should be created from
  52591. */
  52592. constructor(vrGamepad: any);
  52593. /**
  52594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52595. * @param scene scene in which to add meshes
  52596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52597. */
  52598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52599. /**
  52600. * Fired when the A button on this controller is modified
  52601. */
  52602. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52603. /**
  52604. * Fired when the B button on this controller is modified
  52605. */
  52606. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52607. /**
  52608. * Fired when the X button on this controller is modified
  52609. */
  52610. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52611. /**
  52612. * Fired when the Y button on this controller is modified
  52613. */
  52614. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52615. /**
  52616. * Called once for each button that changed state since the last frame
  52617. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52618. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52619. * 2) secondary trigger (same)
  52620. * 3) A (right) X (left), touch, pressed = value
  52621. * 4) B / Y
  52622. * 5) thumb rest
  52623. * @param buttonIdx Which button index changed
  52624. * @param state New state of the button
  52625. * @param changes Which properties on the state changed since last frame
  52626. */
  52627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52628. }
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * Vive Controller
  52633. */
  52634. export class ViveController extends WebVRController {
  52635. /**
  52636. * Base Url for the controller model.
  52637. */
  52638. static MODEL_BASE_URL: string;
  52639. /**
  52640. * File name for the controller model.
  52641. */
  52642. static MODEL_FILENAME: string;
  52643. /**
  52644. * Creates a new ViveController from a gamepad
  52645. * @param vrGamepad the gamepad that the controller should be created from
  52646. */
  52647. constructor(vrGamepad: any);
  52648. /**
  52649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52650. * @param scene scene in which to add meshes
  52651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52652. */
  52653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52654. /**
  52655. * Fired when the left button on this controller is modified
  52656. */
  52657. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52658. /**
  52659. * Fired when the right button on this controller is modified
  52660. */
  52661. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52662. /**
  52663. * Fired when the menu button on this controller is modified
  52664. */
  52665. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52666. /**
  52667. * Called once for each button that changed state since the last frame
  52668. * Vive mapping:
  52669. * 0: touchpad
  52670. * 1: trigger
  52671. * 2: left AND right buttons
  52672. * 3: menu button
  52673. * @param buttonIdx Which button index changed
  52674. * @param state New state of the button
  52675. * @param changes Which properties on the state changed since last frame
  52676. */
  52677. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52678. }
  52679. }
  52680. declare module BABYLON {
  52681. /**
  52682. * Defines the WindowsMotionController object that the state of the windows motion controller
  52683. */
  52684. export class WindowsMotionController extends WebVRController {
  52685. /**
  52686. * The base url used to load the left and right controller models
  52687. */
  52688. static MODEL_BASE_URL: string;
  52689. /**
  52690. * The name of the left controller model file
  52691. */
  52692. static MODEL_LEFT_FILENAME: string;
  52693. /**
  52694. * The name of the right controller model file
  52695. */
  52696. static MODEL_RIGHT_FILENAME: string;
  52697. /**
  52698. * The controller name prefix for this controller type
  52699. */
  52700. static readonly GAMEPAD_ID_PREFIX: string;
  52701. /**
  52702. * The controller id pattern for this controller type
  52703. */
  52704. private static readonly GAMEPAD_ID_PATTERN;
  52705. private _loadedMeshInfo;
  52706. protected readonly _mapping: {
  52707. buttons: string[];
  52708. buttonMeshNames: {
  52709. trigger: string;
  52710. menu: string;
  52711. grip: string;
  52712. thumbstick: string;
  52713. trackpad: string;
  52714. };
  52715. buttonObservableNames: {
  52716. trigger: string;
  52717. menu: string;
  52718. grip: string;
  52719. thumbstick: string;
  52720. trackpad: string;
  52721. };
  52722. axisMeshNames: string[];
  52723. pointingPoseMeshName: string;
  52724. };
  52725. /**
  52726. * Fired when the trackpad on this controller is clicked
  52727. */
  52728. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52729. /**
  52730. * Fired when the trackpad on this controller is modified
  52731. */
  52732. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52733. /**
  52734. * The current x and y values of this controller's trackpad
  52735. */
  52736. trackpad: StickValues;
  52737. /**
  52738. * Creates a new WindowsMotionController from a gamepad
  52739. * @param vrGamepad the gamepad that the controller should be created from
  52740. */
  52741. constructor(vrGamepad: any);
  52742. /**
  52743. * Fired when the trigger on this controller is modified
  52744. */
  52745. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52746. /**
  52747. * Fired when the menu button on this controller is modified
  52748. */
  52749. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52750. /**
  52751. * Fired when the grip button on this controller is modified
  52752. */
  52753. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52754. /**
  52755. * Fired when the thumbstick button on this controller is modified
  52756. */
  52757. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52758. /**
  52759. * Fired when the touchpad button on this controller is modified
  52760. */
  52761. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52762. /**
  52763. * Fired when the touchpad values on this controller are modified
  52764. */
  52765. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52766. protected _updateTrackpad(): void;
  52767. /**
  52768. * Called once per frame by the engine.
  52769. */
  52770. update(): void;
  52771. /**
  52772. * Called once for each button that changed state since the last frame
  52773. * @param buttonIdx Which button index changed
  52774. * @param state New state of the button
  52775. * @param changes Which properties on the state changed since last frame
  52776. */
  52777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52778. /**
  52779. * Moves the buttons on the controller mesh based on their current state
  52780. * @param buttonName the name of the button to move
  52781. * @param buttonValue the value of the button which determines the buttons new position
  52782. */
  52783. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52784. /**
  52785. * Moves the axis on the controller mesh based on its current state
  52786. * @param axis the index of the axis
  52787. * @param axisValue the value of the axis which determines the meshes new position
  52788. * @hidden
  52789. */
  52790. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52791. /**
  52792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52793. * @param scene scene in which to add meshes
  52794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52795. */
  52796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52797. /**
  52798. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52799. * can be transformed by button presses and axes values, based on this._mapping.
  52800. *
  52801. * @param scene scene in which the meshes exist
  52802. * @param meshes list of meshes that make up the controller model to process
  52803. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52804. */
  52805. private processModel;
  52806. private createMeshInfo;
  52807. /**
  52808. * Gets the ray of the controller in the direction the controller is pointing
  52809. * @param length the length the resulting ray should be
  52810. * @returns a ray in the direction the controller is pointing
  52811. */
  52812. getForwardRay(length?: number): Ray;
  52813. /**
  52814. * Disposes of the controller
  52815. */
  52816. dispose(): void;
  52817. }
  52818. /**
  52819. * This class represents a new windows motion controller in XR.
  52820. */
  52821. export class XRWindowsMotionController extends WindowsMotionController {
  52822. /**
  52823. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52824. */
  52825. protected readonly _mapping: {
  52826. buttons: string[];
  52827. buttonMeshNames: {
  52828. trigger: string;
  52829. menu: string;
  52830. grip: string;
  52831. thumbstick: string;
  52832. trackpad: string;
  52833. };
  52834. buttonObservableNames: {
  52835. trigger: string;
  52836. menu: string;
  52837. grip: string;
  52838. thumbstick: string;
  52839. trackpad: string;
  52840. };
  52841. axisMeshNames: string[];
  52842. pointingPoseMeshName: string;
  52843. };
  52844. /**
  52845. * Construct a new XR-Based windows motion controller
  52846. *
  52847. * @param gamepadInfo the gamepad object from the browser
  52848. */
  52849. constructor(gamepadInfo: any);
  52850. /**
  52851. * holds the thumbstick values (X,Y)
  52852. */
  52853. thumbstickValues: StickValues;
  52854. /**
  52855. * Fired when the thumbstick on this controller is clicked
  52856. */
  52857. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52858. /**
  52859. * Fired when the thumbstick on this controller is modified
  52860. */
  52861. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52862. /**
  52863. * Fired when the touchpad button on this controller is modified
  52864. */
  52865. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52866. /**
  52867. * Fired when the touchpad values on this controller are modified
  52868. */
  52869. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52870. /**
  52871. * Fired when the thumbstick button on this controller is modified
  52872. * here to prevent breaking changes
  52873. */
  52874. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52875. /**
  52876. * updating the thumbstick(!) and not the trackpad.
  52877. * This is named this way due to the difference between WebVR and XR and to avoid
  52878. * changing the parent class.
  52879. */
  52880. protected _updateTrackpad(): void;
  52881. /**
  52882. * Disposes the class with joy
  52883. */
  52884. dispose(): void;
  52885. }
  52886. }
  52887. declare module BABYLON {
  52888. /**
  52889. * Class containing static functions to help procedurally build meshes
  52890. */
  52891. export class PolyhedronBuilder {
  52892. /**
  52893. * Creates a polyhedron mesh
  52894. * * 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
  52895. * * The parameter `size` (positive float, default 1) sets the polygon size
  52896. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52897. * * 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`
  52898. * * 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
  52899. * * 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)`)
  52900. * * 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
  52901. * * 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
  52902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52903. * * 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
  52904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52905. * @param name defines the name of the mesh
  52906. * @param options defines the options used to create the mesh
  52907. * @param scene defines the hosting scene
  52908. * @returns the polyhedron mesh
  52909. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52910. */
  52911. static CreatePolyhedron(name: string, options: {
  52912. type?: number;
  52913. size?: number;
  52914. sizeX?: number;
  52915. sizeY?: number;
  52916. sizeZ?: number;
  52917. custom?: any;
  52918. faceUV?: Vector4[];
  52919. faceColors?: Color4[];
  52920. flat?: boolean;
  52921. updatable?: boolean;
  52922. sideOrientation?: number;
  52923. frontUVs?: Vector4;
  52924. backUVs?: Vector4;
  52925. }, scene?: Nullable<Scene>): Mesh;
  52926. }
  52927. }
  52928. declare module BABYLON {
  52929. /**
  52930. * Gizmo that enables scaling a mesh along 3 axis
  52931. */
  52932. export class ScaleGizmo extends Gizmo {
  52933. /**
  52934. * Internal gizmo used for interactions on the x axis
  52935. */
  52936. xGizmo: AxisScaleGizmo;
  52937. /**
  52938. * Internal gizmo used for interactions on the y axis
  52939. */
  52940. yGizmo: AxisScaleGizmo;
  52941. /**
  52942. * Internal gizmo used for interactions on the z axis
  52943. */
  52944. zGizmo: AxisScaleGizmo;
  52945. /**
  52946. * Internal gizmo used to scale all axis equally
  52947. */
  52948. uniformScaleGizmo: AxisScaleGizmo;
  52949. private _meshAttached;
  52950. private _nodeAttached;
  52951. private _updateGizmoRotationToMatchAttachedMesh;
  52952. private _snapDistance;
  52953. private _scaleRatio;
  52954. private _uniformScalingMesh;
  52955. private _octahedron;
  52956. private _sensitivity;
  52957. /** Fires an event when any of it's sub gizmos are dragged */
  52958. onDragStartObservable: Observable<unknown>;
  52959. /** Fires an event when any of it's sub gizmos are released from dragging */
  52960. onDragEndObservable: Observable<unknown>;
  52961. get attachedMesh(): Nullable<AbstractMesh>;
  52962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52963. get attachedNode(): Nullable<Node>;
  52964. set attachedNode(node: Nullable<Node>);
  52965. /**
  52966. * Creates a ScaleGizmo
  52967. * @param gizmoLayer The utility layer the gizmo will be added to
  52968. * @param thickness display gizmo axis thickness
  52969. */
  52970. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52971. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52972. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52973. /**
  52974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52975. */
  52976. set snapDistance(value: number);
  52977. get snapDistance(): number;
  52978. /**
  52979. * Ratio for the scale of the gizmo (Default: 1)
  52980. */
  52981. set scaleRatio(value: number);
  52982. get scaleRatio(): number;
  52983. /**
  52984. * Sensitivity factor for dragging (Default: 1)
  52985. */
  52986. set sensitivity(value: number);
  52987. get sensitivity(): number;
  52988. /**
  52989. * Disposes of the gizmo
  52990. */
  52991. dispose(): void;
  52992. }
  52993. }
  52994. declare module BABYLON {
  52995. /**
  52996. * Single axis scale gizmo
  52997. */
  52998. export class AxisScaleGizmo extends Gizmo {
  52999. /**
  53000. * Drag behavior responsible for the gizmos dragging interactions
  53001. */
  53002. dragBehavior: PointerDragBehavior;
  53003. private _pointerObserver;
  53004. /**
  53005. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53006. */
  53007. snapDistance: number;
  53008. /**
  53009. * Event that fires each time the gizmo snaps to a new location.
  53010. * * snapDistance is the the change in distance
  53011. */
  53012. onSnapObservable: Observable<{
  53013. snapDistance: number;
  53014. }>;
  53015. /**
  53016. * If the scaling operation should be done on all axis (default: false)
  53017. */
  53018. uniformScaling: boolean;
  53019. /**
  53020. * Custom sensitivity value for the drag strength
  53021. */
  53022. sensitivity: number;
  53023. private _isEnabled;
  53024. private _parent;
  53025. private _arrow;
  53026. private _coloredMaterial;
  53027. private _hoverMaterial;
  53028. /**
  53029. * Creates an AxisScaleGizmo
  53030. * @param gizmoLayer The utility layer the gizmo will be added to
  53031. * @param dragAxis The axis which the gizmo will be able to scale on
  53032. * @param color The color of the gizmo
  53033. * @param thickness display gizmo axis thickness
  53034. */
  53035. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53036. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53037. /**
  53038. * If the gizmo is enabled
  53039. */
  53040. set isEnabled(value: boolean);
  53041. get isEnabled(): boolean;
  53042. /**
  53043. * Disposes of the gizmo
  53044. */
  53045. dispose(): void;
  53046. /**
  53047. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53048. * @param mesh The mesh to replace the default mesh of the gizmo
  53049. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53050. */
  53051. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53052. }
  53053. }
  53054. declare module BABYLON {
  53055. /**
  53056. * Bounding box gizmo
  53057. */
  53058. export class BoundingBoxGizmo extends Gizmo {
  53059. private _lineBoundingBox;
  53060. private _rotateSpheresParent;
  53061. private _scaleBoxesParent;
  53062. private _boundingDimensions;
  53063. private _renderObserver;
  53064. private _pointerObserver;
  53065. private _scaleDragSpeed;
  53066. private _tmpQuaternion;
  53067. private _tmpVector;
  53068. private _tmpRotationMatrix;
  53069. /**
  53070. * 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)
  53071. */
  53072. ignoreChildren: boolean;
  53073. /**
  53074. * 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)
  53075. */
  53076. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53077. /**
  53078. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53079. */
  53080. rotationSphereSize: number;
  53081. /**
  53082. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53083. */
  53084. scaleBoxSize: number;
  53085. /**
  53086. * 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)
  53087. */
  53088. fixedDragMeshScreenSize: boolean;
  53089. /**
  53090. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53091. */
  53092. fixedDragMeshScreenSizeDistanceFactor: number;
  53093. /**
  53094. * Fired when a rotation sphere or scale box is dragged
  53095. */
  53096. onDragStartObservable: Observable<{}>;
  53097. /**
  53098. * Fired when a scale box is dragged
  53099. */
  53100. onScaleBoxDragObservable: Observable<{}>;
  53101. /**
  53102. * Fired when a scale box drag is ended
  53103. */
  53104. onScaleBoxDragEndObservable: Observable<{}>;
  53105. /**
  53106. * Fired when a rotation sphere is dragged
  53107. */
  53108. onRotationSphereDragObservable: Observable<{}>;
  53109. /**
  53110. * Fired when a rotation sphere drag is ended
  53111. */
  53112. onRotationSphereDragEndObservable: Observable<{}>;
  53113. /**
  53114. * 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)
  53115. */
  53116. scalePivot: Nullable<Vector3>;
  53117. /**
  53118. * Mesh used as a pivot to rotate the attached node
  53119. */
  53120. private _anchorMesh;
  53121. private _existingMeshScale;
  53122. private _dragMesh;
  53123. private pointerDragBehavior;
  53124. private coloredMaterial;
  53125. private hoverColoredMaterial;
  53126. /**
  53127. * Sets the color of the bounding box gizmo
  53128. * @param color the color to set
  53129. */
  53130. setColor(color: Color3): void;
  53131. /**
  53132. * Creates an BoundingBoxGizmo
  53133. * @param gizmoLayer The utility layer the gizmo will be added to
  53134. * @param color The color of the gizmo
  53135. */
  53136. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53137. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53138. private _selectNode;
  53139. /**
  53140. * Updates the bounding box information for the Gizmo
  53141. */
  53142. updateBoundingBox(): void;
  53143. private _updateRotationSpheres;
  53144. private _updateScaleBoxes;
  53145. /**
  53146. * Enables rotation on the specified axis and disables rotation on the others
  53147. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53148. */
  53149. setEnabledRotationAxis(axis: string): void;
  53150. /**
  53151. * Enables/disables scaling
  53152. * @param enable if scaling should be enabled
  53153. * @param homogeneousScaling defines if scaling should only be homogeneous
  53154. */
  53155. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53156. private _updateDummy;
  53157. /**
  53158. * Enables a pointer drag behavior on the bounding box of the gizmo
  53159. */
  53160. enableDragBehavior(): void;
  53161. /**
  53162. * Disposes of the gizmo
  53163. */
  53164. dispose(): void;
  53165. /**
  53166. * 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)
  53167. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53168. * @returns the bounding box mesh with the passed in mesh as a child
  53169. */
  53170. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53171. /**
  53172. * CustomMeshes are not supported by this gizmo
  53173. * @param mesh The mesh to replace the default mesh of the gizmo
  53174. */
  53175. setCustomMesh(mesh: Mesh): void;
  53176. }
  53177. }
  53178. declare module BABYLON {
  53179. /**
  53180. * Single plane rotation gizmo
  53181. */
  53182. export class PlaneRotationGizmo extends Gizmo {
  53183. /**
  53184. * Drag behavior responsible for the gizmos dragging interactions
  53185. */
  53186. dragBehavior: PointerDragBehavior;
  53187. private _pointerObserver;
  53188. /**
  53189. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53190. */
  53191. snapDistance: number;
  53192. /**
  53193. * Event that fires each time the gizmo snaps to a new location.
  53194. * * snapDistance is the the change in distance
  53195. */
  53196. onSnapObservable: Observable<{
  53197. snapDistance: number;
  53198. }>;
  53199. private _isEnabled;
  53200. private _parent;
  53201. /**
  53202. * Creates a PlaneRotationGizmo
  53203. * @param gizmoLayer The utility layer the gizmo will be added to
  53204. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53205. * @param color The color of the gizmo
  53206. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53207. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53208. * @param thickness display gizmo axis thickness
  53209. */
  53210. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53211. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53212. /**
  53213. * If the gizmo is enabled
  53214. */
  53215. set isEnabled(value: boolean);
  53216. get isEnabled(): boolean;
  53217. /**
  53218. * Disposes of the gizmo
  53219. */
  53220. dispose(): void;
  53221. }
  53222. }
  53223. declare module BABYLON {
  53224. /**
  53225. * Gizmo that enables rotating a mesh along 3 axis
  53226. */
  53227. export class RotationGizmo extends Gizmo {
  53228. /**
  53229. * Internal gizmo used for interactions on the x axis
  53230. */
  53231. xGizmo: PlaneRotationGizmo;
  53232. /**
  53233. * Internal gizmo used for interactions on the y axis
  53234. */
  53235. yGizmo: PlaneRotationGizmo;
  53236. /**
  53237. * Internal gizmo used for interactions on the z axis
  53238. */
  53239. zGizmo: PlaneRotationGizmo;
  53240. /** Fires an event when any of it's sub gizmos are dragged */
  53241. onDragStartObservable: Observable<unknown>;
  53242. /** Fires an event when any of it's sub gizmos are released from dragging */
  53243. onDragEndObservable: Observable<unknown>;
  53244. private _meshAttached;
  53245. private _nodeAttached;
  53246. get attachedMesh(): Nullable<AbstractMesh>;
  53247. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53248. get attachedNode(): Nullable<Node>;
  53249. set attachedNode(node: Nullable<Node>);
  53250. /**
  53251. * Creates a RotationGizmo
  53252. * @param gizmoLayer The utility layer the gizmo will be added to
  53253. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53254. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53255. * @param thickness display gizmo axis thickness
  53256. */
  53257. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53258. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53259. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53260. /**
  53261. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53262. */
  53263. set snapDistance(value: number);
  53264. get snapDistance(): number;
  53265. /**
  53266. * Ratio for the scale of the gizmo (Default: 1)
  53267. */
  53268. set scaleRatio(value: number);
  53269. get scaleRatio(): number;
  53270. /**
  53271. * Disposes of the gizmo
  53272. */
  53273. dispose(): void;
  53274. /**
  53275. * CustomMeshes are not supported by this gizmo
  53276. * @param mesh The mesh to replace the default mesh of the gizmo
  53277. */
  53278. setCustomMesh(mesh: Mesh): void;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53284. */
  53285. export class GizmoManager implements IDisposable {
  53286. private scene;
  53287. /**
  53288. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53289. */
  53290. gizmos: {
  53291. positionGizmo: Nullable<PositionGizmo>;
  53292. rotationGizmo: Nullable<RotationGizmo>;
  53293. scaleGizmo: Nullable<ScaleGizmo>;
  53294. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53295. };
  53296. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53297. clearGizmoOnEmptyPointerEvent: boolean;
  53298. /** Fires an event when the manager is attached to a mesh */
  53299. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53300. private _gizmosEnabled;
  53301. private _pointerObserver;
  53302. private _attachedMesh;
  53303. private _boundingBoxColor;
  53304. private _defaultUtilityLayer;
  53305. private _defaultKeepDepthUtilityLayer;
  53306. private _thickness;
  53307. /**
  53308. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53309. */
  53310. boundingBoxDragBehavior: SixDofDragBehavior;
  53311. /**
  53312. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53313. */
  53314. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53315. /**
  53316. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53317. */
  53318. usePointerToAttachGizmos: boolean;
  53319. /**
  53320. * Utility layer that the bounding box gizmo belongs to
  53321. */
  53322. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53323. /**
  53324. * Utility layer that all gizmos besides bounding box belong to
  53325. */
  53326. get utilityLayer(): UtilityLayerRenderer;
  53327. /**
  53328. * Instatiates a gizmo manager
  53329. * @param scene the scene to overlay the gizmos on top of
  53330. * @param thickness display gizmo axis thickness
  53331. */
  53332. constructor(scene: Scene, thickness?: number);
  53333. /**
  53334. * Attaches a set of gizmos to the specified mesh
  53335. * @param mesh The mesh the gizmo's should be attached to
  53336. */
  53337. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53338. /**
  53339. * If the position gizmo is enabled
  53340. */
  53341. set positionGizmoEnabled(value: boolean);
  53342. get positionGizmoEnabled(): boolean;
  53343. /**
  53344. * If the rotation gizmo is enabled
  53345. */
  53346. set rotationGizmoEnabled(value: boolean);
  53347. get rotationGizmoEnabled(): boolean;
  53348. /**
  53349. * If the scale gizmo is enabled
  53350. */
  53351. set scaleGizmoEnabled(value: boolean);
  53352. get scaleGizmoEnabled(): boolean;
  53353. /**
  53354. * If the boundingBox gizmo is enabled
  53355. */
  53356. set boundingBoxGizmoEnabled(value: boolean);
  53357. get boundingBoxGizmoEnabled(): boolean;
  53358. /**
  53359. * Disposes of the gizmo manager
  53360. */
  53361. dispose(): void;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * A directional light is defined by a direction (what a surprise!).
  53367. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53368. * 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.
  53369. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53370. */
  53371. export class DirectionalLight extends ShadowLight {
  53372. private _shadowFrustumSize;
  53373. /**
  53374. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53375. */
  53376. get shadowFrustumSize(): number;
  53377. /**
  53378. * Specifies a fix frustum size for the shadow generation.
  53379. */
  53380. set shadowFrustumSize(value: number);
  53381. private _shadowOrthoScale;
  53382. /**
  53383. * Gets the shadow projection scale against the optimal computed one.
  53384. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53385. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53386. */
  53387. get shadowOrthoScale(): number;
  53388. /**
  53389. * Sets the shadow projection scale against the optimal computed one.
  53390. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53391. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53392. */
  53393. set shadowOrthoScale(value: number);
  53394. /**
  53395. * Automatically compute the projection matrix to best fit (including all the casters)
  53396. * on each frame.
  53397. */
  53398. autoUpdateExtends: boolean;
  53399. /**
  53400. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53401. * on each frame. autoUpdateExtends must be set to true for this to work
  53402. */
  53403. autoCalcShadowZBounds: boolean;
  53404. private _orthoLeft;
  53405. private _orthoRight;
  53406. private _orthoTop;
  53407. private _orthoBottom;
  53408. /**
  53409. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53410. * The directional light is emitted from everywhere in the given direction.
  53411. * It can cast shadows.
  53412. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53413. * @param name The friendly name of the light
  53414. * @param direction The direction of the light
  53415. * @param scene The scene the light belongs to
  53416. */
  53417. constructor(name: string, direction: Vector3, scene: Scene);
  53418. /**
  53419. * Returns the string "DirectionalLight".
  53420. * @return The class name
  53421. */
  53422. getClassName(): string;
  53423. /**
  53424. * Returns the integer 1.
  53425. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53426. */
  53427. getTypeID(): number;
  53428. /**
  53429. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53430. * Returns the DirectionalLight Shadow projection matrix.
  53431. */
  53432. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53433. /**
  53434. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53435. * Returns the DirectionalLight Shadow projection matrix.
  53436. */
  53437. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53438. /**
  53439. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53440. * Returns the DirectionalLight Shadow projection matrix.
  53441. */
  53442. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53443. protected _buildUniformLayout(): void;
  53444. /**
  53445. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53446. * @param effect The effect to update
  53447. * @param lightIndex The index of the light in the effect to update
  53448. * @returns The directional light
  53449. */
  53450. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53452. /**
  53453. * Gets the minZ used for shadow according to both the scene and the light.
  53454. *
  53455. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53456. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53457. * @param activeCamera The camera we are returning the min for
  53458. * @returns the depth min z
  53459. */
  53460. getDepthMinZ(activeCamera: Camera): number;
  53461. /**
  53462. * Gets the maxZ used for shadow according to both the scene and the light.
  53463. *
  53464. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53465. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53466. * @param activeCamera The camera we are returning the max for
  53467. * @returns the depth max z
  53468. */
  53469. getDepthMaxZ(activeCamera: Camera): number;
  53470. /**
  53471. * Prepares the list of defines specific to the light type.
  53472. * @param defines the list of defines
  53473. * @param lightIndex defines the index of the light for the effect
  53474. */
  53475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53476. }
  53477. }
  53478. declare module BABYLON {
  53479. /**
  53480. * Class containing static functions to help procedurally build meshes
  53481. */
  53482. export class HemisphereBuilder {
  53483. /**
  53484. * Creates a hemisphere mesh
  53485. * @param name defines the name of the mesh
  53486. * @param options defines the options used to create the mesh
  53487. * @param scene defines the hosting scene
  53488. * @returns the hemisphere mesh
  53489. */
  53490. static CreateHemisphere(name: string, options: {
  53491. segments?: number;
  53492. diameter?: number;
  53493. sideOrientation?: number;
  53494. }, scene: any): Mesh;
  53495. }
  53496. }
  53497. declare module BABYLON {
  53498. /**
  53499. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53500. * These values define a cone of light starting from the position, emitting toward the direction.
  53501. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53502. * and the exponent defines the speed of the decay of the light with distance (reach).
  53503. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53504. */
  53505. export class SpotLight extends ShadowLight {
  53506. private _angle;
  53507. private _innerAngle;
  53508. private _cosHalfAngle;
  53509. private _lightAngleScale;
  53510. private _lightAngleOffset;
  53511. /**
  53512. * Gets the cone angle of the spot light in Radians.
  53513. */
  53514. get angle(): number;
  53515. /**
  53516. * Sets the cone angle of the spot light in Radians.
  53517. */
  53518. set angle(value: number);
  53519. /**
  53520. * Only used in gltf falloff mode, this defines the angle where
  53521. * the directional falloff will start before cutting at angle which could be seen
  53522. * as outer angle.
  53523. */
  53524. get innerAngle(): number;
  53525. /**
  53526. * Only used in gltf falloff mode, this defines the angle where
  53527. * the directional falloff will start before cutting at angle which could be seen
  53528. * as outer angle.
  53529. */
  53530. set innerAngle(value: number);
  53531. private _shadowAngleScale;
  53532. /**
  53533. * Allows scaling the angle of the light for shadow generation only.
  53534. */
  53535. get shadowAngleScale(): number;
  53536. /**
  53537. * Allows scaling the angle of the light for shadow generation only.
  53538. */
  53539. set shadowAngleScale(value: number);
  53540. /**
  53541. * The light decay speed with the distance from the emission spot.
  53542. */
  53543. exponent: number;
  53544. private _projectionTextureMatrix;
  53545. /**
  53546. * Allows reading the projecton texture
  53547. */
  53548. get projectionTextureMatrix(): Matrix;
  53549. protected _projectionTextureLightNear: number;
  53550. /**
  53551. * Gets the near clip of the Spotlight for texture projection.
  53552. */
  53553. get projectionTextureLightNear(): number;
  53554. /**
  53555. * Sets the near clip of the Spotlight for texture projection.
  53556. */
  53557. set projectionTextureLightNear(value: number);
  53558. protected _projectionTextureLightFar: number;
  53559. /**
  53560. * Gets the far clip of the Spotlight for texture projection.
  53561. */
  53562. get projectionTextureLightFar(): number;
  53563. /**
  53564. * Sets the far clip of the Spotlight for texture projection.
  53565. */
  53566. set projectionTextureLightFar(value: number);
  53567. protected _projectionTextureUpDirection: Vector3;
  53568. /**
  53569. * Gets the Up vector of the Spotlight for texture projection.
  53570. */
  53571. get projectionTextureUpDirection(): Vector3;
  53572. /**
  53573. * Sets the Up vector of the Spotlight for texture projection.
  53574. */
  53575. set projectionTextureUpDirection(value: Vector3);
  53576. private _projectionTexture;
  53577. /**
  53578. * Gets the projection texture of the light.
  53579. */
  53580. get projectionTexture(): Nullable<BaseTexture>;
  53581. /**
  53582. * Sets the projection texture of the light.
  53583. */
  53584. set projectionTexture(value: Nullable<BaseTexture>);
  53585. private _projectionTextureViewLightDirty;
  53586. private _projectionTextureProjectionLightDirty;
  53587. private _projectionTextureDirty;
  53588. private _projectionTextureViewTargetVector;
  53589. private _projectionTextureViewLightMatrix;
  53590. private _projectionTextureProjectionLightMatrix;
  53591. private _projectionTextureScalingMatrix;
  53592. /**
  53593. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53594. * It can cast shadows.
  53595. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53596. * @param name The light friendly name
  53597. * @param position The position of the spot light in the scene
  53598. * @param direction The direction of the light in the scene
  53599. * @param angle The cone angle of the light in Radians
  53600. * @param exponent The light decay speed with the distance from the emission spot
  53601. * @param scene The scene the lights belongs to
  53602. */
  53603. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53604. /**
  53605. * Returns the string "SpotLight".
  53606. * @returns the class name
  53607. */
  53608. getClassName(): string;
  53609. /**
  53610. * Returns the integer 2.
  53611. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53612. */
  53613. getTypeID(): number;
  53614. /**
  53615. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53616. */
  53617. protected _setDirection(value: Vector3): void;
  53618. /**
  53619. * Overrides the position setter to recompute the projection texture view light Matrix.
  53620. */
  53621. protected _setPosition(value: Vector3): void;
  53622. /**
  53623. * 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.
  53624. * Returns the SpotLight.
  53625. */
  53626. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53627. protected _computeProjectionTextureViewLightMatrix(): void;
  53628. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53629. /**
  53630. * Main function for light texture projection matrix computing.
  53631. */
  53632. protected _computeProjectionTextureMatrix(): void;
  53633. protected _buildUniformLayout(): void;
  53634. private _computeAngleValues;
  53635. /**
  53636. * Sets the passed Effect "effect" with the Light textures.
  53637. * @param effect The effect to update
  53638. * @param lightIndex The index of the light in the effect to update
  53639. * @returns The light
  53640. */
  53641. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53642. /**
  53643. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53644. * @param effect The effect to update
  53645. * @param lightIndex The index of the light in the effect to update
  53646. * @returns The spot light
  53647. */
  53648. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53650. /**
  53651. * Disposes the light and the associated resources.
  53652. */
  53653. dispose(): void;
  53654. /**
  53655. * Prepares the list of defines specific to the light type.
  53656. * @param defines the list of defines
  53657. * @param lightIndex defines the index of the light for the effect
  53658. */
  53659. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53660. }
  53661. }
  53662. declare module BABYLON {
  53663. /**
  53664. * Gizmo that enables viewing a light
  53665. */
  53666. export class LightGizmo extends Gizmo {
  53667. private _lightMesh;
  53668. private _material;
  53669. private _cachedPosition;
  53670. private _cachedForward;
  53671. private _attachedMeshParent;
  53672. /**
  53673. * Creates a LightGizmo
  53674. * @param gizmoLayer The utility layer the gizmo will be added to
  53675. */
  53676. constructor(gizmoLayer?: UtilityLayerRenderer);
  53677. private _light;
  53678. /**
  53679. * The light that the gizmo is attached to
  53680. */
  53681. set light(light: Nullable<Light>);
  53682. get light(): Nullable<Light>;
  53683. /**
  53684. * Gets the material used to render the light gizmo
  53685. */
  53686. get material(): StandardMaterial;
  53687. /**
  53688. * @hidden
  53689. * Updates the gizmo to match the attached mesh's position/rotation
  53690. */
  53691. protected _update(): void;
  53692. private static _Scale;
  53693. /**
  53694. * Creates the lines for a light mesh
  53695. */
  53696. private static _CreateLightLines;
  53697. /**
  53698. * Disposes of the light gizmo
  53699. */
  53700. dispose(): void;
  53701. private static _CreateHemisphericLightMesh;
  53702. private static _CreatePointLightMesh;
  53703. private static _CreateSpotLightMesh;
  53704. private static _CreateDirectionalLightMesh;
  53705. }
  53706. }
  53707. declare module BABYLON {
  53708. /** @hidden */
  53709. export var backgroundFragmentDeclaration: {
  53710. name: string;
  53711. shader: string;
  53712. };
  53713. }
  53714. declare module BABYLON {
  53715. /** @hidden */
  53716. export var backgroundUboDeclaration: {
  53717. name: string;
  53718. shader: string;
  53719. };
  53720. }
  53721. declare module BABYLON {
  53722. /** @hidden */
  53723. export var backgroundPixelShader: {
  53724. name: string;
  53725. shader: string;
  53726. };
  53727. }
  53728. declare module BABYLON {
  53729. /** @hidden */
  53730. export var backgroundVertexDeclaration: {
  53731. name: string;
  53732. shader: string;
  53733. };
  53734. }
  53735. declare module BABYLON {
  53736. /** @hidden */
  53737. export var backgroundVertexShader: {
  53738. name: string;
  53739. shader: string;
  53740. };
  53741. }
  53742. declare module BABYLON {
  53743. /**
  53744. * Background material used to create an efficient environement around your scene.
  53745. */
  53746. export class BackgroundMaterial extends PushMaterial {
  53747. /**
  53748. * Standard reflectance value at parallel view angle.
  53749. */
  53750. static StandardReflectance0: number;
  53751. /**
  53752. * Standard reflectance value at grazing angle.
  53753. */
  53754. static StandardReflectance90: number;
  53755. protected _primaryColor: Color3;
  53756. /**
  53757. * Key light Color (multiply against the environement texture)
  53758. */
  53759. primaryColor: Color3;
  53760. protected __perceptualColor: Nullable<Color3>;
  53761. /**
  53762. * Experimental Internal Use Only.
  53763. *
  53764. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53765. * This acts as a helper to set the primary color to a more "human friendly" value.
  53766. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53767. * output color as close as possible from the chosen value.
  53768. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53769. * part of lighting setup.)
  53770. */
  53771. get _perceptualColor(): Nullable<Color3>;
  53772. set _perceptualColor(value: Nullable<Color3>);
  53773. protected _primaryColorShadowLevel: float;
  53774. /**
  53775. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53776. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53777. */
  53778. get primaryColorShadowLevel(): float;
  53779. set primaryColorShadowLevel(value: float);
  53780. protected _primaryColorHighlightLevel: float;
  53781. /**
  53782. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53783. * The primary color is used at the level chosen to define what the white area would look.
  53784. */
  53785. get primaryColorHighlightLevel(): float;
  53786. set primaryColorHighlightLevel(value: float);
  53787. protected _reflectionTexture: Nullable<BaseTexture>;
  53788. /**
  53789. * Reflection Texture used in the material.
  53790. * Should be author in a specific way for the best result (refer to the documentation).
  53791. */
  53792. reflectionTexture: Nullable<BaseTexture>;
  53793. protected _reflectionBlur: float;
  53794. /**
  53795. * Reflection Texture level of blur.
  53796. *
  53797. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53798. * texture twice.
  53799. */
  53800. reflectionBlur: float;
  53801. protected _diffuseTexture: Nullable<BaseTexture>;
  53802. /**
  53803. * Diffuse Texture used in the material.
  53804. * Should be author in a specific way for the best result (refer to the documentation).
  53805. */
  53806. diffuseTexture: Nullable<BaseTexture>;
  53807. protected _shadowLights: Nullable<IShadowLight[]>;
  53808. /**
  53809. * Specify the list of lights casting shadow on the material.
  53810. * All scene shadow lights will be included if null.
  53811. */
  53812. shadowLights: Nullable<IShadowLight[]>;
  53813. protected _shadowLevel: float;
  53814. /**
  53815. * Helps adjusting the shadow to a softer level if required.
  53816. * 0 means black shadows and 1 means no shadows.
  53817. */
  53818. shadowLevel: float;
  53819. protected _sceneCenter: Vector3;
  53820. /**
  53821. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53822. * It is usually zero but might be interesting to modify according to your setup.
  53823. */
  53824. sceneCenter: Vector3;
  53825. protected _opacityFresnel: boolean;
  53826. /**
  53827. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53828. * This helps ensuring a nice transition when the camera goes under the ground.
  53829. */
  53830. opacityFresnel: boolean;
  53831. protected _reflectionFresnel: boolean;
  53832. /**
  53833. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53834. * This helps adding a mirror texture on the ground.
  53835. */
  53836. reflectionFresnel: boolean;
  53837. protected _reflectionFalloffDistance: number;
  53838. /**
  53839. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53840. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53841. */
  53842. reflectionFalloffDistance: number;
  53843. protected _reflectionAmount: number;
  53844. /**
  53845. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53846. */
  53847. reflectionAmount: number;
  53848. protected _reflectionReflectance0: number;
  53849. /**
  53850. * This specifies the weight of the reflection at grazing angle.
  53851. */
  53852. reflectionReflectance0: number;
  53853. protected _reflectionReflectance90: number;
  53854. /**
  53855. * This specifies the weight of the reflection at a perpendicular point of view.
  53856. */
  53857. reflectionReflectance90: number;
  53858. /**
  53859. * Sets the reflection reflectance fresnel values according to the default standard
  53860. * empirically know to work well :-)
  53861. */
  53862. set reflectionStandardFresnelWeight(value: number);
  53863. protected _useRGBColor: boolean;
  53864. /**
  53865. * Helps to directly use the maps channels instead of their level.
  53866. */
  53867. useRGBColor: boolean;
  53868. protected _enableNoise: boolean;
  53869. /**
  53870. * This helps reducing the banding effect that could occur on the background.
  53871. */
  53872. enableNoise: boolean;
  53873. /**
  53874. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53875. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53876. * Recommended to be keep at 1.0 except for special cases.
  53877. */
  53878. get fovMultiplier(): number;
  53879. set fovMultiplier(value: number);
  53880. private _fovMultiplier;
  53881. /**
  53882. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53883. */
  53884. useEquirectangularFOV: boolean;
  53885. private _maxSimultaneousLights;
  53886. /**
  53887. * Number of Simultaneous lights allowed on the material.
  53888. */
  53889. maxSimultaneousLights: int;
  53890. private _shadowOnly;
  53891. /**
  53892. * Make the material only render shadows
  53893. */
  53894. shadowOnly: boolean;
  53895. /**
  53896. * Default configuration related to image processing available in the Background Material.
  53897. */
  53898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53899. /**
  53900. * Keep track of the image processing observer to allow dispose and replace.
  53901. */
  53902. private _imageProcessingObserver;
  53903. /**
  53904. * Attaches a new image processing configuration to the PBR Material.
  53905. * @param configuration (if null the scene configuration will be use)
  53906. */
  53907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53908. /**
  53909. * Gets the image processing configuration used either in this material.
  53910. */
  53911. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53912. /**
  53913. * Sets the Default image processing configuration used either in the this material.
  53914. *
  53915. * If sets to null, the scene one is in use.
  53916. */
  53917. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53918. /**
  53919. * Gets wether the color curves effect is enabled.
  53920. */
  53921. get cameraColorCurvesEnabled(): boolean;
  53922. /**
  53923. * Sets wether the color curves effect is enabled.
  53924. */
  53925. set cameraColorCurvesEnabled(value: boolean);
  53926. /**
  53927. * Gets wether the color grading effect is enabled.
  53928. */
  53929. get cameraColorGradingEnabled(): boolean;
  53930. /**
  53931. * Gets wether the color grading effect is enabled.
  53932. */
  53933. set cameraColorGradingEnabled(value: boolean);
  53934. /**
  53935. * Gets wether tonemapping is enabled or not.
  53936. */
  53937. get cameraToneMappingEnabled(): boolean;
  53938. /**
  53939. * Sets wether tonemapping is enabled or not
  53940. */
  53941. set cameraToneMappingEnabled(value: boolean);
  53942. /**
  53943. * The camera exposure used on this material.
  53944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53945. * This corresponds to a photographic exposure.
  53946. */
  53947. get cameraExposure(): float;
  53948. /**
  53949. * The camera exposure used on this material.
  53950. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53951. * This corresponds to a photographic exposure.
  53952. */
  53953. set cameraExposure(value: float);
  53954. /**
  53955. * Gets The camera contrast used on this material.
  53956. */
  53957. get cameraContrast(): float;
  53958. /**
  53959. * Sets The camera contrast used on this material.
  53960. */
  53961. set cameraContrast(value: float);
  53962. /**
  53963. * Gets the Color Grading 2D Lookup Texture.
  53964. */
  53965. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53966. /**
  53967. * Sets the Color Grading 2D Lookup Texture.
  53968. */
  53969. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53970. /**
  53971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53973. * 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;
  53974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53975. */
  53976. get cameraColorCurves(): Nullable<ColorCurves>;
  53977. /**
  53978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53980. * 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;
  53981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53982. */
  53983. set cameraColorCurves(value: Nullable<ColorCurves>);
  53984. /**
  53985. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53986. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53987. */
  53988. switchToBGR: boolean;
  53989. private _renderTargets;
  53990. private _reflectionControls;
  53991. private _white;
  53992. private _primaryShadowColor;
  53993. private _primaryHighlightColor;
  53994. /**
  53995. * Instantiates a Background Material in the given scene
  53996. * @param name The friendly name of the material
  53997. * @param scene The scene to add the material to
  53998. */
  53999. constructor(name: string, scene: Scene);
  54000. /**
  54001. * Gets a boolean indicating that current material needs to register RTT
  54002. */
  54003. get hasRenderTargetTextures(): boolean;
  54004. /**
  54005. * The entire material has been created in order to prevent overdraw.
  54006. * @returns false
  54007. */
  54008. needAlphaTesting(): boolean;
  54009. /**
  54010. * The entire material has been created in order to prevent overdraw.
  54011. * @returns true if blending is enable
  54012. */
  54013. needAlphaBlending(): boolean;
  54014. /**
  54015. * Checks wether the material is ready to be rendered for a given mesh.
  54016. * @param mesh The mesh to render
  54017. * @param subMesh The submesh to check against
  54018. * @param useInstances Specify wether or not the material is used with instances
  54019. * @returns true if all the dependencies are ready (Textures, Effects...)
  54020. */
  54021. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54022. /**
  54023. * Compute the primary color according to the chosen perceptual color.
  54024. */
  54025. private _computePrimaryColorFromPerceptualColor;
  54026. /**
  54027. * Compute the highlights and shadow colors according to their chosen levels.
  54028. */
  54029. private _computePrimaryColors;
  54030. /**
  54031. * Build the uniform buffer used in the material.
  54032. */
  54033. buildUniformLayout(): void;
  54034. /**
  54035. * Unbind the material.
  54036. */
  54037. unbind(): void;
  54038. /**
  54039. * Bind only the world matrix to the material.
  54040. * @param world The world matrix to bind.
  54041. */
  54042. bindOnlyWorldMatrix(world: Matrix): void;
  54043. /**
  54044. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54045. * @param world The world matrix to bind.
  54046. * @param subMesh The submesh to bind for.
  54047. */
  54048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54049. /**
  54050. * Checks to see if a texture is used in the material.
  54051. * @param texture - Base texture to use.
  54052. * @returns - Boolean specifying if a texture is used in the material.
  54053. */
  54054. hasTexture(texture: BaseTexture): boolean;
  54055. /**
  54056. * Dispose the material.
  54057. * @param forceDisposeEffect Force disposal of the associated effect.
  54058. * @param forceDisposeTextures Force disposal of the associated textures.
  54059. */
  54060. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54061. /**
  54062. * Clones the material.
  54063. * @param name The cloned name.
  54064. * @returns The cloned material.
  54065. */
  54066. clone(name: string): BackgroundMaterial;
  54067. /**
  54068. * Serializes the current material to its JSON representation.
  54069. * @returns The JSON representation.
  54070. */
  54071. serialize(): any;
  54072. /**
  54073. * Gets the class name of the material
  54074. * @returns "BackgroundMaterial"
  54075. */
  54076. getClassName(): string;
  54077. /**
  54078. * Parse a JSON input to create back a background material.
  54079. * @param source The JSON data to parse
  54080. * @param scene The scene to create the parsed material in
  54081. * @param rootUrl The root url of the assets the material depends upon
  54082. * @returns the instantiated BackgroundMaterial.
  54083. */
  54084. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54085. }
  54086. }
  54087. declare module BABYLON {
  54088. /**
  54089. * Represents the different options available during the creation of
  54090. * a Environment helper.
  54091. *
  54092. * This can control the default ground, skybox and image processing setup of your scene.
  54093. */
  54094. export interface IEnvironmentHelperOptions {
  54095. /**
  54096. * Specifies whether or not to create a ground.
  54097. * True by default.
  54098. */
  54099. createGround: boolean;
  54100. /**
  54101. * Specifies the ground size.
  54102. * 15 by default.
  54103. */
  54104. groundSize: number;
  54105. /**
  54106. * The texture used on the ground for the main color.
  54107. * Comes from the BabylonJS CDN by default.
  54108. *
  54109. * Remarks: Can be either a texture or a url.
  54110. */
  54111. groundTexture: string | BaseTexture;
  54112. /**
  54113. * The color mixed in the ground texture by default.
  54114. * BabylonJS clearColor by default.
  54115. */
  54116. groundColor: Color3;
  54117. /**
  54118. * Specifies the ground opacity.
  54119. * 1 by default.
  54120. */
  54121. groundOpacity: number;
  54122. /**
  54123. * Enables the ground to receive shadows.
  54124. * True by default.
  54125. */
  54126. enableGroundShadow: boolean;
  54127. /**
  54128. * Helps preventing the shadow to be fully black on the ground.
  54129. * 0.5 by default.
  54130. */
  54131. groundShadowLevel: number;
  54132. /**
  54133. * Creates a mirror texture attach to the ground.
  54134. * false by default.
  54135. */
  54136. enableGroundMirror: boolean;
  54137. /**
  54138. * Specifies the ground mirror size ratio.
  54139. * 0.3 by default as the default kernel is 64.
  54140. */
  54141. groundMirrorSizeRatio: number;
  54142. /**
  54143. * Specifies the ground mirror blur kernel size.
  54144. * 64 by default.
  54145. */
  54146. groundMirrorBlurKernel: number;
  54147. /**
  54148. * Specifies the ground mirror visibility amount.
  54149. * 1 by default
  54150. */
  54151. groundMirrorAmount: number;
  54152. /**
  54153. * Specifies the ground mirror reflectance weight.
  54154. * This uses the standard weight of the background material to setup the fresnel effect
  54155. * of the mirror.
  54156. * 1 by default.
  54157. */
  54158. groundMirrorFresnelWeight: number;
  54159. /**
  54160. * Specifies the ground mirror Falloff distance.
  54161. * This can helps reducing the size of the reflection.
  54162. * 0 by Default.
  54163. */
  54164. groundMirrorFallOffDistance: number;
  54165. /**
  54166. * Specifies the ground mirror texture type.
  54167. * Unsigned Int by Default.
  54168. */
  54169. groundMirrorTextureType: number;
  54170. /**
  54171. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54172. * the shown objects.
  54173. */
  54174. groundYBias: number;
  54175. /**
  54176. * Specifies whether or not to create a skybox.
  54177. * True by default.
  54178. */
  54179. createSkybox: boolean;
  54180. /**
  54181. * Specifies the skybox size.
  54182. * 20 by default.
  54183. */
  54184. skyboxSize: number;
  54185. /**
  54186. * The texture used on the skybox for the main color.
  54187. * Comes from the BabylonJS CDN by default.
  54188. *
  54189. * Remarks: Can be either a texture or a url.
  54190. */
  54191. skyboxTexture: string | BaseTexture;
  54192. /**
  54193. * The color mixed in the skybox texture by default.
  54194. * BabylonJS clearColor by default.
  54195. */
  54196. skyboxColor: Color3;
  54197. /**
  54198. * The background rotation around the Y axis of the scene.
  54199. * This helps aligning the key lights of your scene with the background.
  54200. * 0 by default.
  54201. */
  54202. backgroundYRotation: number;
  54203. /**
  54204. * Compute automatically the size of the elements to best fit with the scene.
  54205. */
  54206. sizeAuto: boolean;
  54207. /**
  54208. * Default position of the rootMesh if autoSize is not true.
  54209. */
  54210. rootPosition: Vector3;
  54211. /**
  54212. * Sets up the image processing in the scene.
  54213. * true by default.
  54214. */
  54215. setupImageProcessing: boolean;
  54216. /**
  54217. * The texture used as your environment texture in the scene.
  54218. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54219. *
  54220. * Remarks: Can be either a texture or a url.
  54221. */
  54222. environmentTexture: string | BaseTexture;
  54223. /**
  54224. * The value of the exposure to apply to the scene.
  54225. * 0.6 by default if setupImageProcessing is true.
  54226. */
  54227. cameraExposure: number;
  54228. /**
  54229. * The value of the contrast to apply to the scene.
  54230. * 1.6 by default if setupImageProcessing is true.
  54231. */
  54232. cameraContrast: number;
  54233. /**
  54234. * Specifies whether or not tonemapping should be enabled in the scene.
  54235. * true by default if setupImageProcessing is true.
  54236. */
  54237. toneMappingEnabled: boolean;
  54238. }
  54239. /**
  54240. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54241. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54242. * It also helps with the default setup of your imageProcessing configuration.
  54243. */
  54244. export class EnvironmentHelper {
  54245. /**
  54246. * Default ground texture URL.
  54247. */
  54248. private static _groundTextureCDNUrl;
  54249. /**
  54250. * Default skybox texture URL.
  54251. */
  54252. private static _skyboxTextureCDNUrl;
  54253. /**
  54254. * Default environment texture URL.
  54255. */
  54256. private static _environmentTextureCDNUrl;
  54257. /**
  54258. * Creates the default options for the helper.
  54259. */
  54260. private static _getDefaultOptions;
  54261. private _rootMesh;
  54262. /**
  54263. * Gets the root mesh created by the helper.
  54264. */
  54265. get rootMesh(): Mesh;
  54266. private _skybox;
  54267. /**
  54268. * Gets the skybox created by the helper.
  54269. */
  54270. get skybox(): Nullable<Mesh>;
  54271. private _skyboxTexture;
  54272. /**
  54273. * Gets the skybox texture created by the helper.
  54274. */
  54275. get skyboxTexture(): Nullable<BaseTexture>;
  54276. private _skyboxMaterial;
  54277. /**
  54278. * Gets the skybox material created by the helper.
  54279. */
  54280. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54281. private _ground;
  54282. /**
  54283. * Gets the ground mesh created by the helper.
  54284. */
  54285. get ground(): Nullable<Mesh>;
  54286. private _groundTexture;
  54287. /**
  54288. * Gets the ground texture created by the helper.
  54289. */
  54290. get groundTexture(): Nullable<BaseTexture>;
  54291. private _groundMirror;
  54292. /**
  54293. * Gets the ground mirror created by the helper.
  54294. */
  54295. get groundMirror(): Nullable<MirrorTexture>;
  54296. /**
  54297. * Gets the ground mirror render list to helps pushing the meshes
  54298. * you wish in the ground reflection.
  54299. */
  54300. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54301. private _groundMaterial;
  54302. /**
  54303. * Gets the ground material created by the helper.
  54304. */
  54305. get groundMaterial(): Nullable<BackgroundMaterial>;
  54306. /**
  54307. * Stores the creation options.
  54308. */
  54309. private readonly _scene;
  54310. private _options;
  54311. /**
  54312. * This observable will be notified with any error during the creation of the environment,
  54313. * mainly texture creation errors.
  54314. */
  54315. onErrorObservable: Observable<{
  54316. message?: string;
  54317. exception?: any;
  54318. }>;
  54319. /**
  54320. * constructor
  54321. * @param options Defines the options we want to customize the helper
  54322. * @param scene The scene to add the material to
  54323. */
  54324. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54325. /**
  54326. * Updates the background according to the new options
  54327. * @param options
  54328. */
  54329. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54330. /**
  54331. * Sets the primary color of all the available elements.
  54332. * @param color the main color to affect to the ground and the background
  54333. */
  54334. setMainColor(color: Color3): void;
  54335. /**
  54336. * Setup the image processing according to the specified options.
  54337. */
  54338. private _setupImageProcessing;
  54339. /**
  54340. * Setup the environment texture according to the specified options.
  54341. */
  54342. private _setupEnvironmentTexture;
  54343. /**
  54344. * Setup the background according to the specified options.
  54345. */
  54346. private _setupBackground;
  54347. /**
  54348. * Get the scene sizes according to the setup.
  54349. */
  54350. private _getSceneSize;
  54351. /**
  54352. * Setup the ground according to the specified options.
  54353. */
  54354. private _setupGround;
  54355. /**
  54356. * Setup the ground material according to the specified options.
  54357. */
  54358. private _setupGroundMaterial;
  54359. /**
  54360. * Setup the ground diffuse texture according to the specified options.
  54361. */
  54362. private _setupGroundDiffuseTexture;
  54363. /**
  54364. * Setup the ground mirror texture according to the specified options.
  54365. */
  54366. private _setupGroundMirrorTexture;
  54367. /**
  54368. * Setup the ground to receive the mirror texture.
  54369. */
  54370. private _setupMirrorInGroundMaterial;
  54371. /**
  54372. * Setup the skybox according to the specified options.
  54373. */
  54374. private _setupSkybox;
  54375. /**
  54376. * Setup the skybox material according to the specified options.
  54377. */
  54378. private _setupSkyboxMaterial;
  54379. /**
  54380. * Setup the skybox reflection texture according to the specified options.
  54381. */
  54382. private _setupSkyboxReflectionTexture;
  54383. private _errorHandler;
  54384. /**
  54385. * Dispose all the elements created by the Helper.
  54386. */
  54387. dispose(): void;
  54388. }
  54389. }
  54390. declare module BABYLON {
  54391. /**
  54392. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54393. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54394. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54395. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54396. */
  54397. export class PhotoDome extends TransformNode {
  54398. /**
  54399. * Define the image as a Monoscopic panoramic 360 image.
  54400. */
  54401. static readonly MODE_MONOSCOPIC: number;
  54402. /**
  54403. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54404. */
  54405. static readonly MODE_TOPBOTTOM: number;
  54406. /**
  54407. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54408. */
  54409. static readonly MODE_SIDEBYSIDE: number;
  54410. private _useDirectMapping;
  54411. /**
  54412. * The texture being displayed on the sphere
  54413. */
  54414. protected _photoTexture: Texture;
  54415. /**
  54416. * Gets or sets the texture being displayed on the sphere
  54417. */
  54418. get photoTexture(): Texture;
  54419. set photoTexture(value: Texture);
  54420. /**
  54421. * Observable raised when an error occured while loading the 360 image
  54422. */
  54423. onLoadErrorObservable: Observable<string>;
  54424. /**
  54425. * The skybox material
  54426. */
  54427. protected _material: BackgroundMaterial;
  54428. /**
  54429. * The surface used for the skybox
  54430. */
  54431. protected _mesh: Mesh;
  54432. /**
  54433. * Gets the mesh used for the skybox.
  54434. */
  54435. get mesh(): Mesh;
  54436. /**
  54437. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54438. * Also see the options.resolution property.
  54439. */
  54440. get fovMultiplier(): number;
  54441. set fovMultiplier(value: number);
  54442. private _imageMode;
  54443. /**
  54444. * Gets or set the current video mode for the video. It can be:
  54445. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54446. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54447. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54448. */
  54449. get imageMode(): number;
  54450. set imageMode(value: number);
  54451. /**
  54452. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54453. * @param name Element's name, child elements will append suffixes for their own names.
  54454. * @param urlsOfPhoto defines the url of the photo to display
  54455. * @param options defines an object containing optional or exposed sub element properties
  54456. * @param onError defines a callback called when an error occured while loading the texture
  54457. */
  54458. constructor(name: string, urlOfPhoto: string, options: {
  54459. resolution?: number;
  54460. size?: number;
  54461. useDirectMapping?: boolean;
  54462. faceForward?: boolean;
  54463. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54464. private _onBeforeCameraRenderObserver;
  54465. private _changeImageMode;
  54466. /**
  54467. * Releases resources associated with this node.
  54468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54470. */
  54471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54472. }
  54473. }
  54474. declare module BABYLON {
  54475. /**
  54476. * Class used to host RGBD texture specific utilities
  54477. */
  54478. export class RGBDTextureTools {
  54479. /**
  54480. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54481. * @param texture the texture to expand.
  54482. */
  54483. static ExpandRGBDTexture(texture: Texture): void;
  54484. }
  54485. }
  54486. declare module BABYLON {
  54487. /**
  54488. * Class used to host texture specific utilities
  54489. */
  54490. export class BRDFTextureTools {
  54491. /**
  54492. * Prevents texture cache collision
  54493. */
  54494. private static _instanceNumber;
  54495. /**
  54496. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54497. * @param scene defines the hosting scene
  54498. * @returns the environment BRDF texture
  54499. */
  54500. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54501. private static _environmentBRDFBase64Texture;
  54502. }
  54503. }
  54504. declare module BABYLON {
  54505. /**
  54506. * @hidden
  54507. */
  54508. export interface IMaterialClearCoatDefines {
  54509. CLEARCOAT: boolean;
  54510. CLEARCOAT_DEFAULTIOR: boolean;
  54511. CLEARCOAT_TEXTURE: boolean;
  54512. CLEARCOAT_TEXTUREDIRECTUV: number;
  54513. CLEARCOAT_BUMP: boolean;
  54514. CLEARCOAT_BUMPDIRECTUV: number;
  54515. CLEARCOAT_TINT: boolean;
  54516. CLEARCOAT_TINT_TEXTURE: boolean;
  54517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54518. /** @hidden */
  54519. _areTexturesDirty: boolean;
  54520. }
  54521. /**
  54522. * Define the code related to the clear coat parameters of the pbr material.
  54523. */
  54524. export class PBRClearCoatConfiguration {
  54525. /**
  54526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54527. * The default fits with a polyurethane material.
  54528. */
  54529. private static readonly _DefaultIndexOfRefraction;
  54530. private _isEnabled;
  54531. /**
  54532. * Defines if the clear coat is enabled in the material.
  54533. */
  54534. isEnabled: boolean;
  54535. /**
  54536. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54537. */
  54538. intensity: number;
  54539. /**
  54540. * Defines the clear coat layer roughness.
  54541. */
  54542. roughness: number;
  54543. private _indexOfRefraction;
  54544. /**
  54545. * Defines the index of refraction of the clear coat.
  54546. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54547. * The default fits with a polyurethane material.
  54548. * Changing the default value is more performance intensive.
  54549. */
  54550. indexOfRefraction: number;
  54551. private _texture;
  54552. /**
  54553. * Stores the clear coat values in a texture.
  54554. */
  54555. texture: Nullable<BaseTexture>;
  54556. private _bumpTexture;
  54557. /**
  54558. * Define the clear coat specific bump texture.
  54559. */
  54560. bumpTexture: Nullable<BaseTexture>;
  54561. private _isTintEnabled;
  54562. /**
  54563. * Defines if the clear coat tint is enabled in the material.
  54564. */
  54565. isTintEnabled: boolean;
  54566. /**
  54567. * Defines the clear coat tint of the material.
  54568. * This is only use if tint is enabled
  54569. */
  54570. tintColor: Color3;
  54571. /**
  54572. * Defines the distance at which the tint color should be found in the
  54573. * clear coat media.
  54574. * This is only use if tint is enabled
  54575. */
  54576. tintColorAtDistance: number;
  54577. /**
  54578. * Defines the clear coat layer thickness.
  54579. * This is only use if tint is enabled
  54580. */
  54581. tintThickness: number;
  54582. private _tintTexture;
  54583. /**
  54584. * Stores the clear tint values in a texture.
  54585. * rgb is tint
  54586. * a is a thickness factor
  54587. */
  54588. tintTexture: Nullable<BaseTexture>;
  54589. /** @hidden */
  54590. private _internalMarkAllSubMeshesAsTexturesDirty;
  54591. /** @hidden */
  54592. _markAllSubMeshesAsTexturesDirty(): void;
  54593. /**
  54594. * Instantiate a new istance of clear coat configuration.
  54595. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54596. */
  54597. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54598. /**
  54599. * Gets wehter the submesh is ready to be used or not.
  54600. * @param defines the list of "defines" to update.
  54601. * @param scene defines the scene the material belongs to.
  54602. * @param engine defines the engine the material belongs to.
  54603. * @param disableBumpMap defines wether the material disables bump or not.
  54604. * @returns - boolean indicating that the submesh is ready or not.
  54605. */
  54606. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54607. /**
  54608. * Checks to see if a texture is used in the material.
  54609. * @param defines the list of "defines" to update.
  54610. * @param scene defines the scene to the material belongs to.
  54611. */
  54612. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54613. /**
  54614. * Binds the material data.
  54615. * @param uniformBuffer defines the Uniform buffer to fill in.
  54616. * @param scene defines the scene the material belongs to.
  54617. * @param engine defines the engine the material belongs to.
  54618. * @param disableBumpMap defines wether the material disables bump or not.
  54619. * @param isFrozen defines wether the material is frozen or not.
  54620. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54621. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54622. */
  54623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54624. /**
  54625. * Checks to see if a texture is used in the material.
  54626. * @param texture - Base texture to use.
  54627. * @returns - Boolean specifying if a texture is used in the material.
  54628. */
  54629. hasTexture(texture: BaseTexture): boolean;
  54630. /**
  54631. * Returns an array of the actively used textures.
  54632. * @param activeTextures Array of BaseTextures
  54633. */
  54634. getActiveTextures(activeTextures: BaseTexture[]): void;
  54635. /**
  54636. * Returns the animatable textures.
  54637. * @param animatables Array of animatable textures.
  54638. */
  54639. getAnimatables(animatables: IAnimatable[]): void;
  54640. /**
  54641. * Disposes the resources of the material.
  54642. * @param forceDisposeTextures - Forces the disposal of all textures.
  54643. */
  54644. dispose(forceDisposeTextures?: boolean): void;
  54645. /**
  54646. * Get the current class name of the texture useful for serialization or dynamic coding.
  54647. * @returns "PBRClearCoatConfiguration"
  54648. */
  54649. getClassName(): string;
  54650. /**
  54651. * Add fallbacks to the effect fallbacks list.
  54652. * @param defines defines the Base texture to use.
  54653. * @param fallbacks defines the current fallback list.
  54654. * @param currentRank defines the current fallback rank.
  54655. * @returns the new fallback rank.
  54656. */
  54657. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54658. /**
  54659. * Add the required uniforms to the current list.
  54660. * @param uniforms defines the current uniform list.
  54661. */
  54662. static AddUniforms(uniforms: string[]): void;
  54663. /**
  54664. * Add the required samplers to the current list.
  54665. * @param samplers defines the current sampler list.
  54666. */
  54667. static AddSamplers(samplers: string[]): void;
  54668. /**
  54669. * Add the required uniforms to the current buffer.
  54670. * @param uniformBuffer defines the current uniform buffer.
  54671. */
  54672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54673. /**
  54674. * Makes a duplicate of the current configuration into another one.
  54675. * @param clearCoatConfiguration define the config where to copy the info
  54676. */
  54677. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54678. /**
  54679. * Serializes this clear coat configuration.
  54680. * @returns - An object with the serialized config.
  54681. */
  54682. serialize(): any;
  54683. /**
  54684. * Parses a anisotropy Configuration from a serialized object.
  54685. * @param source - Serialized object.
  54686. * @param scene Defines the scene we are parsing for
  54687. * @param rootUrl Defines the rootUrl to load from
  54688. */
  54689. parse(source: any, scene: Scene, rootUrl: string): void;
  54690. }
  54691. }
  54692. declare module BABYLON {
  54693. /**
  54694. * @hidden
  54695. */
  54696. export interface IMaterialAnisotropicDefines {
  54697. ANISOTROPIC: boolean;
  54698. ANISOTROPIC_TEXTURE: boolean;
  54699. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54700. MAINUV1: boolean;
  54701. _areTexturesDirty: boolean;
  54702. _needUVs: boolean;
  54703. }
  54704. /**
  54705. * Define the code related to the anisotropic parameters of the pbr material.
  54706. */
  54707. export class PBRAnisotropicConfiguration {
  54708. private _isEnabled;
  54709. /**
  54710. * Defines if the anisotropy is enabled in the material.
  54711. */
  54712. isEnabled: boolean;
  54713. /**
  54714. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54715. */
  54716. intensity: number;
  54717. /**
  54718. * Defines if the effect is along the tangents, bitangents or in between.
  54719. * By default, the effect is "strectching" the highlights along the tangents.
  54720. */
  54721. direction: Vector2;
  54722. private _texture;
  54723. /**
  54724. * Stores the anisotropy values in a texture.
  54725. * rg is direction (like normal from -1 to 1)
  54726. * b is a intensity
  54727. */
  54728. texture: Nullable<BaseTexture>;
  54729. /** @hidden */
  54730. private _internalMarkAllSubMeshesAsTexturesDirty;
  54731. /** @hidden */
  54732. _markAllSubMeshesAsTexturesDirty(): void;
  54733. /**
  54734. * Instantiate a new istance of anisotropy configuration.
  54735. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54736. */
  54737. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54738. /**
  54739. * Specifies that the submesh is ready to be used.
  54740. * @param defines the list of "defines" to update.
  54741. * @param scene defines the scene the material belongs to.
  54742. * @returns - boolean indicating that the submesh is ready or not.
  54743. */
  54744. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54745. /**
  54746. * Checks to see if a texture is used in the material.
  54747. * @param defines the list of "defines" to update.
  54748. * @param mesh the mesh we are preparing the defines for.
  54749. * @param scene defines the scene the material belongs to.
  54750. */
  54751. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54752. /**
  54753. * Binds the material data.
  54754. * @param uniformBuffer defines the Uniform buffer to fill in.
  54755. * @param scene defines the scene the material belongs to.
  54756. * @param isFrozen defines wether the material is frozen or not.
  54757. */
  54758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54759. /**
  54760. * Checks to see if a texture is used in the material.
  54761. * @param texture - Base texture to use.
  54762. * @returns - Boolean specifying if a texture is used in the material.
  54763. */
  54764. hasTexture(texture: BaseTexture): boolean;
  54765. /**
  54766. * Returns an array of the actively used textures.
  54767. * @param activeTextures Array of BaseTextures
  54768. */
  54769. getActiveTextures(activeTextures: BaseTexture[]): void;
  54770. /**
  54771. * Returns the animatable textures.
  54772. * @param animatables Array of animatable textures.
  54773. */
  54774. getAnimatables(animatables: IAnimatable[]): void;
  54775. /**
  54776. * Disposes the resources of the material.
  54777. * @param forceDisposeTextures - Forces the disposal of all textures.
  54778. */
  54779. dispose(forceDisposeTextures?: boolean): void;
  54780. /**
  54781. * Get the current class name of the texture useful for serialization or dynamic coding.
  54782. * @returns "PBRAnisotropicConfiguration"
  54783. */
  54784. getClassName(): string;
  54785. /**
  54786. * Add fallbacks to the effect fallbacks list.
  54787. * @param defines defines the Base texture to use.
  54788. * @param fallbacks defines the current fallback list.
  54789. * @param currentRank defines the current fallback rank.
  54790. * @returns the new fallback rank.
  54791. */
  54792. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54793. /**
  54794. * Add the required uniforms to the current list.
  54795. * @param uniforms defines the current uniform list.
  54796. */
  54797. static AddUniforms(uniforms: string[]): void;
  54798. /**
  54799. * Add the required uniforms to the current buffer.
  54800. * @param uniformBuffer defines the current uniform buffer.
  54801. */
  54802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54803. /**
  54804. * Add the required samplers to the current list.
  54805. * @param samplers defines the current sampler list.
  54806. */
  54807. static AddSamplers(samplers: string[]): void;
  54808. /**
  54809. * Makes a duplicate of the current configuration into another one.
  54810. * @param anisotropicConfiguration define the config where to copy the info
  54811. */
  54812. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54813. /**
  54814. * Serializes this anisotropy configuration.
  54815. * @returns - An object with the serialized config.
  54816. */
  54817. serialize(): any;
  54818. /**
  54819. * Parses a anisotropy Configuration from a serialized object.
  54820. * @param source - Serialized object.
  54821. * @param scene Defines the scene we are parsing for
  54822. * @param rootUrl Defines the rootUrl to load from
  54823. */
  54824. parse(source: any, scene: Scene, rootUrl: string): void;
  54825. }
  54826. }
  54827. declare module BABYLON {
  54828. /**
  54829. * @hidden
  54830. */
  54831. export interface IMaterialBRDFDefines {
  54832. BRDF_V_HEIGHT_CORRELATED: boolean;
  54833. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54834. SPHERICAL_HARMONICS: boolean;
  54835. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54836. /** @hidden */
  54837. _areMiscDirty: boolean;
  54838. }
  54839. /**
  54840. * Define the code related to the BRDF parameters of the pbr material.
  54841. */
  54842. export class PBRBRDFConfiguration {
  54843. /**
  54844. * Default value used for the energy conservation.
  54845. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54846. */
  54847. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54848. /**
  54849. * Default value used for the Smith Visibility Height Correlated mode.
  54850. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54851. */
  54852. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54853. /**
  54854. * Default value used for the IBL diffuse part.
  54855. * This can help switching back to the polynomials mode globally which is a tiny bit
  54856. * less GPU intensive at the drawback of a lower quality.
  54857. */
  54858. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54859. /**
  54860. * Default value used for activating energy conservation for the specular workflow.
  54861. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54862. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54863. */
  54864. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54865. private _useEnergyConservation;
  54866. /**
  54867. * Defines if the material uses energy conservation.
  54868. */
  54869. useEnergyConservation: boolean;
  54870. private _useSmithVisibilityHeightCorrelated;
  54871. /**
  54872. * LEGACY Mode set to false
  54873. * Defines if the material uses height smith correlated visibility term.
  54874. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54875. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54876. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54877. * Not relying on height correlated will also disable energy conservation.
  54878. */
  54879. useSmithVisibilityHeightCorrelated: boolean;
  54880. private _useSphericalHarmonics;
  54881. /**
  54882. * LEGACY Mode set to false
  54883. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54884. * diffuse part of the IBL.
  54885. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54886. * to the ground truth.
  54887. */
  54888. useSphericalHarmonics: boolean;
  54889. private _useSpecularGlossinessInputEnergyConservation;
  54890. /**
  54891. * Defines if the material uses energy conservation, when the specular workflow is active.
  54892. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54893. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54894. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54895. */
  54896. useSpecularGlossinessInputEnergyConservation: boolean;
  54897. /** @hidden */
  54898. private _internalMarkAllSubMeshesAsMiscDirty;
  54899. /** @hidden */
  54900. _markAllSubMeshesAsMiscDirty(): void;
  54901. /**
  54902. * Instantiate a new istance of clear coat configuration.
  54903. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54904. */
  54905. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54906. /**
  54907. * Checks to see if a texture is used in the material.
  54908. * @param defines the list of "defines" to update.
  54909. */
  54910. prepareDefines(defines: IMaterialBRDFDefines): void;
  54911. /**
  54912. * Get the current class name of the texture useful for serialization or dynamic coding.
  54913. * @returns "PBRClearCoatConfiguration"
  54914. */
  54915. getClassName(): string;
  54916. /**
  54917. * Makes a duplicate of the current configuration into another one.
  54918. * @param brdfConfiguration define the config where to copy the info
  54919. */
  54920. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54921. /**
  54922. * Serializes this BRDF configuration.
  54923. * @returns - An object with the serialized config.
  54924. */
  54925. serialize(): any;
  54926. /**
  54927. * Parses a anisotropy Configuration from a serialized object.
  54928. * @param source - Serialized object.
  54929. * @param scene Defines the scene we are parsing for
  54930. * @param rootUrl Defines the rootUrl to load from
  54931. */
  54932. parse(source: any, scene: Scene, rootUrl: string): void;
  54933. }
  54934. }
  54935. declare module BABYLON {
  54936. /**
  54937. * @hidden
  54938. */
  54939. export interface IMaterialSheenDefines {
  54940. SHEEN: boolean;
  54941. SHEEN_TEXTURE: boolean;
  54942. SHEEN_TEXTUREDIRECTUV: number;
  54943. SHEEN_LINKWITHALBEDO: boolean;
  54944. SHEEN_ROUGHNESS: boolean;
  54945. SHEEN_ALBEDOSCALING: boolean;
  54946. /** @hidden */
  54947. _areTexturesDirty: boolean;
  54948. }
  54949. /**
  54950. * Define the code related to the Sheen parameters of the pbr material.
  54951. */
  54952. export class PBRSheenConfiguration {
  54953. private _isEnabled;
  54954. /**
  54955. * Defines if the material uses sheen.
  54956. */
  54957. isEnabled: boolean;
  54958. private _linkSheenWithAlbedo;
  54959. /**
  54960. * Defines if the sheen is linked to the sheen color.
  54961. */
  54962. linkSheenWithAlbedo: boolean;
  54963. /**
  54964. * Defines the sheen intensity.
  54965. */
  54966. intensity: number;
  54967. /**
  54968. * Defines the sheen color.
  54969. */
  54970. color: Color3;
  54971. private _texture;
  54972. /**
  54973. * Stores the sheen tint values in a texture.
  54974. * rgb is tint
  54975. * a is a intensity or roughness if roughness has been defined
  54976. */
  54977. texture: Nullable<BaseTexture>;
  54978. private _roughness;
  54979. /**
  54980. * Defines the sheen roughness.
  54981. * It is not taken into account if linkSheenWithAlbedo is true.
  54982. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54983. */
  54984. roughness: Nullable<number>;
  54985. private _albedoScaling;
  54986. /**
  54987. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54988. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54989. * making it easier to setup and tweak the effect
  54990. */
  54991. albedoScaling: boolean;
  54992. /** @hidden */
  54993. private _internalMarkAllSubMeshesAsTexturesDirty;
  54994. /** @hidden */
  54995. _markAllSubMeshesAsTexturesDirty(): void;
  54996. /**
  54997. * Instantiate a new istance of clear coat configuration.
  54998. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54999. */
  55000. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55001. /**
  55002. * Specifies that the submesh is ready to be used.
  55003. * @param defines the list of "defines" to update.
  55004. * @param scene defines the scene the material belongs to.
  55005. * @returns - boolean indicating that the submesh is ready or not.
  55006. */
  55007. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55008. /**
  55009. * Checks to see if a texture is used in the material.
  55010. * @param defines the list of "defines" to update.
  55011. * @param scene defines the scene the material belongs to.
  55012. */
  55013. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55014. /**
  55015. * Binds the material data.
  55016. * @param uniformBuffer defines the Uniform buffer to fill in.
  55017. * @param scene defines the scene the material belongs to.
  55018. * @param isFrozen defines wether the material is frozen or not.
  55019. */
  55020. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55021. /**
  55022. * Checks to see if a texture is used in the material.
  55023. * @param texture - Base texture to use.
  55024. * @returns - Boolean specifying if a texture is used in the material.
  55025. */
  55026. hasTexture(texture: BaseTexture): boolean;
  55027. /**
  55028. * Returns an array of the actively used textures.
  55029. * @param activeTextures Array of BaseTextures
  55030. */
  55031. getActiveTextures(activeTextures: BaseTexture[]): void;
  55032. /**
  55033. * Returns the animatable textures.
  55034. * @param animatables Array of animatable textures.
  55035. */
  55036. getAnimatables(animatables: IAnimatable[]): void;
  55037. /**
  55038. * Disposes the resources of the material.
  55039. * @param forceDisposeTextures - Forces the disposal of all textures.
  55040. */
  55041. dispose(forceDisposeTextures?: boolean): void;
  55042. /**
  55043. * Get the current class name of the texture useful for serialization or dynamic coding.
  55044. * @returns "PBRSheenConfiguration"
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Add fallbacks to the effect fallbacks list.
  55049. * @param defines defines the Base texture to use.
  55050. * @param fallbacks defines the current fallback list.
  55051. * @param currentRank defines the current fallback rank.
  55052. * @returns the new fallback rank.
  55053. */
  55054. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55055. /**
  55056. * Add the required uniforms to the current list.
  55057. * @param uniforms defines the current uniform list.
  55058. */
  55059. static AddUniforms(uniforms: string[]): void;
  55060. /**
  55061. * Add the required uniforms to the current buffer.
  55062. * @param uniformBuffer defines the current uniform buffer.
  55063. */
  55064. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55065. /**
  55066. * Add the required samplers to the current list.
  55067. * @param samplers defines the current sampler list.
  55068. */
  55069. static AddSamplers(samplers: string[]): void;
  55070. /**
  55071. * Makes a duplicate of the current configuration into another one.
  55072. * @param sheenConfiguration define the config where to copy the info
  55073. */
  55074. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55075. /**
  55076. * Serializes this BRDF configuration.
  55077. * @returns - An object with the serialized config.
  55078. */
  55079. serialize(): any;
  55080. /**
  55081. * Parses a anisotropy Configuration from a serialized object.
  55082. * @param source - Serialized object.
  55083. * @param scene Defines the scene we are parsing for
  55084. * @param rootUrl Defines the rootUrl to load from
  55085. */
  55086. parse(source: any, scene: Scene, rootUrl: string): void;
  55087. }
  55088. }
  55089. declare module BABYLON {
  55090. /**
  55091. * @hidden
  55092. */
  55093. export interface IMaterialSubSurfaceDefines {
  55094. SUBSURFACE: boolean;
  55095. SS_REFRACTION: boolean;
  55096. SS_TRANSLUCENCY: boolean;
  55097. SS_SCATTERING: boolean;
  55098. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55099. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55100. SS_REFRACTIONMAP_3D: boolean;
  55101. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55102. SS_LODINREFRACTIONALPHA: boolean;
  55103. SS_GAMMAREFRACTION: boolean;
  55104. SS_RGBDREFRACTION: boolean;
  55105. SS_LINEARSPECULARREFRACTION: boolean;
  55106. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55107. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55108. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55109. /** @hidden */
  55110. _areTexturesDirty: boolean;
  55111. }
  55112. /**
  55113. * Define the code related to the sub surface parameters of the pbr material.
  55114. */
  55115. export class PBRSubSurfaceConfiguration {
  55116. private _isRefractionEnabled;
  55117. /**
  55118. * Defines if the refraction is enabled in the material.
  55119. */
  55120. isRefractionEnabled: boolean;
  55121. private _isTranslucencyEnabled;
  55122. /**
  55123. * Defines if the translucency is enabled in the material.
  55124. */
  55125. isTranslucencyEnabled: boolean;
  55126. private _isScatteringEnabled;
  55127. /**
  55128. * Defines if the sub surface scattering is enabled in the material.
  55129. */
  55130. isScatteringEnabled: boolean;
  55131. private _scatteringDiffusionProfileIndex;
  55132. /**
  55133. * Diffusion profile for subsurface scattering.
  55134. * Useful for better scattering in the skins or foliages.
  55135. */
  55136. get scatteringDiffusionProfile(): Nullable<Color3>;
  55137. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55138. /**
  55139. * Defines the refraction intensity of the material.
  55140. * The refraction when enabled replaces the Diffuse part of the material.
  55141. * The intensity helps transitionning between diffuse and refraction.
  55142. */
  55143. refractionIntensity: number;
  55144. /**
  55145. * Defines the translucency intensity of the material.
  55146. * When translucency has been enabled, this defines how much of the "translucency"
  55147. * is addded to the diffuse part of the material.
  55148. */
  55149. translucencyIntensity: number;
  55150. /**
  55151. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55152. */
  55153. useAlbedoToTintRefraction: boolean;
  55154. private _thicknessTexture;
  55155. /**
  55156. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55157. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55158. * 0 would mean minimumThickness
  55159. * 1 would mean maximumThickness
  55160. * The other channels might be use as a mask to vary the different effects intensity.
  55161. */
  55162. thicknessTexture: Nullable<BaseTexture>;
  55163. private _refractionTexture;
  55164. /**
  55165. * Defines the texture to use for refraction.
  55166. */
  55167. refractionTexture: Nullable<BaseTexture>;
  55168. private _indexOfRefraction;
  55169. /**
  55170. * Index of refraction of the material base layer.
  55171. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55172. *
  55173. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55174. *
  55175. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55176. */
  55177. indexOfRefraction: number;
  55178. private _volumeIndexOfRefraction;
  55179. /**
  55180. * Index of refraction of the material's volume.
  55181. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55182. *
  55183. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55184. * the volume will use the same IOR as the surface.
  55185. */
  55186. get volumeIndexOfRefraction(): number;
  55187. set volumeIndexOfRefraction(value: number);
  55188. private _invertRefractionY;
  55189. /**
  55190. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55191. */
  55192. invertRefractionY: boolean;
  55193. private _linkRefractionWithTransparency;
  55194. /**
  55195. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55196. * Materials half opaque for instance using refraction could benefit from this control.
  55197. */
  55198. linkRefractionWithTransparency: boolean;
  55199. /**
  55200. * Defines the minimum thickness stored in the thickness map.
  55201. * If no thickness map is defined, this value will be used to simulate thickness.
  55202. */
  55203. minimumThickness: number;
  55204. /**
  55205. * Defines the maximum thickness stored in the thickness map.
  55206. */
  55207. maximumThickness: number;
  55208. /**
  55209. * Defines the volume tint of the material.
  55210. * This is used for both translucency and scattering.
  55211. */
  55212. tintColor: Color3;
  55213. /**
  55214. * Defines the distance at which the tint color should be found in the media.
  55215. * This is used for refraction only.
  55216. */
  55217. tintColorAtDistance: number;
  55218. /**
  55219. * Defines how far each channel transmit through the media.
  55220. * It is defined as a color to simplify it selection.
  55221. */
  55222. diffusionDistance: Color3;
  55223. private _useMaskFromThicknessTexture;
  55224. /**
  55225. * Stores the intensity of the different subsurface effects in the thickness texture.
  55226. * * the green channel is the translucency intensity.
  55227. * * the blue channel is the scattering intensity.
  55228. * * the alpha channel is the refraction intensity.
  55229. */
  55230. useMaskFromThicknessTexture: boolean;
  55231. private _scene;
  55232. /** @hidden */
  55233. private _internalMarkAllSubMeshesAsTexturesDirty;
  55234. private _internalMarkScenePrePassDirty;
  55235. /** @hidden */
  55236. _markAllSubMeshesAsTexturesDirty(): void;
  55237. /** @hidden */
  55238. _markScenePrePassDirty(): void;
  55239. /**
  55240. * Instantiate a new istance of sub surface configuration.
  55241. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55242. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55243. * @param scene The scene
  55244. */
  55245. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55246. /**
  55247. * Gets wehter the submesh is ready to be used or not.
  55248. * @param defines the list of "defines" to update.
  55249. * @param scene defines the scene the material belongs to.
  55250. * @returns - boolean indicating that the submesh is ready or not.
  55251. */
  55252. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55253. /**
  55254. * Checks to see if a texture is used in the material.
  55255. * @param defines the list of "defines" to update.
  55256. * @param scene defines the scene to the material belongs to.
  55257. */
  55258. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55259. /**
  55260. * Binds the material data.
  55261. * @param uniformBuffer defines the Uniform buffer to fill in.
  55262. * @param scene defines the scene the material belongs to.
  55263. * @param engine defines the engine the material belongs to.
  55264. * @param isFrozen defines whether the material is frozen or not.
  55265. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55266. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55267. */
  55268. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55269. /**
  55270. * Unbinds the material from the mesh.
  55271. * @param activeEffect defines the effect that should be unbound from.
  55272. * @returns true if unbound, otherwise false
  55273. */
  55274. unbind(activeEffect: Effect): boolean;
  55275. /**
  55276. * Returns the texture used for refraction or null if none is used.
  55277. * @param scene defines the scene the material belongs to.
  55278. * @returns - Refraction texture if present. If no refraction texture and refraction
  55279. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55280. */
  55281. private _getRefractionTexture;
  55282. /**
  55283. * Returns true if alpha blending should be disabled.
  55284. */
  55285. get disableAlphaBlending(): boolean;
  55286. /**
  55287. * Fills the list of render target textures.
  55288. * @param renderTargets the list of render targets to update
  55289. */
  55290. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55291. /**
  55292. * Checks to see if a texture is used in the material.
  55293. * @param texture - Base texture to use.
  55294. * @returns - Boolean specifying if a texture is used in the material.
  55295. */
  55296. hasTexture(texture: BaseTexture): boolean;
  55297. /**
  55298. * Gets a boolean indicating that current material needs to register RTT
  55299. * @returns true if this uses a render target otherwise false.
  55300. */
  55301. hasRenderTargetTextures(): boolean;
  55302. /**
  55303. * Returns an array of the actively used textures.
  55304. * @param activeTextures Array of BaseTextures
  55305. */
  55306. getActiveTextures(activeTextures: BaseTexture[]): void;
  55307. /**
  55308. * Returns the animatable textures.
  55309. * @param animatables Array of animatable textures.
  55310. */
  55311. getAnimatables(animatables: IAnimatable[]): void;
  55312. /**
  55313. * Disposes the resources of the material.
  55314. * @param forceDisposeTextures - Forces the disposal of all textures.
  55315. */
  55316. dispose(forceDisposeTextures?: boolean): void;
  55317. /**
  55318. * Get the current class name of the texture useful for serialization or dynamic coding.
  55319. * @returns "PBRSubSurfaceConfiguration"
  55320. */
  55321. getClassName(): string;
  55322. /**
  55323. * Add fallbacks to the effect fallbacks list.
  55324. * @param defines defines the Base texture to use.
  55325. * @param fallbacks defines the current fallback list.
  55326. * @param currentRank defines the current fallback rank.
  55327. * @returns the new fallback rank.
  55328. */
  55329. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55330. /**
  55331. * Add the required uniforms to the current list.
  55332. * @param uniforms defines the current uniform list.
  55333. */
  55334. static AddUniforms(uniforms: string[]): void;
  55335. /**
  55336. * Add the required samplers to the current list.
  55337. * @param samplers defines the current sampler list.
  55338. */
  55339. static AddSamplers(samplers: string[]): void;
  55340. /**
  55341. * Add the required uniforms to the current buffer.
  55342. * @param uniformBuffer defines the current uniform buffer.
  55343. */
  55344. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55345. /**
  55346. * Makes a duplicate of the current configuration into another one.
  55347. * @param configuration define the config where to copy the info
  55348. */
  55349. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55350. /**
  55351. * Serializes this Sub Surface configuration.
  55352. * @returns - An object with the serialized config.
  55353. */
  55354. serialize(): any;
  55355. /**
  55356. * Parses a anisotropy Configuration from a serialized object.
  55357. * @param source - Serialized object.
  55358. * @param scene Defines the scene we are parsing for
  55359. * @param rootUrl Defines the rootUrl to load from
  55360. */
  55361. parse(source: any, scene: Scene, rootUrl: string): void;
  55362. }
  55363. }
  55364. declare module BABYLON {
  55365. /** @hidden */
  55366. export var pbrFragmentDeclaration: {
  55367. name: string;
  55368. shader: string;
  55369. };
  55370. }
  55371. declare module BABYLON {
  55372. /** @hidden */
  55373. export var pbrUboDeclaration: {
  55374. name: string;
  55375. shader: string;
  55376. };
  55377. }
  55378. declare module BABYLON {
  55379. /** @hidden */
  55380. export var pbrFragmentExtraDeclaration: {
  55381. name: string;
  55382. shader: string;
  55383. };
  55384. }
  55385. declare module BABYLON {
  55386. /** @hidden */
  55387. export var pbrFragmentSamplersDeclaration: {
  55388. name: string;
  55389. shader: string;
  55390. };
  55391. }
  55392. declare module BABYLON {
  55393. /** @hidden */
  55394. export var importanceSampling: {
  55395. name: string;
  55396. shader: string;
  55397. };
  55398. }
  55399. declare module BABYLON {
  55400. /** @hidden */
  55401. export var pbrHelperFunctions: {
  55402. name: string;
  55403. shader: string;
  55404. };
  55405. }
  55406. declare module BABYLON {
  55407. /** @hidden */
  55408. export var harmonicsFunctions: {
  55409. name: string;
  55410. shader: string;
  55411. };
  55412. }
  55413. declare module BABYLON {
  55414. /** @hidden */
  55415. export var pbrDirectLightingSetupFunctions: {
  55416. name: string;
  55417. shader: string;
  55418. };
  55419. }
  55420. declare module BABYLON {
  55421. /** @hidden */
  55422. export var pbrDirectLightingFalloffFunctions: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module BABYLON {
  55428. /** @hidden */
  55429. export var pbrBRDFFunctions: {
  55430. name: string;
  55431. shader: string;
  55432. };
  55433. }
  55434. declare module BABYLON {
  55435. /** @hidden */
  55436. export var hdrFilteringFunctions: {
  55437. name: string;
  55438. shader: string;
  55439. };
  55440. }
  55441. declare module BABYLON {
  55442. /** @hidden */
  55443. export var pbrDirectLightingFunctions: {
  55444. name: string;
  55445. shader: string;
  55446. };
  55447. }
  55448. declare module BABYLON {
  55449. /** @hidden */
  55450. export var pbrIBLFunctions: {
  55451. name: string;
  55452. shader: string;
  55453. };
  55454. }
  55455. declare module BABYLON {
  55456. /** @hidden */
  55457. export var pbrBlockAlbedoOpacity: {
  55458. name: string;
  55459. shader: string;
  55460. };
  55461. }
  55462. declare module BABYLON {
  55463. /** @hidden */
  55464. export var pbrBlockReflectivity: {
  55465. name: string;
  55466. shader: string;
  55467. };
  55468. }
  55469. declare module BABYLON {
  55470. /** @hidden */
  55471. export var pbrBlockAmbientOcclusion: {
  55472. name: string;
  55473. shader: string;
  55474. };
  55475. }
  55476. declare module BABYLON {
  55477. /** @hidden */
  55478. export var pbrBlockAlphaFresnel: {
  55479. name: string;
  55480. shader: string;
  55481. };
  55482. }
  55483. declare module BABYLON {
  55484. /** @hidden */
  55485. export var pbrBlockAnisotropic: {
  55486. name: string;
  55487. shader: string;
  55488. };
  55489. }
  55490. declare module BABYLON {
  55491. /** @hidden */
  55492. export var pbrBlockReflection: {
  55493. name: string;
  55494. shader: string;
  55495. };
  55496. }
  55497. declare module BABYLON {
  55498. /** @hidden */
  55499. export var pbrBlockSheen: {
  55500. name: string;
  55501. shader: string;
  55502. };
  55503. }
  55504. declare module BABYLON {
  55505. /** @hidden */
  55506. export var pbrBlockClearcoat: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module BABYLON {
  55512. /** @hidden */
  55513. export var pbrBlockSubSurface: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module BABYLON {
  55519. /** @hidden */
  55520. export var pbrBlockNormalGeometric: {
  55521. name: string;
  55522. shader: string;
  55523. };
  55524. }
  55525. declare module BABYLON {
  55526. /** @hidden */
  55527. export var pbrBlockNormalFinal: {
  55528. name: string;
  55529. shader: string;
  55530. };
  55531. }
  55532. declare module BABYLON {
  55533. /** @hidden */
  55534. export var pbrBlockLightmapInit: {
  55535. name: string;
  55536. shader: string;
  55537. };
  55538. }
  55539. declare module BABYLON {
  55540. /** @hidden */
  55541. export var pbrBlockGeometryInfo: {
  55542. name: string;
  55543. shader: string;
  55544. };
  55545. }
  55546. declare module BABYLON {
  55547. /** @hidden */
  55548. export var pbrBlockReflectance0: {
  55549. name: string;
  55550. shader: string;
  55551. };
  55552. }
  55553. declare module BABYLON {
  55554. /** @hidden */
  55555. export var pbrBlockReflectance: {
  55556. name: string;
  55557. shader: string;
  55558. };
  55559. }
  55560. declare module BABYLON {
  55561. /** @hidden */
  55562. export var pbrBlockDirectLighting: {
  55563. name: string;
  55564. shader: string;
  55565. };
  55566. }
  55567. declare module BABYLON {
  55568. /** @hidden */
  55569. export var pbrBlockFinalLitComponents: {
  55570. name: string;
  55571. shader: string;
  55572. };
  55573. }
  55574. declare module BABYLON {
  55575. /** @hidden */
  55576. export var pbrBlockFinalUnlitComponents: {
  55577. name: string;
  55578. shader: string;
  55579. };
  55580. }
  55581. declare module BABYLON {
  55582. /** @hidden */
  55583. export var pbrBlockFinalColorComposition: {
  55584. name: string;
  55585. shader: string;
  55586. };
  55587. }
  55588. declare module BABYLON {
  55589. /** @hidden */
  55590. export var pbrBlockImageProcessing: {
  55591. name: string;
  55592. shader: string;
  55593. };
  55594. }
  55595. declare module BABYLON {
  55596. /** @hidden */
  55597. export var pbrDebug: {
  55598. name: string;
  55599. shader: string;
  55600. };
  55601. }
  55602. declare module BABYLON {
  55603. /** @hidden */
  55604. export var pbrPixelShader: {
  55605. name: string;
  55606. shader: string;
  55607. };
  55608. }
  55609. declare module BABYLON {
  55610. /** @hidden */
  55611. export var pbrVertexDeclaration: {
  55612. name: string;
  55613. shader: string;
  55614. };
  55615. }
  55616. declare module BABYLON {
  55617. /** @hidden */
  55618. export var pbrVertexShader: {
  55619. name: string;
  55620. shader: string;
  55621. };
  55622. }
  55623. declare module BABYLON {
  55624. /**
  55625. * Manages the defines for the PBR Material.
  55626. * @hidden
  55627. */
  55628. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55629. PBR: boolean;
  55630. NUM_SAMPLES: string;
  55631. REALTIME_FILTERING: boolean;
  55632. MAINUV1: boolean;
  55633. MAINUV2: boolean;
  55634. UV1: boolean;
  55635. UV2: boolean;
  55636. ALBEDO: boolean;
  55637. GAMMAALBEDO: boolean;
  55638. ALBEDODIRECTUV: number;
  55639. VERTEXCOLOR: boolean;
  55640. DETAIL: boolean;
  55641. DETAILDIRECTUV: number;
  55642. DETAIL_NORMALBLENDMETHOD: number;
  55643. AMBIENT: boolean;
  55644. AMBIENTDIRECTUV: number;
  55645. AMBIENTINGRAYSCALE: boolean;
  55646. OPACITY: boolean;
  55647. VERTEXALPHA: boolean;
  55648. OPACITYDIRECTUV: number;
  55649. OPACITYRGB: boolean;
  55650. ALPHATEST: boolean;
  55651. DEPTHPREPASS: boolean;
  55652. ALPHABLEND: boolean;
  55653. ALPHAFROMALBEDO: boolean;
  55654. ALPHATESTVALUE: string;
  55655. SPECULAROVERALPHA: boolean;
  55656. RADIANCEOVERALPHA: boolean;
  55657. ALPHAFRESNEL: boolean;
  55658. LINEARALPHAFRESNEL: boolean;
  55659. PREMULTIPLYALPHA: boolean;
  55660. EMISSIVE: boolean;
  55661. EMISSIVEDIRECTUV: number;
  55662. REFLECTIVITY: boolean;
  55663. REFLECTIVITYDIRECTUV: number;
  55664. SPECULARTERM: boolean;
  55665. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55666. MICROSURFACEAUTOMATIC: boolean;
  55667. LODBASEDMICROSFURACE: boolean;
  55668. MICROSURFACEMAP: boolean;
  55669. MICROSURFACEMAPDIRECTUV: number;
  55670. METALLICWORKFLOW: boolean;
  55671. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55672. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55673. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55674. AOSTOREINMETALMAPRED: boolean;
  55675. METALLIC_REFLECTANCE: boolean;
  55676. METALLIC_REFLECTANCEDIRECTUV: number;
  55677. ENVIRONMENTBRDF: boolean;
  55678. ENVIRONMENTBRDF_RGBD: boolean;
  55679. NORMAL: boolean;
  55680. TANGENT: boolean;
  55681. BUMP: boolean;
  55682. BUMPDIRECTUV: number;
  55683. OBJECTSPACE_NORMALMAP: boolean;
  55684. PARALLAX: boolean;
  55685. PARALLAXOCCLUSION: boolean;
  55686. NORMALXYSCALE: boolean;
  55687. LIGHTMAP: boolean;
  55688. LIGHTMAPDIRECTUV: number;
  55689. USELIGHTMAPASSHADOWMAP: boolean;
  55690. GAMMALIGHTMAP: boolean;
  55691. RGBDLIGHTMAP: boolean;
  55692. REFLECTION: boolean;
  55693. REFLECTIONMAP_3D: boolean;
  55694. REFLECTIONMAP_SPHERICAL: boolean;
  55695. REFLECTIONMAP_PLANAR: boolean;
  55696. REFLECTIONMAP_CUBIC: boolean;
  55697. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55698. REFLECTIONMAP_PROJECTION: boolean;
  55699. REFLECTIONMAP_SKYBOX: boolean;
  55700. REFLECTIONMAP_EXPLICIT: boolean;
  55701. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55702. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55703. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55704. INVERTCUBICMAP: boolean;
  55705. USESPHERICALFROMREFLECTIONMAP: boolean;
  55706. USEIRRADIANCEMAP: boolean;
  55707. SPHERICAL_HARMONICS: boolean;
  55708. USESPHERICALINVERTEX: boolean;
  55709. REFLECTIONMAP_OPPOSITEZ: boolean;
  55710. LODINREFLECTIONALPHA: boolean;
  55711. GAMMAREFLECTION: boolean;
  55712. RGBDREFLECTION: boolean;
  55713. LINEARSPECULARREFLECTION: boolean;
  55714. RADIANCEOCCLUSION: boolean;
  55715. HORIZONOCCLUSION: boolean;
  55716. INSTANCES: boolean;
  55717. THIN_INSTANCES: boolean;
  55718. PREPASS: boolean;
  55719. SCENE_MRT_COUNT: number;
  55720. NUM_BONE_INFLUENCERS: number;
  55721. BonesPerMesh: number;
  55722. BONETEXTURE: boolean;
  55723. NONUNIFORMSCALING: boolean;
  55724. MORPHTARGETS: boolean;
  55725. MORPHTARGETS_NORMAL: boolean;
  55726. MORPHTARGETS_TANGENT: boolean;
  55727. MORPHTARGETS_UV: boolean;
  55728. NUM_MORPH_INFLUENCERS: number;
  55729. IMAGEPROCESSING: boolean;
  55730. VIGNETTE: boolean;
  55731. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55732. VIGNETTEBLENDMODEOPAQUE: boolean;
  55733. TONEMAPPING: boolean;
  55734. TONEMAPPING_ACES: boolean;
  55735. CONTRAST: boolean;
  55736. COLORCURVES: boolean;
  55737. COLORGRADING: boolean;
  55738. COLORGRADING3D: boolean;
  55739. SAMPLER3DGREENDEPTH: boolean;
  55740. SAMPLER3DBGRMAP: boolean;
  55741. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55742. EXPOSURE: boolean;
  55743. MULTIVIEW: boolean;
  55744. USEPHYSICALLIGHTFALLOFF: boolean;
  55745. USEGLTFLIGHTFALLOFF: boolean;
  55746. TWOSIDEDLIGHTING: boolean;
  55747. SHADOWFLOAT: boolean;
  55748. CLIPPLANE: boolean;
  55749. CLIPPLANE2: boolean;
  55750. CLIPPLANE3: boolean;
  55751. CLIPPLANE4: boolean;
  55752. CLIPPLANE5: boolean;
  55753. CLIPPLANE6: boolean;
  55754. POINTSIZE: boolean;
  55755. FOG: boolean;
  55756. LOGARITHMICDEPTH: boolean;
  55757. FORCENORMALFORWARD: boolean;
  55758. SPECULARAA: boolean;
  55759. CLEARCOAT: boolean;
  55760. CLEARCOAT_DEFAULTIOR: boolean;
  55761. CLEARCOAT_TEXTURE: boolean;
  55762. CLEARCOAT_TEXTUREDIRECTUV: number;
  55763. CLEARCOAT_BUMP: boolean;
  55764. CLEARCOAT_BUMPDIRECTUV: number;
  55765. CLEARCOAT_TINT: boolean;
  55766. CLEARCOAT_TINT_TEXTURE: boolean;
  55767. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55768. ANISOTROPIC: boolean;
  55769. ANISOTROPIC_TEXTURE: boolean;
  55770. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55771. BRDF_V_HEIGHT_CORRELATED: boolean;
  55772. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55773. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55774. SHEEN: boolean;
  55775. SHEEN_TEXTURE: boolean;
  55776. SHEEN_TEXTUREDIRECTUV: number;
  55777. SHEEN_LINKWITHALBEDO: boolean;
  55778. SHEEN_ROUGHNESS: boolean;
  55779. SHEEN_ALBEDOSCALING: boolean;
  55780. SUBSURFACE: boolean;
  55781. SS_REFRACTION: boolean;
  55782. SS_TRANSLUCENCY: boolean;
  55783. SS_SCATTERING: boolean;
  55784. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55785. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55786. SS_REFRACTIONMAP_3D: boolean;
  55787. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55788. SS_LODINREFRACTIONALPHA: boolean;
  55789. SS_GAMMAREFRACTION: boolean;
  55790. SS_RGBDREFRACTION: boolean;
  55791. SS_LINEARSPECULARREFRACTION: boolean;
  55792. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55793. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55794. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55795. UNLIT: boolean;
  55796. DEBUGMODE: number;
  55797. /**
  55798. * Initializes the PBR Material defines.
  55799. */
  55800. constructor();
  55801. /**
  55802. * Resets the PBR Material defines.
  55803. */
  55804. reset(): void;
  55805. }
  55806. /**
  55807. * The Physically based material base class of BJS.
  55808. *
  55809. * This offers the main features of a standard PBR material.
  55810. * For more information, please refer to the documentation :
  55811. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55812. */
  55813. export abstract class PBRBaseMaterial extends PushMaterial {
  55814. /**
  55815. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55816. */
  55817. static readonly PBRMATERIAL_OPAQUE: number;
  55818. /**
  55819. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55820. */
  55821. static readonly PBRMATERIAL_ALPHATEST: number;
  55822. /**
  55823. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55824. */
  55825. static readonly PBRMATERIAL_ALPHABLEND: number;
  55826. /**
  55827. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55828. * They are also discarded below the alpha cutoff threshold to improve performances.
  55829. */
  55830. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55831. /**
  55832. * Defines the default value of how much AO map is occluding the analytical lights
  55833. * (point spot...).
  55834. */
  55835. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55836. /**
  55837. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55838. */
  55839. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55840. /**
  55841. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55842. * to enhance interoperability with other engines.
  55843. */
  55844. static readonly LIGHTFALLOFF_GLTF: number;
  55845. /**
  55846. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55847. * to enhance interoperability with other materials.
  55848. */
  55849. static readonly LIGHTFALLOFF_STANDARD: number;
  55850. /**
  55851. * Intensity of the direct lights e.g. the four lights available in your scene.
  55852. * This impacts both the direct diffuse and specular highlights.
  55853. */
  55854. protected _directIntensity: number;
  55855. /**
  55856. * Intensity of the emissive part of the material.
  55857. * This helps controlling the emissive effect without modifying the emissive color.
  55858. */
  55859. protected _emissiveIntensity: number;
  55860. /**
  55861. * Intensity of the environment e.g. how much the environment will light the object
  55862. * either through harmonics for rough material or through the refelction for shiny ones.
  55863. */
  55864. protected _environmentIntensity: number;
  55865. /**
  55866. * This is a special control allowing the reduction of the specular highlights coming from the
  55867. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55868. */
  55869. protected _specularIntensity: number;
  55870. /**
  55871. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55872. */
  55873. private _lightingInfos;
  55874. /**
  55875. * Debug Control allowing disabling the bump map on this material.
  55876. */
  55877. protected _disableBumpMap: boolean;
  55878. /**
  55879. * AKA Diffuse Texture in standard nomenclature.
  55880. */
  55881. protected _albedoTexture: Nullable<BaseTexture>;
  55882. /**
  55883. * AKA Occlusion Texture in other nomenclature.
  55884. */
  55885. protected _ambientTexture: Nullable<BaseTexture>;
  55886. /**
  55887. * AKA Occlusion Texture Intensity in other nomenclature.
  55888. */
  55889. protected _ambientTextureStrength: number;
  55890. /**
  55891. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55892. * 1 means it completely occludes it
  55893. * 0 mean it has no impact
  55894. */
  55895. protected _ambientTextureImpactOnAnalyticalLights: number;
  55896. /**
  55897. * Stores the alpha values in a texture.
  55898. */
  55899. protected _opacityTexture: Nullable<BaseTexture>;
  55900. /**
  55901. * Stores the reflection values in a texture.
  55902. */
  55903. protected _reflectionTexture: Nullable<BaseTexture>;
  55904. /**
  55905. * Stores the emissive values in a texture.
  55906. */
  55907. protected _emissiveTexture: Nullable<BaseTexture>;
  55908. /**
  55909. * AKA Specular texture in other nomenclature.
  55910. */
  55911. protected _reflectivityTexture: Nullable<BaseTexture>;
  55912. /**
  55913. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55914. */
  55915. protected _metallicTexture: Nullable<BaseTexture>;
  55916. /**
  55917. * Specifies the metallic scalar of the metallic/roughness workflow.
  55918. * Can also be used to scale the metalness values of the metallic texture.
  55919. */
  55920. protected _metallic: Nullable<number>;
  55921. /**
  55922. * Specifies the roughness scalar of the metallic/roughness workflow.
  55923. * Can also be used to scale the roughness values of the metallic texture.
  55924. */
  55925. protected _roughness: Nullable<number>;
  55926. /**
  55927. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55928. * By default the indexOfrefraction is used to compute F0;
  55929. *
  55930. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55931. *
  55932. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55933. * F90 = metallicReflectanceColor;
  55934. */
  55935. protected _metallicF0Factor: number;
  55936. /**
  55937. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55938. * By default the F90 is always 1;
  55939. *
  55940. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55941. *
  55942. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55943. * F90 = metallicReflectanceColor;
  55944. */
  55945. protected _metallicReflectanceColor: Color3;
  55946. /**
  55947. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55948. * This is multiply against the scalar values defined in the material.
  55949. */
  55950. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55951. /**
  55952. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55953. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55954. */
  55955. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55956. /**
  55957. * Stores surface normal data used to displace a mesh in a texture.
  55958. */
  55959. protected _bumpTexture: Nullable<BaseTexture>;
  55960. /**
  55961. * Stores the pre-calculated light information of a mesh in a texture.
  55962. */
  55963. protected _lightmapTexture: Nullable<BaseTexture>;
  55964. /**
  55965. * The color of a material in ambient lighting.
  55966. */
  55967. protected _ambientColor: Color3;
  55968. /**
  55969. * AKA Diffuse Color in other nomenclature.
  55970. */
  55971. protected _albedoColor: Color3;
  55972. /**
  55973. * AKA Specular Color in other nomenclature.
  55974. */
  55975. protected _reflectivityColor: Color3;
  55976. /**
  55977. * The color applied when light is reflected from a material.
  55978. */
  55979. protected _reflectionColor: Color3;
  55980. /**
  55981. * The color applied when light is emitted from a material.
  55982. */
  55983. protected _emissiveColor: Color3;
  55984. /**
  55985. * AKA Glossiness in other nomenclature.
  55986. */
  55987. protected _microSurface: number;
  55988. /**
  55989. * Specifies that the material will use the light map as a show map.
  55990. */
  55991. protected _useLightmapAsShadowmap: boolean;
  55992. /**
  55993. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55994. * makes the reflect vector face the model (under horizon).
  55995. */
  55996. protected _useHorizonOcclusion: boolean;
  55997. /**
  55998. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55999. * too much the area relying on ambient texture to define their ambient occlusion.
  56000. */
  56001. protected _useRadianceOcclusion: boolean;
  56002. /**
  56003. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56004. */
  56005. protected _useAlphaFromAlbedoTexture: boolean;
  56006. /**
  56007. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56008. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56009. */
  56010. protected _useSpecularOverAlpha: boolean;
  56011. /**
  56012. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56013. */
  56014. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56015. /**
  56016. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56017. */
  56018. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56019. /**
  56020. * Specifies if the metallic texture contains the roughness information in its green channel.
  56021. */
  56022. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56023. /**
  56024. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56025. */
  56026. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56027. /**
  56028. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56029. */
  56030. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56031. /**
  56032. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56033. */
  56034. protected _useAmbientInGrayScale: boolean;
  56035. /**
  56036. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56037. * The material will try to infer what glossiness each pixel should be.
  56038. */
  56039. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56040. /**
  56041. * Defines the falloff type used in this material.
  56042. * It by default is Physical.
  56043. */
  56044. protected _lightFalloff: number;
  56045. /**
  56046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56048. */
  56049. protected _useRadianceOverAlpha: boolean;
  56050. /**
  56051. * Allows using an object space normal map (instead of tangent space).
  56052. */
  56053. protected _useObjectSpaceNormalMap: boolean;
  56054. /**
  56055. * Allows using the bump map in parallax mode.
  56056. */
  56057. protected _useParallax: boolean;
  56058. /**
  56059. * Allows using the bump map in parallax occlusion mode.
  56060. */
  56061. protected _useParallaxOcclusion: boolean;
  56062. /**
  56063. * Controls the scale bias of the parallax mode.
  56064. */
  56065. protected _parallaxScaleBias: number;
  56066. /**
  56067. * If sets to true, disables all the lights affecting the material.
  56068. */
  56069. protected _disableLighting: boolean;
  56070. /**
  56071. * Number of Simultaneous lights allowed on the material.
  56072. */
  56073. protected _maxSimultaneousLights: number;
  56074. /**
  56075. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56076. */
  56077. protected _invertNormalMapX: boolean;
  56078. /**
  56079. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56080. */
  56081. protected _invertNormalMapY: boolean;
  56082. /**
  56083. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56084. */
  56085. protected _twoSidedLighting: boolean;
  56086. /**
  56087. * Defines the alpha limits in alpha test mode.
  56088. */
  56089. protected _alphaCutOff: number;
  56090. /**
  56091. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56092. */
  56093. protected _forceAlphaTest: boolean;
  56094. /**
  56095. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56096. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56097. */
  56098. protected _useAlphaFresnel: boolean;
  56099. /**
  56100. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56101. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56102. */
  56103. protected _useLinearAlphaFresnel: boolean;
  56104. /**
  56105. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56106. * from cos thetav and roughness:
  56107. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56108. */
  56109. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56110. /**
  56111. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56112. */
  56113. protected _forceIrradianceInFragment: boolean;
  56114. private _realTimeFiltering;
  56115. /**
  56116. * Enables realtime filtering on the texture.
  56117. */
  56118. get realTimeFiltering(): boolean;
  56119. set realTimeFiltering(b: boolean);
  56120. private _realTimeFilteringQuality;
  56121. /**
  56122. * Quality switch for realtime filtering
  56123. */
  56124. get realTimeFilteringQuality(): number;
  56125. set realTimeFilteringQuality(n: number);
  56126. /**
  56127. * Can this material render to several textures at once
  56128. */
  56129. get canRenderToMRT(): boolean;
  56130. /**
  56131. * Force normal to face away from face.
  56132. */
  56133. protected _forceNormalForward: boolean;
  56134. /**
  56135. * Enables specular anti aliasing in the PBR shader.
  56136. * It will both interacts on the Geometry for analytical and IBL lighting.
  56137. * It also prefilter the roughness map based on the bump values.
  56138. */
  56139. protected _enableSpecularAntiAliasing: boolean;
  56140. /**
  56141. * Default configuration related to image processing available in the PBR Material.
  56142. */
  56143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56144. /**
  56145. * Keep track of the image processing observer to allow dispose and replace.
  56146. */
  56147. private _imageProcessingObserver;
  56148. /**
  56149. * Attaches a new image processing configuration to the PBR Material.
  56150. * @param configuration
  56151. */
  56152. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56153. /**
  56154. * Stores the available render targets.
  56155. */
  56156. private _renderTargets;
  56157. /**
  56158. * Sets the global ambient color for the material used in lighting calculations.
  56159. */
  56160. private _globalAmbientColor;
  56161. /**
  56162. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56163. */
  56164. private _useLogarithmicDepth;
  56165. /**
  56166. * If set to true, no lighting calculations will be applied.
  56167. */
  56168. private _unlit;
  56169. private _debugMode;
  56170. /**
  56171. * @hidden
  56172. * This is reserved for the inspector.
  56173. * Defines the material debug mode.
  56174. * It helps seeing only some components of the material while troubleshooting.
  56175. */
  56176. debugMode: number;
  56177. /**
  56178. * @hidden
  56179. * This is reserved for the inspector.
  56180. * Specify from where on screen the debug mode should start.
  56181. * The value goes from -1 (full screen) to 1 (not visible)
  56182. * It helps with side by side comparison against the final render
  56183. * This defaults to -1
  56184. */
  56185. private debugLimit;
  56186. /**
  56187. * @hidden
  56188. * This is reserved for the inspector.
  56189. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56190. * You can use the factor to better multiply the final value.
  56191. */
  56192. private debugFactor;
  56193. /**
  56194. * Defines the clear coat layer parameters for the material.
  56195. */
  56196. readonly clearCoat: PBRClearCoatConfiguration;
  56197. /**
  56198. * Defines the anisotropic parameters for the material.
  56199. */
  56200. readonly anisotropy: PBRAnisotropicConfiguration;
  56201. /**
  56202. * Defines the BRDF parameters for the material.
  56203. */
  56204. readonly brdf: PBRBRDFConfiguration;
  56205. /**
  56206. * Defines the Sheen parameters for the material.
  56207. */
  56208. readonly sheen: PBRSheenConfiguration;
  56209. /**
  56210. * Defines the SubSurface parameters for the material.
  56211. */
  56212. readonly subSurface: PBRSubSurfaceConfiguration;
  56213. /**
  56214. * Defines the detail map parameters for the material.
  56215. */
  56216. readonly detailMap: DetailMapConfiguration;
  56217. protected _rebuildInParallel: boolean;
  56218. /**
  56219. * Instantiates a new PBRMaterial instance.
  56220. *
  56221. * @param name The material name
  56222. * @param scene The scene the material will be use in.
  56223. */
  56224. constructor(name: string, scene: Scene);
  56225. /**
  56226. * Gets a boolean indicating that current material needs to register RTT
  56227. */
  56228. get hasRenderTargetTextures(): boolean;
  56229. /**
  56230. * Gets the name of the material class.
  56231. */
  56232. getClassName(): string;
  56233. /**
  56234. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56235. */
  56236. get useLogarithmicDepth(): boolean;
  56237. /**
  56238. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56239. */
  56240. set useLogarithmicDepth(value: boolean);
  56241. /**
  56242. * Returns true if alpha blending should be disabled.
  56243. */
  56244. protected get _disableAlphaBlending(): boolean;
  56245. /**
  56246. * Specifies whether or not this material should be rendered in alpha blend mode.
  56247. */
  56248. needAlphaBlending(): boolean;
  56249. /**
  56250. * Specifies whether or not this material should be rendered in alpha test mode.
  56251. */
  56252. needAlphaTesting(): boolean;
  56253. /**
  56254. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56255. */
  56256. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56257. /**
  56258. * Gets the texture used for the alpha test.
  56259. */
  56260. getAlphaTestTexture(): Nullable<BaseTexture>;
  56261. /**
  56262. * Specifies that the submesh is ready to be used.
  56263. * @param mesh - BJS mesh.
  56264. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56265. * @param useInstances - Specifies that instances should be used.
  56266. * @returns - boolean indicating that the submesh is ready or not.
  56267. */
  56268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56269. /**
  56270. * Specifies if the material uses metallic roughness workflow.
  56271. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56272. */
  56273. isMetallicWorkflow(): boolean;
  56274. private _prepareEffect;
  56275. private _prepareDefines;
  56276. /**
  56277. * Force shader compilation
  56278. */
  56279. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56280. /**
  56281. * Initializes the uniform buffer layout for the shader.
  56282. */
  56283. buildUniformLayout(): void;
  56284. /**
  56285. * Unbinds the material from the mesh
  56286. */
  56287. unbind(): void;
  56288. /**
  56289. * Binds the submesh data.
  56290. * @param world - The world matrix.
  56291. * @param mesh - The BJS mesh.
  56292. * @param subMesh - A submesh of the BJS mesh.
  56293. */
  56294. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56295. /**
  56296. * Returns the animatable textures.
  56297. * @returns - Array of animatable textures.
  56298. */
  56299. getAnimatables(): IAnimatable[];
  56300. /**
  56301. * Returns the texture used for reflections.
  56302. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56303. */
  56304. private _getReflectionTexture;
  56305. /**
  56306. * Returns an array of the actively used textures.
  56307. * @returns - Array of BaseTextures
  56308. */
  56309. getActiveTextures(): BaseTexture[];
  56310. /**
  56311. * Checks to see if a texture is used in the material.
  56312. * @param texture - Base texture to use.
  56313. * @returns - Boolean specifying if a texture is used in the material.
  56314. */
  56315. hasTexture(texture: BaseTexture): boolean;
  56316. /**
  56317. * Sets the required values to the prepass renderer.
  56318. * @param prePassRenderer defines the prepass renderer to setup
  56319. */
  56320. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56321. /**
  56322. * Disposes the resources of the material.
  56323. * @param forceDisposeEffect - Forces the disposal of effects.
  56324. * @param forceDisposeTextures - Forces the disposal of all textures.
  56325. */
  56326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56327. }
  56328. }
  56329. declare module BABYLON {
  56330. /**
  56331. * The Physically based material of BJS.
  56332. *
  56333. * This offers the main features of a standard PBR material.
  56334. * For more information, please refer to the documentation :
  56335. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56336. */
  56337. export class PBRMaterial extends PBRBaseMaterial {
  56338. /**
  56339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56340. */
  56341. static readonly PBRMATERIAL_OPAQUE: number;
  56342. /**
  56343. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56344. */
  56345. static readonly PBRMATERIAL_ALPHATEST: number;
  56346. /**
  56347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56348. */
  56349. static readonly PBRMATERIAL_ALPHABLEND: number;
  56350. /**
  56351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56352. * They are also discarded below the alpha cutoff threshold to improve performances.
  56353. */
  56354. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56355. /**
  56356. * Defines the default value of how much AO map is occluding the analytical lights
  56357. * (point spot...).
  56358. */
  56359. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56360. /**
  56361. * Intensity of the direct lights e.g. the four lights available in your scene.
  56362. * This impacts both the direct diffuse and specular highlights.
  56363. */
  56364. directIntensity: number;
  56365. /**
  56366. * Intensity of the emissive part of the material.
  56367. * This helps controlling the emissive effect without modifying the emissive color.
  56368. */
  56369. emissiveIntensity: number;
  56370. /**
  56371. * Intensity of the environment e.g. how much the environment will light the object
  56372. * either through harmonics for rough material or through the refelction for shiny ones.
  56373. */
  56374. environmentIntensity: number;
  56375. /**
  56376. * This is a special control allowing the reduction of the specular highlights coming from the
  56377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56378. */
  56379. specularIntensity: number;
  56380. /**
  56381. * Debug Control allowing disabling the bump map on this material.
  56382. */
  56383. disableBumpMap: boolean;
  56384. /**
  56385. * AKA Diffuse Texture in standard nomenclature.
  56386. */
  56387. albedoTexture: BaseTexture;
  56388. /**
  56389. * AKA Occlusion Texture in other nomenclature.
  56390. */
  56391. ambientTexture: BaseTexture;
  56392. /**
  56393. * AKA Occlusion Texture Intensity in other nomenclature.
  56394. */
  56395. ambientTextureStrength: number;
  56396. /**
  56397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56398. * 1 means it completely occludes it
  56399. * 0 mean it has no impact
  56400. */
  56401. ambientTextureImpactOnAnalyticalLights: number;
  56402. /**
  56403. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56404. */
  56405. opacityTexture: BaseTexture;
  56406. /**
  56407. * Stores the reflection values in a texture.
  56408. */
  56409. reflectionTexture: Nullable<BaseTexture>;
  56410. /**
  56411. * Stores the emissive values in a texture.
  56412. */
  56413. emissiveTexture: BaseTexture;
  56414. /**
  56415. * AKA Specular texture in other nomenclature.
  56416. */
  56417. reflectivityTexture: BaseTexture;
  56418. /**
  56419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56420. */
  56421. metallicTexture: BaseTexture;
  56422. /**
  56423. * Specifies the metallic scalar of the metallic/roughness workflow.
  56424. * Can also be used to scale the metalness values of the metallic texture.
  56425. */
  56426. metallic: Nullable<number>;
  56427. /**
  56428. * Specifies the roughness scalar of the metallic/roughness workflow.
  56429. * Can also be used to scale the roughness values of the metallic texture.
  56430. */
  56431. roughness: Nullable<number>;
  56432. /**
  56433. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56434. * By default the indexOfrefraction is used to compute F0;
  56435. *
  56436. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56437. *
  56438. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56439. * F90 = metallicReflectanceColor;
  56440. */
  56441. metallicF0Factor: number;
  56442. /**
  56443. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56444. * By default the F90 is always 1;
  56445. *
  56446. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56447. *
  56448. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56449. * F90 = metallicReflectanceColor;
  56450. */
  56451. metallicReflectanceColor: Color3;
  56452. /**
  56453. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56454. * This is multiply against the scalar values defined in the material.
  56455. */
  56456. metallicReflectanceTexture: Nullable<BaseTexture>;
  56457. /**
  56458. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56459. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56460. */
  56461. microSurfaceTexture: BaseTexture;
  56462. /**
  56463. * Stores surface normal data used to displace a mesh in a texture.
  56464. */
  56465. bumpTexture: BaseTexture;
  56466. /**
  56467. * Stores the pre-calculated light information of a mesh in a texture.
  56468. */
  56469. lightmapTexture: BaseTexture;
  56470. /**
  56471. * Stores the refracted light information in a texture.
  56472. */
  56473. get refractionTexture(): Nullable<BaseTexture>;
  56474. set refractionTexture(value: Nullable<BaseTexture>);
  56475. /**
  56476. * The color of a material in ambient lighting.
  56477. */
  56478. ambientColor: Color3;
  56479. /**
  56480. * AKA Diffuse Color in other nomenclature.
  56481. */
  56482. albedoColor: Color3;
  56483. /**
  56484. * AKA Specular Color in other nomenclature.
  56485. */
  56486. reflectivityColor: Color3;
  56487. /**
  56488. * The color reflected from the material.
  56489. */
  56490. reflectionColor: Color3;
  56491. /**
  56492. * The color emitted from the material.
  56493. */
  56494. emissiveColor: Color3;
  56495. /**
  56496. * AKA Glossiness in other nomenclature.
  56497. */
  56498. microSurface: number;
  56499. /**
  56500. * Index of refraction of the material base layer.
  56501. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56502. *
  56503. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56504. *
  56505. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56506. */
  56507. get indexOfRefraction(): number;
  56508. set indexOfRefraction(value: number);
  56509. /**
  56510. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56511. */
  56512. get invertRefractionY(): boolean;
  56513. set invertRefractionY(value: boolean);
  56514. /**
  56515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56516. * Materials half opaque for instance using refraction could benefit from this control.
  56517. */
  56518. get linkRefractionWithTransparency(): boolean;
  56519. set linkRefractionWithTransparency(value: boolean);
  56520. /**
  56521. * If true, the light map contains occlusion information instead of lighting info.
  56522. */
  56523. useLightmapAsShadowmap: boolean;
  56524. /**
  56525. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56526. */
  56527. useAlphaFromAlbedoTexture: boolean;
  56528. /**
  56529. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56530. */
  56531. forceAlphaTest: boolean;
  56532. /**
  56533. * Defines the alpha limits in alpha test mode.
  56534. */
  56535. alphaCutOff: number;
  56536. /**
  56537. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56538. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56539. */
  56540. useSpecularOverAlpha: boolean;
  56541. /**
  56542. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56543. */
  56544. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56545. /**
  56546. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56547. */
  56548. useRoughnessFromMetallicTextureAlpha: boolean;
  56549. /**
  56550. * Specifies if the metallic texture contains the roughness information in its green channel.
  56551. */
  56552. useRoughnessFromMetallicTextureGreen: boolean;
  56553. /**
  56554. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56555. */
  56556. useMetallnessFromMetallicTextureBlue: boolean;
  56557. /**
  56558. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56559. */
  56560. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56561. /**
  56562. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56563. */
  56564. useAmbientInGrayScale: boolean;
  56565. /**
  56566. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56567. * The material will try to infer what glossiness each pixel should be.
  56568. */
  56569. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56570. /**
  56571. * BJS is using an harcoded light falloff based on a manually sets up range.
  56572. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56573. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56574. */
  56575. get usePhysicalLightFalloff(): boolean;
  56576. /**
  56577. * BJS is using an harcoded light falloff based on a manually sets up range.
  56578. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56579. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56580. */
  56581. set usePhysicalLightFalloff(value: boolean);
  56582. /**
  56583. * In order to support the falloff compatibility with gltf, a special mode has been added
  56584. * to reproduce the gltf light falloff.
  56585. */
  56586. get useGLTFLightFalloff(): boolean;
  56587. /**
  56588. * In order to support the falloff compatibility with gltf, a special mode has been added
  56589. * to reproduce the gltf light falloff.
  56590. */
  56591. set useGLTFLightFalloff(value: boolean);
  56592. /**
  56593. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56594. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56595. */
  56596. useRadianceOverAlpha: boolean;
  56597. /**
  56598. * Allows using an object space normal map (instead of tangent space).
  56599. */
  56600. useObjectSpaceNormalMap: boolean;
  56601. /**
  56602. * Allows using the bump map in parallax mode.
  56603. */
  56604. useParallax: boolean;
  56605. /**
  56606. * Allows using the bump map in parallax occlusion mode.
  56607. */
  56608. useParallaxOcclusion: boolean;
  56609. /**
  56610. * Controls the scale bias of the parallax mode.
  56611. */
  56612. parallaxScaleBias: number;
  56613. /**
  56614. * If sets to true, disables all the lights affecting the material.
  56615. */
  56616. disableLighting: boolean;
  56617. /**
  56618. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56619. */
  56620. forceIrradianceInFragment: boolean;
  56621. /**
  56622. * Number of Simultaneous lights allowed on the material.
  56623. */
  56624. maxSimultaneousLights: number;
  56625. /**
  56626. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56627. */
  56628. invertNormalMapX: boolean;
  56629. /**
  56630. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56631. */
  56632. invertNormalMapY: boolean;
  56633. /**
  56634. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56635. */
  56636. twoSidedLighting: boolean;
  56637. /**
  56638. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56639. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56640. */
  56641. useAlphaFresnel: boolean;
  56642. /**
  56643. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56644. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56645. */
  56646. useLinearAlphaFresnel: boolean;
  56647. /**
  56648. * Let user defines the brdf lookup texture used for IBL.
  56649. * A default 8bit version is embedded but you could point at :
  56650. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56651. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56652. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56653. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56654. */
  56655. environmentBRDFTexture: Nullable<BaseTexture>;
  56656. /**
  56657. * Force normal to face away from face.
  56658. */
  56659. forceNormalForward: boolean;
  56660. /**
  56661. * Enables specular anti aliasing in the PBR shader.
  56662. * It will both interacts on the Geometry for analytical and IBL lighting.
  56663. * It also prefilter the roughness map based on the bump values.
  56664. */
  56665. enableSpecularAntiAliasing: boolean;
  56666. /**
  56667. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56668. * makes the reflect vector face the model (under horizon).
  56669. */
  56670. useHorizonOcclusion: boolean;
  56671. /**
  56672. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56673. * too much the area relying on ambient texture to define their ambient occlusion.
  56674. */
  56675. useRadianceOcclusion: boolean;
  56676. /**
  56677. * If set to true, no lighting calculations will be applied.
  56678. */
  56679. unlit: boolean;
  56680. /**
  56681. * Gets the image processing configuration used either in this material.
  56682. */
  56683. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56684. /**
  56685. * Sets the Default image processing configuration used either in the this material.
  56686. *
  56687. * If sets to null, the scene one is in use.
  56688. */
  56689. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56690. /**
  56691. * Gets wether the color curves effect is enabled.
  56692. */
  56693. get cameraColorCurvesEnabled(): boolean;
  56694. /**
  56695. * Sets wether the color curves effect is enabled.
  56696. */
  56697. set cameraColorCurvesEnabled(value: boolean);
  56698. /**
  56699. * Gets wether the color grading effect is enabled.
  56700. */
  56701. get cameraColorGradingEnabled(): boolean;
  56702. /**
  56703. * Gets wether the color grading effect is enabled.
  56704. */
  56705. set cameraColorGradingEnabled(value: boolean);
  56706. /**
  56707. * Gets wether tonemapping is enabled or not.
  56708. */
  56709. get cameraToneMappingEnabled(): boolean;
  56710. /**
  56711. * Sets wether tonemapping is enabled or not
  56712. */
  56713. set cameraToneMappingEnabled(value: boolean);
  56714. /**
  56715. * The camera exposure used on this material.
  56716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56717. * This corresponds to a photographic exposure.
  56718. */
  56719. get cameraExposure(): number;
  56720. /**
  56721. * The camera exposure used on this material.
  56722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56723. * This corresponds to a photographic exposure.
  56724. */
  56725. set cameraExposure(value: number);
  56726. /**
  56727. * Gets The camera contrast used on this material.
  56728. */
  56729. get cameraContrast(): number;
  56730. /**
  56731. * Sets The camera contrast used on this material.
  56732. */
  56733. set cameraContrast(value: number);
  56734. /**
  56735. * Gets the Color Grading 2D Lookup Texture.
  56736. */
  56737. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56738. /**
  56739. * Sets the Color Grading 2D Lookup Texture.
  56740. */
  56741. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56742. /**
  56743. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56744. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56745. * 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;
  56746. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56747. */
  56748. get cameraColorCurves(): Nullable<ColorCurves>;
  56749. /**
  56750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56752. * 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;
  56753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56754. */
  56755. set cameraColorCurves(value: Nullable<ColorCurves>);
  56756. /**
  56757. * Instantiates a new PBRMaterial instance.
  56758. *
  56759. * @param name The material name
  56760. * @param scene The scene the material will be use in.
  56761. */
  56762. constructor(name: string, scene: Scene);
  56763. /**
  56764. * Returns the name of this material class.
  56765. */
  56766. getClassName(): string;
  56767. /**
  56768. * Makes a duplicate of the current material.
  56769. * @param name - name to use for the new material.
  56770. */
  56771. clone(name: string): PBRMaterial;
  56772. /**
  56773. * Serializes this PBR Material.
  56774. * @returns - An object with the serialized material.
  56775. */
  56776. serialize(): any;
  56777. /**
  56778. * Parses a PBR Material from a serialized object.
  56779. * @param source - Serialized object.
  56780. * @param scene - BJS scene instance.
  56781. * @param rootUrl - url for the scene object
  56782. * @returns - PBRMaterial
  56783. */
  56784. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56785. }
  56786. }
  56787. declare module BABYLON {
  56788. /**
  56789. * Direct draw surface info
  56790. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56791. */
  56792. export interface DDSInfo {
  56793. /**
  56794. * Width of the texture
  56795. */
  56796. width: number;
  56797. /**
  56798. * Width of the texture
  56799. */
  56800. height: number;
  56801. /**
  56802. * Number of Mipmaps for the texture
  56803. * @see https://en.wikipedia.org/wiki/Mipmap
  56804. */
  56805. mipmapCount: number;
  56806. /**
  56807. * If the textures format is a known fourCC format
  56808. * @see https://www.fourcc.org/
  56809. */
  56810. isFourCC: boolean;
  56811. /**
  56812. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56813. */
  56814. isRGB: boolean;
  56815. /**
  56816. * If the texture is a lumincance format
  56817. */
  56818. isLuminance: boolean;
  56819. /**
  56820. * If this is a cube texture
  56821. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56822. */
  56823. isCube: boolean;
  56824. /**
  56825. * If the texture is a compressed format eg. FOURCC_DXT1
  56826. */
  56827. isCompressed: boolean;
  56828. /**
  56829. * The dxgiFormat of the texture
  56830. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56831. */
  56832. dxgiFormat: number;
  56833. /**
  56834. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56835. */
  56836. textureType: number;
  56837. /**
  56838. * Sphericle polynomial created for the dds texture
  56839. */
  56840. sphericalPolynomial?: SphericalPolynomial;
  56841. }
  56842. /**
  56843. * Class used to provide DDS decompression tools
  56844. */
  56845. export class DDSTools {
  56846. /**
  56847. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56848. */
  56849. static StoreLODInAlphaChannel: boolean;
  56850. /**
  56851. * Gets DDS information from an array buffer
  56852. * @param data defines the array buffer view to read data from
  56853. * @returns the DDS information
  56854. */
  56855. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56856. private static _FloatView;
  56857. private static _Int32View;
  56858. private static _ToHalfFloat;
  56859. private static _FromHalfFloat;
  56860. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56861. private static _GetHalfFloatRGBAArrayBuffer;
  56862. private static _GetFloatRGBAArrayBuffer;
  56863. private static _GetFloatAsUIntRGBAArrayBuffer;
  56864. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56865. private static _GetRGBAArrayBuffer;
  56866. private static _ExtractLongWordOrder;
  56867. private static _GetRGBArrayBuffer;
  56868. private static _GetLuminanceArrayBuffer;
  56869. /**
  56870. * Uploads DDS Levels to a Babylon Texture
  56871. * @hidden
  56872. */
  56873. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56874. }
  56875. interface ThinEngine {
  56876. /**
  56877. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56878. * @param rootUrl defines the url where the file to load is located
  56879. * @param scene defines the current scene
  56880. * @param lodScale defines scale to apply to the mip map selection
  56881. * @param lodOffset defines offset to apply to the mip map selection
  56882. * @param onLoad defines an optional callback raised when the texture is loaded
  56883. * @param onError defines an optional callback raised if there is an issue to load the texture
  56884. * @param format defines the format of the data
  56885. * @param forcedExtension defines the extension to use to pick the right loader
  56886. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56887. * @returns the cube texture as an InternalTexture
  56888. */
  56889. 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;
  56890. }
  56891. }
  56892. declare module BABYLON {
  56893. /**
  56894. * Implementation of the DDS Texture Loader.
  56895. * @hidden
  56896. */
  56897. export class _DDSTextureLoader implements IInternalTextureLoader {
  56898. /**
  56899. * Defines wether the loader supports cascade loading the different faces.
  56900. */
  56901. readonly supportCascades: boolean;
  56902. /**
  56903. * This returns if the loader support the current file information.
  56904. * @param extension defines the file extension of the file being loaded
  56905. * @returns true if the loader can load the specified file
  56906. */
  56907. canLoad(extension: string): boolean;
  56908. /**
  56909. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56910. * @param data contains the texture data
  56911. * @param texture defines the BabylonJS internal texture
  56912. * @param createPolynomials will be true if polynomials have been requested
  56913. * @param onLoad defines the callback to trigger once the texture is ready
  56914. * @param onError defines the callback to trigger in case of error
  56915. */
  56916. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56917. /**
  56918. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56919. * @param data contains the texture data
  56920. * @param texture defines the BabylonJS internal texture
  56921. * @param callback defines the method to call once ready to upload
  56922. */
  56923. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Implementation of the ENV Texture Loader.
  56929. * @hidden
  56930. */
  56931. export class _ENVTextureLoader implements IInternalTextureLoader {
  56932. /**
  56933. * Defines wether the loader supports cascade loading the different faces.
  56934. */
  56935. readonly supportCascades: boolean;
  56936. /**
  56937. * This returns if the loader support the current file information.
  56938. * @param extension defines the file extension of the file being loaded
  56939. * @returns true if the loader can load the specified file
  56940. */
  56941. canLoad(extension: string): boolean;
  56942. /**
  56943. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56944. * @param data contains the texture data
  56945. * @param texture defines the BabylonJS internal texture
  56946. * @param createPolynomials will be true if polynomials have been requested
  56947. * @param onLoad defines the callback to trigger once the texture is ready
  56948. * @param onError defines the callback to trigger in case of error
  56949. */
  56950. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56951. /**
  56952. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56953. * @param data contains the texture data
  56954. * @param texture defines the BabylonJS internal texture
  56955. * @param callback defines the method to call once ready to upload
  56956. */
  56957. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56958. }
  56959. }
  56960. declare module BABYLON {
  56961. /**
  56962. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56963. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56964. */
  56965. export class KhronosTextureContainer {
  56966. /** contents of the KTX container file */
  56967. data: ArrayBufferView;
  56968. private static HEADER_LEN;
  56969. private static COMPRESSED_2D;
  56970. private static COMPRESSED_3D;
  56971. private static TEX_2D;
  56972. private static TEX_3D;
  56973. /**
  56974. * Gets the openGL type
  56975. */
  56976. glType: number;
  56977. /**
  56978. * Gets the openGL type size
  56979. */
  56980. glTypeSize: number;
  56981. /**
  56982. * Gets the openGL format
  56983. */
  56984. glFormat: number;
  56985. /**
  56986. * Gets the openGL internal format
  56987. */
  56988. glInternalFormat: number;
  56989. /**
  56990. * Gets the base internal format
  56991. */
  56992. glBaseInternalFormat: number;
  56993. /**
  56994. * Gets image width in pixel
  56995. */
  56996. pixelWidth: number;
  56997. /**
  56998. * Gets image height in pixel
  56999. */
  57000. pixelHeight: number;
  57001. /**
  57002. * Gets image depth in pixels
  57003. */
  57004. pixelDepth: number;
  57005. /**
  57006. * Gets the number of array elements
  57007. */
  57008. numberOfArrayElements: number;
  57009. /**
  57010. * Gets the number of faces
  57011. */
  57012. numberOfFaces: number;
  57013. /**
  57014. * Gets the number of mipmap levels
  57015. */
  57016. numberOfMipmapLevels: number;
  57017. /**
  57018. * Gets the bytes of key value data
  57019. */
  57020. bytesOfKeyValueData: number;
  57021. /**
  57022. * Gets the load type
  57023. */
  57024. loadType: number;
  57025. /**
  57026. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57027. */
  57028. isInvalid: boolean;
  57029. /**
  57030. * Creates a new KhronosTextureContainer
  57031. * @param data contents of the KTX container file
  57032. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57033. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57034. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57035. */
  57036. constructor(
  57037. /** contents of the KTX container file */
  57038. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57039. /**
  57040. * Uploads KTX content to a Babylon Texture.
  57041. * It is assumed that the texture has already been created & is currently bound
  57042. * @hidden
  57043. */
  57044. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57045. private _upload2DCompressedLevels;
  57046. /**
  57047. * Checks if the given data starts with a KTX file identifier.
  57048. * @param data the data to check
  57049. * @returns true if the data is a KTX file or false otherwise
  57050. */
  57051. static IsValid(data: ArrayBufferView): boolean;
  57052. }
  57053. }
  57054. declare module BABYLON {
  57055. /**
  57056. * Class for loading KTX2 files
  57057. * !!! Experimental Extension Subject to Changes !!!
  57058. * @hidden
  57059. */
  57060. export class KhronosTextureContainer2 {
  57061. private static _ModulePromise;
  57062. private static _TranscodeFormat;
  57063. constructor(engine: ThinEngine);
  57064. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57065. private _determineTranscodeFormat;
  57066. /**
  57067. * Checks if the given data starts with a KTX2 file identifier.
  57068. * @param data the data to check
  57069. * @returns true if the data is a KTX2 file or false otherwise
  57070. */
  57071. static IsValid(data: ArrayBufferView): boolean;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /**
  57076. * Implementation of the KTX Texture Loader.
  57077. * @hidden
  57078. */
  57079. export class _KTXTextureLoader implements IInternalTextureLoader {
  57080. /**
  57081. * Defines wether the loader supports cascade loading the different faces.
  57082. */
  57083. readonly supportCascades: boolean;
  57084. /**
  57085. * This returns if the loader support the current file information.
  57086. * @param extension defines the file extension of the file being loaded
  57087. * @param mimeType defines the optional mime type of the file being loaded
  57088. * @returns true if the loader can load the specified file
  57089. */
  57090. canLoad(extension: string, mimeType?: string): boolean;
  57091. /**
  57092. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57093. * @param data contains the texture data
  57094. * @param texture defines the BabylonJS internal texture
  57095. * @param createPolynomials will be true if polynomials have been requested
  57096. * @param onLoad defines the callback to trigger once the texture is ready
  57097. * @param onError defines the callback to trigger in case of error
  57098. */
  57099. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57100. /**
  57101. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57102. * @param data contains the texture data
  57103. * @param texture defines the BabylonJS internal texture
  57104. * @param callback defines the method to call once ready to upload
  57105. */
  57106. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57107. }
  57108. }
  57109. declare module BABYLON {
  57110. /** @hidden */
  57111. export var _forceSceneHelpersToBundle: boolean;
  57112. interface Scene {
  57113. /**
  57114. * Creates a default light for the scene.
  57115. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57116. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57117. */
  57118. createDefaultLight(replace?: boolean): void;
  57119. /**
  57120. * Creates a default camera for the scene.
  57121. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57122. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57123. * @param replace has default false, when true replaces the active camera in the scene
  57124. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57125. */
  57126. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57127. /**
  57128. * Creates a default camera and a default light.
  57129. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57130. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57131. * @param replace has the default false, when true replaces the active camera/light in the scene
  57132. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57133. */
  57134. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57135. /**
  57136. * Creates a new sky box
  57137. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57138. * @param environmentTexture defines the texture to use as environment texture
  57139. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57140. * @param scale defines the overall scale of the skybox
  57141. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57142. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57143. * @returns a new mesh holding the sky box
  57144. */
  57145. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57146. /**
  57147. * Creates a new environment
  57148. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57149. * @param options defines the options you can use to configure the environment
  57150. * @returns the new EnvironmentHelper
  57151. */
  57152. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57153. /**
  57154. * Creates a new VREXperienceHelper
  57155. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57156. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57157. * @returns a new VREXperienceHelper
  57158. */
  57159. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57160. /**
  57161. * Creates a new WebXRDefaultExperience
  57162. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57163. * @param options experience options
  57164. * @returns a promise for a new WebXRDefaultExperience
  57165. */
  57166. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57167. }
  57168. }
  57169. declare module BABYLON {
  57170. /**
  57171. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57172. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57173. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57174. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57175. */
  57176. export class VideoDome extends TransformNode {
  57177. /**
  57178. * Define the video source as a Monoscopic panoramic 360 video.
  57179. */
  57180. static readonly MODE_MONOSCOPIC: number;
  57181. /**
  57182. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57183. */
  57184. static readonly MODE_TOPBOTTOM: number;
  57185. /**
  57186. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57187. */
  57188. static readonly MODE_SIDEBYSIDE: number;
  57189. private _halfDome;
  57190. private _useDirectMapping;
  57191. /**
  57192. * The video texture being displayed on the sphere
  57193. */
  57194. protected _videoTexture: VideoTexture;
  57195. /**
  57196. * Gets the video texture being displayed on the sphere
  57197. */
  57198. get videoTexture(): VideoTexture;
  57199. /**
  57200. * The skybox material
  57201. */
  57202. protected _material: BackgroundMaterial;
  57203. /**
  57204. * The surface used for the video dome
  57205. */
  57206. protected _mesh: Mesh;
  57207. /**
  57208. * Gets the mesh used for the video dome.
  57209. */
  57210. get mesh(): Mesh;
  57211. /**
  57212. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57213. */
  57214. private _halfDomeMask;
  57215. /**
  57216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57217. * Also see the options.resolution property.
  57218. */
  57219. get fovMultiplier(): number;
  57220. set fovMultiplier(value: number);
  57221. private _videoMode;
  57222. /**
  57223. * Gets or set the current video mode for the video. It can be:
  57224. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57225. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57226. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57227. */
  57228. get videoMode(): number;
  57229. set videoMode(value: number);
  57230. /**
  57231. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57232. *
  57233. */
  57234. get halfDome(): boolean;
  57235. /**
  57236. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57237. */
  57238. set halfDome(enabled: boolean);
  57239. /**
  57240. * Oberserver used in Stereoscopic VR Mode.
  57241. */
  57242. private _onBeforeCameraRenderObserver;
  57243. /**
  57244. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57245. * @param name Element's name, child elements will append suffixes for their own names.
  57246. * @param urlsOrVideo defines the url(s) or the video element to use
  57247. * @param options An object containing optional or exposed sub element properties
  57248. */
  57249. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57250. resolution?: number;
  57251. clickToPlay?: boolean;
  57252. autoPlay?: boolean;
  57253. loop?: boolean;
  57254. size?: number;
  57255. poster?: string;
  57256. faceForward?: boolean;
  57257. useDirectMapping?: boolean;
  57258. halfDomeMode?: boolean;
  57259. }, scene: Scene);
  57260. private _changeVideoMode;
  57261. /**
  57262. * Releases resources associated with this node.
  57263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57265. */
  57266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57267. }
  57268. }
  57269. declare module BABYLON {
  57270. /**
  57271. * This class can be used to get instrumentation data from a Babylon engine
  57272. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57273. */
  57274. export class EngineInstrumentation implements IDisposable {
  57275. /**
  57276. * Define the instrumented engine.
  57277. */
  57278. engine: Engine;
  57279. private _captureGPUFrameTime;
  57280. private _gpuFrameTimeToken;
  57281. private _gpuFrameTime;
  57282. private _captureShaderCompilationTime;
  57283. private _shaderCompilationTime;
  57284. private _onBeginFrameObserver;
  57285. private _onEndFrameObserver;
  57286. private _onBeforeShaderCompilationObserver;
  57287. private _onAfterShaderCompilationObserver;
  57288. /**
  57289. * Gets the perf counter used for GPU frame time
  57290. */
  57291. get gpuFrameTimeCounter(): PerfCounter;
  57292. /**
  57293. * Gets the GPU frame time capture status
  57294. */
  57295. get captureGPUFrameTime(): boolean;
  57296. /**
  57297. * Enable or disable the GPU frame time capture
  57298. */
  57299. set captureGPUFrameTime(value: boolean);
  57300. /**
  57301. * Gets the perf counter used for shader compilation time
  57302. */
  57303. get shaderCompilationTimeCounter(): PerfCounter;
  57304. /**
  57305. * Gets the shader compilation time capture status
  57306. */
  57307. get captureShaderCompilationTime(): boolean;
  57308. /**
  57309. * Enable or disable the shader compilation time capture
  57310. */
  57311. set captureShaderCompilationTime(value: boolean);
  57312. /**
  57313. * Instantiates a new engine instrumentation.
  57314. * This class can be used to get instrumentation data from a Babylon engine
  57315. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57316. * @param engine Defines the engine to instrument
  57317. */
  57318. constructor(
  57319. /**
  57320. * Define the instrumented engine.
  57321. */
  57322. engine: Engine);
  57323. /**
  57324. * Dispose and release associated resources.
  57325. */
  57326. dispose(): void;
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * This class can be used to get instrumentation data from a Babylon engine
  57332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57333. */
  57334. export class SceneInstrumentation implements IDisposable {
  57335. /**
  57336. * Defines the scene to instrument
  57337. */
  57338. scene: Scene;
  57339. private _captureActiveMeshesEvaluationTime;
  57340. private _activeMeshesEvaluationTime;
  57341. private _captureRenderTargetsRenderTime;
  57342. private _renderTargetsRenderTime;
  57343. private _captureFrameTime;
  57344. private _frameTime;
  57345. private _captureRenderTime;
  57346. private _renderTime;
  57347. private _captureInterFrameTime;
  57348. private _interFrameTime;
  57349. private _captureParticlesRenderTime;
  57350. private _particlesRenderTime;
  57351. private _captureSpritesRenderTime;
  57352. private _spritesRenderTime;
  57353. private _capturePhysicsTime;
  57354. private _physicsTime;
  57355. private _captureAnimationsTime;
  57356. private _animationsTime;
  57357. private _captureCameraRenderTime;
  57358. private _cameraRenderTime;
  57359. private _onBeforeActiveMeshesEvaluationObserver;
  57360. private _onAfterActiveMeshesEvaluationObserver;
  57361. private _onBeforeRenderTargetsRenderObserver;
  57362. private _onAfterRenderTargetsRenderObserver;
  57363. private _onAfterRenderObserver;
  57364. private _onBeforeDrawPhaseObserver;
  57365. private _onAfterDrawPhaseObserver;
  57366. private _onBeforeAnimationsObserver;
  57367. private _onBeforeParticlesRenderingObserver;
  57368. private _onAfterParticlesRenderingObserver;
  57369. private _onBeforeSpritesRenderingObserver;
  57370. private _onAfterSpritesRenderingObserver;
  57371. private _onBeforePhysicsObserver;
  57372. private _onAfterPhysicsObserver;
  57373. private _onAfterAnimationsObserver;
  57374. private _onBeforeCameraRenderObserver;
  57375. private _onAfterCameraRenderObserver;
  57376. /**
  57377. * Gets the perf counter used for active meshes evaluation time
  57378. */
  57379. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57380. /**
  57381. * Gets the active meshes evaluation time capture status
  57382. */
  57383. get captureActiveMeshesEvaluationTime(): boolean;
  57384. /**
  57385. * Enable or disable the active meshes evaluation time capture
  57386. */
  57387. set captureActiveMeshesEvaluationTime(value: boolean);
  57388. /**
  57389. * Gets the perf counter used for render targets render time
  57390. */
  57391. get renderTargetsRenderTimeCounter(): PerfCounter;
  57392. /**
  57393. * Gets the render targets render time capture status
  57394. */
  57395. get captureRenderTargetsRenderTime(): boolean;
  57396. /**
  57397. * Enable or disable the render targets render time capture
  57398. */
  57399. set captureRenderTargetsRenderTime(value: boolean);
  57400. /**
  57401. * Gets the perf counter used for particles render time
  57402. */
  57403. get particlesRenderTimeCounter(): PerfCounter;
  57404. /**
  57405. * Gets the particles render time capture status
  57406. */
  57407. get captureParticlesRenderTime(): boolean;
  57408. /**
  57409. * Enable or disable the particles render time capture
  57410. */
  57411. set captureParticlesRenderTime(value: boolean);
  57412. /**
  57413. * Gets the perf counter used for sprites render time
  57414. */
  57415. get spritesRenderTimeCounter(): PerfCounter;
  57416. /**
  57417. * Gets the sprites render time capture status
  57418. */
  57419. get captureSpritesRenderTime(): boolean;
  57420. /**
  57421. * Enable or disable the sprites render time capture
  57422. */
  57423. set captureSpritesRenderTime(value: boolean);
  57424. /**
  57425. * Gets the perf counter used for physics time
  57426. */
  57427. get physicsTimeCounter(): PerfCounter;
  57428. /**
  57429. * Gets the physics time capture status
  57430. */
  57431. get capturePhysicsTime(): boolean;
  57432. /**
  57433. * Enable or disable the physics time capture
  57434. */
  57435. set capturePhysicsTime(value: boolean);
  57436. /**
  57437. * Gets the perf counter used for animations time
  57438. */
  57439. get animationsTimeCounter(): PerfCounter;
  57440. /**
  57441. * Gets the animations time capture status
  57442. */
  57443. get captureAnimationsTime(): boolean;
  57444. /**
  57445. * Enable or disable the animations time capture
  57446. */
  57447. set captureAnimationsTime(value: boolean);
  57448. /**
  57449. * Gets the perf counter used for frame time capture
  57450. */
  57451. get frameTimeCounter(): PerfCounter;
  57452. /**
  57453. * Gets the frame time capture status
  57454. */
  57455. get captureFrameTime(): boolean;
  57456. /**
  57457. * Enable or disable the frame time capture
  57458. */
  57459. set captureFrameTime(value: boolean);
  57460. /**
  57461. * Gets the perf counter used for inter-frames time capture
  57462. */
  57463. get interFrameTimeCounter(): PerfCounter;
  57464. /**
  57465. * Gets the inter-frames time capture status
  57466. */
  57467. get captureInterFrameTime(): boolean;
  57468. /**
  57469. * Enable or disable the inter-frames time capture
  57470. */
  57471. set captureInterFrameTime(value: boolean);
  57472. /**
  57473. * Gets the perf counter used for render time capture
  57474. */
  57475. get renderTimeCounter(): PerfCounter;
  57476. /**
  57477. * Gets the render time capture status
  57478. */
  57479. get captureRenderTime(): boolean;
  57480. /**
  57481. * Enable or disable the render time capture
  57482. */
  57483. set captureRenderTime(value: boolean);
  57484. /**
  57485. * Gets the perf counter used for camera render time capture
  57486. */
  57487. get cameraRenderTimeCounter(): PerfCounter;
  57488. /**
  57489. * Gets the camera render time capture status
  57490. */
  57491. get captureCameraRenderTime(): boolean;
  57492. /**
  57493. * Enable or disable the camera render time capture
  57494. */
  57495. set captureCameraRenderTime(value: boolean);
  57496. /**
  57497. * Gets the perf counter used for draw calls
  57498. */
  57499. get drawCallsCounter(): PerfCounter;
  57500. /**
  57501. * Instantiates a new scene instrumentation.
  57502. * This class can be used to get instrumentation data from a Babylon engine
  57503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57504. * @param scene Defines the scene to instrument
  57505. */
  57506. constructor(
  57507. /**
  57508. * Defines the scene to instrument
  57509. */
  57510. scene: Scene);
  57511. /**
  57512. * Dispose and release associated resources.
  57513. */
  57514. dispose(): void;
  57515. }
  57516. }
  57517. declare module BABYLON {
  57518. /** @hidden */
  57519. export var glowMapGenerationPixelShader: {
  57520. name: string;
  57521. shader: string;
  57522. };
  57523. }
  57524. declare module BABYLON {
  57525. /** @hidden */
  57526. export var glowMapGenerationVertexShader: {
  57527. name: string;
  57528. shader: string;
  57529. };
  57530. }
  57531. declare module BABYLON {
  57532. /**
  57533. * Effect layer options. This helps customizing the behaviour
  57534. * of the effect layer.
  57535. */
  57536. export interface IEffectLayerOptions {
  57537. /**
  57538. * Multiplication factor apply to the canvas size to compute the render target size
  57539. * used to generated the objects (the smaller the faster).
  57540. */
  57541. mainTextureRatio: number;
  57542. /**
  57543. * Enforces a fixed size texture to ensure effect stability across devices.
  57544. */
  57545. mainTextureFixedSize?: number;
  57546. /**
  57547. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57548. */
  57549. alphaBlendingMode: number;
  57550. /**
  57551. * The camera attached to the layer.
  57552. */
  57553. camera: Nullable<Camera>;
  57554. /**
  57555. * The rendering group to draw the layer in.
  57556. */
  57557. renderingGroupId: number;
  57558. }
  57559. /**
  57560. * The effect layer Helps adding post process effect blended with the main pass.
  57561. *
  57562. * This can be for instance use to generate glow or higlight effects on the scene.
  57563. *
  57564. * The effect layer class can not be used directly and is intented to inherited from to be
  57565. * customized per effects.
  57566. */
  57567. export abstract class EffectLayer {
  57568. private _vertexBuffers;
  57569. private _indexBuffer;
  57570. private _cachedDefines;
  57571. private _effectLayerMapGenerationEffect;
  57572. private _effectLayerOptions;
  57573. private _mergeEffect;
  57574. protected _scene: Scene;
  57575. protected _engine: Engine;
  57576. protected _maxSize: number;
  57577. protected _mainTextureDesiredSize: ISize;
  57578. protected _mainTexture: RenderTargetTexture;
  57579. protected _shouldRender: boolean;
  57580. protected _postProcesses: PostProcess[];
  57581. protected _textures: BaseTexture[];
  57582. protected _emissiveTextureAndColor: {
  57583. texture: Nullable<BaseTexture>;
  57584. color: Color4;
  57585. };
  57586. /**
  57587. * The name of the layer
  57588. */
  57589. name: string;
  57590. /**
  57591. * The clear color of the texture used to generate the glow map.
  57592. */
  57593. neutralColor: Color4;
  57594. /**
  57595. * Specifies whether the highlight layer is enabled or not.
  57596. */
  57597. isEnabled: boolean;
  57598. /**
  57599. * Gets the camera attached to the layer.
  57600. */
  57601. get camera(): Nullable<Camera>;
  57602. /**
  57603. * Gets the rendering group id the layer should render in.
  57604. */
  57605. get renderingGroupId(): number;
  57606. set renderingGroupId(renderingGroupId: number);
  57607. /**
  57608. * An event triggered when the effect layer has been disposed.
  57609. */
  57610. onDisposeObservable: Observable<EffectLayer>;
  57611. /**
  57612. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57613. */
  57614. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57615. /**
  57616. * An event triggered when the generated texture is being merged in the scene.
  57617. */
  57618. onBeforeComposeObservable: Observable<EffectLayer>;
  57619. /**
  57620. * An event triggered when the mesh is rendered into the effect render target.
  57621. */
  57622. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57623. /**
  57624. * An event triggered after the mesh has been rendered into the effect render target.
  57625. */
  57626. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57627. /**
  57628. * An event triggered when the generated texture has been merged in the scene.
  57629. */
  57630. onAfterComposeObservable: Observable<EffectLayer>;
  57631. /**
  57632. * An event triggered when the efffect layer changes its size.
  57633. */
  57634. onSizeChangedObservable: Observable<EffectLayer>;
  57635. /** @hidden */
  57636. static _SceneComponentInitialization: (scene: Scene) => void;
  57637. /**
  57638. * Instantiates a new effect Layer and references it in the scene.
  57639. * @param name The name of the layer
  57640. * @param scene The scene to use the layer in
  57641. */
  57642. constructor(
  57643. /** The Friendly of the effect in the scene */
  57644. name: string, scene: Scene);
  57645. /**
  57646. * Get the effect name of the layer.
  57647. * @return The effect name
  57648. */
  57649. abstract getEffectName(): string;
  57650. /**
  57651. * Checks for the readiness of the element composing the layer.
  57652. * @param subMesh the mesh to check for
  57653. * @param useInstances specify whether or not to use instances to render the mesh
  57654. * @return true if ready otherwise, false
  57655. */
  57656. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57657. /**
  57658. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57659. * @returns true if the effect requires stencil during the main canvas render pass.
  57660. */
  57661. abstract needStencil(): boolean;
  57662. /**
  57663. * Create the merge effect. This is the shader use to blit the information back
  57664. * to the main canvas at the end of the scene rendering.
  57665. * @returns The effect containing the shader used to merge the effect on the main canvas
  57666. */
  57667. protected abstract _createMergeEffect(): Effect;
  57668. /**
  57669. * Creates the render target textures and post processes used in the effect layer.
  57670. */
  57671. protected abstract _createTextureAndPostProcesses(): void;
  57672. /**
  57673. * Implementation specific of rendering the generating effect on the main canvas.
  57674. * @param effect The effect used to render through
  57675. */
  57676. protected abstract _internalRender(effect: Effect): void;
  57677. /**
  57678. * Sets the required values for both the emissive texture and and the main color.
  57679. */
  57680. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57681. /**
  57682. * Free any resources and references associated to a mesh.
  57683. * Internal use
  57684. * @param mesh The mesh to free.
  57685. */
  57686. abstract _disposeMesh(mesh: Mesh): void;
  57687. /**
  57688. * Serializes this layer (Glow or Highlight for example)
  57689. * @returns a serialized layer object
  57690. */
  57691. abstract serialize?(): any;
  57692. /**
  57693. * Initializes the effect layer with the required options.
  57694. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57695. */
  57696. protected _init(options: Partial<IEffectLayerOptions>): void;
  57697. /**
  57698. * Generates the index buffer of the full screen quad blending to the main canvas.
  57699. */
  57700. private _generateIndexBuffer;
  57701. /**
  57702. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57703. */
  57704. private _generateVertexBuffer;
  57705. /**
  57706. * Sets the main texture desired size which is the closest power of two
  57707. * of the engine canvas size.
  57708. */
  57709. private _setMainTextureSize;
  57710. /**
  57711. * Creates the main texture for the effect layer.
  57712. */
  57713. protected _createMainTexture(): void;
  57714. /**
  57715. * Adds specific effects defines.
  57716. * @param defines The defines to add specifics to.
  57717. */
  57718. protected _addCustomEffectDefines(defines: string[]): void;
  57719. /**
  57720. * Checks for the readiness of the element composing the layer.
  57721. * @param subMesh the mesh to check for
  57722. * @param useInstances specify whether or not to use instances to render the mesh
  57723. * @param emissiveTexture the associated emissive texture used to generate the glow
  57724. * @return true if ready otherwise, false
  57725. */
  57726. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57727. /**
  57728. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57729. */
  57730. render(): void;
  57731. /**
  57732. * Determine if a given mesh will be used in the current effect.
  57733. * @param mesh mesh to test
  57734. * @returns true if the mesh will be used
  57735. */
  57736. hasMesh(mesh: AbstractMesh): boolean;
  57737. /**
  57738. * Returns true if the layer contains information to display, otherwise false.
  57739. * @returns true if the glow layer should be rendered
  57740. */
  57741. shouldRender(): boolean;
  57742. /**
  57743. * Returns true if the mesh should render, otherwise false.
  57744. * @param mesh The mesh to render
  57745. * @returns true if it should render otherwise false
  57746. */
  57747. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57748. /**
  57749. * Returns true if the mesh can be rendered, otherwise false.
  57750. * @param mesh The mesh to render
  57751. * @param material The material used on the mesh
  57752. * @returns true if it can be rendered otherwise false
  57753. */
  57754. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57755. /**
  57756. * Returns true if the mesh should render, otherwise false.
  57757. * @param mesh The mesh to render
  57758. * @returns true if it should render otherwise false
  57759. */
  57760. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57761. /**
  57762. * Renders the submesh passed in parameter to the generation map.
  57763. */
  57764. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57765. /**
  57766. * Defines whether the current material of the mesh should be use to render the effect.
  57767. * @param mesh defines the current mesh to render
  57768. */
  57769. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57770. /**
  57771. * Rebuild the required buffers.
  57772. * @hidden Internal use only.
  57773. */
  57774. _rebuild(): void;
  57775. /**
  57776. * Dispose only the render target textures and post process.
  57777. */
  57778. private _disposeTextureAndPostProcesses;
  57779. /**
  57780. * Dispose the highlight layer and free resources.
  57781. */
  57782. dispose(): void;
  57783. /**
  57784. * Gets the class name of the effect layer
  57785. * @returns the string with the class name of the effect layer
  57786. */
  57787. getClassName(): string;
  57788. /**
  57789. * Creates an effect layer from parsed effect layer data
  57790. * @param parsedEffectLayer defines effect layer data
  57791. * @param scene defines the current scene
  57792. * @param rootUrl defines the root URL containing the effect layer information
  57793. * @returns a parsed effect Layer
  57794. */
  57795. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57796. }
  57797. }
  57798. declare module BABYLON {
  57799. interface AbstractScene {
  57800. /**
  57801. * The list of effect layers (highlights/glow) added to the scene
  57802. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57803. * @see https://doc.babylonjs.com/how_to/glow_layer
  57804. */
  57805. effectLayers: Array<EffectLayer>;
  57806. /**
  57807. * Removes the given effect layer from this scene.
  57808. * @param toRemove defines the effect layer to remove
  57809. * @returns the index of the removed effect layer
  57810. */
  57811. removeEffectLayer(toRemove: EffectLayer): number;
  57812. /**
  57813. * Adds the given effect layer to this scene
  57814. * @param newEffectLayer defines the effect layer to add
  57815. */
  57816. addEffectLayer(newEffectLayer: EffectLayer): void;
  57817. }
  57818. /**
  57819. * Defines the layer scene component responsible to manage any effect layers
  57820. * in a given scene.
  57821. */
  57822. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57823. /**
  57824. * The component name helpfull to identify the component in the list of scene components.
  57825. */
  57826. readonly name: string;
  57827. /**
  57828. * The scene the component belongs to.
  57829. */
  57830. scene: Scene;
  57831. private _engine;
  57832. private _renderEffects;
  57833. private _needStencil;
  57834. private _previousStencilState;
  57835. /**
  57836. * Creates a new instance of the component for the given scene
  57837. * @param scene Defines the scene to register the component in
  57838. */
  57839. constructor(scene: Scene);
  57840. /**
  57841. * Registers the component in a given scene
  57842. */
  57843. register(): void;
  57844. /**
  57845. * Rebuilds the elements related to this component in case of
  57846. * context lost for instance.
  57847. */
  57848. rebuild(): void;
  57849. /**
  57850. * Serializes the component data to the specified json object
  57851. * @param serializationObject The object to serialize to
  57852. */
  57853. serialize(serializationObject: any): void;
  57854. /**
  57855. * Adds all the elements from the container to the scene
  57856. * @param container the container holding the elements
  57857. */
  57858. addFromContainer(container: AbstractScene): void;
  57859. /**
  57860. * Removes all the elements in the container from the scene
  57861. * @param container contains the elements to remove
  57862. * @param dispose if the removed element should be disposed (default: false)
  57863. */
  57864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57865. /**
  57866. * Disposes the component and the associated ressources.
  57867. */
  57868. dispose(): void;
  57869. private _isReadyForMesh;
  57870. private _renderMainTexture;
  57871. private _setStencil;
  57872. private _setStencilBack;
  57873. private _draw;
  57874. private _drawCamera;
  57875. private _drawRenderingGroup;
  57876. }
  57877. }
  57878. declare module BABYLON {
  57879. /** @hidden */
  57880. export var glowMapMergePixelShader: {
  57881. name: string;
  57882. shader: string;
  57883. };
  57884. }
  57885. declare module BABYLON {
  57886. /** @hidden */
  57887. export var glowMapMergeVertexShader: {
  57888. name: string;
  57889. shader: string;
  57890. };
  57891. }
  57892. declare module BABYLON {
  57893. interface AbstractScene {
  57894. /**
  57895. * Return a the first highlight layer of the scene with a given name.
  57896. * @param name The name of the highlight layer to look for.
  57897. * @return The highlight layer if found otherwise null.
  57898. */
  57899. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57900. }
  57901. /**
  57902. * Glow layer options. This helps customizing the behaviour
  57903. * of the glow layer.
  57904. */
  57905. export interface IGlowLayerOptions {
  57906. /**
  57907. * Multiplication factor apply to the canvas size to compute the render target size
  57908. * used to generated the glowing objects (the smaller the faster).
  57909. */
  57910. mainTextureRatio: number;
  57911. /**
  57912. * Enforces a fixed size texture to ensure resize independant blur.
  57913. */
  57914. mainTextureFixedSize?: number;
  57915. /**
  57916. * How big is the kernel of the blur texture.
  57917. */
  57918. blurKernelSize: number;
  57919. /**
  57920. * The camera attached to the layer.
  57921. */
  57922. camera: Nullable<Camera>;
  57923. /**
  57924. * Enable MSAA by chosing the number of samples.
  57925. */
  57926. mainTextureSamples?: number;
  57927. /**
  57928. * The rendering group to draw the layer in.
  57929. */
  57930. renderingGroupId: number;
  57931. }
  57932. /**
  57933. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57934. *
  57935. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57936. *
  57937. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57938. */
  57939. export class GlowLayer extends EffectLayer {
  57940. /**
  57941. * Effect Name of the layer.
  57942. */
  57943. static readonly EffectName: string;
  57944. /**
  57945. * The default blur kernel size used for the glow.
  57946. */
  57947. static DefaultBlurKernelSize: number;
  57948. /**
  57949. * The default texture size ratio used for the glow.
  57950. */
  57951. static DefaultTextureRatio: number;
  57952. /**
  57953. * Sets the kernel size of the blur.
  57954. */
  57955. set blurKernelSize(value: number);
  57956. /**
  57957. * Gets the kernel size of the blur.
  57958. */
  57959. get blurKernelSize(): number;
  57960. /**
  57961. * Sets the glow intensity.
  57962. */
  57963. set intensity(value: number);
  57964. /**
  57965. * Gets the glow intensity.
  57966. */
  57967. get intensity(): number;
  57968. private _options;
  57969. private _intensity;
  57970. private _horizontalBlurPostprocess1;
  57971. private _verticalBlurPostprocess1;
  57972. private _horizontalBlurPostprocess2;
  57973. private _verticalBlurPostprocess2;
  57974. private _blurTexture1;
  57975. private _blurTexture2;
  57976. private _postProcesses1;
  57977. private _postProcesses2;
  57978. private _includedOnlyMeshes;
  57979. private _excludedMeshes;
  57980. private _meshesUsingTheirOwnMaterials;
  57981. /**
  57982. * Callback used to let the user override the color selection on a per mesh basis
  57983. */
  57984. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57985. /**
  57986. * Callback used to let the user override the texture selection on a per mesh basis
  57987. */
  57988. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57989. /**
  57990. * Instantiates a new glow Layer and references it to the scene.
  57991. * @param name The name of the layer
  57992. * @param scene The scene to use the layer in
  57993. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57994. */
  57995. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57996. /**
  57997. * Get the effect name of the layer.
  57998. * @return The effect name
  57999. */
  58000. getEffectName(): string;
  58001. /**
  58002. * Create the merge effect. This is the shader use to blit the information back
  58003. * to the main canvas at the end of the scene rendering.
  58004. */
  58005. protected _createMergeEffect(): Effect;
  58006. /**
  58007. * Creates the render target textures and post processes used in the glow layer.
  58008. */
  58009. protected _createTextureAndPostProcesses(): void;
  58010. /**
  58011. * Checks for the readiness of the element composing the layer.
  58012. * @param subMesh the mesh to check for
  58013. * @param useInstances specify wether or not to use instances to render the mesh
  58014. * @param emissiveTexture the associated emissive texture used to generate the glow
  58015. * @return true if ready otherwise, false
  58016. */
  58017. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58018. /**
  58019. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58020. */
  58021. needStencil(): boolean;
  58022. /**
  58023. * Returns true if the mesh can be rendered, otherwise false.
  58024. * @param mesh The mesh to render
  58025. * @param material The material used on the mesh
  58026. * @returns true if it can be rendered otherwise false
  58027. */
  58028. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58029. /**
  58030. * Implementation specific of rendering the generating effect on the main canvas.
  58031. * @param effect The effect used to render through
  58032. */
  58033. protected _internalRender(effect: Effect): void;
  58034. /**
  58035. * Sets the required values for both the emissive texture and and the main color.
  58036. */
  58037. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58038. /**
  58039. * Returns true if the mesh should render, otherwise false.
  58040. * @param mesh The mesh to render
  58041. * @returns true if it should render otherwise false
  58042. */
  58043. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58044. /**
  58045. * Adds specific effects defines.
  58046. * @param defines The defines to add specifics to.
  58047. */
  58048. protected _addCustomEffectDefines(defines: string[]): void;
  58049. /**
  58050. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58051. * @param mesh The mesh to exclude from the glow layer
  58052. */
  58053. addExcludedMesh(mesh: Mesh): void;
  58054. /**
  58055. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58056. * @param mesh The mesh to remove
  58057. */
  58058. removeExcludedMesh(mesh: Mesh): void;
  58059. /**
  58060. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58061. * @param mesh The mesh to include in the glow layer
  58062. */
  58063. addIncludedOnlyMesh(mesh: Mesh): void;
  58064. /**
  58065. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58066. * @param mesh The mesh to remove
  58067. */
  58068. removeIncludedOnlyMesh(mesh: Mesh): void;
  58069. /**
  58070. * Determine if a given mesh will be used in the glow layer
  58071. * @param mesh The mesh to test
  58072. * @returns true if the mesh will be highlighted by the current glow layer
  58073. */
  58074. hasMesh(mesh: AbstractMesh): boolean;
  58075. /**
  58076. * Defines whether the current material of the mesh should be use to render the effect.
  58077. * @param mesh defines the current mesh to render
  58078. */
  58079. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58080. /**
  58081. * Add a mesh to be rendered through its own material and not with emissive only.
  58082. * @param mesh The mesh for which we need to use its material
  58083. */
  58084. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58085. /**
  58086. * Remove a mesh from being rendered through its own material and not with emissive only.
  58087. * @param mesh The mesh for which we need to not use its material
  58088. */
  58089. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58090. /**
  58091. * Free any resources and references associated to a mesh.
  58092. * Internal use
  58093. * @param mesh The mesh to free.
  58094. * @hidden
  58095. */
  58096. _disposeMesh(mesh: Mesh): void;
  58097. /**
  58098. * Gets the class name of the effect layer
  58099. * @returns the string with the class name of the effect layer
  58100. */
  58101. getClassName(): string;
  58102. /**
  58103. * Serializes this glow layer
  58104. * @returns a serialized glow layer object
  58105. */
  58106. serialize(): any;
  58107. /**
  58108. * Creates a Glow Layer from parsed glow layer data
  58109. * @param parsedGlowLayer defines glow layer data
  58110. * @param scene defines the current scene
  58111. * @param rootUrl defines the root URL containing the glow layer information
  58112. * @returns a parsed Glow Layer
  58113. */
  58114. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58115. }
  58116. }
  58117. declare module BABYLON {
  58118. /** @hidden */
  58119. export var glowBlurPostProcessPixelShader: {
  58120. name: string;
  58121. shader: string;
  58122. };
  58123. }
  58124. declare module BABYLON {
  58125. interface AbstractScene {
  58126. /**
  58127. * Return a the first highlight layer of the scene with a given name.
  58128. * @param name The name of the highlight layer to look for.
  58129. * @return The highlight layer if found otherwise null.
  58130. */
  58131. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58132. }
  58133. /**
  58134. * Highlight layer options. This helps customizing the behaviour
  58135. * of the highlight layer.
  58136. */
  58137. export interface IHighlightLayerOptions {
  58138. /**
  58139. * Multiplication factor apply to the canvas size to compute the render target size
  58140. * used to generated the glowing objects (the smaller the faster).
  58141. */
  58142. mainTextureRatio: number;
  58143. /**
  58144. * Enforces a fixed size texture to ensure resize independant blur.
  58145. */
  58146. mainTextureFixedSize?: number;
  58147. /**
  58148. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58149. * of the picture to blur (the smaller the faster).
  58150. */
  58151. blurTextureSizeRatio: number;
  58152. /**
  58153. * How big in texel of the blur texture is the vertical blur.
  58154. */
  58155. blurVerticalSize: number;
  58156. /**
  58157. * How big in texel of the blur texture is the horizontal blur.
  58158. */
  58159. blurHorizontalSize: number;
  58160. /**
  58161. * Alpha blending mode used to apply the blur. Default is combine.
  58162. */
  58163. alphaBlendingMode: number;
  58164. /**
  58165. * The camera attached to the layer.
  58166. */
  58167. camera: Nullable<Camera>;
  58168. /**
  58169. * Should we display highlight as a solid stroke?
  58170. */
  58171. isStroke?: boolean;
  58172. /**
  58173. * The rendering group to draw the layer in.
  58174. */
  58175. renderingGroupId: number;
  58176. }
  58177. /**
  58178. * The highlight layer Helps adding a glow effect around a mesh.
  58179. *
  58180. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58181. * glowy meshes to your scene.
  58182. *
  58183. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58184. */
  58185. export class HighlightLayer extends EffectLayer {
  58186. name: string;
  58187. /**
  58188. * Effect Name of the highlight layer.
  58189. */
  58190. static readonly EffectName: string;
  58191. /**
  58192. * The neutral color used during the preparation of the glow effect.
  58193. * This is black by default as the blend operation is a blend operation.
  58194. */
  58195. static NeutralColor: Color4;
  58196. /**
  58197. * Stencil value used for glowing meshes.
  58198. */
  58199. static GlowingMeshStencilReference: number;
  58200. /**
  58201. * Stencil value used for the other meshes in the scene.
  58202. */
  58203. static NormalMeshStencilReference: number;
  58204. /**
  58205. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58206. */
  58207. innerGlow: boolean;
  58208. /**
  58209. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58210. */
  58211. outerGlow: boolean;
  58212. /**
  58213. * Specifies the horizontal size of the blur.
  58214. */
  58215. set blurHorizontalSize(value: number);
  58216. /**
  58217. * Specifies the vertical size of the blur.
  58218. */
  58219. set blurVerticalSize(value: number);
  58220. /**
  58221. * Gets the horizontal size of the blur.
  58222. */
  58223. get blurHorizontalSize(): number;
  58224. /**
  58225. * Gets the vertical size of the blur.
  58226. */
  58227. get blurVerticalSize(): number;
  58228. /**
  58229. * An event triggered when the highlight layer is being blurred.
  58230. */
  58231. onBeforeBlurObservable: Observable<HighlightLayer>;
  58232. /**
  58233. * An event triggered when the highlight layer has been blurred.
  58234. */
  58235. onAfterBlurObservable: Observable<HighlightLayer>;
  58236. private _instanceGlowingMeshStencilReference;
  58237. private _options;
  58238. private _downSamplePostprocess;
  58239. private _horizontalBlurPostprocess;
  58240. private _verticalBlurPostprocess;
  58241. private _blurTexture;
  58242. private _meshes;
  58243. private _excludedMeshes;
  58244. /**
  58245. * Instantiates a new highlight Layer and references it to the scene..
  58246. * @param name The name of the layer
  58247. * @param scene The scene to use the layer in
  58248. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58249. */
  58250. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58251. /**
  58252. * Get the effect name of the layer.
  58253. * @return The effect name
  58254. */
  58255. getEffectName(): string;
  58256. /**
  58257. * Create the merge effect. This is the shader use to blit the information back
  58258. * to the main canvas at the end of the scene rendering.
  58259. */
  58260. protected _createMergeEffect(): Effect;
  58261. /**
  58262. * Creates the render target textures and post processes used in the highlight layer.
  58263. */
  58264. protected _createTextureAndPostProcesses(): void;
  58265. /**
  58266. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58267. */
  58268. needStencil(): boolean;
  58269. /**
  58270. * Checks for the readiness of the element composing the layer.
  58271. * @param subMesh the mesh to check for
  58272. * @param useInstances specify wether or not to use instances to render the mesh
  58273. * @param emissiveTexture the associated emissive texture used to generate the glow
  58274. * @return true if ready otherwise, false
  58275. */
  58276. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58277. /**
  58278. * Implementation specific of rendering the generating effect on the main canvas.
  58279. * @param effect The effect used to render through
  58280. */
  58281. protected _internalRender(effect: Effect): void;
  58282. /**
  58283. * Returns true if the layer contains information to display, otherwise false.
  58284. */
  58285. shouldRender(): boolean;
  58286. /**
  58287. * Returns true if the mesh should render, otherwise false.
  58288. * @param mesh The mesh to render
  58289. * @returns true if it should render otherwise false
  58290. */
  58291. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58292. /**
  58293. * Returns true if the mesh can be rendered, otherwise false.
  58294. * @param mesh The mesh to render
  58295. * @param material The material used on the mesh
  58296. * @returns true if it can be rendered otherwise false
  58297. */
  58298. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58299. /**
  58300. * Adds specific effects defines.
  58301. * @param defines The defines to add specifics to.
  58302. */
  58303. protected _addCustomEffectDefines(defines: string[]): void;
  58304. /**
  58305. * Sets the required values for both the emissive texture and and the main color.
  58306. */
  58307. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58308. /**
  58309. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58310. * @param mesh The mesh to exclude from the highlight layer
  58311. */
  58312. addExcludedMesh(mesh: Mesh): void;
  58313. /**
  58314. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58315. * @param mesh The mesh to highlight
  58316. */
  58317. removeExcludedMesh(mesh: Mesh): void;
  58318. /**
  58319. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58320. * @param mesh mesh to test
  58321. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58322. */
  58323. hasMesh(mesh: AbstractMesh): boolean;
  58324. /**
  58325. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58326. * @param mesh The mesh to highlight
  58327. * @param color The color of the highlight
  58328. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58329. */
  58330. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58331. /**
  58332. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58333. * @param mesh The mesh to highlight
  58334. */
  58335. removeMesh(mesh: Mesh): void;
  58336. /**
  58337. * Remove all the meshes currently referenced in the highlight layer
  58338. */
  58339. removeAllMeshes(): void;
  58340. /**
  58341. * Force the stencil to the normal expected value for none glowing parts
  58342. */
  58343. private _defaultStencilReference;
  58344. /**
  58345. * Free any resources and references associated to a mesh.
  58346. * Internal use
  58347. * @param mesh The mesh to free.
  58348. * @hidden
  58349. */
  58350. _disposeMesh(mesh: Mesh): void;
  58351. /**
  58352. * Dispose the highlight layer and free resources.
  58353. */
  58354. dispose(): void;
  58355. /**
  58356. * Gets the class name of the effect layer
  58357. * @returns the string with the class name of the effect layer
  58358. */
  58359. getClassName(): string;
  58360. /**
  58361. * Serializes this Highlight layer
  58362. * @returns a serialized Highlight layer object
  58363. */
  58364. serialize(): any;
  58365. /**
  58366. * Creates a Highlight layer from parsed Highlight layer data
  58367. * @param parsedHightlightLayer defines the Highlight layer data
  58368. * @param scene defines the current scene
  58369. * @param rootUrl defines the root URL containing the Highlight layer information
  58370. * @returns a parsed Highlight layer
  58371. */
  58372. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58373. }
  58374. }
  58375. declare module BABYLON {
  58376. interface AbstractScene {
  58377. /**
  58378. * The list of layers (background and foreground) of the scene
  58379. */
  58380. layers: Array<Layer>;
  58381. }
  58382. /**
  58383. * Defines the layer scene component responsible to manage any layers
  58384. * in a given scene.
  58385. */
  58386. export class LayerSceneComponent implements ISceneComponent {
  58387. /**
  58388. * The component name helpfull to identify the component in the list of scene components.
  58389. */
  58390. readonly name: string;
  58391. /**
  58392. * The scene the component belongs to.
  58393. */
  58394. scene: Scene;
  58395. private _engine;
  58396. /**
  58397. * Creates a new instance of the component for the given scene
  58398. * @param scene Defines the scene to register the component in
  58399. */
  58400. constructor(scene: Scene);
  58401. /**
  58402. * Registers the component in a given scene
  58403. */
  58404. register(): void;
  58405. /**
  58406. * Rebuilds the elements related to this component in case of
  58407. * context lost for instance.
  58408. */
  58409. rebuild(): void;
  58410. /**
  58411. * Disposes the component and the associated ressources.
  58412. */
  58413. dispose(): void;
  58414. private _draw;
  58415. private _drawCameraPredicate;
  58416. private _drawCameraBackground;
  58417. private _drawCameraForeground;
  58418. private _drawRenderTargetPredicate;
  58419. private _drawRenderTargetBackground;
  58420. private _drawRenderTargetForeground;
  58421. /**
  58422. * Adds all the elements from the container to the scene
  58423. * @param container the container holding the elements
  58424. */
  58425. addFromContainer(container: AbstractScene): void;
  58426. /**
  58427. * Removes all the elements in the container from the scene
  58428. * @param container contains the elements to remove
  58429. * @param dispose if the removed element should be disposed (default: false)
  58430. */
  58431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58432. }
  58433. }
  58434. declare module BABYLON {
  58435. /** @hidden */
  58436. export var layerPixelShader: {
  58437. name: string;
  58438. shader: string;
  58439. };
  58440. }
  58441. declare module BABYLON {
  58442. /** @hidden */
  58443. export var layerVertexShader: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module BABYLON {
  58449. /**
  58450. * This represents a full screen 2d layer.
  58451. * This can be useful to display a picture in the background of your scene for instance.
  58452. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58453. */
  58454. export class Layer {
  58455. /**
  58456. * Define the name of the layer.
  58457. */
  58458. name: string;
  58459. /**
  58460. * Define the texture the layer should display.
  58461. */
  58462. texture: Nullable<Texture>;
  58463. /**
  58464. * Is the layer in background or foreground.
  58465. */
  58466. isBackground: boolean;
  58467. /**
  58468. * Define the color of the layer (instead of texture).
  58469. */
  58470. color: Color4;
  58471. /**
  58472. * Define the scale of the layer in order to zoom in out of the texture.
  58473. */
  58474. scale: Vector2;
  58475. /**
  58476. * Define an offset for the layer in order to shift the texture.
  58477. */
  58478. offset: Vector2;
  58479. /**
  58480. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58481. */
  58482. alphaBlendingMode: number;
  58483. /**
  58484. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58485. * Alpha test will not mix with the background color in case of transparency.
  58486. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58487. */
  58488. alphaTest: boolean;
  58489. /**
  58490. * Define a mask to restrict the layer to only some of the scene cameras.
  58491. */
  58492. layerMask: number;
  58493. /**
  58494. * Define the list of render target the layer is visible into.
  58495. */
  58496. renderTargetTextures: RenderTargetTexture[];
  58497. /**
  58498. * Define if the layer is only used in renderTarget or if it also
  58499. * renders in the main frame buffer of the canvas.
  58500. */
  58501. renderOnlyInRenderTargetTextures: boolean;
  58502. private _scene;
  58503. private _vertexBuffers;
  58504. private _indexBuffer;
  58505. private _effect;
  58506. private _previousDefines;
  58507. /**
  58508. * An event triggered when the layer is disposed.
  58509. */
  58510. onDisposeObservable: Observable<Layer>;
  58511. private _onDisposeObserver;
  58512. /**
  58513. * Back compatibility with callback before the onDisposeObservable existed.
  58514. * The set callback will be triggered when the layer has been disposed.
  58515. */
  58516. set onDispose(callback: () => void);
  58517. /**
  58518. * An event triggered before rendering the scene
  58519. */
  58520. onBeforeRenderObservable: Observable<Layer>;
  58521. private _onBeforeRenderObserver;
  58522. /**
  58523. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58524. * The set callback will be triggered just before rendering the layer.
  58525. */
  58526. set onBeforeRender(callback: () => void);
  58527. /**
  58528. * An event triggered after rendering the scene
  58529. */
  58530. onAfterRenderObservable: Observable<Layer>;
  58531. private _onAfterRenderObserver;
  58532. /**
  58533. * Back compatibility with callback before the onAfterRenderObservable existed.
  58534. * The set callback will be triggered just after rendering the layer.
  58535. */
  58536. set onAfterRender(callback: () => void);
  58537. /**
  58538. * Instantiates a new layer.
  58539. * This represents a full screen 2d layer.
  58540. * This can be useful to display a picture in the background of your scene for instance.
  58541. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58542. * @param name Define the name of the layer in the scene
  58543. * @param imgUrl Define the url of the texture to display in the layer
  58544. * @param scene Define the scene the layer belongs to
  58545. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58546. * @param color Defines a color for the layer
  58547. */
  58548. constructor(
  58549. /**
  58550. * Define the name of the layer.
  58551. */
  58552. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58553. private _createIndexBuffer;
  58554. /** @hidden */
  58555. _rebuild(): void;
  58556. /**
  58557. * Renders the layer in the scene.
  58558. */
  58559. render(): void;
  58560. /**
  58561. * Disposes and releases the associated ressources.
  58562. */
  58563. dispose(): void;
  58564. }
  58565. }
  58566. declare module BABYLON {
  58567. /** @hidden */
  58568. export var lensFlarePixelShader: {
  58569. name: string;
  58570. shader: string;
  58571. };
  58572. }
  58573. declare module BABYLON {
  58574. /** @hidden */
  58575. export var lensFlareVertexShader: {
  58576. name: string;
  58577. shader: string;
  58578. };
  58579. }
  58580. declare module BABYLON {
  58581. /**
  58582. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58583. * It is usually composed of several `lensFlare`.
  58584. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58585. */
  58586. export class LensFlareSystem {
  58587. /**
  58588. * Define the name of the lens flare system
  58589. */
  58590. name: string;
  58591. /**
  58592. * List of lens flares used in this system.
  58593. */
  58594. lensFlares: LensFlare[];
  58595. /**
  58596. * Define a limit from the border the lens flare can be visible.
  58597. */
  58598. borderLimit: number;
  58599. /**
  58600. * Define a viewport border we do not want to see the lens flare in.
  58601. */
  58602. viewportBorder: number;
  58603. /**
  58604. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58605. */
  58606. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58607. /**
  58608. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58609. */
  58610. layerMask: number;
  58611. /**
  58612. * Define the id of the lens flare system in the scene.
  58613. * (equal to name by default)
  58614. */
  58615. id: string;
  58616. private _scene;
  58617. private _emitter;
  58618. private _vertexBuffers;
  58619. private _indexBuffer;
  58620. private _effect;
  58621. private _positionX;
  58622. private _positionY;
  58623. private _isEnabled;
  58624. /** @hidden */
  58625. static _SceneComponentInitialization: (scene: Scene) => void;
  58626. /**
  58627. * Instantiates a lens flare system.
  58628. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58629. * It is usually composed of several `lensFlare`.
  58630. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58631. * @param name Define the name of the lens flare system in the scene
  58632. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58633. * @param scene Define the scene the lens flare system belongs to
  58634. */
  58635. constructor(
  58636. /**
  58637. * Define the name of the lens flare system
  58638. */
  58639. name: string, emitter: any, scene: Scene);
  58640. /**
  58641. * Define if the lens flare system is enabled.
  58642. */
  58643. get isEnabled(): boolean;
  58644. set isEnabled(value: boolean);
  58645. /**
  58646. * Get the scene the effects belongs to.
  58647. * @returns the scene holding the lens flare system
  58648. */
  58649. getScene(): Scene;
  58650. /**
  58651. * Get the emitter of the lens flare system.
  58652. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58653. * @returns the emitter of the lens flare system
  58654. */
  58655. getEmitter(): any;
  58656. /**
  58657. * Set the emitter of the lens flare system.
  58658. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58659. * @param newEmitter Define the new emitter of the system
  58660. */
  58661. setEmitter(newEmitter: any): void;
  58662. /**
  58663. * Get the lens flare system emitter position.
  58664. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58665. * @returns the position
  58666. */
  58667. getEmitterPosition(): Vector3;
  58668. /**
  58669. * @hidden
  58670. */
  58671. computeEffectivePosition(globalViewport: Viewport): boolean;
  58672. /** @hidden */
  58673. _isVisible(): boolean;
  58674. /**
  58675. * @hidden
  58676. */
  58677. render(): boolean;
  58678. /**
  58679. * Dispose and release the lens flare with its associated resources.
  58680. */
  58681. dispose(): void;
  58682. /**
  58683. * Parse a lens flare system from a JSON repressentation
  58684. * @param parsedLensFlareSystem Define the JSON to parse
  58685. * @param scene Define the scene the parsed system should be instantiated in
  58686. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58687. * @returns the parsed system
  58688. */
  58689. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58690. /**
  58691. * Serialize the current Lens Flare System into a JSON representation.
  58692. * @returns the serialized JSON
  58693. */
  58694. serialize(): any;
  58695. }
  58696. }
  58697. declare module BABYLON {
  58698. /**
  58699. * This represents one of the lens effect in a `lensFlareSystem`.
  58700. * It controls one of the indiviual texture used in the effect.
  58701. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58702. */
  58703. export class LensFlare {
  58704. /**
  58705. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58706. */
  58707. size: number;
  58708. /**
  58709. * 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.
  58710. */
  58711. position: number;
  58712. /**
  58713. * Define the lens color.
  58714. */
  58715. color: Color3;
  58716. /**
  58717. * Define the lens texture.
  58718. */
  58719. texture: Nullable<Texture>;
  58720. /**
  58721. * Define the alpha mode to render this particular lens.
  58722. */
  58723. alphaMode: number;
  58724. private _system;
  58725. /**
  58726. * Creates a new Lens Flare.
  58727. * This represents one of the lens effect in a `lensFlareSystem`.
  58728. * It controls one of the indiviual texture used in the effect.
  58729. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58730. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58731. * @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.
  58732. * @param color Define the lens color
  58733. * @param imgUrl Define the lens texture url
  58734. * @param system Define the `lensFlareSystem` this flare is part of
  58735. * @returns The newly created Lens Flare
  58736. */
  58737. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58738. /**
  58739. * Instantiates a new Lens Flare.
  58740. * This represents one of the lens effect in a `lensFlareSystem`.
  58741. * It controls one of the indiviual texture used in the effect.
  58742. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58743. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58744. * @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.
  58745. * @param color Define the lens color
  58746. * @param imgUrl Define the lens texture url
  58747. * @param system Define the `lensFlareSystem` this flare is part of
  58748. */
  58749. constructor(
  58750. /**
  58751. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58752. */
  58753. size: number,
  58754. /**
  58755. * 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.
  58756. */
  58757. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58758. /**
  58759. * Dispose and release the lens flare with its associated resources.
  58760. */
  58761. dispose(): void;
  58762. }
  58763. }
  58764. declare module BABYLON {
  58765. interface AbstractScene {
  58766. /**
  58767. * The list of lens flare system added to the scene
  58768. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58769. */
  58770. lensFlareSystems: Array<LensFlareSystem>;
  58771. /**
  58772. * Removes the given lens flare system from this scene.
  58773. * @param toRemove The lens flare system to remove
  58774. * @returns The index of the removed lens flare system
  58775. */
  58776. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58777. /**
  58778. * Adds the given lens flare system to this scene
  58779. * @param newLensFlareSystem The lens flare system to add
  58780. */
  58781. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58782. /**
  58783. * Gets a lens flare system using its name
  58784. * @param name defines the name to look for
  58785. * @returns the lens flare system or null if not found
  58786. */
  58787. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58788. /**
  58789. * Gets a lens flare system using its id
  58790. * @param id defines the id to look for
  58791. * @returns the lens flare system or null if not found
  58792. */
  58793. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58794. }
  58795. /**
  58796. * Defines the lens flare scene component responsible to manage any lens flares
  58797. * in a given scene.
  58798. */
  58799. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58800. /**
  58801. * The component name helpfull to identify the component in the list of scene components.
  58802. */
  58803. readonly name: string;
  58804. /**
  58805. * The scene the component belongs to.
  58806. */
  58807. scene: Scene;
  58808. /**
  58809. * Creates a new instance of the component for the given scene
  58810. * @param scene Defines the scene to register the component in
  58811. */
  58812. constructor(scene: Scene);
  58813. /**
  58814. * Registers the component in a given scene
  58815. */
  58816. register(): void;
  58817. /**
  58818. * Rebuilds the elements related to this component in case of
  58819. * context lost for instance.
  58820. */
  58821. rebuild(): void;
  58822. /**
  58823. * Adds all the elements from the container to the scene
  58824. * @param container the container holding the elements
  58825. */
  58826. addFromContainer(container: AbstractScene): void;
  58827. /**
  58828. * Removes all the elements in the container from the scene
  58829. * @param container contains the elements to remove
  58830. * @param dispose if the removed element should be disposed (default: false)
  58831. */
  58832. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58833. /**
  58834. * Serializes the component data to the specified json object
  58835. * @param serializationObject The object to serialize to
  58836. */
  58837. serialize(serializationObject: any): void;
  58838. /**
  58839. * Disposes the component and the associated ressources.
  58840. */
  58841. dispose(): void;
  58842. private _draw;
  58843. }
  58844. }
  58845. declare module BABYLON {
  58846. /** @hidden */
  58847. export var depthPixelShader: {
  58848. name: string;
  58849. shader: string;
  58850. };
  58851. }
  58852. declare module BABYLON {
  58853. /** @hidden */
  58854. export var depthVertexShader: {
  58855. name: string;
  58856. shader: string;
  58857. };
  58858. }
  58859. declare module BABYLON {
  58860. /**
  58861. * This represents a depth renderer in Babylon.
  58862. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58863. */
  58864. export class DepthRenderer {
  58865. private _scene;
  58866. private _depthMap;
  58867. private _effect;
  58868. private readonly _storeNonLinearDepth;
  58869. private readonly _clearColor;
  58870. /** Get if the depth renderer is using packed depth or not */
  58871. readonly isPacked: boolean;
  58872. private _cachedDefines;
  58873. private _camera;
  58874. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58875. enabled: boolean;
  58876. /**
  58877. * Specifiess that the depth renderer will only be used within
  58878. * the camera it is created for.
  58879. * This can help forcing its rendering during the camera processing.
  58880. */
  58881. useOnlyInActiveCamera: boolean;
  58882. /** @hidden */
  58883. static _SceneComponentInitialization: (scene: Scene) => void;
  58884. /**
  58885. * Instantiates a depth renderer
  58886. * @param scene The scene the renderer belongs to
  58887. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58888. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58889. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58890. */
  58891. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58892. /**
  58893. * Creates the depth rendering effect and checks if the effect is ready.
  58894. * @param subMesh The submesh to be used to render the depth map of
  58895. * @param useInstances If multiple world instances should be used
  58896. * @returns if the depth renderer is ready to render the depth map
  58897. */
  58898. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58899. /**
  58900. * Gets the texture which the depth map will be written to.
  58901. * @returns The depth map texture
  58902. */
  58903. getDepthMap(): RenderTargetTexture;
  58904. /**
  58905. * Disposes of the depth renderer.
  58906. */
  58907. dispose(): void;
  58908. }
  58909. }
  58910. declare module BABYLON {
  58911. /** @hidden */
  58912. export var minmaxReduxPixelShader: {
  58913. name: string;
  58914. shader: string;
  58915. };
  58916. }
  58917. declare module BABYLON {
  58918. /**
  58919. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58920. * and maximum values from all values of the texture.
  58921. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58922. * The source values are read from the red channel of the texture.
  58923. */
  58924. export class MinMaxReducer {
  58925. /**
  58926. * Observable triggered when the computation has been performed
  58927. */
  58928. onAfterReductionPerformed: Observable<{
  58929. min: number;
  58930. max: number;
  58931. }>;
  58932. protected _camera: Camera;
  58933. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58934. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58935. protected _postProcessManager: PostProcessManager;
  58936. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58937. protected _forceFullscreenViewport: boolean;
  58938. /**
  58939. * Creates a min/max reducer
  58940. * @param camera The camera to use for the post processes
  58941. */
  58942. constructor(camera: Camera);
  58943. /**
  58944. * Gets the texture used to read the values from.
  58945. */
  58946. get sourceTexture(): Nullable<RenderTargetTexture>;
  58947. /**
  58948. * Sets the source texture to read the values from.
  58949. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58950. * because in such textures '1' value must not be taken into account to compute the maximum
  58951. * as this value is used to clear the texture.
  58952. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58953. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58954. * @param depthRedux Indicates if the texture is a depth texture or not
  58955. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58956. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58957. */
  58958. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58959. /**
  58960. * Defines the refresh rate of the computation.
  58961. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58962. */
  58963. get refreshRate(): number;
  58964. set refreshRate(value: number);
  58965. protected _activated: boolean;
  58966. /**
  58967. * Gets the activation status of the reducer
  58968. */
  58969. get activated(): boolean;
  58970. /**
  58971. * Activates the reduction computation.
  58972. * When activated, the observers registered in onAfterReductionPerformed are
  58973. * called after the compuation is performed
  58974. */
  58975. activate(): void;
  58976. /**
  58977. * Deactivates the reduction computation.
  58978. */
  58979. deactivate(): void;
  58980. /**
  58981. * Disposes the min/max reducer
  58982. * @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.
  58983. */
  58984. dispose(disposeAll?: boolean): void;
  58985. }
  58986. }
  58987. declare module BABYLON {
  58988. /**
  58989. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58990. */
  58991. export class DepthReducer extends MinMaxReducer {
  58992. private _depthRenderer;
  58993. private _depthRendererId;
  58994. /**
  58995. * Gets the depth renderer used for the computation.
  58996. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58997. */
  58998. get depthRenderer(): Nullable<DepthRenderer>;
  58999. /**
  59000. * Creates a depth reducer
  59001. * @param camera The camera used to render the depth texture
  59002. */
  59003. constructor(camera: Camera);
  59004. /**
  59005. * Sets the depth renderer to use to generate the depth map
  59006. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59007. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59008. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59009. */
  59010. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59011. /** @hidden */
  59012. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59013. /**
  59014. * Activates the reduction computation.
  59015. * When activated, the observers registered in onAfterReductionPerformed are
  59016. * called after the compuation is performed
  59017. */
  59018. activate(): void;
  59019. /**
  59020. * Deactivates the reduction computation.
  59021. */
  59022. deactivate(): void;
  59023. /**
  59024. * Disposes the depth reducer
  59025. * @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.
  59026. */
  59027. dispose(disposeAll?: boolean): void;
  59028. }
  59029. }
  59030. declare module BABYLON {
  59031. /**
  59032. * A CSM implementation allowing casting shadows on large scenes.
  59033. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59034. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59035. */
  59036. export class CascadedShadowGenerator extends ShadowGenerator {
  59037. private static readonly frustumCornersNDCSpace;
  59038. /**
  59039. * Name of the CSM class
  59040. */
  59041. static CLASSNAME: string;
  59042. /**
  59043. * Defines the default number of cascades used by the CSM.
  59044. */
  59045. static readonly DEFAULT_CASCADES_COUNT: number;
  59046. /**
  59047. * Defines the minimum number of cascades used by the CSM.
  59048. */
  59049. static readonly MIN_CASCADES_COUNT: number;
  59050. /**
  59051. * Defines the maximum number of cascades used by the CSM.
  59052. */
  59053. static readonly MAX_CASCADES_COUNT: number;
  59054. protected _validateFilter(filter: number): number;
  59055. /**
  59056. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59057. */
  59058. penumbraDarkness: number;
  59059. private _numCascades;
  59060. /**
  59061. * Gets or set the number of cascades used by the CSM.
  59062. */
  59063. get numCascades(): number;
  59064. set numCascades(value: number);
  59065. /**
  59066. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59067. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59068. */
  59069. stabilizeCascades: boolean;
  59070. private _freezeShadowCastersBoundingInfo;
  59071. private _freezeShadowCastersBoundingInfoObservable;
  59072. /**
  59073. * Enables or disables the shadow casters bounding info computation.
  59074. * If your shadow casters don't move, you can disable this feature.
  59075. * If it is enabled, the bounding box computation is done every frame.
  59076. */
  59077. get freezeShadowCastersBoundingInfo(): boolean;
  59078. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59079. private _scbiMin;
  59080. private _scbiMax;
  59081. protected _computeShadowCastersBoundingInfo(): void;
  59082. protected _shadowCastersBoundingInfo: BoundingInfo;
  59083. /**
  59084. * Gets or sets the shadow casters bounding info.
  59085. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59086. * so that the system won't overwrite the bounds you provide
  59087. */
  59088. get shadowCastersBoundingInfo(): BoundingInfo;
  59089. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59090. protected _breaksAreDirty: boolean;
  59091. protected _minDistance: number;
  59092. protected _maxDistance: number;
  59093. /**
  59094. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59095. *
  59096. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59097. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59098. * @param min minimal distance for the breaks (default to 0.)
  59099. * @param max maximal distance for the breaks (default to 1.)
  59100. */
  59101. setMinMaxDistance(min: number, max: number): void;
  59102. /** Gets the minimal distance used in the cascade break computation */
  59103. get minDistance(): number;
  59104. /** Gets the maximal distance used in the cascade break computation */
  59105. get maxDistance(): number;
  59106. /**
  59107. * Gets the class name of that object
  59108. * @returns "CascadedShadowGenerator"
  59109. */
  59110. getClassName(): string;
  59111. private _cascadeMinExtents;
  59112. private _cascadeMaxExtents;
  59113. /**
  59114. * Gets a cascade minimum extents
  59115. * @param cascadeIndex index of the cascade
  59116. * @returns the minimum cascade extents
  59117. */
  59118. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59119. /**
  59120. * Gets a cascade maximum extents
  59121. * @param cascadeIndex index of the cascade
  59122. * @returns the maximum cascade extents
  59123. */
  59124. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59125. private _cascades;
  59126. private _currentLayer;
  59127. private _viewSpaceFrustumsZ;
  59128. private _viewMatrices;
  59129. private _projectionMatrices;
  59130. private _transformMatrices;
  59131. private _transformMatricesAsArray;
  59132. private _frustumLengths;
  59133. private _lightSizeUVCorrection;
  59134. private _depthCorrection;
  59135. private _frustumCornersWorldSpace;
  59136. private _frustumCenter;
  59137. private _shadowCameraPos;
  59138. private _shadowMaxZ;
  59139. /**
  59140. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59141. * It defaults to camera.maxZ
  59142. */
  59143. get shadowMaxZ(): number;
  59144. /**
  59145. * Sets the shadow max z distance.
  59146. */
  59147. set shadowMaxZ(value: number);
  59148. protected _debug: boolean;
  59149. /**
  59150. * Gets or sets the debug flag.
  59151. * When enabled, the cascades are materialized by different colors on the screen.
  59152. */
  59153. get debug(): boolean;
  59154. set debug(dbg: boolean);
  59155. private _depthClamp;
  59156. /**
  59157. * Gets or sets the depth clamping value.
  59158. *
  59159. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59160. * to account for the shadow casters far away.
  59161. *
  59162. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59163. */
  59164. get depthClamp(): boolean;
  59165. set depthClamp(value: boolean);
  59166. private _cascadeBlendPercentage;
  59167. /**
  59168. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59169. * It defaults to 0.1 (10% blending).
  59170. */
  59171. get cascadeBlendPercentage(): number;
  59172. set cascadeBlendPercentage(value: number);
  59173. private _lambda;
  59174. /**
  59175. * Gets or set the lambda parameter.
  59176. * This parameter is used to split the camera frustum and create the cascades.
  59177. * 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.
  59178. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59179. */
  59180. get lambda(): number;
  59181. set lambda(value: number);
  59182. /**
  59183. * Gets the view matrix corresponding to a given cascade
  59184. * @param cascadeNum cascade to retrieve the view matrix from
  59185. * @returns the cascade view matrix
  59186. */
  59187. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59188. /**
  59189. * Gets the projection matrix corresponding to a given cascade
  59190. * @param cascadeNum cascade to retrieve the projection matrix from
  59191. * @returns the cascade projection matrix
  59192. */
  59193. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59194. /**
  59195. * Gets the transformation matrix corresponding to a given cascade
  59196. * @param cascadeNum cascade to retrieve the transformation matrix from
  59197. * @returns the cascade transformation matrix
  59198. */
  59199. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59200. private _depthRenderer;
  59201. /**
  59202. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59203. *
  59204. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59205. *
  59206. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59207. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59208. * @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
  59209. */
  59210. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59211. private _depthReducer;
  59212. private _autoCalcDepthBounds;
  59213. /**
  59214. * Gets or sets the autoCalcDepthBounds property.
  59215. *
  59216. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59217. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59218. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59219. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59220. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59221. */
  59222. get autoCalcDepthBounds(): boolean;
  59223. set autoCalcDepthBounds(value: boolean);
  59224. /**
  59225. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59226. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59227. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59228. * for setting the refresh rate on the renderer yourself!
  59229. */
  59230. get autoCalcDepthBoundsRefreshRate(): number;
  59231. set autoCalcDepthBoundsRefreshRate(value: number);
  59232. /**
  59233. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59234. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59235. * you change the camera near/far planes!
  59236. */
  59237. splitFrustum(): void;
  59238. private _splitFrustum;
  59239. private _computeMatrices;
  59240. private _computeFrustumInWorldSpace;
  59241. private _computeCascadeFrustum;
  59242. /**
  59243. * Support test.
  59244. */
  59245. static get IsSupported(): boolean;
  59246. /** @hidden */
  59247. static _SceneComponentInitialization: (scene: Scene) => void;
  59248. /**
  59249. * Creates a Cascaded Shadow Generator object.
  59250. * A ShadowGenerator is the required tool to use the shadows.
  59251. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59252. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59253. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59254. * @param light The directional light object generating the shadows.
  59255. * @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.
  59256. */
  59257. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59258. protected _initializeGenerator(): void;
  59259. protected _createTargetRenderTexture(): void;
  59260. protected _initializeShadowMap(): void;
  59261. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59262. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59263. /**
  59264. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59265. * @param defines Defines of the material we want to update
  59266. * @param lightIndex Index of the light in the enabled light list of the material
  59267. */
  59268. prepareDefines(defines: any, lightIndex: number): void;
  59269. /**
  59270. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59271. * defined in the generator but impacting the effect).
  59272. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59273. * @param effect The effect we are binfing the information for
  59274. */
  59275. bindShadowLight(lightIndex: string, effect: Effect): void;
  59276. /**
  59277. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59278. * (eq to view projection * shadow projection matrices)
  59279. * @returns The transform matrix used to create the shadow map
  59280. */
  59281. getTransformMatrix(): Matrix;
  59282. /**
  59283. * Disposes the ShadowGenerator.
  59284. * Returns nothing.
  59285. */
  59286. dispose(): void;
  59287. /**
  59288. * Serializes the shadow generator setup to a json object.
  59289. * @returns The serialized JSON object
  59290. */
  59291. serialize(): any;
  59292. /**
  59293. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59294. * @param parsedShadowGenerator The JSON object to parse
  59295. * @param scene The scene to create the shadow map for
  59296. * @returns The parsed shadow generator
  59297. */
  59298. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59299. }
  59300. }
  59301. declare module BABYLON {
  59302. /**
  59303. * Defines the shadow generator component responsible to manage any shadow generators
  59304. * in a given scene.
  59305. */
  59306. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59307. /**
  59308. * The component name helpfull to identify the component in the list of scene components.
  59309. */
  59310. readonly name: string;
  59311. /**
  59312. * The scene the component belongs to.
  59313. */
  59314. scene: Scene;
  59315. /**
  59316. * Creates a new instance of the component for the given scene
  59317. * @param scene Defines the scene to register the component in
  59318. */
  59319. constructor(scene: Scene);
  59320. /**
  59321. * Registers the component in a given scene
  59322. */
  59323. register(): void;
  59324. /**
  59325. * Rebuilds the elements related to this component in case of
  59326. * context lost for instance.
  59327. */
  59328. rebuild(): void;
  59329. /**
  59330. * Serializes the component data to the specified json object
  59331. * @param serializationObject The object to serialize to
  59332. */
  59333. serialize(serializationObject: any): void;
  59334. /**
  59335. * Adds all the elements from the container to the scene
  59336. * @param container the container holding the elements
  59337. */
  59338. addFromContainer(container: AbstractScene): void;
  59339. /**
  59340. * Removes all the elements in the container from the scene
  59341. * @param container contains the elements to remove
  59342. * @param dispose if the removed element should be disposed (default: false)
  59343. */
  59344. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59345. /**
  59346. * Rebuilds the elements related to this component in case of
  59347. * context lost for instance.
  59348. */
  59349. dispose(): void;
  59350. private _gatherRenderTargets;
  59351. }
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * A point light is a light defined by an unique point in world space.
  59356. * The light is emitted in every direction from this point.
  59357. * A good example of a point light is a standard light bulb.
  59358. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59359. */
  59360. export class PointLight extends ShadowLight {
  59361. private _shadowAngle;
  59362. /**
  59363. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59364. * This specifies what angle the shadow will use to be created.
  59365. *
  59366. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59367. */
  59368. get shadowAngle(): number;
  59369. /**
  59370. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59371. * This specifies what angle the shadow will use to be created.
  59372. *
  59373. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59374. */
  59375. set shadowAngle(value: number);
  59376. /**
  59377. * Gets the direction if it has been set.
  59378. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59379. */
  59380. get direction(): Vector3;
  59381. /**
  59382. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59383. */
  59384. set direction(value: Vector3);
  59385. /**
  59386. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59387. * A PointLight emits the light in every direction.
  59388. * It can cast shadows.
  59389. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59390. * ```javascript
  59391. * var pointLight = new PointLight("pl", camera.position, scene);
  59392. * ```
  59393. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59394. * @param name The light friendly name
  59395. * @param position The position of the point light in the scene
  59396. * @param scene The scene the lights belongs to
  59397. */
  59398. constructor(name: string, position: Vector3, scene: Scene);
  59399. /**
  59400. * Returns the string "PointLight"
  59401. * @returns the class name
  59402. */
  59403. getClassName(): string;
  59404. /**
  59405. * Returns the integer 0.
  59406. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59407. */
  59408. getTypeID(): number;
  59409. /**
  59410. * Specifies wether or not the shadowmap should be a cube texture.
  59411. * @returns true if the shadowmap needs to be a cube texture.
  59412. */
  59413. needCube(): boolean;
  59414. /**
  59415. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59416. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59417. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59418. */
  59419. getShadowDirection(faceIndex?: number): Vector3;
  59420. /**
  59421. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59422. * - fov = PI / 2
  59423. * - aspect ratio : 1.0
  59424. * - z-near and far equal to the active camera minZ and maxZ.
  59425. * Returns the PointLight.
  59426. */
  59427. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59428. protected _buildUniformLayout(): void;
  59429. /**
  59430. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59431. * @param effect The effect to update
  59432. * @param lightIndex The index of the light in the effect to update
  59433. * @returns The point light
  59434. */
  59435. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59436. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59437. /**
  59438. * Prepares the list of defines specific to the light type.
  59439. * @param defines the list of defines
  59440. * @param lightIndex defines the index of the light for the effect
  59441. */
  59442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59443. }
  59444. }
  59445. declare module BABYLON {
  59446. /**
  59447. * Header information of HDR texture files.
  59448. */
  59449. export interface HDRInfo {
  59450. /**
  59451. * The height of the texture in pixels.
  59452. */
  59453. height: number;
  59454. /**
  59455. * The width of the texture in pixels.
  59456. */
  59457. width: number;
  59458. /**
  59459. * The index of the beginning of the data in the binary file.
  59460. */
  59461. dataPosition: number;
  59462. }
  59463. /**
  59464. * This groups tools to convert HDR texture to native colors array.
  59465. */
  59466. export class HDRTools {
  59467. private static Ldexp;
  59468. private static Rgbe2float;
  59469. private static readStringLine;
  59470. /**
  59471. * Reads header information from an RGBE texture stored in a native array.
  59472. * More information on this format are available here:
  59473. * https://en.wikipedia.org/wiki/RGBE_image_format
  59474. *
  59475. * @param uint8array The binary file stored in native array.
  59476. * @return The header information.
  59477. */
  59478. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59479. /**
  59480. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59481. * This RGBE texture needs to store the information as a panorama.
  59482. *
  59483. * More information on this format are available here:
  59484. * https://en.wikipedia.org/wiki/RGBE_image_format
  59485. *
  59486. * @param buffer The binary file stored in an array buffer.
  59487. * @param size The expected size of the extracted cubemap.
  59488. * @return The Cube Map information.
  59489. */
  59490. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59491. /**
  59492. * Returns the pixels data extracted from an RGBE texture.
  59493. * This pixels will be stored left to right up to down in the R G B order in one array.
  59494. *
  59495. * More information on this format are available here:
  59496. * https://en.wikipedia.org/wiki/RGBE_image_format
  59497. *
  59498. * @param uint8array The binary file stored in an array buffer.
  59499. * @param hdrInfo The header information of the file.
  59500. * @return The pixels data in RGB right to left up to down order.
  59501. */
  59502. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59503. private static RGBE_ReadPixels_RLE;
  59504. private static RGBE_ReadPixels_NOT_RLE;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /**
  59509. * Effect Render Options
  59510. */
  59511. export interface IEffectRendererOptions {
  59512. /**
  59513. * Defines the vertices positions.
  59514. */
  59515. positions?: number[];
  59516. /**
  59517. * Defines the indices.
  59518. */
  59519. indices?: number[];
  59520. }
  59521. /**
  59522. * Helper class to render one or more effects.
  59523. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59524. */
  59525. export class EffectRenderer {
  59526. private engine;
  59527. private static _DefaultOptions;
  59528. private _vertexBuffers;
  59529. private _indexBuffer;
  59530. private _fullscreenViewport;
  59531. /**
  59532. * Creates an effect renderer
  59533. * @param engine the engine to use for rendering
  59534. * @param options defines the options of the effect renderer
  59535. */
  59536. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59537. /**
  59538. * Sets the current viewport in normalized coordinates 0-1
  59539. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59540. */
  59541. setViewport(viewport?: Viewport): void;
  59542. /**
  59543. * Binds the embedded attributes buffer to the effect.
  59544. * @param effect Defines the effect to bind the attributes for
  59545. */
  59546. bindBuffers(effect: Effect): void;
  59547. /**
  59548. * Sets the current effect wrapper to use during draw.
  59549. * The effect needs to be ready before calling this api.
  59550. * This also sets the default full screen position attribute.
  59551. * @param effectWrapper Defines the effect to draw with
  59552. */
  59553. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59554. /**
  59555. * Restores engine states
  59556. */
  59557. restoreStates(): void;
  59558. /**
  59559. * Draws a full screen quad.
  59560. */
  59561. draw(): void;
  59562. private isRenderTargetTexture;
  59563. /**
  59564. * renders one or more effects to a specified texture
  59565. * @param effectWrapper the effect to renderer
  59566. * @param outputTexture texture to draw to, if null it will render to the screen.
  59567. */
  59568. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59569. /**
  59570. * Disposes of the effect renderer
  59571. */
  59572. dispose(): void;
  59573. }
  59574. /**
  59575. * Options to create an EffectWrapper
  59576. */
  59577. interface EffectWrapperCreationOptions {
  59578. /**
  59579. * Engine to use to create the effect
  59580. */
  59581. engine: ThinEngine;
  59582. /**
  59583. * Fragment shader for the effect
  59584. */
  59585. fragmentShader: string;
  59586. /**
  59587. * Use the shader store instead of direct source code
  59588. */
  59589. useShaderStore?: boolean;
  59590. /**
  59591. * Vertex shader for the effect
  59592. */
  59593. vertexShader?: string;
  59594. /**
  59595. * Attributes to use in the shader
  59596. */
  59597. attributeNames?: Array<string>;
  59598. /**
  59599. * Uniforms to use in the shader
  59600. */
  59601. uniformNames?: Array<string>;
  59602. /**
  59603. * Texture sampler names to use in the shader
  59604. */
  59605. samplerNames?: Array<string>;
  59606. /**
  59607. * Defines to use in the shader
  59608. */
  59609. defines?: Array<string>;
  59610. /**
  59611. * Callback when effect is compiled
  59612. */
  59613. onCompiled?: Nullable<(effect: Effect) => void>;
  59614. /**
  59615. * The friendly name of the effect displayed in Spector.
  59616. */
  59617. name?: string;
  59618. }
  59619. /**
  59620. * Wraps an effect to be used for rendering
  59621. */
  59622. export class EffectWrapper {
  59623. /**
  59624. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59625. */
  59626. onApplyObservable: Observable<{}>;
  59627. /**
  59628. * The underlying effect
  59629. */
  59630. effect: Effect;
  59631. /**
  59632. * Creates an effect to be renderer
  59633. * @param creationOptions options to create the effect
  59634. */
  59635. constructor(creationOptions: EffectWrapperCreationOptions);
  59636. /**
  59637. * Disposes of the effect wrapper
  59638. */
  59639. dispose(): void;
  59640. }
  59641. }
  59642. declare module BABYLON {
  59643. /** @hidden */
  59644. export var hdrFilteringVertexShader: {
  59645. name: string;
  59646. shader: string;
  59647. };
  59648. }
  59649. declare module BABYLON {
  59650. /** @hidden */
  59651. export var hdrFilteringPixelShader: {
  59652. name: string;
  59653. shader: string;
  59654. };
  59655. }
  59656. declare module BABYLON {
  59657. /**
  59658. * Options for texture filtering
  59659. */
  59660. interface IHDRFilteringOptions {
  59661. /**
  59662. * Scales pixel intensity for the input HDR map.
  59663. */
  59664. hdrScale?: number;
  59665. /**
  59666. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59667. */
  59668. quality?: number;
  59669. }
  59670. /**
  59671. * Filters HDR maps to get correct renderings of PBR reflections
  59672. */
  59673. export class HDRFiltering {
  59674. private _engine;
  59675. private _effectRenderer;
  59676. private _effectWrapper;
  59677. private _lodGenerationOffset;
  59678. private _lodGenerationScale;
  59679. /**
  59680. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59681. * you care about baking speed.
  59682. */
  59683. quality: number;
  59684. /**
  59685. * Scales pixel intensity for the input HDR map.
  59686. */
  59687. hdrScale: number;
  59688. /**
  59689. * Instantiates HDR filter for reflection maps
  59690. *
  59691. * @param engine Thin engine
  59692. * @param options Options
  59693. */
  59694. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59695. private _createRenderTarget;
  59696. private _prefilterInternal;
  59697. private _createEffect;
  59698. /**
  59699. * Get a value indicating if the filter is ready to be used
  59700. * @param texture Texture to filter
  59701. * @returns true if the filter is ready
  59702. */
  59703. isReady(texture: BaseTexture): boolean;
  59704. /**
  59705. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59706. * Prefiltering will be invoked at the end of next rendering pass.
  59707. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59708. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59709. * @param texture Texture to filter
  59710. * @param onFinished Callback when filtering is done
  59711. * @return Promise called when prefiltering is done
  59712. */
  59713. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59714. }
  59715. }
  59716. declare module BABYLON {
  59717. /**
  59718. * This represents a texture coming from an HDR input.
  59719. *
  59720. * The only supported format is currently panorama picture stored in RGBE format.
  59721. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59722. */
  59723. export class HDRCubeTexture extends BaseTexture {
  59724. private static _facesMapping;
  59725. private _generateHarmonics;
  59726. private _noMipmap;
  59727. private _prefilterOnLoad;
  59728. private _textureMatrix;
  59729. private _size;
  59730. private _onLoad;
  59731. private _onError;
  59732. /**
  59733. * The texture URL.
  59734. */
  59735. url: string;
  59736. /**
  59737. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59738. */
  59739. coordinatesMode: number;
  59740. protected _isBlocking: boolean;
  59741. /**
  59742. * Sets wether or not the texture is blocking during loading.
  59743. */
  59744. set isBlocking(value: boolean);
  59745. /**
  59746. * Gets wether or not the texture is blocking during loading.
  59747. */
  59748. get isBlocking(): boolean;
  59749. protected _rotationY: number;
  59750. /**
  59751. * Sets texture matrix rotation angle around Y axis in radians.
  59752. */
  59753. set rotationY(value: number);
  59754. /**
  59755. * Gets texture matrix rotation angle around Y axis radians.
  59756. */
  59757. get rotationY(): number;
  59758. /**
  59759. * Gets or sets the center of the bounding box associated with the cube texture
  59760. * It must define where the camera used to render the texture was set
  59761. */
  59762. boundingBoxPosition: Vector3;
  59763. private _boundingBoxSize;
  59764. /**
  59765. * Gets or sets the size of the bounding box associated with the cube texture
  59766. * When defined, the cubemap will switch to local mode
  59767. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59768. * @example https://www.babylonjs-playground.com/#RNASML
  59769. */
  59770. set boundingBoxSize(value: Vector3);
  59771. get boundingBoxSize(): Vector3;
  59772. /**
  59773. * Instantiates an HDRTexture from the following parameters.
  59774. *
  59775. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59776. * @param sceneOrEngine The scene or engine the texture will be used in
  59777. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59778. * @param noMipmap Forces to not generate the mipmap if true
  59779. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59780. * @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)
  59781. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59782. */
  59783. 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>);
  59784. /**
  59785. * Get the current class name of the texture useful for serialization or dynamic coding.
  59786. * @returns "HDRCubeTexture"
  59787. */
  59788. getClassName(): string;
  59789. /**
  59790. * Occurs when the file is raw .hdr file.
  59791. */
  59792. private loadTexture;
  59793. clone(): HDRCubeTexture;
  59794. delayLoad(): void;
  59795. /**
  59796. * Get the texture reflection matrix used to rotate/transform the reflection.
  59797. * @returns the reflection matrix
  59798. */
  59799. getReflectionTextureMatrix(): Matrix;
  59800. /**
  59801. * Set the texture reflection matrix used to rotate/transform the reflection.
  59802. * @param value Define the reflection matrix to set
  59803. */
  59804. setReflectionTextureMatrix(value: Matrix): void;
  59805. /**
  59806. * Parses a JSON representation of an HDR Texture in order to create the texture
  59807. * @param parsedTexture Define the JSON representation
  59808. * @param scene Define the scene the texture should be created in
  59809. * @param rootUrl Define the root url in case we need to load relative dependencies
  59810. * @returns the newly created texture after parsing
  59811. */
  59812. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59813. serialize(): any;
  59814. }
  59815. }
  59816. declare module BABYLON {
  59817. /**
  59818. * Class used to control physics engine
  59819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59820. */
  59821. export class PhysicsEngine implements IPhysicsEngine {
  59822. private _physicsPlugin;
  59823. /**
  59824. * Global value used to control the smallest number supported by the simulation
  59825. */
  59826. static Epsilon: number;
  59827. private _impostors;
  59828. private _joints;
  59829. private _subTimeStep;
  59830. /**
  59831. * Gets the gravity vector used by the simulation
  59832. */
  59833. gravity: Vector3;
  59834. /**
  59835. * Factory used to create the default physics plugin.
  59836. * @returns The default physics plugin
  59837. */
  59838. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59839. /**
  59840. * Creates a new Physics Engine
  59841. * @param gravity defines the gravity vector used by the simulation
  59842. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59843. */
  59844. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59845. /**
  59846. * Sets the gravity vector used by the simulation
  59847. * @param gravity defines the gravity vector to use
  59848. */
  59849. setGravity(gravity: Vector3): void;
  59850. /**
  59851. * Set the time step of the physics engine.
  59852. * Default is 1/60.
  59853. * To slow it down, enter 1/600 for example.
  59854. * To speed it up, 1/30
  59855. * @param newTimeStep defines the new timestep to apply to this world.
  59856. */
  59857. setTimeStep(newTimeStep?: number): void;
  59858. /**
  59859. * Get the time step of the physics engine.
  59860. * @returns the current time step
  59861. */
  59862. getTimeStep(): number;
  59863. /**
  59864. * Set the sub time step of the physics engine.
  59865. * Default is 0 meaning there is no sub steps
  59866. * To increase physics resolution precision, set a small value (like 1 ms)
  59867. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59868. */
  59869. setSubTimeStep(subTimeStep?: number): void;
  59870. /**
  59871. * Get the sub time step of the physics engine.
  59872. * @returns the current sub time step
  59873. */
  59874. getSubTimeStep(): number;
  59875. /**
  59876. * Release all resources
  59877. */
  59878. dispose(): void;
  59879. /**
  59880. * Gets the name of the current physics plugin
  59881. * @returns the name of the plugin
  59882. */
  59883. getPhysicsPluginName(): string;
  59884. /**
  59885. * Adding a new impostor for the impostor tracking.
  59886. * This will be done by the impostor itself.
  59887. * @param impostor the impostor to add
  59888. */
  59889. addImpostor(impostor: PhysicsImpostor): void;
  59890. /**
  59891. * Remove an impostor from the engine.
  59892. * This impostor and its mesh will not longer be updated by the physics engine.
  59893. * @param impostor the impostor to remove
  59894. */
  59895. removeImpostor(impostor: PhysicsImpostor): void;
  59896. /**
  59897. * Add a joint to the physics engine
  59898. * @param mainImpostor defines the main impostor to which the joint is added.
  59899. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59900. * @param joint defines the joint that will connect both impostors.
  59901. */
  59902. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59903. /**
  59904. * Removes a joint from the simulation
  59905. * @param mainImpostor defines the impostor used with the joint
  59906. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59907. * @param joint defines the joint to remove
  59908. */
  59909. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59910. /**
  59911. * Called by the scene. No need to call it.
  59912. * @param delta defines the timespam between frames
  59913. */
  59914. _step(delta: number): void;
  59915. /**
  59916. * Gets the current plugin used to run the simulation
  59917. * @returns current plugin
  59918. */
  59919. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59920. /**
  59921. * Gets the list of physic impostors
  59922. * @returns an array of PhysicsImpostor
  59923. */
  59924. getImpostors(): Array<PhysicsImpostor>;
  59925. /**
  59926. * Gets the impostor for a physics enabled object
  59927. * @param object defines the object impersonated by the impostor
  59928. * @returns the PhysicsImpostor or null if not found
  59929. */
  59930. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59931. /**
  59932. * Gets the impostor for a physics body object
  59933. * @param body defines physics body used by the impostor
  59934. * @returns the PhysicsImpostor or null if not found
  59935. */
  59936. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59937. /**
  59938. * Does a raycast in the physics world
  59939. * @param from when should the ray start?
  59940. * @param to when should the ray end?
  59941. * @returns PhysicsRaycastResult
  59942. */
  59943. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59944. }
  59945. }
  59946. declare module BABYLON {
  59947. /** @hidden */
  59948. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59949. private _useDeltaForWorldStep;
  59950. world: any;
  59951. name: string;
  59952. private _physicsMaterials;
  59953. private _fixedTimeStep;
  59954. private _cannonRaycastResult;
  59955. private _raycastResult;
  59956. private _physicsBodysToRemoveAfterStep;
  59957. private _firstFrame;
  59958. BJSCANNON: any;
  59959. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59960. setGravity(gravity: Vector3): void;
  59961. setTimeStep(timeStep: number): void;
  59962. getTimeStep(): number;
  59963. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59964. private _removeMarkedPhysicsBodiesFromWorld;
  59965. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59966. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59967. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59968. private _processChildMeshes;
  59969. removePhysicsBody(impostor: PhysicsImpostor): void;
  59970. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59971. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59972. private _addMaterial;
  59973. private _checkWithEpsilon;
  59974. private _createShape;
  59975. private _createHeightmap;
  59976. private _minus90X;
  59977. private _plus90X;
  59978. private _tmpPosition;
  59979. private _tmpDeltaPosition;
  59980. private _tmpUnityRotation;
  59981. private _updatePhysicsBodyTransformation;
  59982. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59984. isSupported(): boolean;
  59985. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59987. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59989. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59990. getBodyMass(impostor: PhysicsImpostor): number;
  59991. getBodyFriction(impostor: PhysicsImpostor): number;
  59992. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59993. getBodyRestitution(impostor: PhysicsImpostor): number;
  59994. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59995. sleepBody(impostor: PhysicsImpostor): void;
  59996. wakeUpBody(impostor: PhysicsImpostor): void;
  59997. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59998. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59999. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60000. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60001. getRadius(impostor: PhysicsImpostor): number;
  60002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60003. dispose(): void;
  60004. private _extendNamespace;
  60005. /**
  60006. * Does a raycast in the physics world
  60007. * @param from when should the ray start?
  60008. * @param to when should the ray end?
  60009. * @returns PhysicsRaycastResult
  60010. */
  60011. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60012. }
  60013. }
  60014. declare module BABYLON {
  60015. /** @hidden */
  60016. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60017. private _useDeltaForWorldStep;
  60018. world: any;
  60019. name: string;
  60020. BJSOIMO: any;
  60021. private _raycastResult;
  60022. private _fixedTimeStep;
  60023. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60024. setGravity(gravity: Vector3): void;
  60025. setTimeStep(timeStep: number): void;
  60026. getTimeStep(): number;
  60027. private _tmpImpostorsArray;
  60028. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60029. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60030. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60031. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60032. private _tmpPositionVector;
  60033. removePhysicsBody(impostor: PhysicsImpostor): void;
  60034. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60035. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60036. isSupported(): boolean;
  60037. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60038. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60044. getBodyMass(impostor: PhysicsImpostor): number;
  60045. getBodyFriction(impostor: PhysicsImpostor): number;
  60046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60047. getBodyRestitution(impostor: PhysicsImpostor): number;
  60048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60049. sleepBody(impostor: PhysicsImpostor): void;
  60050. wakeUpBody(impostor: PhysicsImpostor): void;
  60051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60052. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60054. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60055. getRadius(impostor: PhysicsImpostor): number;
  60056. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60057. dispose(): void;
  60058. /**
  60059. * Does a raycast in the physics world
  60060. * @param from when should the ray start?
  60061. * @param to when should the ray end?
  60062. * @returns PhysicsRaycastResult
  60063. */
  60064. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60065. }
  60066. }
  60067. declare module BABYLON {
  60068. /**
  60069. * Class containing static functions to help procedurally build meshes
  60070. */
  60071. export class RibbonBuilder {
  60072. /**
  60073. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60074. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60075. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60076. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60077. * * 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
  60078. * * 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
  60079. * * 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
  60080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60081. * * 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
  60082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60083. * * 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
  60084. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60085. * * 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
  60086. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60088. * @param name defines the name of the mesh
  60089. * @param options defines the options used to create the mesh
  60090. * @param scene defines the hosting scene
  60091. * @returns the ribbon mesh
  60092. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60093. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60094. */
  60095. static CreateRibbon(name: string, options: {
  60096. pathArray: Vector3[][];
  60097. closeArray?: boolean;
  60098. closePath?: boolean;
  60099. offset?: number;
  60100. updatable?: boolean;
  60101. sideOrientation?: number;
  60102. frontUVs?: Vector4;
  60103. backUVs?: Vector4;
  60104. instance?: Mesh;
  60105. invertUV?: boolean;
  60106. uvs?: Vector2[];
  60107. colors?: Color4[];
  60108. }, scene?: Nullable<Scene>): Mesh;
  60109. }
  60110. }
  60111. declare module BABYLON {
  60112. /**
  60113. * Class containing static functions to help procedurally build meshes
  60114. */
  60115. export class ShapeBuilder {
  60116. /**
  60117. * 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.
  60118. * * 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.
  60119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60120. * * 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.
  60121. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60122. * * 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
  60123. * * 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
  60124. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60126. * * 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
  60127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60129. * @param name defines the name of the mesh
  60130. * @param options defines the options used to create the mesh
  60131. * @param scene defines the hosting scene
  60132. * @returns the extruded shape mesh
  60133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60135. */
  60136. static ExtrudeShape(name: string, options: {
  60137. shape: Vector3[];
  60138. path: Vector3[];
  60139. scale?: number;
  60140. rotation?: number;
  60141. cap?: number;
  60142. updatable?: boolean;
  60143. sideOrientation?: number;
  60144. frontUVs?: Vector4;
  60145. backUVs?: Vector4;
  60146. instance?: Mesh;
  60147. invertUV?: boolean;
  60148. }, scene?: Nullable<Scene>): Mesh;
  60149. /**
  60150. * Creates an custom extruded shape mesh.
  60151. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60152. * * 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.
  60153. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60154. * * 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
  60155. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60156. * * 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
  60157. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60158. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60159. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60160. * * 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
  60161. * * 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
  60162. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60164. * * 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
  60165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60167. * @param name defines the name of the mesh
  60168. * @param options defines the options used to create the mesh
  60169. * @param scene defines the hosting scene
  60170. * @returns the custom extruded shape mesh
  60171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60174. */
  60175. static ExtrudeShapeCustom(name: string, options: {
  60176. shape: Vector3[];
  60177. path: Vector3[];
  60178. scaleFunction?: any;
  60179. rotationFunction?: any;
  60180. ribbonCloseArray?: boolean;
  60181. ribbonClosePath?: boolean;
  60182. cap?: number;
  60183. updatable?: boolean;
  60184. sideOrientation?: number;
  60185. frontUVs?: Vector4;
  60186. backUVs?: Vector4;
  60187. instance?: Mesh;
  60188. invertUV?: boolean;
  60189. }, scene?: Nullable<Scene>): Mesh;
  60190. private static _ExtrudeShapeGeneric;
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /**
  60195. * AmmoJS Physics plugin
  60196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60197. * @see https://github.com/kripken/ammo.js/
  60198. */
  60199. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60200. private _useDeltaForWorldStep;
  60201. /**
  60202. * Reference to the Ammo library
  60203. */
  60204. bjsAMMO: any;
  60205. /**
  60206. * Created ammoJS world which physics bodies are added to
  60207. */
  60208. world: any;
  60209. /**
  60210. * Name of the plugin
  60211. */
  60212. name: string;
  60213. private _timeStep;
  60214. private _fixedTimeStep;
  60215. private _maxSteps;
  60216. private _tmpQuaternion;
  60217. private _tmpAmmoTransform;
  60218. private _tmpAmmoQuaternion;
  60219. private _tmpAmmoConcreteContactResultCallback;
  60220. private _collisionConfiguration;
  60221. private _dispatcher;
  60222. private _overlappingPairCache;
  60223. private _solver;
  60224. private _softBodySolver;
  60225. private _tmpAmmoVectorA;
  60226. private _tmpAmmoVectorB;
  60227. private _tmpAmmoVectorC;
  60228. private _tmpAmmoVectorD;
  60229. private _tmpContactCallbackResult;
  60230. private _tmpAmmoVectorRCA;
  60231. private _tmpAmmoVectorRCB;
  60232. private _raycastResult;
  60233. private static readonly DISABLE_COLLISION_FLAG;
  60234. private static readonly KINEMATIC_FLAG;
  60235. private static readonly DISABLE_DEACTIVATION_FLAG;
  60236. /**
  60237. * Initializes the ammoJS plugin
  60238. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60239. * @param ammoInjection can be used to inject your own ammo reference
  60240. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60241. */
  60242. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60243. /**
  60244. * Sets the gravity of the physics world (m/(s^2))
  60245. * @param gravity Gravity to set
  60246. */
  60247. setGravity(gravity: Vector3): void;
  60248. /**
  60249. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60250. * @param timeStep timestep to use in seconds
  60251. */
  60252. setTimeStep(timeStep: number): void;
  60253. /**
  60254. * 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)
  60255. * @param fixedTimeStep fixedTimeStep to use in seconds
  60256. */
  60257. setFixedTimeStep(fixedTimeStep: number): void;
  60258. /**
  60259. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60260. * @param maxSteps the maximum number of steps by the physics engine per frame
  60261. */
  60262. setMaxSteps(maxSteps: number): void;
  60263. /**
  60264. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60265. * @returns the current timestep in seconds
  60266. */
  60267. getTimeStep(): number;
  60268. /**
  60269. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60270. */
  60271. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60272. private _isImpostorInContact;
  60273. private _isImpostorPairInContact;
  60274. private _stepSimulation;
  60275. /**
  60276. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60277. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60278. * After the step the babylon meshes are set to the position of the physics imposters
  60279. * @param delta amount of time to step forward
  60280. * @param impostors array of imposters to update before/after the step
  60281. */
  60282. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60283. /**
  60284. * Update babylon mesh to match physics world object
  60285. * @param impostor imposter to match
  60286. */
  60287. private _afterSoftStep;
  60288. /**
  60289. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60290. * @param impostor imposter to match
  60291. */
  60292. private _ropeStep;
  60293. /**
  60294. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60295. * @param impostor imposter to match
  60296. */
  60297. private _softbodyOrClothStep;
  60298. private _tmpMatrix;
  60299. /**
  60300. * Applies an impulse on the imposter
  60301. * @param impostor imposter to apply impulse to
  60302. * @param force amount of force to be applied to the imposter
  60303. * @param contactPoint the location to apply the impulse on the imposter
  60304. */
  60305. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60306. /**
  60307. * Applies a force on the imposter
  60308. * @param impostor imposter to apply force
  60309. * @param force amount of force to be applied to the imposter
  60310. * @param contactPoint the location to apply the force on the imposter
  60311. */
  60312. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60313. /**
  60314. * Creates a physics body using the plugin
  60315. * @param impostor the imposter to create the physics body on
  60316. */
  60317. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60318. /**
  60319. * Removes the physics body from the imposter and disposes of the body's memory
  60320. * @param impostor imposter to remove the physics body from
  60321. */
  60322. removePhysicsBody(impostor: PhysicsImpostor): void;
  60323. /**
  60324. * Generates a joint
  60325. * @param impostorJoint the imposter joint to create the joint with
  60326. */
  60327. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60328. /**
  60329. * Removes a joint
  60330. * @param impostorJoint the imposter joint to remove the joint from
  60331. */
  60332. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60333. private _addMeshVerts;
  60334. /**
  60335. * Initialise the soft body vertices to match its object's (mesh) vertices
  60336. * Softbody vertices (nodes) are in world space and to match this
  60337. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60338. * @param impostor to create the softbody for
  60339. */
  60340. private _softVertexData;
  60341. /**
  60342. * Create an impostor's soft body
  60343. * @param impostor to create the softbody for
  60344. */
  60345. private _createSoftbody;
  60346. /**
  60347. * Create cloth for an impostor
  60348. * @param impostor to create the softbody for
  60349. */
  60350. private _createCloth;
  60351. /**
  60352. * Create rope for an impostor
  60353. * @param impostor to create the softbody for
  60354. */
  60355. private _createRope;
  60356. /**
  60357. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60358. * @param impostor to create the custom physics shape for
  60359. */
  60360. private _createCustom;
  60361. private _addHullVerts;
  60362. private _createShape;
  60363. /**
  60364. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60365. * @param impostor imposter containing the physics body and babylon object
  60366. */
  60367. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60368. /**
  60369. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60370. * @param impostor imposter containing the physics body and babylon object
  60371. * @param newPosition new position
  60372. * @param newRotation new rotation
  60373. */
  60374. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60375. /**
  60376. * If this plugin is supported
  60377. * @returns true if its supported
  60378. */
  60379. isSupported(): boolean;
  60380. /**
  60381. * Sets the linear velocity of the physics body
  60382. * @param impostor imposter to set the velocity on
  60383. * @param velocity velocity to set
  60384. */
  60385. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60386. /**
  60387. * Sets the angular velocity of the physics body
  60388. * @param impostor imposter to set the velocity on
  60389. * @param velocity velocity to set
  60390. */
  60391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60392. /**
  60393. * gets the linear velocity
  60394. * @param impostor imposter to get linear velocity from
  60395. * @returns linear velocity
  60396. */
  60397. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60398. /**
  60399. * gets the angular velocity
  60400. * @param impostor imposter to get angular velocity from
  60401. * @returns angular velocity
  60402. */
  60403. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60404. /**
  60405. * Sets the mass of physics body
  60406. * @param impostor imposter to set the mass on
  60407. * @param mass mass to set
  60408. */
  60409. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60410. /**
  60411. * Gets the mass of the physics body
  60412. * @param impostor imposter to get the mass from
  60413. * @returns mass
  60414. */
  60415. getBodyMass(impostor: PhysicsImpostor): number;
  60416. /**
  60417. * Gets friction of the impostor
  60418. * @param impostor impostor to get friction from
  60419. * @returns friction value
  60420. */
  60421. getBodyFriction(impostor: PhysicsImpostor): number;
  60422. /**
  60423. * Sets friction of the impostor
  60424. * @param impostor impostor to set friction on
  60425. * @param friction friction value
  60426. */
  60427. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60428. /**
  60429. * Gets restitution of the impostor
  60430. * @param impostor impostor to get restitution from
  60431. * @returns restitution value
  60432. */
  60433. getBodyRestitution(impostor: PhysicsImpostor): number;
  60434. /**
  60435. * Sets resitution of the impostor
  60436. * @param impostor impostor to set resitution on
  60437. * @param restitution resitution value
  60438. */
  60439. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60440. /**
  60441. * Gets pressure inside the impostor
  60442. * @param impostor impostor to get pressure from
  60443. * @returns pressure value
  60444. */
  60445. getBodyPressure(impostor: PhysicsImpostor): number;
  60446. /**
  60447. * Sets pressure inside a soft body impostor
  60448. * Cloth and rope must remain 0 pressure
  60449. * @param impostor impostor to set pressure on
  60450. * @param pressure pressure value
  60451. */
  60452. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60453. /**
  60454. * Gets stiffness of the impostor
  60455. * @param impostor impostor to get stiffness from
  60456. * @returns pressure value
  60457. */
  60458. getBodyStiffness(impostor: PhysicsImpostor): number;
  60459. /**
  60460. * Sets stiffness of the impostor
  60461. * @param impostor impostor to set stiffness on
  60462. * @param stiffness stiffness value from 0 to 1
  60463. */
  60464. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60465. /**
  60466. * Gets velocityIterations of the impostor
  60467. * @param impostor impostor to get velocity iterations from
  60468. * @returns velocityIterations value
  60469. */
  60470. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60471. /**
  60472. * Sets velocityIterations of the impostor
  60473. * @param impostor impostor to set velocity iterations on
  60474. * @param velocityIterations velocityIterations value
  60475. */
  60476. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60477. /**
  60478. * Gets positionIterations of the impostor
  60479. * @param impostor impostor to get position iterations from
  60480. * @returns positionIterations value
  60481. */
  60482. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60483. /**
  60484. * Sets positionIterations of the impostor
  60485. * @param impostor impostor to set position on
  60486. * @param positionIterations positionIterations value
  60487. */
  60488. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60489. /**
  60490. * Append an anchor to a cloth object
  60491. * @param impostor is the cloth impostor to add anchor to
  60492. * @param otherImpostor is the rigid impostor to anchor to
  60493. * @param width ratio across width from 0 to 1
  60494. * @param height ratio up height from 0 to 1
  60495. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60496. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60497. */
  60498. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60499. /**
  60500. * Append an hook to a rope object
  60501. * @param impostor is the rope impostor to add hook to
  60502. * @param otherImpostor is the rigid impostor to hook to
  60503. * @param length ratio along the rope from 0 to 1
  60504. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60505. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60506. */
  60507. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60508. /**
  60509. * Sleeps the physics body and stops it from being active
  60510. * @param impostor impostor to sleep
  60511. */
  60512. sleepBody(impostor: PhysicsImpostor): void;
  60513. /**
  60514. * Activates the physics body
  60515. * @param impostor impostor to activate
  60516. */
  60517. wakeUpBody(impostor: PhysicsImpostor): void;
  60518. /**
  60519. * Updates the distance parameters of the joint
  60520. * @param joint joint to update
  60521. * @param maxDistance maximum distance of the joint
  60522. * @param minDistance minimum distance of the joint
  60523. */
  60524. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60525. /**
  60526. * Sets a motor on the joint
  60527. * @param joint joint to set motor on
  60528. * @param speed speed of the motor
  60529. * @param maxForce maximum force of the motor
  60530. * @param motorIndex index of the motor
  60531. */
  60532. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60533. /**
  60534. * Sets the motors limit
  60535. * @param joint joint to set limit on
  60536. * @param upperLimit upper limit
  60537. * @param lowerLimit lower limit
  60538. */
  60539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60540. /**
  60541. * Syncs the position and rotation of a mesh with the impostor
  60542. * @param mesh mesh to sync
  60543. * @param impostor impostor to update the mesh with
  60544. */
  60545. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60546. /**
  60547. * Gets the radius of the impostor
  60548. * @param impostor impostor to get radius from
  60549. * @returns the radius
  60550. */
  60551. getRadius(impostor: PhysicsImpostor): number;
  60552. /**
  60553. * Gets the box size of the impostor
  60554. * @param impostor impostor to get box size from
  60555. * @param result the resulting box size
  60556. */
  60557. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60558. /**
  60559. * Disposes of the impostor
  60560. */
  60561. dispose(): void;
  60562. /**
  60563. * Does a raycast in the physics world
  60564. * @param from when should the ray start?
  60565. * @param to when should the ray end?
  60566. * @returns PhysicsRaycastResult
  60567. */
  60568. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60569. }
  60570. }
  60571. declare module BABYLON {
  60572. interface AbstractScene {
  60573. /**
  60574. * The list of reflection probes added to the scene
  60575. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60576. */
  60577. reflectionProbes: Array<ReflectionProbe>;
  60578. /**
  60579. * Removes the given reflection probe from this scene.
  60580. * @param toRemove The reflection probe to remove
  60581. * @returns The index of the removed reflection probe
  60582. */
  60583. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60584. /**
  60585. * Adds the given reflection probe to this scene.
  60586. * @param newReflectionProbe The reflection probe to add
  60587. */
  60588. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60589. }
  60590. /**
  60591. * Class used to generate realtime reflection / refraction cube textures
  60592. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60593. */
  60594. export class ReflectionProbe {
  60595. /** defines the name of the probe */
  60596. name: string;
  60597. private _scene;
  60598. private _renderTargetTexture;
  60599. private _projectionMatrix;
  60600. private _viewMatrix;
  60601. private _target;
  60602. private _add;
  60603. private _attachedMesh;
  60604. private _invertYAxis;
  60605. /** Gets or sets probe position (center of the cube map) */
  60606. position: Vector3;
  60607. /**
  60608. * Creates a new reflection probe
  60609. * @param name defines the name of the probe
  60610. * @param size defines the texture resolution (for each face)
  60611. * @param scene defines the hosting scene
  60612. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60613. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60614. */
  60615. constructor(
  60616. /** defines the name of the probe */
  60617. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60618. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60619. get samples(): number;
  60620. set samples(value: number);
  60621. /** Gets or sets the refresh rate to use (on every frame by default) */
  60622. get refreshRate(): number;
  60623. set refreshRate(value: number);
  60624. /**
  60625. * Gets the hosting scene
  60626. * @returns a Scene
  60627. */
  60628. getScene(): Scene;
  60629. /** Gets the internal CubeTexture used to render to */
  60630. get cubeTexture(): RenderTargetTexture;
  60631. /** Gets the list of meshes to render */
  60632. get renderList(): Nullable<AbstractMesh[]>;
  60633. /**
  60634. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60635. * @param mesh defines the mesh to attach to
  60636. */
  60637. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60638. /**
  60639. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60640. * @param renderingGroupId The rendering group id corresponding to its index
  60641. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60642. */
  60643. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60644. /**
  60645. * Clean all associated resources
  60646. */
  60647. dispose(): void;
  60648. /**
  60649. * Converts the reflection probe information to a readable string for debug purpose.
  60650. * @param fullDetails Supports for multiple levels of logging within scene loading
  60651. * @returns the human readable reflection probe info
  60652. */
  60653. toString(fullDetails?: boolean): string;
  60654. /**
  60655. * Get the class name of the relfection probe.
  60656. * @returns "ReflectionProbe"
  60657. */
  60658. getClassName(): string;
  60659. /**
  60660. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60661. * @returns The JSON representation of the texture
  60662. */
  60663. serialize(): any;
  60664. /**
  60665. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60666. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60667. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60668. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60669. * @returns The parsed reflection probe if successful
  60670. */
  60671. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60672. }
  60673. }
  60674. declare module BABYLON {
  60675. /** @hidden */
  60676. export var _BabylonLoaderRegistered: boolean;
  60677. /**
  60678. * Helps setting up some configuration for the babylon file loader.
  60679. */
  60680. export class BabylonFileLoaderConfiguration {
  60681. /**
  60682. * The loader does not allow injecting custom physix engine into the plugins.
  60683. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60684. * So you could set this variable to your engine import to make it work.
  60685. */
  60686. static LoaderInjectedPhysicsEngine: any;
  60687. }
  60688. }
  60689. declare module BABYLON {
  60690. /**
  60691. * The Physically based simple base material of BJS.
  60692. *
  60693. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60694. * It is used as the base class for both the specGloss and metalRough conventions.
  60695. */
  60696. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60697. /**
  60698. * Number of Simultaneous lights allowed on the material.
  60699. */
  60700. maxSimultaneousLights: number;
  60701. /**
  60702. * If sets to true, disables all the lights affecting the material.
  60703. */
  60704. disableLighting: boolean;
  60705. /**
  60706. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60707. */
  60708. environmentTexture: BaseTexture;
  60709. /**
  60710. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60711. */
  60712. invertNormalMapX: boolean;
  60713. /**
  60714. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60715. */
  60716. invertNormalMapY: boolean;
  60717. /**
  60718. * Normal map used in the model.
  60719. */
  60720. normalTexture: BaseTexture;
  60721. /**
  60722. * Emissivie color used to self-illuminate the model.
  60723. */
  60724. emissiveColor: Color3;
  60725. /**
  60726. * Emissivie texture used to self-illuminate the model.
  60727. */
  60728. emissiveTexture: BaseTexture;
  60729. /**
  60730. * Occlusion Channel Strenght.
  60731. */
  60732. occlusionStrength: number;
  60733. /**
  60734. * Occlusion Texture of the material (adding extra occlusion effects).
  60735. */
  60736. occlusionTexture: BaseTexture;
  60737. /**
  60738. * Defines the alpha limits in alpha test mode.
  60739. */
  60740. alphaCutOff: number;
  60741. /**
  60742. * Gets the current double sided mode.
  60743. */
  60744. get doubleSided(): boolean;
  60745. /**
  60746. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60747. */
  60748. set doubleSided(value: boolean);
  60749. /**
  60750. * Stores the pre-calculated light information of a mesh in a texture.
  60751. */
  60752. lightmapTexture: BaseTexture;
  60753. /**
  60754. * If true, the light map contains occlusion information instead of lighting info.
  60755. */
  60756. useLightmapAsShadowmap: boolean;
  60757. /**
  60758. * Instantiates a new PBRMaterial instance.
  60759. *
  60760. * @param name The material name
  60761. * @param scene The scene the material will be use in.
  60762. */
  60763. constructor(name: string, scene: Scene);
  60764. getClassName(): string;
  60765. }
  60766. }
  60767. declare module BABYLON {
  60768. /**
  60769. * The PBR material of BJS following the metal roughness convention.
  60770. *
  60771. * This fits to the PBR convention in the GLTF definition:
  60772. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60773. */
  60774. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60775. /**
  60776. * The base color has two different interpretations depending on the value of metalness.
  60777. * When the material is a metal, the base color is the specific measured reflectance value
  60778. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60779. * of the material.
  60780. */
  60781. baseColor: Color3;
  60782. /**
  60783. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60784. * well as opacity information in the alpha channel.
  60785. */
  60786. baseTexture: BaseTexture;
  60787. /**
  60788. * Specifies the metallic scalar value of the material.
  60789. * Can also be used to scale the metalness values of the metallic texture.
  60790. */
  60791. metallic: number;
  60792. /**
  60793. * Specifies the roughness scalar value of the material.
  60794. * Can also be used to scale the roughness values of the metallic texture.
  60795. */
  60796. roughness: number;
  60797. /**
  60798. * Texture containing both the metallic value in the B channel and the
  60799. * roughness value in the G channel to keep better precision.
  60800. */
  60801. metallicRoughnessTexture: BaseTexture;
  60802. /**
  60803. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60804. *
  60805. * @param name The material name
  60806. * @param scene The scene the material will be use in.
  60807. */
  60808. constructor(name: string, scene: Scene);
  60809. /**
  60810. * Return the currrent class name of the material.
  60811. */
  60812. getClassName(): string;
  60813. /**
  60814. * Makes a duplicate of the current material.
  60815. * @param name - name to use for the new material.
  60816. */
  60817. clone(name: string): PBRMetallicRoughnessMaterial;
  60818. /**
  60819. * Serialize the material to a parsable JSON object.
  60820. */
  60821. serialize(): any;
  60822. /**
  60823. * Parses a JSON object correponding to the serialize function.
  60824. */
  60825. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * The PBR material of BJS following the specular glossiness convention.
  60831. *
  60832. * This fits to the PBR convention in the GLTF definition:
  60833. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60834. */
  60835. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60836. /**
  60837. * Specifies the diffuse color of the material.
  60838. */
  60839. diffuseColor: Color3;
  60840. /**
  60841. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60842. * channel.
  60843. */
  60844. diffuseTexture: BaseTexture;
  60845. /**
  60846. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60847. */
  60848. specularColor: Color3;
  60849. /**
  60850. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60851. */
  60852. glossiness: number;
  60853. /**
  60854. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60855. */
  60856. specularGlossinessTexture: BaseTexture;
  60857. /**
  60858. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60859. *
  60860. * @param name The material name
  60861. * @param scene The scene the material will be use in.
  60862. */
  60863. constructor(name: string, scene: Scene);
  60864. /**
  60865. * Return the currrent class name of the material.
  60866. */
  60867. getClassName(): string;
  60868. /**
  60869. * Makes a duplicate of the current material.
  60870. * @param name - name to use for the new material.
  60871. */
  60872. clone(name: string): PBRSpecularGlossinessMaterial;
  60873. /**
  60874. * Serialize the material to a parsable JSON object.
  60875. */
  60876. serialize(): any;
  60877. /**
  60878. * Parses a JSON object correponding to the serialize function.
  60879. */
  60880. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60881. }
  60882. }
  60883. declare module BABYLON {
  60884. /**
  60885. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60886. * It can help converting any input color in a desired output one. This can then be used to create effects
  60887. * from sepia, black and white to sixties or futuristic rendering...
  60888. *
  60889. * The only supported format is currently 3dl.
  60890. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60891. */
  60892. export class ColorGradingTexture extends BaseTexture {
  60893. /**
  60894. * The texture URL.
  60895. */
  60896. url: string;
  60897. /**
  60898. * Empty line regex stored for GC.
  60899. */
  60900. private static _noneEmptyLineRegex;
  60901. private _textureMatrix;
  60902. private _onLoad;
  60903. /**
  60904. * Instantiates a ColorGradingTexture from the following parameters.
  60905. *
  60906. * @param url The location of the color gradind data (currently only supporting 3dl)
  60907. * @param sceneOrEngine The scene or engine the texture will be used in
  60908. * @param onLoad defines a callback triggered when the texture has been loaded
  60909. */
  60910. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60911. /**
  60912. * Fires the onload event from the constructor if requested.
  60913. */
  60914. private _triggerOnLoad;
  60915. /**
  60916. * Returns the texture matrix used in most of the material.
  60917. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60918. */
  60919. getTextureMatrix(): Matrix;
  60920. /**
  60921. * Occurs when the file being loaded is a .3dl LUT file.
  60922. */
  60923. private load3dlTexture;
  60924. /**
  60925. * Starts the loading process of the texture.
  60926. */
  60927. private loadTexture;
  60928. /**
  60929. * Clones the color gradind texture.
  60930. */
  60931. clone(): ColorGradingTexture;
  60932. /**
  60933. * Called during delayed load for textures.
  60934. */
  60935. delayLoad(): void;
  60936. /**
  60937. * Parses a color grading texture serialized by Babylon.
  60938. * @param parsedTexture The texture information being parsedTexture
  60939. * @param scene The scene to load the texture in
  60940. * @param rootUrl The root url of the data assets to load
  60941. * @return A color gradind texture
  60942. */
  60943. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60944. /**
  60945. * Serializes the LUT texture to json format.
  60946. */
  60947. serialize(): any;
  60948. }
  60949. }
  60950. declare module BABYLON {
  60951. /**
  60952. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60953. */
  60954. export class EquiRectangularCubeTexture extends BaseTexture {
  60955. /** The six faces of the cube. */
  60956. private static _FacesMapping;
  60957. private _noMipmap;
  60958. private _onLoad;
  60959. private _onError;
  60960. /** The size of the cubemap. */
  60961. private _size;
  60962. /** The buffer of the image. */
  60963. private _buffer;
  60964. /** The width of the input image. */
  60965. private _width;
  60966. /** The height of the input image. */
  60967. private _height;
  60968. /** The URL to the image. */
  60969. url: string;
  60970. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60971. coordinatesMode: number;
  60972. /**
  60973. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60974. * @param url The location of the image
  60975. * @param scene The scene the texture will be used in
  60976. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60977. * @param noMipmap Forces to not generate the mipmap if true
  60978. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60979. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60980. * @param onLoad — defines a callback called when texture is loaded
  60981. * @param onError — defines a callback called if there is an error
  60982. */
  60983. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60984. /**
  60985. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60986. */
  60987. private loadImage;
  60988. /**
  60989. * Convert the image buffer into a cubemap and create a CubeTexture.
  60990. */
  60991. private loadTexture;
  60992. /**
  60993. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60994. * @param buffer The ArrayBuffer that should be converted.
  60995. * @returns The buffer as Float32Array.
  60996. */
  60997. private getFloat32ArrayFromArrayBuffer;
  60998. /**
  60999. * Get the current class name of the texture useful for serialization or dynamic coding.
  61000. * @returns "EquiRectangularCubeTexture"
  61001. */
  61002. getClassName(): string;
  61003. /**
  61004. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61005. * @returns A clone of the current EquiRectangularCubeTexture.
  61006. */
  61007. clone(): EquiRectangularCubeTexture;
  61008. }
  61009. }
  61010. declare module BABYLON {
  61011. /**
  61012. * Defines the options related to the creation of an HtmlElementTexture
  61013. */
  61014. export interface IHtmlElementTextureOptions {
  61015. /**
  61016. * Defines wether mip maps should be created or not.
  61017. */
  61018. generateMipMaps?: boolean;
  61019. /**
  61020. * Defines the sampling mode of the texture.
  61021. */
  61022. samplingMode?: number;
  61023. /**
  61024. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61025. */
  61026. engine: Nullable<ThinEngine>;
  61027. /**
  61028. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61029. */
  61030. scene: Nullable<Scene>;
  61031. }
  61032. /**
  61033. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61034. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61035. * is automatically managed.
  61036. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61037. * in your application.
  61038. *
  61039. * As the update is not automatic, you need to call them manually.
  61040. */
  61041. export class HtmlElementTexture extends BaseTexture {
  61042. /**
  61043. * The texture URL.
  61044. */
  61045. element: HTMLVideoElement | HTMLCanvasElement;
  61046. private static readonly DefaultOptions;
  61047. private _textureMatrix;
  61048. private _isVideo;
  61049. private _generateMipMaps;
  61050. private _samplingMode;
  61051. /**
  61052. * Instantiates a HtmlElementTexture from the following parameters.
  61053. *
  61054. * @param name Defines the name of the texture
  61055. * @param element Defines the video or canvas the texture is filled with
  61056. * @param options Defines the other none mandatory texture creation options
  61057. */
  61058. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61059. private _createInternalTexture;
  61060. /**
  61061. * Returns the texture matrix used in most of the material.
  61062. */
  61063. getTextureMatrix(): Matrix;
  61064. /**
  61065. * Updates the content of the texture.
  61066. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61067. */
  61068. update(invertY?: Nullable<boolean>): void;
  61069. }
  61070. }
  61071. declare module BABYLON {
  61072. /**
  61073. * Based on jsTGALoader - Javascript loader for TGA file
  61074. * By Vincent Thibault
  61075. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61076. */
  61077. export class TGATools {
  61078. private static _TYPE_INDEXED;
  61079. private static _TYPE_RGB;
  61080. private static _TYPE_GREY;
  61081. private static _TYPE_RLE_INDEXED;
  61082. private static _TYPE_RLE_RGB;
  61083. private static _TYPE_RLE_GREY;
  61084. private static _ORIGIN_MASK;
  61085. private static _ORIGIN_SHIFT;
  61086. private static _ORIGIN_BL;
  61087. private static _ORIGIN_BR;
  61088. private static _ORIGIN_UL;
  61089. private static _ORIGIN_UR;
  61090. /**
  61091. * Gets the header of a TGA file
  61092. * @param data defines the TGA data
  61093. * @returns the header
  61094. */
  61095. static GetTGAHeader(data: Uint8Array): any;
  61096. /**
  61097. * Uploads TGA content to a Babylon Texture
  61098. * @hidden
  61099. */
  61100. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61101. /** @hidden */
  61102. 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;
  61103. /** @hidden */
  61104. 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;
  61105. /** @hidden */
  61106. 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;
  61107. /** @hidden */
  61108. 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;
  61109. /** @hidden */
  61110. 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;
  61111. /** @hidden */
  61112. 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;
  61113. }
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * Implementation of the TGA Texture Loader.
  61118. * @hidden
  61119. */
  61120. export class _TGATextureLoader implements IInternalTextureLoader {
  61121. /**
  61122. * Defines wether the loader supports cascade loading the different faces.
  61123. */
  61124. readonly supportCascades: boolean;
  61125. /**
  61126. * This returns if the loader support the current file information.
  61127. * @param extension defines the file extension of the file being loaded
  61128. * @returns true if the loader can load the specified file
  61129. */
  61130. canLoad(extension: string): boolean;
  61131. /**
  61132. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61133. * @param data contains the texture data
  61134. * @param texture defines the BabylonJS internal texture
  61135. * @param createPolynomials will be true if polynomials have been requested
  61136. * @param onLoad defines the callback to trigger once the texture is ready
  61137. * @param onError defines the callback to trigger in case of error
  61138. */
  61139. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61140. /**
  61141. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61142. * @param data contains the texture data
  61143. * @param texture defines the BabylonJS internal texture
  61144. * @param callback defines the method to call once ready to upload
  61145. */
  61146. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61147. }
  61148. }
  61149. declare module BABYLON {
  61150. /**
  61151. * Info about the .basis files
  61152. */
  61153. class BasisFileInfo {
  61154. /**
  61155. * If the file has alpha
  61156. */
  61157. hasAlpha: boolean;
  61158. /**
  61159. * Info about each image of the basis file
  61160. */
  61161. images: Array<{
  61162. levels: Array<{
  61163. width: number;
  61164. height: number;
  61165. transcodedPixels: ArrayBufferView;
  61166. }>;
  61167. }>;
  61168. }
  61169. /**
  61170. * Result of transcoding a basis file
  61171. */
  61172. class TranscodeResult {
  61173. /**
  61174. * Info about the .basis file
  61175. */
  61176. fileInfo: BasisFileInfo;
  61177. /**
  61178. * Format to use when loading the file
  61179. */
  61180. format: number;
  61181. }
  61182. /**
  61183. * Configuration options for the Basis transcoder
  61184. */
  61185. export class BasisTranscodeConfiguration {
  61186. /**
  61187. * Supported compression formats used to determine the supported output format of the transcoder
  61188. */
  61189. supportedCompressionFormats?: {
  61190. /**
  61191. * etc1 compression format
  61192. */
  61193. etc1?: boolean;
  61194. /**
  61195. * s3tc compression format
  61196. */
  61197. s3tc?: boolean;
  61198. /**
  61199. * pvrtc compression format
  61200. */
  61201. pvrtc?: boolean;
  61202. /**
  61203. * etc2 compression format
  61204. */
  61205. etc2?: boolean;
  61206. };
  61207. /**
  61208. * If mipmap levels should be loaded for transcoded images (Default: true)
  61209. */
  61210. loadMipmapLevels?: boolean;
  61211. /**
  61212. * Index of a single image to load (Default: all images)
  61213. */
  61214. loadSingleImage?: number;
  61215. }
  61216. /**
  61217. * Used to load .Basis files
  61218. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61219. */
  61220. export class BasisTools {
  61221. private static _IgnoreSupportedFormats;
  61222. /**
  61223. * URL to use when loading the basis transcoder
  61224. */
  61225. static JSModuleURL: string;
  61226. /**
  61227. * URL to use when loading the wasm module for the transcoder
  61228. */
  61229. static WasmModuleURL: string;
  61230. /**
  61231. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61232. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61233. * @returns internal format corresponding to the Basis format
  61234. */
  61235. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61236. private static _WorkerPromise;
  61237. private static _Worker;
  61238. private static _actionId;
  61239. private static _CreateWorkerAsync;
  61240. /**
  61241. * Transcodes a loaded image file to compressed pixel data
  61242. * @param data image data to transcode
  61243. * @param config configuration options for the transcoding
  61244. * @returns a promise resulting in the transcoded image
  61245. */
  61246. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61247. /**
  61248. * Loads a texture from the transcode result
  61249. * @param texture texture load to
  61250. * @param transcodeResult the result of transcoding the basis file to load from
  61251. */
  61252. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Loader for .basis file format
  61258. */
  61259. export class _BasisTextureLoader implements IInternalTextureLoader {
  61260. /**
  61261. * Defines whether the loader supports cascade loading the different faces.
  61262. */
  61263. readonly supportCascades: boolean;
  61264. /**
  61265. * This returns if the loader support the current file information.
  61266. * @param extension defines the file extension of the file being loaded
  61267. * @returns true if the loader can load the specified file
  61268. */
  61269. canLoad(extension: string): boolean;
  61270. /**
  61271. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61272. * @param data contains the texture data
  61273. * @param texture defines the BabylonJS internal texture
  61274. * @param createPolynomials will be true if polynomials have been requested
  61275. * @param onLoad defines the callback to trigger once the texture is ready
  61276. * @param onError defines the callback to trigger in case of error
  61277. */
  61278. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61279. /**
  61280. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61281. * @param data contains the texture data
  61282. * @param texture defines the BabylonJS internal texture
  61283. * @param callback defines the method to call once ready to upload
  61284. */
  61285. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61286. }
  61287. }
  61288. declare module BABYLON {
  61289. /**
  61290. * Defines the basic options interface of a TexturePacker Frame
  61291. */
  61292. export interface ITexturePackerFrame {
  61293. /**
  61294. * The frame ID
  61295. */
  61296. id: number;
  61297. /**
  61298. * The frames Scale
  61299. */
  61300. scale: Vector2;
  61301. /**
  61302. * The Frames offset
  61303. */
  61304. offset: Vector2;
  61305. }
  61306. /**
  61307. * This is a support class for frame Data on texture packer sets.
  61308. */
  61309. export class TexturePackerFrame implements ITexturePackerFrame {
  61310. /**
  61311. * The frame ID
  61312. */
  61313. id: number;
  61314. /**
  61315. * The frames Scale
  61316. */
  61317. scale: Vector2;
  61318. /**
  61319. * The Frames offset
  61320. */
  61321. offset: Vector2;
  61322. /**
  61323. * Initializes a texture package frame.
  61324. * @param id The numerical frame identifier
  61325. * @param scale Scalar Vector2 for UV frame
  61326. * @param offset Vector2 for the frame position in UV units.
  61327. * @returns TexturePackerFrame
  61328. */
  61329. constructor(id: number, scale: Vector2, offset: Vector2);
  61330. }
  61331. }
  61332. declare module BABYLON {
  61333. /**
  61334. * Defines the basic options interface of a TexturePacker
  61335. */
  61336. export interface ITexturePackerOptions {
  61337. /**
  61338. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61339. */
  61340. map?: string[];
  61341. /**
  61342. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61343. */
  61344. uvsIn?: string;
  61345. /**
  61346. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61347. */
  61348. uvsOut?: string;
  61349. /**
  61350. * number representing the layout style. Defaults to LAYOUT_STRIP
  61351. */
  61352. layout?: number;
  61353. /**
  61354. * number of columns if using custom column count layout(2). This defaults to 4.
  61355. */
  61356. colnum?: number;
  61357. /**
  61358. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61359. */
  61360. updateInputMeshes?: boolean;
  61361. /**
  61362. * boolean flag to dispose all the source textures. Defaults to true.
  61363. */
  61364. disposeSources?: boolean;
  61365. /**
  61366. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61367. */
  61368. fillBlanks?: boolean;
  61369. /**
  61370. * string value representing the context fill style color. Defaults to 'black'.
  61371. */
  61372. customFillColor?: string;
  61373. /**
  61374. * Width and Height Value of each Frame in the TexturePacker Sets
  61375. */
  61376. frameSize?: number;
  61377. /**
  61378. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61379. */
  61380. paddingRatio?: number;
  61381. /**
  61382. * Number that declares the fill method for the padding gutter.
  61383. */
  61384. paddingMode?: number;
  61385. /**
  61386. * If in SUBUV_COLOR padding mode what color to use.
  61387. */
  61388. paddingColor?: Color3 | Color4;
  61389. }
  61390. /**
  61391. * Defines the basic interface of a TexturePacker JSON File
  61392. */
  61393. export interface ITexturePackerJSON {
  61394. /**
  61395. * The frame ID
  61396. */
  61397. name: string;
  61398. /**
  61399. * The base64 channel data
  61400. */
  61401. sets: any;
  61402. /**
  61403. * The options of the Packer
  61404. */
  61405. options: ITexturePackerOptions;
  61406. /**
  61407. * The frame data of the Packer
  61408. */
  61409. frames: Array<number>;
  61410. }
  61411. /**
  61412. * This is a support class that generates a series of packed texture sets.
  61413. * @see https://doc.babylonjs.com/babylon101/materials
  61414. */
  61415. export class TexturePacker {
  61416. /** Packer Layout Constant 0 */
  61417. static readonly LAYOUT_STRIP: number;
  61418. /** Packer Layout Constant 1 */
  61419. static readonly LAYOUT_POWER2: number;
  61420. /** Packer Layout Constant 2 */
  61421. static readonly LAYOUT_COLNUM: number;
  61422. /** Packer Layout Constant 0 */
  61423. static readonly SUBUV_WRAP: number;
  61424. /** Packer Layout Constant 1 */
  61425. static readonly SUBUV_EXTEND: number;
  61426. /** Packer Layout Constant 2 */
  61427. static readonly SUBUV_COLOR: number;
  61428. /** The Name of the Texture Package */
  61429. name: string;
  61430. /** The scene scope of the TexturePacker */
  61431. scene: Scene;
  61432. /** The Meshes to target */
  61433. meshes: AbstractMesh[];
  61434. /** Arguments passed with the Constructor */
  61435. options: ITexturePackerOptions;
  61436. /** The promise that is started upon initialization */
  61437. promise: Nullable<Promise<TexturePacker | string>>;
  61438. /** The Container object for the channel sets that are generated */
  61439. sets: object;
  61440. /** The Container array for the frames that are generated */
  61441. frames: TexturePackerFrame[];
  61442. /** The expected number of textures the system is parsing. */
  61443. private _expecting;
  61444. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61445. private _paddingValue;
  61446. /**
  61447. * Initializes a texture package series from an array of meshes or a single mesh.
  61448. * @param name The name of the package
  61449. * @param meshes The target meshes to compose the package from
  61450. * @param options The arguments that texture packer should follow while building.
  61451. * @param scene The scene which the textures are scoped to.
  61452. * @returns TexturePacker
  61453. */
  61454. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61455. /**
  61456. * Starts the package process
  61457. * @param resolve The promises resolution function
  61458. * @returns TexturePacker
  61459. */
  61460. private _createFrames;
  61461. /**
  61462. * Calculates the Size of the Channel Sets
  61463. * @returns Vector2
  61464. */
  61465. private _calculateSize;
  61466. /**
  61467. * Calculates the UV data for the frames.
  61468. * @param baseSize the base frameSize
  61469. * @param padding the base frame padding
  61470. * @param dtSize size of the Dynamic Texture for that channel
  61471. * @param dtUnits is 1/dtSize
  61472. * @param update flag to update the input meshes
  61473. */
  61474. private _calculateMeshUVFrames;
  61475. /**
  61476. * Calculates the frames Offset.
  61477. * @param index of the frame
  61478. * @returns Vector2
  61479. */
  61480. private _getFrameOffset;
  61481. /**
  61482. * Updates a Mesh to the frame data
  61483. * @param mesh that is the target
  61484. * @param frameID or the frame index
  61485. */
  61486. private _updateMeshUV;
  61487. /**
  61488. * Updates a Meshes materials to use the texture packer channels
  61489. * @param m is the mesh to target
  61490. * @param force all channels on the packer to be set.
  61491. */
  61492. private _updateTextureReferences;
  61493. /**
  61494. * Public method to set a Mesh to a frame
  61495. * @param m that is the target
  61496. * @param frameID or the frame index
  61497. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61498. */
  61499. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61500. /**
  61501. * Starts the async promise to compile the texture packer.
  61502. * @returns Promise<void>
  61503. */
  61504. processAsync(): Promise<void>;
  61505. /**
  61506. * Disposes all textures associated with this packer
  61507. */
  61508. dispose(): void;
  61509. /**
  61510. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61511. * @param imageType is the image type to use.
  61512. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61513. */
  61514. download(imageType?: string, quality?: number): void;
  61515. /**
  61516. * Public method to load a texturePacker JSON file.
  61517. * @param data of the JSON file in string format.
  61518. */
  61519. updateFromJSON(data: string): void;
  61520. }
  61521. }
  61522. declare module BABYLON {
  61523. /**
  61524. * 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.
  61525. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61526. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61527. */
  61528. export class CustomProceduralTexture extends ProceduralTexture {
  61529. private _animate;
  61530. private _time;
  61531. private _config;
  61532. private _texturePath;
  61533. /**
  61534. * Instantiates a new Custom Procedural Texture.
  61535. * 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.
  61536. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61537. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61538. * @param name Define the name of the texture
  61539. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61540. * @param size Define the size of the texture to create
  61541. * @param scene Define the scene the texture belongs to
  61542. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61543. * @param generateMipMaps Define if the texture should creates mip maps or not
  61544. */
  61545. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61546. private _loadJson;
  61547. /**
  61548. * Is the texture ready to be used ? (rendered at least once)
  61549. * @returns true if ready, otherwise, false.
  61550. */
  61551. isReady(): boolean;
  61552. /**
  61553. * Render the texture to its associated render target.
  61554. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61555. */
  61556. render(useCameraPostProcess?: boolean): void;
  61557. /**
  61558. * Update the list of dependant textures samplers in the shader.
  61559. */
  61560. updateTextures(): void;
  61561. /**
  61562. * Update the uniform values of the procedural texture in the shader.
  61563. */
  61564. updateShaderUniforms(): void;
  61565. /**
  61566. * Define if the texture animates or not.
  61567. */
  61568. get animate(): boolean;
  61569. set animate(value: boolean);
  61570. }
  61571. }
  61572. declare module BABYLON {
  61573. /** @hidden */
  61574. export var noisePixelShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module BABYLON {
  61580. /**
  61581. * Class used to generate noise procedural textures
  61582. */
  61583. export class NoiseProceduralTexture extends ProceduralTexture {
  61584. private _time;
  61585. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61586. brightness: number;
  61587. /** Defines the number of octaves to process */
  61588. octaves: number;
  61589. /** Defines the level of persistence (0.8 by default) */
  61590. persistence: number;
  61591. /** Gets or sets animation speed factor (default is 1) */
  61592. animationSpeedFactor: number;
  61593. /**
  61594. * Creates a new NoiseProceduralTexture
  61595. * @param name defines the name fo the texture
  61596. * @param size defines the size of the texture (default is 256)
  61597. * @param scene defines the hosting scene
  61598. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61599. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61600. */
  61601. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61602. private _updateShaderUniforms;
  61603. protected _getDefines(): string;
  61604. /** Generate the current state of the procedural texture */
  61605. render(useCameraPostProcess?: boolean): void;
  61606. /**
  61607. * Serializes this noise procedural texture
  61608. * @returns a serialized noise procedural texture object
  61609. */
  61610. serialize(): any;
  61611. /**
  61612. * Clone the texture.
  61613. * @returns the cloned texture
  61614. */
  61615. clone(): NoiseProceduralTexture;
  61616. /**
  61617. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61618. * @param parsedTexture defines parsed texture data
  61619. * @param scene defines the current scene
  61620. * @param rootUrl defines the root URL containing noise procedural texture information
  61621. * @returns a parsed NoiseProceduralTexture
  61622. */
  61623. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61624. }
  61625. }
  61626. declare module BABYLON {
  61627. /**
  61628. * Raw cube texture where the raw buffers are passed in
  61629. */
  61630. export class RawCubeTexture extends CubeTexture {
  61631. /**
  61632. * Creates a cube texture where the raw buffers are passed in.
  61633. * @param scene defines the scene the texture is attached to
  61634. * @param data defines the array of data to use to create each face
  61635. * @param size defines the size of the textures
  61636. * @param format defines the format of the data
  61637. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61638. * @param generateMipMaps defines if the engine should generate the mip levels
  61639. * @param invertY defines if data must be stored with Y axis inverted
  61640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61641. * @param compression defines the compression used (null by default)
  61642. */
  61643. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61644. /**
  61645. * Updates the raw cube texture.
  61646. * @param data defines the data to store
  61647. * @param format defines the data format
  61648. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61649. * @param invertY defines if data must be stored with Y axis inverted
  61650. * @param compression defines the compression used (null by default)
  61651. * @param level defines which level of the texture to update
  61652. */
  61653. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61654. /**
  61655. * Updates a raw cube texture with RGBD encoded data.
  61656. * @param data defines the array of data [mipmap][face] to use to create each face
  61657. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61660. * @returns a promsie that resolves when the operation is complete
  61661. */
  61662. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61663. /**
  61664. * Clones the raw cube texture.
  61665. * @return a new cube texture
  61666. */
  61667. clone(): CubeTexture;
  61668. /** @hidden */
  61669. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61670. }
  61671. }
  61672. declare module BABYLON {
  61673. /**
  61674. * Class used to store 2D array textures containing user data
  61675. */
  61676. export class RawTexture2DArray extends Texture {
  61677. /** Gets or sets the texture format to use */
  61678. format: number;
  61679. /**
  61680. * Create a new RawTexture2DArray
  61681. * @param data defines the data of the texture
  61682. * @param width defines the width of the texture
  61683. * @param height defines the height of the texture
  61684. * @param depth defines the number of layers of the texture
  61685. * @param format defines the texture format to use
  61686. * @param scene defines the hosting scene
  61687. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61688. * @param invertY defines if texture must be stored with Y axis inverted
  61689. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61691. */
  61692. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61693. /** Gets or sets the texture format to use */
  61694. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61695. /**
  61696. * Update the texture with new data
  61697. * @param data defines the data to store in the texture
  61698. */
  61699. update(data: ArrayBufferView): void;
  61700. }
  61701. }
  61702. declare module BABYLON {
  61703. /**
  61704. * Class used to store 3D textures containing user data
  61705. */
  61706. export class RawTexture3D extends Texture {
  61707. /** Gets or sets the texture format to use */
  61708. format: number;
  61709. /**
  61710. * Create a new RawTexture3D
  61711. * @param data defines the data of the texture
  61712. * @param width defines the width of the texture
  61713. * @param height defines the height of the texture
  61714. * @param depth defines the depth of the texture
  61715. * @param format defines the texture format to use
  61716. * @param scene defines the hosting scene
  61717. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61718. * @param invertY defines if texture must be stored with Y axis inverted
  61719. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61721. */
  61722. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61723. /** Gets or sets the texture format to use */
  61724. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61725. /**
  61726. * Update the texture with new data
  61727. * @param data defines the data to store in the texture
  61728. */
  61729. update(data: ArrayBufferView): void;
  61730. }
  61731. }
  61732. declare module BABYLON {
  61733. /**
  61734. * Creates a refraction texture used by refraction channel of the standard material.
  61735. * It is like a mirror but to see through a material.
  61736. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61737. */
  61738. export class RefractionTexture extends RenderTargetTexture {
  61739. /**
  61740. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61741. * 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.
  61742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61743. */
  61744. refractionPlane: Plane;
  61745. /**
  61746. * Define how deep under the surface we should see.
  61747. */
  61748. depth: number;
  61749. /**
  61750. * Creates a refraction texture used by refraction channel of the standard material.
  61751. * It is like a mirror but to see through a material.
  61752. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61753. * @param name Define the texture name
  61754. * @param size Define the size of the underlying texture
  61755. * @param scene Define the scene the refraction belongs to
  61756. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61757. */
  61758. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61759. /**
  61760. * Clone the refraction texture.
  61761. * @returns the cloned texture
  61762. */
  61763. clone(): RefractionTexture;
  61764. /**
  61765. * Serialize the texture to a JSON representation you could use in Parse later on
  61766. * @returns the serialized JSON representation
  61767. */
  61768. serialize(): any;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * Block used to add support for vertex skinning (bones)
  61774. */
  61775. export class BonesBlock extends NodeMaterialBlock {
  61776. /**
  61777. * Creates a new BonesBlock
  61778. * @param name defines the block name
  61779. */
  61780. constructor(name: string);
  61781. /**
  61782. * Initialize the block and prepare the context for build
  61783. * @param state defines the state that will be used for the build
  61784. */
  61785. initialize(state: NodeMaterialBuildState): void;
  61786. /**
  61787. * Gets the current class name
  61788. * @returns the class name
  61789. */
  61790. getClassName(): string;
  61791. /**
  61792. * Gets the matrix indices input component
  61793. */
  61794. get matricesIndices(): NodeMaterialConnectionPoint;
  61795. /**
  61796. * Gets the matrix weights input component
  61797. */
  61798. get matricesWeights(): NodeMaterialConnectionPoint;
  61799. /**
  61800. * Gets the extra matrix indices input component
  61801. */
  61802. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the extra matrix weights input component
  61805. */
  61806. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the world input component
  61809. */
  61810. get world(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the output component
  61813. */
  61814. get output(): NodeMaterialConnectionPoint;
  61815. autoConfigure(material: NodeMaterial): void;
  61816. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61819. protected _buildBlock(state: NodeMaterialBuildState): this;
  61820. }
  61821. }
  61822. declare module BABYLON {
  61823. /**
  61824. * Block used to add support for instances
  61825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61826. */
  61827. export class InstancesBlock extends NodeMaterialBlock {
  61828. /**
  61829. * Creates a new InstancesBlock
  61830. * @param name defines the block name
  61831. */
  61832. constructor(name: string);
  61833. /**
  61834. * Gets the current class name
  61835. * @returns the class name
  61836. */
  61837. getClassName(): string;
  61838. /**
  61839. * Gets the first world row input component
  61840. */
  61841. get world0(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the second world row input component
  61844. */
  61845. get world1(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the third world row input component
  61848. */
  61849. get world2(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the forth world row input component
  61852. */
  61853. get world3(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the world input component
  61856. */
  61857. get world(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the output component
  61860. */
  61861. get output(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the isntanceID component
  61864. */
  61865. get instanceID(): NodeMaterialConnectionPoint;
  61866. autoConfigure(material: NodeMaterial): void;
  61867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61868. protected _buildBlock(state: NodeMaterialBuildState): this;
  61869. }
  61870. }
  61871. declare module BABYLON {
  61872. /**
  61873. * Block used to add morph targets support to vertex shader
  61874. */
  61875. export class MorphTargetsBlock extends NodeMaterialBlock {
  61876. private _repeatableContentAnchor;
  61877. /**
  61878. * Create a new MorphTargetsBlock
  61879. * @param name defines the block name
  61880. */
  61881. constructor(name: string);
  61882. /**
  61883. * Gets the current class name
  61884. * @returns the class name
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Gets the position input component
  61889. */
  61890. get position(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the normal input component
  61893. */
  61894. get normal(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the tangent input component
  61897. */
  61898. get tangent(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the tangent input component
  61901. */
  61902. get uv(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the position output component
  61905. */
  61906. get positionOutput(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the normal output component
  61909. */
  61910. get normalOutput(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the tangent output component
  61913. */
  61914. get tangentOutput(): NodeMaterialConnectionPoint;
  61915. /**
  61916. * Gets the tangent output component
  61917. */
  61918. get uvOutput(): NodeMaterialConnectionPoint;
  61919. initialize(state: NodeMaterialBuildState): void;
  61920. autoConfigure(material: NodeMaterial): void;
  61921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61923. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61924. protected _buildBlock(state: NodeMaterialBuildState): this;
  61925. }
  61926. }
  61927. declare module BABYLON {
  61928. /**
  61929. * Block used to get data information from a light
  61930. */
  61931. export class LightInformationBlock extends NodeMaterialBlock {
  61932. private _lightDataUniformName;
  61933. private _lightColorUniformName;
  61934. private _lightTypeDefineName;
  61935. /**
  61936. * Gets or sets the light associated with this block
  61937. */
  61938. light: Nullable<Light>;
  61939. /**
  61940. * Creates a new LightInformationBlock
  61941. * @param name defines the block name
  61942. */
  61943. constructor(name: string);
  61944. /**
  61945. * Gets the current class name
  61946. * @returns the class name
  61947. */
  61948. getClassName(): string;
  61949. /**
  61950. * Gets the world position input component
  61951. */
  61952. get worldPosition(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the direction output component
  61955. */
  61956. get direction(): NodeMaterialConnectionPoint;
  61957. /**
  61958. * Gets the direction output component
  61959. */
  61960. get color(): NodeMaterialConnectionPoint;
  61961. /**
  61962. * Gets the direction output component
  61963. */
  61964. get intensity(): NodeMaterialConnectionPoint;
  61965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61967. protected _buildBlock(state: NodeMaterialBuildState): this;
  61968. serialize(): any;
  61969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61970. }
  61971. }
  61972. declare module BABYLON {
  61973. /**
  61974. * Block used to add image processing support to fragment shader
  61975. */
  61976. export class ImageProcessingBlock extends NodeMaterialBlock {
  61977. /**
  61978. * Create a new ImageProcessingBlock
  61979. * @param name defines the block name
  61980. */
  61981. constructor(name: string);
  61982. /**
  61983. * Gets the current class name
  61984. * @returns the class name
  61985. */
  61986. getClassName(): string;
  61987. /**
  61988. * Gets the color input component
  61989. */
  61990. get color(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the output component
  61993. */
  61994. get output(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Initialize the block and prepare the context for build
  61997. * @param state defines the state that will be used for the build
  61998. */
  61999. initialize(state: NodeMaterialBuildState): void;
  62000. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62003. protected _buildBlock(state: NodeMaterialBuildState): this;
  62004. }
  62005. }
  62006. declare module BABYLON {
  62007. /**
  62008. * Block used to pertub normals based on a normal map
  62009. */
  62010. export class PerturbNormalBlock extends NodeMaterialBlock {
  62011. private _tangentSpaceParameterName;
  62012. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62013. invertX: boolean;
  62014. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62015. invertY: boolean;
  62016. /**
  62017. * Create a new PerturbNormalBlock
  62018. * @param name defines the block name
  62019. */
  62020. constructor(name: string);
  62021. /**
  62022. * Gets the current class name
  62023. * @returns the class name
  62024. */
  62025. getClassName(): string;
  62026. /**
  62027. * Gets the world position input component
  62028. */
  62029. get worldPosition(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the world normal input component
  62032. */
  62033. get worldNormal(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the world tangent input component
  62036. */
  62037. get worldTangent(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the uv input component
  62040. */
  62041. get uv(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the normal map color input component
  62044. */
  62045. get normalMapColor(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the strength input component
  62048. */
  62049. get strength(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the output component
  62052. */
  62053. get output(): NodeMaterialConnectionPoint;
  62054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62056. autoConfigure(material: NodeMaterial): void;
  62057. protected _buildBlock(state: NodeMaterialBuildState): this;
  62058. protected _dumpPropertiesCode(): string;
  62059. serialize(): any;
  62060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62061. }
  62062. }
  62063. declare module BABYLON {
  62064. /**
  62065. * Block used to discard a pixel if a value is smaller than a cutoff
  62066. */
  62067. export class DiscardBlock extends NodeMaterialBlock {
  62068. /**
  62069. * Create a new DiscardBlock
  62070. * @param name defines the block name
  62071. */
  62072. constructor(name: string);
  62073. /**
  62074. * Gets the current class name
  62075. * @returns the class name
  62076. */
  62077. getClassName(): string;
  62078. /**
  62079. * Gets the color input component
  62080. */
  62081. get value(): NodeMaterialConnectionPoint;
  62082. /**
  62083. * Gets the cutoff input component
  62084. */
  62085. get cutoff(): NodeMaterialConnectionPoint;
  62086. protected _buildBlock(state: NodeMaterialBuildState): this;
  62087. }
  62088. }
  62089. declare module BABYLON {
  62090. /**
  62091. * Block used to test if the fragment shader is front facing
  62092. */
  62093. export class FrontFacingBlock extends NodeMaterialBlock {
  62094. /**
  62095. * Creates a new FrontFacingBlock
  62096. * @param name defines the block name
  62097. */
  62098. constructor(name: string);
  62099. /**
  62100. * Gets the current class name
  62101. * @returns the class name
  62102. */
  62103. getClassName(): string;
  62104. /**
  62105. * Gets the output component
  62106. */
  62107. get output(): NodeMaterialConnectionPoint;
  62108. protected _buildBlock(state: NodeMaterialBuildState): this;
  62109. }
  62110. }
  62111. declare module BABYLON {
  62112. /**
  62113. * Block used to get the derivative value on x and y of a given input
  62114. */
  62115. export class DerivativeBlock extends NodeMaterialBlock {
  62116. /**
  62117. * Create a new DerivativeBlock
  62118. * @param name defines the block name
  62119. */
  62120. constructor(name: string);
  62121. /**
  62122. * Gets the current class name
  62123. * @returns the class name
  62124. */
  62125. getClassName(): string;
  62126. /**
  62127. * Gets the input component
  62128. */
  62129. get input(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the derivative output on x
  62132. */
  62133. get dx(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the derivative output on y
  62136. */
  62137. get dy(): NodeMaterialConnectionPoint;
  62138. protected _buildBlock(state: NodeMaterialBuildState): this;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Block used to make gl_FragCoord available
  62144. */
  62145. export class FragCoordBlock extends NodeMaterialBlock {
  62146. /**
  62147. * Creates a new FragCoordBlock
  62148. * @param name defines the block name
  62149. */
  62150. constructor(name: string);
  62151. /**
  62152. * Gets the current class name
  62153. * @returns the class name
  62154. */
  62155. getClassName(): string;
  62156. /**
  62157. * Gets the xy component
  62158. */
  62159. get xy(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the xyz component
  62162. */
  62163. get xyz(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the xyzw component
  62166. */
  62167. get xyzw(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the x component
  62170. */
  62171. get x(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the y component
  62174. */
  62175. get y(): NodeMaterialConnectionPoint;
  62176. /**
  62177. * Gets the z component
  62178. */
  62179. get z(): NodeMaterialConnectionPoint;
  62180. /**
  62181. * Gets the w component
  62182. */
  62183. get output(): NodeMaterialConnectionPoint;
  62184. protected writeOutputs(state: NodeMaterialBuildState): string;
  62185. protected _buildBlock(state: NodeMaterialBuildState): this;
  62186. }
  62187. }
  62188. declare module BABYLON {
  62189. /**
  62190. * Block used to get the screen sizes
  62191. */
  62192. export class ScreenSizeBlock extends NodeMaterialBlock {
  62193. private _varName;
  62194. private _scene;
  62195. /**
  62196. * Creates a new ScreenSizeBlock
  62197. * @param name defines the block name
  62198. */
  62199. constructor(name: string);
  62200. /**
  62201. * Gets the current class name
  62202. * @returns the class name
  62203. */
  62204. getClassName(): string;
  62205. /**
  62206. * Gets the xy component
  62207. */
  62208. get xy(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the x component
  62211. */
  62212. get x(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the y component
  62215. */
  62216. get y(): NodeMaterialConnectionPoint;
  62217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62218. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62219. protected _buildBlock(state: NodeMaterialBuildState): this;
  62220. }
  62221. }
  62222. declare module BABYLON {
  62223. /**
  62224. * Block used to add support for scene fog
  62225. */
  62226. export class FogBlock extends NodeMaterialBlock {
  62227. private _fogDistanceName;
  62228. private _fogParameters;
  62229. /**
  62230. * Create a new FogBlock
  62231. * @param name defines the block name
  62232. */
  62233. constructor(name: string);
  62234. /**
  62235. * Gets the current class name
  62236. * @returns the class name
  62237. */
  62238. getClassName(): string;
  62239. /**
  62240. * Gets the world position input component
  62241. */
  62242. get worldPosition(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the view input component
  62245. */
  62246. get view(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the color input component
  62249. */
  62250. get input(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the fog color input component
  62253. */
  62254. get fogColor(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the output component
  62257. */
  62258. get output(): NodeMaterialConnectionPoint;
  62259. autoConfigure(material: NodeMaterial): void;
  62260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62262. protected _buildBlock(state: NodeMaterialBuildState): this;
  62263. }
  62264. }
  62265. declare module BABYLON {
  62266. /**
  62267. * Block used to add light in the fragment shader
  62268. */
  62269. export class LightBlock extends NodeMaterialBlock {
  62270. private _lightId;
  62271. /**
  62272. * Gets or sets the light associated with this block
  62273. */
  62274. light: Nullable<Light>;
  62275. /**
  62276. * Create a new LightBlock
  62277. * @param name defines the block name
  62278. */
  62279. constructor(name: string);
  62280. /**
  62281. * Gets the current class name
  62282. * @returns the class name
  62283. */
  62284. getClassName(): string;
  62285. /**
  62286. * Gets the world position input component
  62287. */
  62288. get worldPosition(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the world normal input component
  62291. */
  62292. get worldNormal(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the camera (or eye) position component
  62295. */
  62296. get cameraPosition(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the glossiness component
  62299. */
  62300. get glossiness(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the glossinness power component
  62303. */
  62304. get glossPower(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the diffuse color component
  62307. */
  62308. get diffuseColor(): NodeMaterialConnectionPoint;
  62309. /**
  62310. * Gets the specular color component
  62311. */
  62312. get specularColor(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the diffuse output component
  62315. */
  62316. get diffuseOutput(): NodeMaterialConnectionPoint;
  62317. /**
  62318. * Gets the specular output component
  62319. */
  62320. get specularOutput(): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Gets the shadow output component
  62323. */
  62324. get shadow(): NodeMaterialConnectionPoint;
  62325. autoConfigure(material: NodeMaterial): void;
  62326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62327. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62329. private _injectVertexCode;
  62330. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62331. serialize(): any;
  62332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Block used to read a reflection texture from a sampler
  62338. */
  62339. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62340. /**
  62341. * Create a new ReflectionTextureBlock
  62342. * @param name defines the block name
  62343. */
  62344. constructor(name: string);
  62345. /**
  62346. * Gets the current class name
  62347. * @returns the class name
  62348. */
  62349. getClassName(): string;
  62350. /**
  62351. * Gets the world position input component
  62352. */
  62353. get position(): NodeMaterialConnectionPoint;
  62354. /**
  62355. * Gets the world position input component
  62356. */
  62357. get worldPosition(): NodeMaterialConnectionPoint;
  62358. /**
  62359. * Gets the world normal input component
  62360. */
  62361. get worldNormal(): NodeMaterialConnectionPoint;
  62362. /**
  62363. * Gets the world input component
  62364. */
  62365. get world(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the camera (or eye) position component
  62368. */
  62369. get cameraPosition(): NodeMaterialConnectionPoint;
  62370. /**
  62371. * Gets the view input component
  62372. */
  62373. get view(): NodeMaterialConnectionPoint;
  62374. /**
  62375. * Gets the rgb output component
  62376. */
  62377. get rgb(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the rgba output component
  62380. */
  62381. get rgba(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Gets the r output component
  62384. */
  62385. get r(): NodeMaterialConnectionPoint;
  62386. /**
  62387. * Gets the g output component
  62388. */
  62389. get g(): NodeMaterialConnectionPoint;
  62390. /**
  62391. * Gets the b output component
  62392. */
  62393. get b(): NodeMaterialConnectionPoint;
  62394. /**
  62395. * Gets the a output component
  62396. */
  62397. get a(): NodeMaterialConnectionPoint;
  62398. autoConfigure(material: NodeMaterial): void;
  62399. protected _buildBlock(state: NodeMaterialBuildState): this;
  62400. }
  62401. }
  62402. declare module BABYLON {
  62403. /**
  62404. * Block used to add 2 vectors
  62405. */
  62406. export class AddBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Creates a new AddBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Gets the current class name
  62414. * @returns the class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets the left operand input component
  62419. */
  62420. get left(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the right operand input component
  62423. */
  62424. get right(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the output component
  62427. */
  62428. get output(): NodeMaterialConnectionPoint;
  62429. protected _buildBlock(state: NodeMaterialBuildState): this;
  62430. }
  62431. }
  62432. declare module BABYLON {
  62433. /**
  62434. * Block used to scale a vector by a float
  62435. */
  62436. export class ScaleBlock extends NodeMaterialBlock {
  62437. /**
  62438. * Creates a new ScaleBlock
  62439. * @param name defines the block name
  62440. */
  62441. constructor(name: string);
  62442. /**
  62443. * Gets the current class name
  62444. * @returns the class name
  62445. */
  62446. getClassName(): string;
  62447. /**
  62448. * Gets the input component
  62449. */
  62450. get input(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the factor input component
  62453. */
  62454. get factor(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the output component
  62457. */
  62458. get output(): NodeMaterialConnectionPoint;
  62459. protected _buildBlock(state: NodeMaterialBuildState): this;
  62460. }
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * Block used to clamp a float
  62465. */
  62466. export class ClampBlock extends NodeMaterialBlock {
  62467. /** Gets or sets the minimum range */
  62468. minimum: number;
  62469. /** Gets or sets the maximum range */
  62470. maximum: number;
  62471. /**
  62472. * Creates a new ClampBlock
  62473. * @param name defines the block name
  62474. */
  62475. constructor(name: string);
  62476. /**
  62477. * Gets the current class name
  62478. * @returns the class name
  62479. */
  62480. getClassName(): string;
  62481. /**
  62482. * Gets the value input component
  62483. */
  62484. get value(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the output component
  62487. */
  62488. get output(): NodeMaterialConnectionPoint;
  62489. protected _buildBlock(state: NodeMaterialBuildState): this;
  62490. protected _dumpPropertiesCode(): string;
  62491. serialize(): any;
  62492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62493. }
  62494. }
  62495. declare module BABYLON {
  62496. /**
  62497. * Block used to apply a cross product between 2 vectors
  62498. */
  62499. export class CrossBlock extends NodeMaterialBlock {
  62500. /**
  62501. * Creates a new CrossBlock
  62502. * @param name defines the block name
  62503. */
  62504. constructor(name: string);
  62505. /**
  62506. * Gets the current class name
  62507. * @returns the class name
  62508. */
  62509. getClassName(): string;
  62510. /**
  62511. * Gets the left operand input component
  62512. */
  62513. get left(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the right operand input component
  62516. */
  62517. get right(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the output component
  62520. */
  62521. get output(): NodeMaterialConnectionPoint;
  62522. protected _buildBlock(state: NodeMaterialBuildState): this;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * Block used to apply a dot product between 2 vectors
  62528. */
  62529. export class DotBlock extends NodeMaterialBlock {
  62530. /**
  62531. * Creates a new DotBlock
  62532. * @param name defines the block name
  62533. */
  62534. constructor(name: string);
  62535. /**
  62536. * Gets the current class name
  62537. * @returns the class name
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Gets the left operand input component
  62542. */
  62543. get left(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the right operand input component
  62546. */
  62547. get right(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the output component
  62550. */
  62551. get output(): NodeMaterialConnectionPoint;
  62552. protected _buildBlock(state: NodeMaterialBuildState): this;
  62553. }
  62554. }
  62555. declare module BABYLON {
  62556. /**
  62557. * Block used to normalize a vector
  62558. */
  62559. export class NormalizeBlock extends NodeMaterialBlock {
  62560. /**
  62561. * Creates a new NormalizeBlock
  62562. * @param name defines the block name
  62563. */
  62564. constructor(name: string);
  62565. /**
  62566. * Gets the current class name
  62567. * @returns the class name
  62568. */
  62569. getClassName(): string;
  62570. /**
  62571. * Gets the input component
  62572. */
  62573. get input(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the output component
  62576. */
  62577. get output(): NodeMaterialConnectionPoint;
  62578. protected _buildBlock(state: NodeMaterialBuildState): this;
  62579. }
  62580. }
  62581. declare module BABYLON {
  62582. /**
  62583. * Operations supported by the Trigonometry block
  62584. */
  62585. export enum TrigonometryBlockOperations {
  62586. /** Cos */
  62587. Cos = 0,
  62588. /** Sin */
  62589. Sin = 1,
  62590. /** Abs */
  62591. Abs = 2,
  62592. /** Exp */
  62593. Exp = 3,
  62594. /** Exp2 */
  62595. Exp2 = 4,
  62596. /** Round */
  62597. Round = 5,
  62598. /** Floor */
  62599. Floor = 6,
  62600. /** Ceiling */
  62601. Ceiling = 7,
  62602. /** Square root */
  62603. Sqrt = 8,
  62604. /** Log */
  62605. Log = 9,
  62606. /** Tangent */
  62607. Tan = 10,
  62608. /** Arc tangent */
  62609. ArcTan = 11,
  62610. /** Arc cosinus */
  62611. ArcCos = 12,
  62612. /** Arc sinus */
  62613. ArcSin = 13,
  62614. /** Fraction */
  62615. Fract = 14,
  62616. /** Sign */
  62617. Sign = 15,
  62618. /** To radians (from degrees) */
  62619. Radians = 16,
  62620. /** To degrees (from radians) */
  62621. Degrees = 17
  62622. }
  62623. /**
  62624. * Block used to apply trigonometry operation to floats
  62625. */
  62626. export class TrigonometryBlock extends NodeMaterialBlock {
  62627. /**
  62628. * Gets or sets the operation applied by the block
  62629. */
  62630. operation: TrigonometryBlockOperations;
  62631. /**
  62632. * Creates a new TrigonometryBlock
  62633. * @param name defines the block name
  62634. */
  62635. constructor(name: string);
  62636. /**
  62637. * Gets the current class name
  62638. * @returns the class name
  62639. */
  62640. getClassName(): string;
  62641. /**
  62642. * Gets the input component
  62643. */
  62644. get input(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. serialize(): any;
  62651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62652. protected _dumpPropertiesCode(): string;
  62653. }
  62654. }
  62655. declare module BABYLON {
  62656. /**
  62657. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62658. */
  62659. export class ColorMergerBlock extends NodeMaterialBlock {
  62660. /**
  62661. * Create a new ColorMergerBlock
  62662. * @param name defines the block name
  62663. */
  62664. constructor(name: string);
  62665. /**
  62666. * Gets the current class name
  62667. * @returns the class name
  62668. */
  62669. getClassName(): string;
  62670. /**
  62671. * Gets the rgb component (input)
  62672. */
  62673. get rgbIn(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the r component (input)
  62676. */
  62677. get r(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the g component (input)
  62680. */
  62681. get g(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the b component (input)
  62684. */
  62685. get b(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the a component (input)
  62688. */
  62689. get a(): NodeMaterialConnectionPoint;
  62690. /**
  62691. * Gets the rgba component (output)
  62692. */
  62693. get rgba(): NodeMaterialConnectionPoint;
  62694. /**
  62695. * Gets the rgb component (output)
  62696. */
  62697. get rgbOut(): NodeMaterialConnectionPoint;
  62698. /**
  62699. * Gets the rgb component (output)
  62700. * @deprecated Please use rgbOut instead.
  62701. */
  62702. get rgb(): NodeMaterialConnectionPoint;
  62703. protected _buildBlock(state: NodeMaterialBuildState): this;
  62704. }
  62705. }
  62706. declare module BABYLON {
  62707. /**
  62708. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62709. */
  62710. export class VectorSplitterBlock extends NodeMaterialBlock {
  62711. /**
  62712. * Create a new VectorSplitterBlock
  62713. * @param name defines the block name
  62714. */
  62715. constructor(name: string);
  62716. /**
  62717. * Gets the current class name
  62718. * @returns the class name
  62719. */
  62720. getClassName(): string;
  62721. /**
  62722. * Gets the xyzw component (input)
  62723. */
  62724. get xyzw(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the xyz component (input)
  62727. */
  62728. get xyzIn(): NodeMaterialConnectionPoint;
  62729. /**
  62730. * Gets the xy component (input)
  62731. */
  62732. get xyIn(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the xyz component (output)
  62735. */
  62736. get xyzOut(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the xy component (output)
  62739. */
  62740. get xyOut(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the x component (output)
  62743. */
  62744. get x(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the y component (output)
  62747. */
  62748. get y(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the z component (output)
  62751. */
  62752. get z(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the w component (output)
  62755. */
  62756. get w(): NodeMaterialConnectionPoint;
  62757. protected _inputRename(name: string): string;
  62758. protected _outputRename(name: string): string;
  62759. protected _buildBlock(state: NodeMaterialBuildState): this;
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /**
  62764. * Block used to lerp between 2 values
  62765. */
  62766. export class LerpBlock extends NodeMaterialBlock {
  62767. /**
  62768. * Creates a new LerpBlock
  62769. * @param name defines the block name
  62770. */
  62771. constructor(name: string);
  62772. /**
  62773. * Gets the current class name
  62774. * @returns the class name
  62775. */
  62776. getClassName(): string;
  62777. /**
  62778. * Gets the left operand input component
  62779. */
  62780. get left(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the right operand input component
  62783. */
  62784. get right(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the gradient operand input component
  62787. */
  62788. get gradient(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the output component
  62791. */
  62792. get output(): NodeMaterialConnectionPoint;
  62793. protected _buildBlock(state: NodeMaterialBuildState): this;
  62794. }
  62795. }
  62796. declare module BABYLON {
  62797. /**
  62798. * Block used to divide 2 vectors
  62799. */
  62800. export class DivideBlock extends NodeMaterialBlock {
  62801. /**
  62802. * Creates a new DivideBlock
  62803. * @param name defines the block name
  62804. */
  62805. constructor(name: string);
  62806. /**
  62807. * Gets the current class name
  62808. * @returns the class name
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Gets the left operand input component
  62813. */
  62814. get left(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the right operand input component
  62817. */
  62818. get right(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the output component
  62821. */
  62822. get output(): NodeMaterialConnectionPoint;
  62823. protected _buildBlock(state: NodeMaterialBuildState): this;
  62824. }
  62825. }
  62826. declare module BABYLON {
  62827. /**
  62828. * Block used to subtract 2 vectors
  62829. */
  62830. export class SubtractBlock extends NodeMaterialBlock {
  62831. /**
  62832. * Creates a new SubtractBlock
  62833. * @param name defines the block name
  62834. */
  62835. constructor(name: string);
  62836. /**
  62837. * Gets the current class name
  62838. * @returns the class name
  62839. */
  62840. getClassName(): string;
  62841. /**
  62842. * Gets the left operand input component
  62843. */
  62844. get left(): NodeMaterialConnectionPoint;
  62845. /**
  62846. * Gets the right operand input component
  62847. */
  62848. get right(): NodeMaterialConnectionPoint;
  62849. /**
  62850. * Gets the output component
  62851. */
  62852. get output(): NodeMaterialConnectionPoint;
  62853. protected _buildBlock(state: NodeMaterialBuildState): this;
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /**
  62858. * Block used to step a value
  62859. */
  62860. export class StepBlock extends NodeMaterialBlock {
  62861. /**
  62862. * Creates a new StepBlock
  62863. * @param name defines the block name
  62864. */
  62865. constructor(name: string);
  62866. /**
  62867. * Gets the current class name
  62868. * @returns the class name
  62869. */
  62870. getClassName(): string;
  62871. /**
  62872. * Gets the value operand input component
  62873. */
  62874. get value(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the edge operand input component
  62877. */
  62878. get edge(): NodeMaterialConnectionPoint;
  62879. /**
  62880. * Gets the output component
  62881. */
  62882. get output(): NodeMaterialConnectionPoint;
  62883. protected _buildBlock(state: NodeMaterialBuildState): this;
  62884. }
  62885. }
  62886. declare module BABYLON {
  62887. /**
  62888. * Block used to get the opposite (1 - x) of a value
  62889. */
  62890. export class OneMinusBlock extends NodeMaterialBlock {
  62891. /**
  62892. * Creates a new OneMinusBlock
  62893. * @param name defines the block name
  62894. */
  62895. constructor(name: string);
  62896. /**
  62897. * Gets the current class name
  62898. * @returns the class name
  62899. */
  62900. getClassName(): string;
  62901. /**
  62902. * Gets the input component
  62903. */
  62904. get input(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the output component
  62907. */
  62908. get output(): NodeMaterialConnectionPoint;
  62909. protected _buildBlock(state: NodeMaterialBuildState): this;
  62910. }
  62911. }
  62912. declare module BABYLON {
  62913. /**
  62914. * Block used to get the view direction
  62915. */
  62916. export class ViewDirectionBlock extends NodeMaterialBlock {
  62917. /**
  62918. * Creates a new ViewDirectionBlock
  62919. * @param name defines the block name
  62920. */
  62921. constructor(name: string);
  62922. /**
  62923. * Gets the current class name
  62924. * @returns the class name
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Gets the world position component
  62929. */
  62930. get worldPosition(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the camera position component
  62933. */
  62934. get cameraPosition(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the output component
  62937. */
  62938. get output(): NodeMaterialConnectionPoint;
  62939. autoConfigure(material: NodeMaterial): void;
  62940. protected _buildBlock(state: NodeMaterialBuildState): this;
  62941. }
  62942. }
  62943. declare module BABYLON {
  62944. /**
  62945. * Block used to compute fresnel value
  62946. */
  62947. export class FresnelBlock extends NodeMaterialBlock {
  62948. /**
  62949. * Create a new FresnelBlock
  62950. * @param name defines the block name
  62951. */
  62952. constructor(name: string);
  62953. /**
  62954. * Gets the current class name
  62955. * @returns the class name
  62956. */
  62957. getClassName(): string;
  62958. /**
  62959. * Gets the world normal input component
  62960. */
  62961. get worldNormal(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the view direction input component
  62964. */
  62965. get viewDirection(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the bias input component
  62968. */
  62969. get bias(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the camera (or eye) position component
  62972. */
  62973. get power(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the fresnel output component
  62976. */
  62977. get fresnel(): NodeMaterialConnectionPoint;
  62978. autoConfigure(material: NodeMaterial): void;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Block used to get the max of 2 values
  62985. */
  62986. export class MaxBlock extends NodeMaterialBlock {
  62987. /**
  62988. * Creates a new MaxBlock
  62989. * @param name defines the block name
  62990. */
  62991. constructor(name: string);
  62992. /**
  62993. * Gets the current class name
  62994. * @returns the class name
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * Gets the left operand input component
  62999. */
  63000. get left(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the right operand input component
  63003. */
  63004. get right(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the output component
  63007. */
  63008. get output(): NodeMaterialConnectionPoint;
  63009. protected _buildBlock(state: NodeMaterialBuildState): this;
  63010. }
  63011. }
  63012. declare module BABYLON {
  63013. /**
  63014. * Block used to get the min of 2 values
  63015. */
  63016. export class MinBlock extends NodeMaterialBlock {
  63017. /**
  63018. * Creates a new MinBlock
  63019. * @param name defines the block name
  63020. */
  63021. constructor(name: string);
  63022. /**
  63023. * Gets the current class name
  63024. * @returns the class name
  63025. */
  63026. getClassName(): string;
  63027. /**
  63028. * Gets the left operand input component
  63029. */
  63030. get left(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the right operand input component
  63033. */
  63034. get right(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the output component
  63037. */
  63038. get output(): NodeMaterialConnectionPoint;
  63039. protected _buildBlock(state: NodeMaterialBuildState): this;
  63040. }
  63041. }
  63042. declare module BABYLON {
  63043. /**
  63044. * Block used to get the distance between 2 values
  63045. */
  63046. export class DistanceBlock extends NodeMaterialBlock {
  63047. /**
  63048. * Creates a new DistanceBlock
  63049. * @param name defines the block name
  63050. */
  63051. constructor(name: string);
  63052. /**
  63053. * Gets the current class name
  63054. * @returns the class name
  63055. */
  63056. getClassName(): string;
  63057. /**
  63058. * Gets the left operand input component
  63059. */
  63060. get left(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the right operand input component
  63063. */
  63064. get right(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the output component
  63067. */
  63068. get output(): NodeMaterialConnectionPoint;
  63069. protected _buildBlock(state: NodeMaterialBuildState): this;
  63070. }
  63071. }
  63072. declare module BABYLON {
  63073. /**
  63074. * Block used to get the length of a vector
  63075. */
  63076. export class LengthBlock extends NodeMaterialBlock {
  63077. /**
  63078. * Creates a new LengthBlock
  63079. * @param name defines the block name
  63080. */
  63081. constructor(name: string);
  63082. /**
  63083. * Gets the current class name
  63084. * @returns the class name
  63085. */
  63086. getClassName(): string;
  63087. /**
  63088. * Gets the value input component
  63089. */
  63090. get value(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the output component
  63093. */
  63094. get output(): NodeMaterialConnectionPoint;
  63095. protected _buildBlock(state: NodeMaterialBuildState): this;
  63096. }
  63097. }
  63098. declare module BABYLON {
  63099. /**
  63100. * Block used to get negative version of a value (i.e. x * -1)
  63101. */
  63102. export class NegateBlock extends NodeMaterialBlock {
  63103. /**
  63104. * Creates a new NegateBlock
  63105. * @param name defines the block name
  63106. */
  63107. constructor(name: string);
  63108. /**
  63109. * Gets the current class name
  63110. * @returns the class name
  63111. */
  63112. getClassName(): string;
  63113. /**
  63114. * Gets the value input component
  63115. */
  63116. get value(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the output component
  63119. */
  63120. get output(): NodeMaterialConnectionPoint;
  63121. protected _buildBlock(state: NodeMaterialBuildState): this;
  63122. }
  63123. }
  63124. declare module BABYLON {
  63125. /**
  63126. * Block used to get the value of the first parameter raised to the power of the second
  63127. */
  63128. export class PowBlock extends NodeMaterialBlock {
  63129. /**
  63130. * Creates a new PowBlock
  63131. * @param name defines the block name
  63132. */
  63133. constructor(name: string);
  63134. /**
  63135. * Gets the current class name
  63136. * @returns the class name
  63137. */
  63138. getClassName(): string;
  63139. /**
  63140. * Gets the value operand input component
  63141. */
  63142. get value(): NodeMaterialConnectionPoint;
  63143. /**
  63144. * Gets the power operand input component
  63145. */
  63146. get power(): NodeMaterialConnectionPoint;
  63147. /**
  63148. * Gets the output component
  63149. */
  63150. get output(): NodeMaterialConnectionPoint;
  63151. protected _buildBlock(state: NodeMaterialBuildState): this;
  63152. }
  63153. }
  63154. declare module BABYLON {
  63155. /**
  63156. * Block used to get a random number
  63157. */
  63158. export class RandomNumberBlock extends NodeMaterialBlock {
  63159. /**
  63160. * Creates a new RandomNumberBlock
  63161. * @param name defines the block name
  63162. */
  63163. constructor(name: string);
  63164. /**
  63165. * Gets the current class name
  63166. * @returns the class name
  63167. */
  63168. getClassName(): string;
  63169. /**
  63170. * Gets the seed input component
  63171. */
  63172. get seed(): NodeMaterialConnectionPoint;
  63173. /**
  63174. * Gets the output component
  63175. */
  63176. get output(): NodeMaterialConnectionPoint;
  63177. protected _buildBlock(state: NodeMaterialBuildState): this;
  63178. }
  63179. }
  63180. declare module BABYLON {
  63181. /**
  63182. * Block used to compute arc tangent of 2 values
  63183. */
  63184. export class ArcTan2Block extends NodeMaterialBlock {
  63185. /**
  63186. * Creates a new ArcTan2Block
  63187. * @param name defines the block name
  63188. */
  63189. constructor(name: string);
  63190. /**
  63191. * Gets the current class name
  63192. * @returns the class name
  63193. */
  63194. getClassName(): string;
  63195. /**
  63196. * Gets the x operand input component
  63197. */
  63198. get x(): NodeMaterialConnectionPoint;
  63199. /**
  63200. * Gets the y operand input component
  63201. */
  63202. get y(): NodeMaterialConnectionPoint;
  63203. /**
  63204. * Gets the output component
  63205. */
  63206. get output(): NodeMaterialConnectionPoint;
  63207. protected _buildBlock(state: NodeMaterialBuildState): this;
  63208. }
  63209. }
  63210. declare module BABYLON {
  63211. /**
  63212. * Block used to smooth step a value
  63213. */
  63214. export class SmoothStepBlock extends NodeMaterialBlock {
  63215. /**
  63216. * Creates a new SmoothStepBlock
  63217. * @param name defines the block name
  63218. */
  63219. constructor(name: string);
  63220. /**
  63221. * Gets the current class name
  63222. * @returns the class name
  63223. */
  63224. getClassName(): string;
  63225. /**
  63226. * Gets the value operand input component
  63227. */
  63228. get value(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the first edge operand input component
  63231. */
  63232. get edge0(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the second edge operand input component
  63235. */
  63236. get edge1(): NodeMaterialConnectionPoint;
  63237. /**
  63238. * Gets the output component
  63239. */
  63240. get output(): NodeMaterialConnectionPoint;
  63241. protected _buildBlock(state: NodeMaterialBuildState): this;
  63242. }
  63243. }
  63244. declare module BABYLON {
  63245. /**
  63246. * Block used to get the reciprocal (1 / x) of a value
  63247. */
  63248. export class ReciprocalBlock extends NodeMaterialBlock {
  63249. /**
  63250. * Creates a new ReciprocalBlock
  63251. * @param name defines the block name
  63252. */
  63253. constructor(name: string);
  63254. /**
  63255. * Gets the current class name
  63256. * @returns the class name
  63257. */
  63258. getClassName(): string;
  63259. /**
  63260. * Gets the input component
  63261. */
  63262. get input(): NodeMaterialConnectionPoint;
  63263. /**
  63264. * Gets the output component
  63265. */
  63266. get output(): NodeMaterialConnectionPoint;
  63267. protected _buildBlock(state: NodeMaterialBuildState): this;
  63268. }
  63269. }
  63270. declare module BABYLON {
  63271. /**
  63272. * Block used to replace a color by another one
  63273. */
  63274. export class ReplaceColorBlock extends NodeMaterialBlock {
  63275. /**
  63276. * Creates a new ReplaceColorBlock
  63277. * @param name defines the block name
  63278. */
  63279. constructor(name: string);
  63280. /**
  63281. * Gets the current class name
  63282. * @returns the class name
  63283. */
  63284. getClassName(): string;
  63285. /**
  63286. * Gets the value input component
  63287. */
  63288. get value(): NodeMaterialConnectionPoint;
  63289. /**
  63290. * Gets the reference input component
  63291. */
  63292. get reference(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the distance input component
  63295. */
  63296. get distance(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the replacement input component
  63299. */
  63300. get replacement(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the output component
  63303. */
  63304. get output(): NodeMaterialConnectionPoint;
  63305. protected _buildBlock(state: NodeMaterialBuildState): this;
  63306. }
  63307. }
  63308. declare module BABYLON {
  63309. /**
  63310. * Block used to posterize a value
  63311. * @see https://en.wikipedia.org/wiki/Posterization
  63312. */
  63313. export class PosterizeBlock extends NodeMaterialBlock {
  63314. /**
  63315. * Creates a new PosterizeBlock
  63316. * @param name defines the block name
  63317. */
  63318. constructor(name: string);
  63319. /**
  63320. * Gets the current class name
  63321. * @returns the class name
  63322. */
  63323. getClassName(): string;
  63324. /**
  63325. * Gets the value input component
  63326. */
  63327. get value(): NodeMaterialConnectionPoint;
  63328. /**
  63329. * Gets the steps input component
  63330. */
  63331. get steps(): NodeMaterialConnectionPoint;
  63332. /**
  63333. * Gets the output component
  63334. */
  63335. get output(): NodeMaterialConnectionPoint;
  63336. protected _buildBlock(state: NodeMaterialBuildState): this;
  63337. }
  63338. }
  63339. declare module BABYLON {
  63340. /**
  63341. * Operations supported by the Wave block
  63342. */
  63343. export enum WaveBlockKind {
  63344. /** SawTooth */
  63345. SawTooth = 0,
  63346. /** Square */
  63347. Square = 1,
  63348. /** Triangle */
  63349. Triangle = 2
  63350. }
  63351. /**
  63352. * Block used to apply wave operation to floats
  63353. */
  63354. export class WaveBlock extends NodeMaterialBlock {
  63355. /**
  63356. * Gets or sets the kibnd of wave to be applied by the block
  63357. */
  63358. kind: WaveBlockKind;
  63359. /**
  63360. * Creates a new WaveBlock
  63361. * @param name defines the block name
  63362. */
  63363. constructor(name: string);
  63364. /**
  63365. * Gets the current class name
  63366. * @returns the class name
  63367. */
  63368. getClassName(): string;
  63369. /**
  63370. * Gets the input component
  63371. */
  63372. get input(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the output component
  63375. */
  63376. get output(): NodeMaterialConnectionPoint;
  63377. protected _buildBlock(state: NodeMaterialBuildState): this;
  63378. serialize(): any;
  63379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63380. }
  63381. }
  63382. declare module BABYLON {
  63383. /**
  63384. * Class used to store a color step for the GradientBlock
  63385. */
  63386. export class GradientBlockColorStep {
  63387. /**
  63388. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63389. */
  63390. step: number;
  63391. /**
  63392. * Gets or sets the color associated with this step
  63393. */
  63394. color: Color3;
  63395. /**
  63396. * Creates a new GradientBlockColorStep
  63397. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63398. * @param color defines the color associated with this step
  63399. */
  63400. constructor(
  63401. /**
  63402. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63403. */
  63404. step: number,
  63405. /**
  63406. * Gets or sets the color associated with this step
  63407. */
  63408. color: Color3);
  63409. }
  63410. /**
  63411. * Block used to return a color from a gradient based on an input value between 0 and 1
  63412. */
  63413. export class GradientBlock extends NodeMaterialBlock {
  63414. /**
  63415. * Gets or sets the list of color steps
  63416. */
  63417. colorSteps: GradientBlockColorStep[];
  63418. /**
  63419. * Creates a new GradientBlock
  63420. * @param name defines the block name
  63421. */
  63422. constructor(name: string);
  63423. /**
  63424. * Gets the current class name
  63425. * @returns the class name
  63426. */
  63427. getClassName(): string;
  63428. /**
  63429. * Gets the gradient input component
  63430. */
  63431. get gradient(): NodeMaterialConnectionPoint;
  63432. /**
  63433. * Gets the output component
  63434. */
  63435. get output(): NodeMaterialConnectionPoint;
  63436. private _writeColorConstant;
  63437. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63438. serialize(): any;
  63439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63440. protected _dumpPropertiesCode(): string;
  63441. }
  63442. }
  63443. declare module BABYLON {
  63444. /**
  63445. * Block used to normalize lerp between 2 values
  63446. */
  63447. export class NLerpBlock extends NodeMaterialBlock {
  63448. /**
  63449. * Creates a new NLerpBlock
  63450. * @param name defines the block name
  63451. */
  63452. constructor(name: string);
  63453. /**
  63454. * Gets the current class name
  63455. * @returns the class name
  63456. */
  63457. getClassName(): string;
  63458. /**
  63459. * Gets the left operand input component
  63460. */
  63461. get left(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the right operand input component
  63464. */
  63465. get right(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the gradient operand input component
  63468. */
  63469. get gradient(): NodeMaterialConnectionPoint;
  63470. /**
  63471. * Gets the output component
  63472. */
  63473. get output(): NodeMaterialConnectionPoint;
  63474. protected _buildBlock(state: NodeMaterialBuildState): this;
  63475. }
  63476. }
  63477. declare module BABYLON {
  63478. /**
  63479. * block used to Generate a Worley Noise 3D Noise Pattern
  63480. */
  63481. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63482. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63483. manhattanDistance: boolean;
  63484. /**
  63485. * Creates a new WorleyNoise3DBlock
  63486. * @param name defines the block name
  63487. */
  63488. constructor(name: string);
  63489. /**
  63490. * Gets the current class name
  63491. * @returns the class name
  63492. */
  63493. getClassName(): string;
  63494. /**
  63495. * Gets the seed input component
  63496. */
  63497. get seed(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the jitter input component
  63500. */
  63501. get jitter(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the output component
  63504. */
  63505. get output(): NodeMaterialConnectionPoint;
  63506. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63507. /**
  63508. * Exposes the properties to the UI?
  63509. */
  63510. protected _dumpPropertiesCode(): string;
  63511. /**
  63512. * Exposes the properties to the Seralize?
  63513. */
  63514. serialize(): any;
  63515. /**
  63516. * Exposes the properties to the deseralize?
  63517. */
  63518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63524. */
  63525. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63526. /**
  63527. * Creates a new SimplexPerlin3DBlock
  63528. * @param name defines the block name
  63529. */
  63530. constructor(name: string);
  63531. /**
  63532. * Gets the current class name
  63533. * @returns the class name
  63534. */
  63535. getClassName(): string;
  63536. /**
  63537. * Gets the seed operand input component
  63538. */
  63539. get seed(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the output component
  63542. */
  63543. get output(): NodeMaterialConnectionPoint;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63545. }
  63546. }
  63547. declare module BABYLON {
  63548. /**
  63549. * Block used to blend normals
  63550. */
  63551. export class NormalBlendBlock extends NodeMaterialBlock {
  63552. /**
  63553. * Creates a new NormalBlendBlock
  63554. * @param name defines the block name
  63555. */
  63556. constructor(name: string);
  63557. /**
  63558. * Gets the current class name
  63559. * @returns the class name
  63560. */
  63561. getClassName(): string;
  63562. /**
  63563. * Gets the first input component
  63564. */
  63565. get normalMap0(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the second input component
  63568. */
  63569. get normalMap1(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the output component
  63572. */
  63573. get output(): NodeMaterialConnectionPoint;
  63574. protected _buildBlock(state: NodeMaterialBuildState): this;
  63575. }
  63576. }
  63577. declare module BABYLON {
  63578. /**
  63579. * Block used to rotate a 2d vector by a given angle
  63580. */
  63581. export class Rotate2dBlock extends NodeMaterialBlock {
  63582. /**
  63583. * Creates a new Rotate2dBlock
  63584. * @param name defines the block name
  63585. */
  63586. constructor(name: string);
  63587. /**
  63588. * Gets the current class name
  63589. * @returns the class name
  63590. */
  63591. getClassName(): string;
  63592. /**
  63593. * Gets the input vector
  63594. */
  63595. get input(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the input angle
  63598. */
  63599. get angle(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the output component
  63602. */
  63603. get output(): NodeMaterialConnectionPoint;
  63604. autoConfigure(material: NodeMaterial): void;
  63605. protected _buildBlock(state: NodeMaterialBuildState): this;
  63606. }
  63607. }
  63608. declare module BABYLON {
  63609. /**
  63610. * Block used to get the reflected vector from a direction and a normal
  63611. */
  63612. export class ReflectBlock extends NodeMaterialBlock {
  63613. /**
  63614. * Creates a new ReflectBlock
  63615. * @param name defines the block name
  63616. */
  63617. constructor(name: string);
  63618. /**
  63619. * Gets the current class name
  63620. * @returns the class name
  63621. */
  63622. getClassName(): string;
  63623. /**
  63624. * Gets the incident component
  63625. */
  63626. get incident(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the normal component
  63629. */
  63630. get normal(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the output component
  63633. */
  63634. get output(): NodeMaterialConnectionPoint;
  63635. protected _buildBlock(state: NodeMaterialBuildState): this;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Block used to get the refracted vector from a direction and a normal
  63641. */
  63642. export class RefractBlock extends NodeMaterialBlock {
  63643. /**
  63644. * Creates a new RefractBlock
  63645. * @param name defines the block name
  63646. */
  63647. constructor(name: string);
  63648. /**
  63649. * Gets the current class name
  63650. * @returns the class name
  63651. */
  63652. getClassName(): string;
  63653. /**
  63654. * Gets the incident component
  63655. */
  63656. get incident(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the normal component
  63659. */
  63660. get normal(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the index of refraction component
  63663. */
  63664. get ior(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the output component
  63667. */
  63668. get output(): NodeMaterialConnectionPoint;
  63669. protected _buildBlock(state: NodeMaterialBuildState): this;
  63670. }
  63671. }
  63672. declare module BABYLON {
  63673. /**
  63674. * Block used to desaturate a color
  63675. */
  63676. export class DesaturateBlock extends NodeMaterialBlock {
  63677. /**
  63678. * Creates a new DesaturateBlock
  63679. * @param name defines the block name
  63680. */
  63681. constructor(name: string);
  63682. /**
  63683. * Gets the current class name
  63684. * @returns the class name
  63685. */
  63686. getClassName(): string;
  63687. /**
  63688. * Gets the color operand input component
  63689. */
  63690. get color(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the level operand input component
  63693. */
  63694. get level(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. protected _buildBlock(state: NodeMaterialBuildState): this;
  63700. }
  63701. }
  63702. declare module BABYLON {
  63703. /**
  63704. * Block used to implement the ambient occlusion module of the PBR material
  63705. */
  63706. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63707. /**
  63708. * Create a new AmbientOcclusionBlock
  63709. * @param name defines the block name
  63710. */
  63711. constructor(name: string);
  63712. /**
  63713. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63714. */
  63715. useAmbientInGrayScale: boolean;
  63716. /**
  63717. * Initialize the block and prepare the context for build
  63718. * @param state defines the state that will be used for the build
  63719. */
  63720. initialize(state: NodeMaterialBuildState): void;
  63721. /**
  63722. * Gets the current class name
  63723. * @returns the class name
  63724. */
  63725. getClassName(): string;
  63726. /**
  63727. * Gets the texture input component
  63728. */
  63729. get texture(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the texture intensity component
  63732. */
  63733. get intensity(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the direct light intensity input component
  63736. */
  63737. get directLightIntensity(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the ambient occlusion object output component
  63740. */
  63741. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the main code of the block (fragment side)
  63744. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63745. * @returns the shader code
  63746. */
  63747. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63749. protected _buildBlock(state: NodeMaterialBuildState): this;
  63750. protected _dumpPropertiesCode(): string;
  63751. serialize(): any;
  63752. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63753. }
  63754. }
  63755. declare module BABYLON {
  63756. /**
  63757. * Block used to implement the reflection module of the PBR material
  63758. */
  63759. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63760. /** @hidden */
  63761. _defineLODReflectionAlpha: string;
  63762. /** @hidden */
  63763. _defineLinearSpecularReflection: string;
  63764. private _vEnvironmentIrradianceName;
  63765. /** @hidden */
  63766. _vReflectionMicrosurfaceInfosName: string;
  63767. /** @hidden */
  63768. _vReflectionInfosName: string;
  63769. /** @hidden */
  63770. _vReflectionFilteringInfoName: string;
  63771. private _scene;
  63772. /**
  63773. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63774. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63775. * It's less burden on the user side in the editor part.
  63776. */
  63777. /** @hidden */
  63778. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63779. /** @hidden */
  63780. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63781. /** @hidden */
  63782. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63783. /**
  63784. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63785. * diffuse part of the IBL.
  63786. */
  63787. useSphericalHarmonics: boolean;
  63788. /**
  63789. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63790. */
  63791. forceIrradianceInFragment: boolean;
  63792. /**
  63793. * Create a new ReflectionBlock
  63794. * @param name defines the block name
  63795. */
  63796. constructor(name: string);
  63797. /**
  63798. * Gets the current class name
  63799. * @returns the class name
  63800. */
  63801. getClassName(): string;
  63802. /**
  63803. * Gets the position input component
  63804. */
  63805. get position(): NodeMaterialConnectionPoint;
  63806. /**
  63807. * Gets the world position input component
  63808. */
  63809. get worldPosition(): NodeMaterialConnectionPoint;
  63810. /**
  63811. * Gets the world normal input component
  63812. */
  63813. get worldNormal(): NodeMaterialConnectionPoint;
  63814. /**
  63815. * Gets the world input component
  63816. */
  63817. get world(): NodeMaterialConnectionPoint;
  63818. /**
  63819. * Gets the camera (or eye) position component
  63820. */
  63821. get cameraPosition(): NodeMaterialConnectionPoint;
  63822. /**
  63823. * Gets the view input component
  63824. */
  63825. get view(): NodeMaterialConnectionPoint;
  63826. /**
  63827. * Gets the color input component
  63828. */
  63829. get color(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the reflection object output component
  63832. */
  63833. get reflection(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63836. */
  63837. get hasTexture(): boolean;
  63838. /**
  63839. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63840. */
  63841. get reflectionColor(): string;
  63842. protected _getTexture(): Nullable<BaseTexture>;
  63843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63845. /**
  63846. * Gets the code to inject in the vertex shader
  63847. * @param state current state of the node material building
  63848. * @returns the shader code
  63849. */
  63850. handleVertexSide(state: NodeMaterialBuildState): string;
  63851. /**
  63852. * Gets the main code of the block (fragment side)
  63853. * @param state current state of the node material building
  63854. * @param normalVarName name of the existing variable corresponding to the normal
  63855. * @returns the shader code
  63856. */
  63857. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63858. protected _buildBlock(state: NodeMaterialBuildState): this;
  63859. protected _dumpPropertiesCode(): string;
  63860. serialize(): any;
  63861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63862. }
  63863. }
  63864. declare module BABYLON {
  63865. /**
  63866. * Block used to implement the sheen module of the PBR material
  63867. */
  63868. export class SheenBlock extends NodeMaterialBlock {
  63869. /**
  63870. * Create a new SheenBlock
  63871. * @param name defines the block name
  63872. */
  63873. constructor(name: string);
  63874. /**
  63875. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63876. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63877. * making it easier to setup and tweak the effect
  63878. */
  63879. albedoScaling: boolean;
  63880. /**
  63881. * Defines if the sheen is linked to the sheen color.
  63882. */
  63883. linkSheenWithAlbedo: boolean;
  63884. /**
  63885. * Initialize the block and prepare the context for build
  63886. * @param state defines the state that will be used for the build
  63887. */
  63888. initialize(state: NodeMaterialBuildState): void;
  63889. /**
  63890. * Gets the current class name
  63891. * @returns the class name
  63892. */
  63893. getClassName(): string;
  63894. /**
  63895. * Gets the intensity input component
  63896. */
  63897. get intensity(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the color input component
  63900. */
  63901. get color(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the roughness input component
  63904. */
  63905. get roughness(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the sheen object output component
  63908. */
  63909. get sheen(): NodeMaterialConnectionPoint;
  63910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63911. /**
  63912. * Gets the main code of the block (fragment side)
  63913. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63914. * @returns the shader code
  63915. */
  63916. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63917. protected _buildBlock(state: NodeMaterialBuildState): this;
  63918. protected _dumpPropertiesCode(): string;
  63919. serialize(): any;
  63920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Block used to implement the reflectivity module of the PBR material
  63926. */
  63927. export class ReflectivityBlock extends NodeMaterialBlock {
  63928. private _metallicReflectanceColor;
  63929. private _metallicF0Factor;
  63930. /** @hidden */
  63931. _vMetallicReflectanceFactorsName: string;
  63932. /**
  63933. * The property below is set by the main PBR block prior to calling methods of this class.
  63934. */
  63935. /** @hidden */
  63936. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63937. /**
  63938. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63939. */
  63940. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63941. /**
  63942. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63943. */
  63944. useMetallnessFromMetallicTextureBlue: boolean;
  63945. /**
  63946. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63947. */
  63948. useRoughnessFromMetallicTextureAlpha: boolean;
  63949. /**
  63950. * Specifies if the metallic texture contains the roughness information in its green channel.
  63951. */
  63952. useRoughnessFromMetallicTextureGreen: boolean;
  63953. /**
  63954. * Create a new ReflectivityBlock
  63955. * @param name defines the block name
  63956. */
  63957. constructor(name: string);
  63958. /**
  63959. * Initialize the block and prepare the context for build
  63960. * @param state defines the state that will be used for the build
  63961. */
  63962. initialize(state: NodeMaterialBuildState): void;
  63963. /**
  63964. * Gets the current class name
  63965. * @returns the class name
  63966. */
  63967. getClassName(): string;
  63968. /**
  63969. * Gets the metallic input component
  63970. */
  63971. get metallic(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the roughness input component
  63974. */
  63975. get roughness(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the texture input component
  63978. */
  63979. get texture(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the reflectivity object output component
  63982. */
  63983. get reflectivity(): NodeMaterialConnectionPoint;
  63984. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63985. /**
  63986. * Gets the main code of the block (fragment side)
  63987. * @param state current state of the node material building
  63988. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63989. * @returns the shader code
  63990. */
  63991. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63993. protected _buildBlock(state: NodeMaterialBuildState): this;
  63994. protected _dumpPropertiesCode(): string;
  63995. serialize(): any;
  63996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63997. }
  63998. }
  63999. declare module BABYLON {
  64000. /**
  64001. * Block used to implement the anisotropy module of the PBR material
  64002. */
  64003. export class AnisotropyBlock extends NodeMaterialBlock {
  64004. /**
  64005. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64006. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64007. * It's less burden on the user side in the editor part.
  64008. */
  64009. /** @hidden */
  64010. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64011. /** @hidden */
  64012. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64013. /**
  64014. * Create a new AnisotropyBlock
  64015. * @param name defines the block name
  64016. */
  64017. constructor(name: string);
  64018. /**
  64019. * Initialize the block and prepare the context for build
  64020. * @param state defines the state that will be used for the build
  64021. */
  64022. initialize(state: NodeMaterialBuildState): void;
  64023. /**
  64024. * Gets the current class name
  64025. * @returns the class name
  64026. */
  64027. getClassName(): string;
  64028. /**
  64029. * Gets the intensity input component
  64030. */
  64031. get intensity(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the direction input component
  64034. */
  64035. get direction(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the texture input component
  64038. */
  64039. get texture(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the uv input component
  64042. */
  64043. get uv(): NodeMaterialConnectionPoint;
  64044. /**
  64045. * Gets the worldTangent input component
  64046. */
  64047. get worldTangent(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the anisotropy object output component
  64050. */
  64051. get anisotropy(): NodeMaterialConnectionPoint;
  64052. private _generateTBNSpace;
  64053. /**
  64054. * Gets the main code of the block (fragment side)
  64055. * @param state current state of the node material building
  64056. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64057. * @returns the shader code
  64058. */
  64059. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64061. protected _buildBlock(state: NodeMaterialBuildState): this;
  64062. }
  64063. }
  64064. declare module BABYLON {
  64065. /**
  64066. * Block used to implement the clear coat module of the PBR material
  64067. */
  64068. export class ClearCoatBlock extends NodeMaterialBlock {
  64069. private _scene;
  64070. /**
  64071. * Create a new ClearCoatBlock
  64072. * @param name defines the block name
  64073. */
  64074. constructor(name: string);
  64075. /**
  64076. * Initialize the block and prepare the context for build
  64077. * @param state defines the state that will be used for the build
  64078. */
  64079. initialize(state: NodeMaterialBuildState): void;
  64080. /**
  64081. * Gets the current class name
  64082. * @returns the class name
  64083. */
  64084. getClassName(): string;
  64085. /**
  64086. * Gets the intensity input component
  64087. */
  64088. get intensity(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the roughness input component
  64091. */
  64092. get roughness(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the ior input component
  64095. */
  64096. get ior(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the texture input component
  64099. */
  64100. get texture(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the bump texture input component
  64103. */
  64104. get bumpTexture(): NodeMaterialConnectionPoint;
  64105. /**
  64106. * Gets the uv input component
  64107. */
  64108. get uv(): NodeMaterialConnectionPoint;
  64109. /**
  64110. * Gets the tint color input component
  64111. */
  64112. get tintColor(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the tint "at distance" input component
  64115. */
  64116. get tintAtDistance(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the tint thickness input component
  64119. */
  64120. get tintThickness(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the world tangent input component
  64123. */
  64124. get worldTangent(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the clear coat object output component
  64127. */
  64128. get clearcoat(): NodeMaterialConnectionPoint;
  64129. autoConfigure(material: NodeMaterial): void;
  64130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64132. private _generateTBNSpace;
  64133. /**
  64134. * Gets the main code of the block (fragment side)
  64135. * @param state current state of the node material building
  64136. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64137. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64138. * @param worldPosVarName name of the variable holding the world position
  64139. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64140. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64141. * @param worldNormalVarName name of the variable holding the world normal
  64142. * @returns the shader code
  64143. */
  64144. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64145. protected _buildBlock(state: NodeMaterialBuildState): this;
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * Block used to implement the sub surface module of the PBR material
  64151. */
  64152. export class SubSurfaceBlock extends NodeMaterialBlock {
  64153. /**
  64154. * Create a new SubSurfaceBlock
  64155. * @param name defines the block name
  64156. */
  64157. constructor(name: string);
  64158. /**
  64159. * Stores the intensity of the different subsurface effects in the thickness texture.
  64160. * * the green channel is the translucency intensity.
  64161. * * the blue channel is the scattering intensity.
  64162. * * the alpha channel is the refraction intensity.
  64163. */
  64164. useMaskFromThicknessTexture: boolean;
  64165. /**
  64166. * Initialize the block and prepare the context for build
  64167. * @param state defines the state that will be used for the build
  64168. */
  64169. initialize(state: NodeMaterialBuildState): void;
  64170. /**
  64171. * Gets the current class name
  64172. * @returns the class name
  64173. */
  64174. getClassName(): string;
  64175. /**
  64176. * Gets the min thickness input component
  64177. */
  64178. get minThickness(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the max thickness input component
  64181. */
  64182. get maxThickness(): NodeMaterialConnectionPoint;
  64183. /**
  64184. * Gets the thickness texture component
  64185. */
  64186. get thicknessTexture(): NodeMaterialConnectionPoint;
  64187. /**
  64188. * Gets the tint color input component
  64189. */
  64190. get tintColor(): NodeMaterialConnectionPoint;
  64191. /**
  64192. * Gets the translucency intensity input component
  64193. */
  64194. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the translucency diffusion distance input component
  64197. */
  64198. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the refraction object parameters
  64201. */
  64202. get refraction(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the sub surface object output component
  64205. */
  64206. get subsurface(): NodeMaterialConnectionPoint;
  64207. autoConfigure(material: NodeMaterial): void;
  64208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64209. /**
  64210. * Gets the main code of the block (fragment side)
  64211. * @param state current state of the node material building
  64212. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64213. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64214. * @param worldPosVarName name of the variable holding the world position
  64215. * @returns the shader code
  64216. */
  64217. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64218. protected _buildBlock(state: NodeMaterialBuildState): this;
  64219. }
  64220. }
  64221. declare module BABYLON {
  64222. /**
  64223. * Block used to implement the PBR metallic/roughness model
  64224. */
  64225. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64226. /**
  64227. * Gets or sets the light associated with this block
  64228. */
  64229. light: Nullable<Light>;
  64230. private _lightId;
  64231. private _scene;
  64232. private _environmentBRDFTexture;
  64233. private _environmentBrdfSamplerName;
  64234. private _vNormalWName;
  64235. private _invertNormalName;
  64236. /**
  64237. * Create a new ReflectionBlock
  64238. * @param name defines the block name
  64239. */
  64240. constructor(name: string);
  64241. /**
  64242. * Intensity of the direct lights e.g. the four lights available in your scene.
  64243. * This impacts both the direct diffuse and specular highlights.
  64244. */
  64245. directIntensity: number;
  64246. /**
  64247. * Intensity of the environment e.g. how much the environment will light the object
  64248. * either through harmonics for rough material or through the refelction for shiny ones.
  64249. */
  64250. environmentIntensity: number;
  64251. /**
  64252. * This is a special control allowing the reduction of the specular highlights coming from the
  64253. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64254. */
  64255. specularIntensity: number;
  64256. /**
  64257. * Defines the falloff type used in this material.
  64258. * It by default is Physical.
  64259. */
  64260. lightFalloff: number;
  64261. /**
  64262. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64263. */
  64264. useAlphaFromAlbedoTexture: boolean;
  64265. /**
  64266. * Specifies that alpha test should be used
  64267. */
  64268. useAlphaTest: boolean;
  64269. /**
  64270. * Defines the alpha limits in alpha test mode.
  64271. */
  64272. alphaTestCutoff: number;
  64273. /**
  64274. * Specifies that alpha blending should be used
  64275. */
  64276. useAlphaBlending: boolean;
  64277. /**
  64278. * Defines if the alpha value should be determined via the rgb values.
  64279. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64280. */
  64281. opacityRGB: boolean;
  64282. /**
  64283. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64284. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64285. */
  64286. useRadianceOverAlpha: boolean;
  64287. /**
  64288. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64290. */
  64291. useSpecularOverAlpha: boolean;
  64292. /**
  64293. * Enables specular anti aliasing in the PBR shader.
  64294. * It will both interacts on the Geometry for analytical and IBL lighting.
  64295. * It also prefilter the roughness map based on the bump values.
  64296. */
  64297. enableSpecularAntiAliasing: boolean;
  64298. /**
  64299. * Enables realtime filtering on the texture.
  64300. */
  64301. realTimeFiltering: boolean;
  64302. /**
  64303. * Quality switch for realtime filtering
  64304. */
  64305. realTimeFilteringQuality: number;
  64306. /**
  64307. * Defines if the material uses energy conservation.
  64308. */
  64309. useEnergyConservation: boolean;
  64310. /**
  64311. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64312. * too much the area relying on ambient texture to define their ambient occlusion.
  64313. */
  64314. useRadianceOcclusion: boolean;
  64315. /**
  64316. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64317. * makes the reflect vector face the model (under horizon).
  64318. */
  64319. useHorizonOcclusion: boolean;
  64320. /**
  64321. * If set to true, no lighting calculations will be applied.
  64322. */
  64323. unlit: boolean;
  64324. /**
  64325. * Force normal to face away from face.
  64326. */
  64327. forceNormalForward: boolean;
  64328. /**
  64329. * Defines the material debug mode.
  64330. * It helps seeing only some components of the material while troubleshooting.
  64331. */
  64332. debugMode: number;
  64333. /**
  64334. * Specify from where on screen the debug mode should start.
  64335. * The value goes from -1 (full screen) to 1 (not visible)
  64336. * It helps with side by side comparison against the final render
  64337. * This defaults to 0
  64338. */
  64339. debugLimit: number;
  64340. /**
  64341. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64342. * You can use the factor to better multiply the final value.
  64343. */
  64344. debugFactor: number;
  64345. /**
  64346. * Initialize the block and prepare the context for build
  64347. * @param state defines the state that will be used for the build
  64348. */
  64349. initialize(state: NodeMaterialBuildState): void;
  64350. /**
  64351. * Gets the current class name
  64352. * @returns the class name
  64353. */
  64354. getClassName(): string;
  64355. /**
  64356. * Gets the world position input component
  64357. */
  64358. get worldPosition(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the world normal input component
  64361. */
  64362. get worldNormal(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the perturbed normal input component
  64365. */
  64366. get perturbedNormal(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the camera position input component
  64369. */
  64370. get cameraPosition(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the base color input component
  64373. */
  64374. get baseColor(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the opacity texture input component
  64377. */
  64378. get opacityTexture(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the ambient color input component
  64381. */
  64382. get ambientColor(): NodeMaterialConnectionPoint;
  64383. /**
  64384. * Gets the reflectivity object parameters
  64385. */
  64386. get reflectivity(): NodeMaterialConnectionPoint;
  64387. /**
  64388. * Gets the ambient occlusion object parameters
  64389. */
  64390. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64391. /**
  64392. * Gets the reflection object parameters
  64393. */
  64394. get reflection(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the sheen object parameters
  64397. */
  64398. get sheen(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the clear coat object parameters
  64401. */
  64402. get clearcoat(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the sub surface object parameters
  64405. */
  64406. get subsurface(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the anisotropy object parameters
  64409. */
  64410. get anisotropy(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the ambient output component
  64413. */
  64414. get ambient(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the diffuse output component
  64417. */
  64418. get diffuse(): NodeMaterialConnectionPoint;
  64419. /**
  64420. * Gets the specular output component
  64421. */
  64422. get specular(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the sheen output component
  64425. */
  64426. get sheenDir(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the clear coat output component
  64429. */
  64430. get clearcoatDir(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the indirect diffuse output component
  64433. */
  64434. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the indirect specular output component
  64437. */
  64438. get specularIndirect(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the indirect sheen output component
  64441. */
  64442. get sheenIndirect(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the indirect clear coat output component
  64445. */
  64446. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the refraction output component
  64449. */
  64450. get refraction(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the global lighting output component
  64453. */
  64454. get lighting(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the shadow output component
  64457. */
  64458. get shadow(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the alpha output component
  64461. */
  64462. get alpha(): NodeMaterialConnectionPoint;
  64463. autoConfigure(material: NodeMaterial): void;
  64464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64465. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64466. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64467. private _injectVertexCode;
  64468. /**
  64469. * Gets the code corresponding to the albedo/opacity module
  64470. * @returns the shader code
  64471. */
  64472. getAlbedoOpacityCode(): string;
  64473. protected _buildBlock(state: NodeMaterialBuildState): this;
  64474. protected _dumpPropertiesCode(): string;
  64475. serialize(): any;
  64476. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64477. }
  64478. }
  64479. declare module BABYLON {
  64480. /**
  64481. * Block used to compute value of one parameter modulo another
  64482. */
  64483. export class ModBlock extends NodeMaterialBlock {
  64484. /**
  64485. * Creates a new ModBlock
  64486. * @param name defines the block name
  64487. */
  64488. constructor(name: string);
  64489. /**
  64490. * Gets the current class name
  64491. * @returns the class name
  64492. */
  64493. getClassName(): string;
  64494. /**
  64495. * Gets the left operand input component
  64496. */
  64497. get left(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the right operand input component
  64500. */
  64501. get right(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the output component
  64504. */
  64505. get output(): NodeMaterialConnectionPoint;
  64506. protected _buildBlock(state: NodeMaterialBuildState): this;
  64507. }
  64508. }
  64509. declare module BABYLON {
  64510. /**
  64511. * Helper class to push actions to a pool of workers.
  64512. */
  64513. export class WorkerPool implements IDisposable {
  64514. private _workerInfos;
  64515. private _pendingActions;
  64516. /**
  64517. * Constructor
  64518. * @param workers Array of workers to use for actions
  64519. */
  64520. constructor(workers: Array<Worker>);
  64521. /**
  64522. * Terminates all workers and clears any pending actions.
  64523. */
  64524. dispose(): void;
  64525. /**
  64526. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64527. * pended until a worker has completed its action.
  64528. * @param action The action to perform. Call onComplete when the action is complete.
  64529. */
  64530. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64531. private _execute;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Configuration for Draco compression
  64537. */
  64538. export interface IDracoCompressionConfiguration {
  64539. /**
  64540. * Configuration for the decoder.
  64541. */
  64542. decoder: {
  64543. /**
  64544. * The url to the WebAssembly module.
  64545. */
  64546. wasmUrl?: string;
  64547. /**
  64548. * The url to the WebAssembly binary.
  64549. */
  64550. wasmBinaryUrl?: string;
  64551. /**
  64552. * The url to the fallback JavaScript module.
  64553. */
  64554. fallbackUrl?: string;
  64555. };
  64556. }
  64557. /**
  64558. * Draco compression (https://google.github.io/draco/)
  64559. *
  64560. * This class wraps the Draco module.
  64561. *
  64562. * **Encoder**
  64563. *
  64564. * The encoder is not currently implemented.
  64565. *
  64566. * **Decoder**
  64567. *
  64568. * 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.
  64569. *
  64570. * To update the configuration, use the following code:
  64571. * ```javascript
  64572. * DracoCompression.Configuration = {
  64573. * decoder: {
  64574. * wasmUrl: "<url to the WebAssembly library>",
  64575. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64576. * fallbackUrl: "<url to the fallback JavaScript library>",
  64577. * }
  64578. * };
  64579. * ```
  64580. *
  64581. * 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.
  64582. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64583. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64584. *
  64585. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64586. * ```javascript
  64587. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64588. * ```
  64589. *
  64590. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64591. */
  64592. export class DracoCompression implements IDisposable {
  64593. private _workerPoolPromise?;
  64594. private _decoderModulePromise?;
  64595. /**
  64596. * The configuration. Defaults to the following urls:
  64597. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64598. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64599. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64600. */
  64601. static Configuration: IDracoCompressionConfiguration;
  64602. /**
  64603. * Returns true if the decoder configuration is available.
  64604. */
  64605. static get DecoderAvailable(): boolean;
  64606. /**
  64607. * Default number of workers to create when creating the draco compression object.
  64608. */
  64609. static DefaultNumWorkers: number;
  64610. private static GetDefaultNumWorkers;
  64611. private static _Default;
  64612. /**
  64613. * Default instance for the draco compression object.
  64614. */
  64615. static get Default(): DracoCompression;
  64616. /**
  64617. * Constructor
  64618. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64619. */
  64620. constructor(numWorkers?: number);
  64621. /**
  64622. * Stop all async operations and release resources.
  64623. */
  64624. dispose(): void;
  64625. /**
  64626. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64627. * @returns a promise that resolves when ready
  64628. */
  64629. whenReadyAsync(): Promise<void>;
  64630. /**
  64631. * Decode Draco compressed mesh data to vertex data.
  64632. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64633. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64634. * @returns A promise that resolves with the decoded vertex data
  64635. */
  64636. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64637. [kind: string]: number;
  64638. }): Promise<VertexData>;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * Class for building Constructive Solid Geometry
  64644. */
  64645. export class CSG {
  64646. private polygons;
  64647. /**
  64648. * The world matrix
  64649. */
  64650. matrix: Matrix;
  64651. /**
  64652. * Stores the position
  64653. */
  64654. position: Vector3;
  64655. /**
  64656. * Stores the rotation
  64657. */
  64658. rotation: Vector3;
  64659. /**
  64660. * Stores the rotation quaternion
  64661. */
  64662. rotationQuaternion: Nullable<Quaternion>;
  64663. /**
  64664. * Stores the scaling vector
  64665. */
  64666. scaling: Vector3;
  64667. /**
  64668. * Convert the Mesh to CSG
  64669. * @param mesh The Mesh to convert to CSG
  64670. * @returns A new CSG from the Mesh
  64671. */
  64672. static FromMesh(mesh: Mesh): CSG;
  64673. /**
  64674. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64675. * @param polygons Polygons used to construct a CSG solid
  64676. */
  64677. private static FromPolygons;
  64678. /**
  64679. * Clones, or makes a deep copy, of the CSG
  64680. * @returns A new CSG
  64681. */
  64682. clone(): CSG;
  64683. /**
  64684. * Unions this CSG with another CSG
  64685. * @param csg The CSG to union against this CSG
  64686. * @returns The unioned CSG
  64687. */
  64688. union(csg: CSG): CSG;
  64689. /**
  64690. * Unions this CSG with another CSG in place
  64691. * @param csg The CSG to union against this CSG
  64692. */
  64693. unionInPlace(csg: CSG): void;
  64694. /**
  64695. * Subtracts this CSG with another CSG
  64696. * @param csg The CSG to subtract against this CSG
  64697. * @returns A new CSG
  64698. */
  64699. subtract(csg: CSG): CSG;
  64700. /**
  64701. * Subtracts this CSG with another CSG in place
  64702. * @param csg The CSG to subtact against this CSG
  64703. */
  64704. subtractInPlace(csg: CSG): void;
  64705. /**
  64706. * Intersect this CSG with another CSG
  64707. * @param csg The CSG to intersect against this CSG
  64708. * @returns A new CSG
  64709. */
  64710. intersect(csg: CSG): CSG;
  64711. /**
  64712. * Intersects this CSG with another CSG in place
  64713. * @param csg The CSG to intersect against this CSG
  64714. */
  64715. intersectInPlace(csg: CSG): void;
  64716. /**
  64717. * Return a new CSG solid with solid and empty space switched. This solid is
  64718. * not modified.
  64719. * @returns A new CSG solid with solid and empty space switched
  64720. */
  64721. inverse(): CSG;
  64722. /**
  64723. * Inverses the CSG in place
  64724. */
  64725. inverseInPlace(): void;
  64726. /**
  64727. * This is used to keep meshes transformations so they can be restored
  64728. * when we build back a Babylon Mesh
  64729. * NB : All CSG operations are performed in world coordinates
  64730. * @param csg The CSG to copy the transform attributes from
  64731. * @returns This CSG
  64732. */
  64733. copyTransformAttributes(csg: CSG): CSG;
  64734. /**
  64735. * Build Raw mesh from CSG
  64736. * Coordinates here are in world space
  64737. * @param name The name of the mesh geometry
  64738. * @param scene The Scene
  64739. * @param keepSubMeshes Specifies if the submeshes should be kept
  64740. * @returns A new Mesh
  64741. */
  64742. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64743. /**
  64744. * Build Mesh from CSG taking material and transforms into account
  64745. * @param name The name of the Mesh
  64746. * @param material The material of the Mesh
  64747. * @param scene The Scene
  64748. * @param keepSubMeshes Specifies if submeshes should be kept
  64749. * @returns The new Mesh
  64750. */
  64751. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64752. }
  64753. }
  64754. declare module BABYLON {
  64755. /**
  64756. * Class used to create a trail following a mesh
  64757. */
  64758. export class TrailMesh extends Mesh {
  64759. private _generator;
  64760. private _autoStart;
  64761. private _running;
  64762. private _diameter;
  64763. private _length;
  64764. private _sectionPolygonPointsCount;
  64765. private _sectionVectors;
  64766. private _sectionNormalVectors;
  64767. private _beforeRenderObserver;
  64768. /**
  64769. * @constructor
  64770. * @param name The value used by scene.getMeshByName() to do a lookup.
  64771. * @param generator The mesh or transform node to generate a trail.
  64772. * @param scene The scene to add this mesh to.
  64773. * @param diameter Diameter of trailing mesh. Default is 1.
  64774. * @param length Length of trailing mesh. Default is 60.
  64775. * @param autoStart Automatically start trailing mesh. Default true.
  64776. */
  64777. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64778. /**
  64779. * "TrailMesh"
  64780. * @returns "TrailMesh"
  64781. */
  64782. getClassName(): string;
  64783. private _createMesh;
  64784. /**
  64785. * Start trailing mesh.
  64786. */
  64787. start(): void;
  64788. /**
  64789. * Stop trailing mesh.
  64790. */
  64791. stop(): void;
  64792. /**
  64793. * Update trailing mesh geometry.
  64794. */
  64795. update(): void;
  64796. /**
  64797. * Returns a new TrailMesh object.
  64798. * @param name is a string, the name given to the new mesh
  64799. * @param newGenerator use new generator object for cloned trail mesh
  64800. * @returns a new mesh
  64801. */
  64802. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64803. /**
  64804. * Serializes this trail mesh
  64805. * @param serializationObject object to write serialization to
  64806. */
  64807. serialize(serializationObject: any): void;
  64808. /**
  64809. * Parses a serialized trail mesh
  64810. * @param parsedMesh the serialized mesh
  64811. * @param scene the scene to create the trail mesh in
  64812. * @returns the created trail mesh
  64813. */
  64814. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Class containing static functions to help procedurally build meshes
  64820. */
  64821. export class TiledBoxBuilder {
  64822. /**
  64823. * Creates a box mesh
  64824. * 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)
  64825. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64827. * * 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
  64828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64829. * @param name defines the name of the mesh
  64830. * @param options defines the options used to create the mesh
  64831. * @param scene defines the hosting scene
  64832. * @returns the box mesh
  64833. */
  64834. static CreateTiledBox(name: string, options: {
  64835. pattern?: number;
  64836. width?: number;
  64837. height?: number;
  64838. depth?: number;
  64839. tileSize?: number;
  64840. tileWidth?: number;
  64841. tileHeight?: number;
  64842. alignHorizontal?: number;
  64843. alignVertical?: number;
  64844. faceUV?: Vector4[];
  64845. faceColors?: Color4[];
  64846. sideOrientation?: number;
  64847. updatable?: boolean;
  64848. }, scene?: Nullable<Scene>): Mesh;
  64849. }
  64850. }
  64851. declare module BABYLON {
  64852. /**
  64853. * Class containing static functions to help procedurally build meshes
  64854. */
  64855. export class TorusKnotBuilder {
  64856. /**
  64857. * Creates a torus knot mesh
  64858. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64859. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64860. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64861. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64863. * * 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
  64864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64865. * @param name defines the name of the mesh
  64866. * @param options defines the options used to create the mesh
  64867. * @param scene defines the hosting scene
  64868. * @returns the torus knot mesh
  64869. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64870. */
  64871. static CreateTorusKnot(name: string, options: {
  64872. radius?: number;
  64873. tube?: number;
  64874. radialSegments?: number;
  64875. tubularSegments?: number;
  64876. p?: number;
  64877. q?: number;
  64878. updatable?: boolean;
  64879. sideOrientation?: number;
  64880. frontUVs?: Vector4;
  64881. backUVs?: Vector4;
  64882. }, scene: any): Mesh;
  64883. }
  64884. }
  64885. declare module BABYLON {
  64886. /**
  64887. * Polygon
  64888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64889. */
  64890. export class Polygon {
  64891. /**
  64892. * Creates a rectangle
  64893. * @param xmin bottom X coord
  64894. * @param ymin bottom Y coord
  64895. * @param xmax top X coord
  64896. * @param ymax top Y coord
  64897. * @returns points that make the resulting rectation
  64898. */
  64899. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64900. /**
  64901. * Creates a circle
  64902. * @param radius radius of circle
  64903. * @param cx scale in x
  64904. * @param cy scale in y
  64905. * @param numberOfSides number of sides that make up the circle
  64906. * @returns points that make the resulting circle
  64907. */
  64908. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64909. /**
  64910. * Creates a polygon from input string
  64911. * @param input Input polygon data
  64912. * @returns the parsed points
  64913. */
  64914. static Parse(input: string): Vector2[];
  64915. /**
  64916. * Starts building a polygon from x and y coordinates
  64917. * @param x x coordinate
  64918. * @param y y coordinate
  64919. * @returns the started path2
  64920. */
  64921. static StartingAt(x: number, y: number): Path2;
  64922. }
  64923. /**
  64924. * Builds a polygon
  64925. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64926. */
  64927. export class PolygonMeshBuilder {
  64928. private _points;
  64929. private _outlinepoints;
  64930. private _holes;
  64931. private _name;
  64932. private _scene;
  64933. private _epoints;
  64934. private _eholes;
  64935. private _addToepoint;
  64936. /**
  64937. * Babylon reference to the earcut plugin.
  64938. */
  64939. bjsEarcut: any;
  64940. /**
  64941. * Creates a PolygonMeshBuilder
  64942. * @param name name of the builder
  64943. * @param contours Path of the polygon
  64944. * @param scene scene to add to when creating the mesh
  64945. * @param earcutInjection can be used to inject your own earcut reference
  64946. */
  64947. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64948. /**
  64949. * Adds a whole within the polygon
  64950. * @param hole Array of points defining the hole
  64951. * @returns this
  64952. */
  64953. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64954. /**
  64955. * Creates the polygon
  64956. * @param updatable If the mesh should be updatable
  64957. * @param depth The depth of the mesh created
  64958. * @returns the created mesh
  64959. */
  64960. build(updatable?: boolean, depth?: number): Mesh;
  64961. /**
  64962. * Creates the polygon
  64963. * @param depth The depth of the mesh created
  64964. * @returns the created VertexData
  64965. */
  64966. buildVertexData(depth?: number): VertexData;
  64967. /**
  64968. * Adds a side to the polygon
  64969. * @param positions points that make the polygon
  64970. * @param normals normals of the polygon
  64971. * @param uvs uvs of the polygon
  64972. * @param indices indices of the polygon
  64973. * @param bounds bounds of the polygon
  64974. * @param points points of the polygon
  64975. * @param depth depth of the polygon
  64976. * @param flip flip of the polygon
  64977. */
  64978. private addSide;
  64979. }
  64980. }
  64981. declare module BABYLON {
  64982. /**
  64983. * Class containing static functions to help procedurally build meshes
  64984. */
  64985. export class PolygonBuilder {
  64986. /**
  64987. * Creates a polygon mesh
  64988. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64989. * * 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
  64990. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64992. * * 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)
  64993. * * Remember you can only change the shape positions, not their number when updating a polygon
  64994. * @param name defines the name of the mesh
  64995. * @param options defines the options used to create the mesh
  64996. * @param scene defines the hosting scene
  64997. * @param earcutInjection can be used to inject your own earcut reference
  64998. * @returns the polygon mesh
  64999. */
  65000. static CreatePolygon(name: string, options: {
  65001. shape: Vector3[];
  65002. holes?: Vector3[][];
  65003. depth?: number;
  65004. faceUV?: Vector4[];
  65005. faceColors?: Color4[];
  65006. updatable?: boolean;
  65007. sideOrientation?: number;
  65008. frontUVs?: Vector4;
  65009. backUVs?: Vector4;
  65010. wrap?: boolean;
  65011. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65012. /**
  65013. * Creates an extruded polygon mesh, with depth in the Y direction.
  65014. * * 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)
  65015. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65016. * @param name defines the name of the mesh
  65017. * @param options defines the options used to create the mesh
  65018. * @param scene defines the hosting scene
  65019. * @param earcutInjection can be used to inject your own earcut reference
  65020. * @returns the polygon mesh
  65021. */
  65022. static ExtrudePolygon(name: string, options: {
  65023. shape: Vector3[];
  65024. holes?: Vector3[][];
  65025. depth?: number;
  65026. faceUV?: Vector4[];
  65027. faceColors?: Color4[];
  65028. updatable?: boolean;
  65029. sideOrientation?: number;
  65030. frontUVs?: Vector4;
  65031. backUVs?: Vector4;
  65032. wrap?: boolean;
  65033. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65034. }
  65035. }
  65036. declare module BABYLON {
  65037. /**
  65038. * Class containing static functions to help procedurally build meshes
  65039. */
  65040. export class LatheBuilder {
  65041. /**
  65042. * Creates lathe mesh.
  65043. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65044. * * 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
  65045. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65046. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65047. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65048. * * 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
  65049. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65050. * * 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
  65051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65052. * * 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
  65053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65055. * @param name defines the name of the mesh
  65056. * @param options defines the options used to create the mesh
  65057. * @param scene defines the hosting scene
  65058. * @returns the lathe mesh
  65059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65060. */
  65061. static CreateLathe(name: string, options: {
  65062. shape: Vector3[];
  65063. radius?: number;
  65064. tessellation?: number;
  65065. clip?: number;
  65066. arc?: number;
  65067. closed?: boolean;
  65068. updatable?: boolean;
  65069. sideOrientation?: number;
  65070. frontUVs?: Vector4;
  65071. backUVs?: Vector4;
  65072. cap?: number;
  65073. invertUV?: boolean;
  65074. }, scene?: Nullable<Scene>): Mesh;
  65075. }
  65076. }
  65077. declare module BABYLON {
  65078. /**
  65079. * Class containing static functions to help procedurally build meshes
  65080. */
  65081. export class TiledPlaneBuilder {
  65082. /**
  65083. * Creates a tiled plane mesh
  65084. * * The parameter `pattern` will, depending on value, do nothing or
  65085. * * * flip (reflect about central vertical) alternate tiles across and up
  65086. * * * flip every tile on alternate rows
  65087. * * * rotate (180 degs) alternate tiles across and up
  65088. * * * rotate every tile on alternate rows
  65089. * * * flip and rotate alternate tiles across and up
  65090. * * * flip and rotate every tile on alternate rows
  65091. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65092. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65093. * * 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
  65094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65095. * * 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)
  65096. * * 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)
  65097. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65098. * @param name defines the name of the mesh
  65099. * @param options defines the options used to create the mesh
  65100. * @param scene defines the hosting scene
  65101. * @returns the box mesh
  65102. */
  65103. static CreateTiledPlane(name: string, options: {
  65104. pattern?: number;
  65105. tileSize?: number;
  65106. tileWidth?: number;
  65107. tileHeight?: number;
  65108. size?: number;
  65109. width?: number;
  65110. height?: number;
  65111. alignHorizontal?: number;
  65112. alignVertical?: number;
  65113. sideOrientation?: number;
  65114. frontUVs?: Vector4;
  65115. backUVs?: Vector4;
  65116. updatable?: boolean;
  65117. }, scene?: Nullable<Scene>): Mesh;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. * Class containing static functions to help procedurally build meshes
  65123. */
  65124. export class TubeBuilder {
  65125. /**
  65126. * Creates a tube mesh.
  65127. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65128. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65129. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65130. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65131. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65132. * * 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)
  65133. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65134. * * 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
  65135. * * 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
  65136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65137. * * 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
  65138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65140. * @param name defines the name of the mesh
  65141. * @param options defines the options used to create the mesh
  65142. * @param scene defines the hosting scene
  65143. * @returns the tube mesh
  65144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65145. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65146. */
  65147. static CreateTube(name: string, options: {
  65148. path: Vector3[];
  65149. radius?: number;
  65150. tessellation?: number;
  65151. radiusFunction?: {
  65152. (i: number, distance: number): number;
  65153. };
  65154. cap?: number;
  65155. arc?: number;
  65156. updatable?: boolean;
  65157. sideOrientation?: number;
  65158. frontUVs?: Vector4;
  65159. backUVs?: Vector4;
  65160. instance?: Mesh;
  65161. invertUV?: boolean;
  65162. }, scene?: Nullable<Scene>): Mesh;
  65163. }
  65164. }
  65165. declare module BABYLON {
  65166. /**
  65167. * Class containing static functions to help procedurally build meshes
  65168. */
  65169. export class IcoSphereBuilder {
  65170. /**
  65171. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65172. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65173. * * 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`)
  65174. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65175. * * 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
  65176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65177. * * 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
  65178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65179. * @param name defines the name of the mesh
  65180. * @param options defines the options used to create the mesh
  65181. * @param scene defines the hosting scene
  65182. * @returns the icosahedron mesh
  65183. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65184. */
  65185. static CreateIcoSphere(name: string, options: {
  65186. radius?: number;
  65187. radiusX?: number;
  65188. radiusY?: number;
  65189. radiusZ?: number;
  65190. flat?: boolean;
  65191. subdivisions?: number;
  65192. sideOrientation?: number;
  65193. frontUVs?: Vector4;
  65194. backUVs?: Vector4;
  65195. updatable?: boolean;
  65196. }, scene?: Nullable<Scene>): Mesh;
  65197. }
  65198. }
  65199. declare module BABYLON {
  65200. /**
  65201. * Class containing static functions to help procedurally build meshes
  65202. */
  65203. export class DecalBuilder {
  65204. /**
  65205. * Creates a decal mesh.
  65206. * 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
  65207. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65208. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65209. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65210. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65211. * @param name defines the name of the mesh
  65212. * @param sourceMesh defines the mesh where the decal must be applied
  65213. * @param options defines the options used to create the mesh
  65214. * @param scene defines the hosting scene
  65215. * @returns the decal mesh
  65216. * @see https://doc.babylonjs.com/how_to/decals
  65217. */
  65218. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65219. position?: Vector3;
  65220. normal?: Vector3;
  65221. size?: Vector3;
  65222. angle?: number;
  65223. }): Mesh;
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /**
  65228. * Class containing static functions to help procedurally build meshes
  65229. */
  65230. export class MeshBuilder {
  65231. /**
  65232. * Creates a box mesh
  65233. * * The parameter `size` sets the size (float) of each box side (default 1)
  65234. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65235. * * 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)
  65236. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65238. * * 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
  65239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65240. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65241. * @param name defines the name of the mesh
  65242. * @param options defines the options used to create the mesh
  65243. * @param scene defines the hosting scene
  65244. * @returns the box mesh
  65245. */
  65246. static CreateBox(name: string, options: {
  65247. size?: number;
  65248. width?: number;
  65249. height?: number;
  65250. depth?: number;
  65251. faceUV?: Vector4[];
  65252. faceColors?: Color4[];
  65253. sideOrientation?: number;
  65254. frontUVs?: Vector4;
  65255. backUVs?: Vector4;
  65256. wrap?: boolean;
  65257. topBaseAt?: number;
  65258. bottomBaseAt?: number;
  65259. updatable?: boolean;
  65260. }, scene?: Nullable<Scene>): Mesh;
  65261. /**
  65262. * Creates a tiled box mesh
  65263. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65265. * @param name defines the name of the mesh
  65266. * @param options defines the options used to create the mesh
  65267. * @param scene defines the hosting scene
  65268. * @returns the tiled box mesh
  65269. */
  65270. static CreateTiledBox(name: string, options: {
  65271. pattern?: number;
  65272. size?: number;
  65273. width?: number;
  65274. height?: number;
  65275. depth: number;
  65276. tileSize?: number;
  65277. tileWidth?: number;
  65278. tileHeight?: number;
  65279. faceUV?: Vector4[];
  65280. faceColors?: Color4[];
  65281. alignHorizontal?: number;
  65282. alignVertical?: number;
  65283. sideOrientation?: number;
  65284. updatable?: boolean;
  65285. }, scene?: Nullable<Scene>): Mesh;
  65286. /**
  65287. * Creates a sphere mesh
  65288. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65289. * * 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`)
  65290. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65291. * * 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
  65292. * * 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)
  65293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65294. * * 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
  65295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65296. * @param name defines the name of the mesh
  65297. * @param options defines the options used to create the mesh
  65298. * @param scene defines the hosting scene
  65299. * @returns the sphere mesh
  65300. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65301. */
  65302. static CreateSphere(name: string, options: {
  65303. segments?: number;
  65304. diameter?: number;
  65305. diameterX?: number;
  65306. diameterY?: number;
  65307. diameterZ?: number;
  65308. arc?: number;
  65309. slice?: number;
  65310. sideOrientation?: number;
  65311. frontUVs?: Vector4;
  65312. backUVs?: Vector4;
  65313. updatable?: boolean;
  65314. }, scene?: Nullable<Scene>): Mesh;
  65315. /**
  65316. * Creates a plane polygonal mesh. By default, this is a disc
  65317. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65318. * * 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
  65319. * * 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
  65320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65321. * * 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
  65322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65323. * @param name defines the name of the mesh
  65324. * @param options defines the options used to create the mesh
  65325. * @param scene defines the hosting scene
  65326. * @returns the plane polygonal mesh
  65327. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65328. */
  65329. static CreateDisc(name: string, options: {
  65330. radius?: number;
  65331. tessellation?: number;
  65332. arc?: number;
  65333. updatable?: boolean;
  65334. sideOrientation?: number;
  65335. frontUVs?: Vector4;
  65336. backUVs?: Vector4;
  65337. }, scene?: Nullable<Scene>): Mesh;
  65338. /**
  65339. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65340. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65341. * * 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`)
  65342. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65343. * * 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
  65344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65345. * * 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
  65346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65347. * @param name defines the name of the mesh
  65348. * @param options defines the options used to create the mesh
  65349. * @param scene defines the hosting scene
  65350. * @returns the icosahedron mesh
  65351. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65352. */
  65353. static CreateIcoSphere(name: string, options: {
  65354. radius?: number;
  65355. radiusX?: number;
  65356. radiusY?: number;
  65357. radiusZ?: number;
  65358. flat?: boolean;
  65359. subdivisions?: number;
  65360. sideOrientation?: number;
  65361. frontUVs?: Vector4;
  65362. backUVs?: Vector4;
  65363. updatable?: boolean;
  65364. }, scene?: Nullable<Scene>): Mesh;
  65365. /**
  65366. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65367. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65368. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65369. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65370. * * 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
  65371. * * 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
  65372. * * 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
  65373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65374. * * 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
  65375. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65376. * * 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
  65377. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65378. * * 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
  65379. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65381. * @param name defines the name of the mesh
  65382. * @param options defines the options used to create the mesh
  65383. * @param scene defines the hosting scene
  65384. * @returns the ribbon mesh
  65385. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65386. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65387. */
  65388. static CreateRibbon(name: string, options: {
  65389. pathArray: Vector3[][];
  65390. closeArray?: boolean;
  65391. closePath?: boolean;
  65392. offset?: number;
  65393. updatable?: boolean;
  65394. sideOrientation?: number;
  65395. frontUVs?: Vector4;
  65396. backUVs?: Vector4;
  65397. instance?: Mesh;
  65398. invertUV?: boolean;
  65399. uvs?: Vector2[];
  65400. colors?: Color4[];
  65401. }, scene?: Nullable<Scene>): Mesh;
  65402. /**
  65403. * Creates a cylinder or a cone mesh
  65404. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65405. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65406. * * 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.
  65407. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65408. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65409. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65410. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65411. * * 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).
  65412. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65413. * * 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).
  65414. * * 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
  65415. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65416. * * 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
  65417. * * 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.
  65418. * * If `enclose` is false, a ring surface is one element.
  65419. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65420. * * 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
  65421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65422. * * 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
  65423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65424. * @param name defines the name of the mesh
  65425. * @param options defines the options used to create the mesh
  65426. * @param scene defines the hosting scene
  65427. * @returns the cylinder mesh
  65428. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65429. */
  65430. static CreateCylinder(name: string, options: {
  65431. height?: number;
  65432. diameterTop?: number;
  65433. diameterBottom?: number;
  65434. diameter?: number;
  65435. tessellation?: number;
  65436. subdivisions?: number;
  65437. arc?: number;
  65438. faceColors?: Color4[];
  65439. faceUV?: Vector4[];
  65440. updatable?: boolean;
  65441. hasRings?: boolean;
  65442. enclose?: boolean;
  65443. cap?: number;
  65444. sideOrientation?: number;
  65445. frontUVs?: Vector4;
  65446. backUVs?: Vector4;
  65447. }, scene?: Nullable<Scene>): Mesh;
  65448. /**
  65449. * Creates a torus mesh
  65450. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65451. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65452. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65454. * * 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
  65455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65456. * @param name defines the name of the mesh
  65457. * @param options defines the options used to create the mesh
  65458. * @param scene defines the hosting scene
  65459. * @returns the torus mesh
  65460. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65461. */
  65462. static CreateTorus(name: string, options: {
  65463. diameter?: number;
  65464. thickness?: number;
  65465. tessellation?: number;
  65466. updatable?: boolean;
  65467. sideOrientation?: number;
  65468. frontUVs?: Vector4;
  65469. backUVs?: Vector4;
  65470. }, scene?: Nullable<Scene>): Mesh;
  65471. /**
  65472. * Creates a torus knot mesh
  65473. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65474. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65475. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65476. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65478. * * 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
  65479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65480. * @param name defines the name of the mesh
  65481. * @param options defines the options used to create the mesh
  65482. * @param scene defines the hosting scene
  65483. * @returns the torus knot mesh
  65484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65485. */
  65486. static CreateTorusKnot(name: string, options: {
  65487. radius?: number;
  65488. tube?: number;
  65489. radialSegments?: number;
  65490. tubularSegments?: number;
  65491. p?: number;
  65492. q?: number;
  65493. updatable?: boolean;
  65494. sideOrientation?: number;
  65495. frontUVs?: Vector4;
  65496. backUVs?: Vector4;
  65497. }, scene?: Nullable<Scene>): Mesh;
  65498. /**
  65499. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65500. * * 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
  65501. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65502. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65503. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65504. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65505. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65506. * * 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
  65507. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65510. * @param name defines the name of the new line system
  65511. * @param options defines the options used to create the line system
  65512. * @param scene defines the hosting scene
  65513. * @returns a new line system mesh
  65514. */
  65515. static CreateLineSystem(name: string, options: {
  65516. lines: Vector3[][];
  65517. updatable?: boolean;
  65518. instance?: Nullable<LinesMesh>;
  65519. colors?: Nullable<Color4[][]>;
  65520. useVertexAlpha?: boolean;
  65521. }, scene: Nullable<Scene>): LinesMesh;
  65522. /**
  65523. * Creates a line mesh
  65524. * 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
  65525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65526. * * The parameter `points` is an array successive Vector3
  65527. * * 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
  65528. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65529. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65530. * * When updating an instance, remember that only point positions can change, not the number of points
  65531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65533. * @param name defines the name of the new line system
  65534. * @param options defines the options used to create the line system
  65535. * @param scene defines the hosting scene
  65536. * @returns a new line mesh
  65537. */
  65538. static CreateLines(name: string, options: {
  65539. points: Vector3[];
  65540. updatable?: boolean;
  65541. instance?: Nullable<LinesMesh>;
  65542. colors?: Color4[];
  65543. useVertexAlpha?: boolean;
  65544. }, scene?: Nullable<Scene>): LinesMesh;
  65545. /**
  65546. * Creates a dashed line mesh
  65547. * * 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
  65548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65549. * * The parameter `points` is an array successive Vector3
  65550. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65551. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65552. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65553. * * 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
  65554. * * When updating an instance, remember that only point positions can change, not the number of points
  65555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65556. * @param name defines the name of the mesh
  65557. * @param options defines the options used to create the mesh
  65558. * @param scene defines the hosting scene
  65559. * @returns the dashed line mesh
  65560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65561. */
  65562. static CreateDashedLines(name: string, options: {
  65563. points: Vector3[];
  65564. dashSize?: number;
  65565. gapSize?: number;
  65566. dashNb?: number;
  65567. updatable?: boolean;
  65568. instance?: LinesMesh;
  65569. }, scene?: Nullable<Scene>): LinesMesh;
  65570. /**
  65571. * 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.
  65572. * * 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.
  65573. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65574. * * 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.
  65575. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65576. * * 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
  65577. * * 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
  65578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65580. * * 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
  65581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65583. * @param name defines the name of the mesh
  65584. * @param options defines the options used to create the mesh
  65585. * @param scene defines the hosting scene
  65586. * @returns the extruded shape mesh
  65587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65589. */
  65590. static ExtrudeShape(name: string, options: {
  65591. shape: Vector3[];
  65592. path: Vector3[];
  65593. scale?: number;
  65594. rotation?: number;
  65595. cap?: number;
  65596. updatable?: boolean;
  65597. sideOrientation?: number;
  65598. frontUVs?: Vector4;
  65599. backUVs?: Vector4;
  65600. instance?: Mesh;
  65601. invertUV?: boolean;
  65602. }, scene?: Nullable<Scene>): Mesh;
  65603. /**
  65604. * Creates an custom extruded shape mesh.
  65605. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65606. * * 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.
  65607. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65608. * * 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
  65609. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65610. * * 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
  65611. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65612. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65613. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65614. * * 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
  65615. * * 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
  65616. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65618. * * 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
  65619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65621. * @param name defines the name of the mesh
  65622. * @param options defines the options used to create the mesh
  65623. * @param scene defines the hosting scene
  65624. * @returns the custom extruded shape mesh
  65625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65626. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65628. */
  65629. static ExtrudeShapeCustom(name: string, options: {
  65630. shape: Vector3[];
  65631. path: Vector3[];
  65632. scaleFunction?: any;
  65633. rotationFunction?: any;
  65634. ribbonCloseArray?: boolean;
  65635. ribbonClosePath?: boolean;
  65636. cap?: number;
  65637. updatable?: boolean;
  65638. sideOrientation?: number;
  65639. frontUVs?: Vector4;
  65640. backUVs?: Vector4;
  65641. instance?: Mesh;
  65642. invertUV?: boolean;
  65643. }, scene?: Nullable<Scene>): Mesh;
  65644. /**
  65645. * Creates lathe mesh.
  65646. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65647. * * 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
  65648. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65649. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65650. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65651. * * 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
  65652. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65653. * * 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
  65654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65655. * * 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
  65656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65658. * @param name defines the name of the mesh
  65659. * @param options defines the options used to create the mesh
  65660. * @param scene defines the hosting scene
  65661. * @returns the lathe mesh
  65662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65663. */
  65664. static CreateLathe(name: string, options: {
  65665. shape: Vector3[];
  65666. radius?: number;
  65667. tessellation?: number;
  65668. clip?: number;
  65669. arc?: number;
  65670. closed?: boolean;
  65671. updatable?: boolean;
  65672. sideOrientation?: number;
  65673. frontUVs?: Vector4;
  65674. backUVs?: Vector4;
  65675. cap?: number;
  65676. invertUV?: boolean;
  65677. }, scene?: Nullable<Scene>): Mesh;
  65678. /**
  65679. * Creates a tiled plane mesh
  65680. * * You can set a limited pattern arrangement with the tiles
  65681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65682. * * 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
  65683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65684. * @param name defines the name of the mesh
  65685. * @param options defines the options used to create the mesh
  65686. * @param scene defines the hosting scene
  65687. * @returns the plane mesh
  65688. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65689. */
  65690. static CreateTiledPlane(name: string, options: {
  65691. pattern?: number;
  65692. tileSize?: number;
  65693. tileWidth?: number;
  65694. tileHeight?: number;
  65695. size?: number;
  65696. width?: number;
  65697. height?: number;
  65698. alignHorizontal?: number;
  65699. alignVertical?: number;
  65700. sideOrientation?: number;
  65701. frontUVs?: Vector4;
  65702. backUVs?: Vector4;
  65703. updatable?: boolean;
  65704. }, scene?: Nullable<Scene>): Mesh;
  65705. /**
  65706. * Creates a plane mesh
  65707. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65708. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65709. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65711. * * 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
  65712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65713. * @param name defines the name of the mesh
  65714. * @param options defines the options used to create the mesh
  65715. * @param scene defines the hosting scene
  65716. * @returns the plane mesh
  65717. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65718. */
  65719. static CreatePlane(name: string, options: {
  65720. size?: number;
  65721. width?: number;
  65722. height?: number;
  65723. sideOrientation?: number;
  65724. frontUVs?: Vector4;
  65725. backUVs?: Vector4;
  65726. updatable?: boolean;
  65727. sourcePlane?: Plane;
  65728. }, scene?: Nullable<Scene>): Mesh;
  65729. /**
  65730. * Creates a ground mesh
  65731. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65732. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65734. * @param name defines the name of the mesh
  65735. * @param options defines the options used to create the mesh
  65736. * @param scene defines the hosting scene
  65737. * @returns the ground mesh
  65738. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65739. */
  65740. static CreateGround(name: string, options: {
  65741. width?: number;
  65742. height?: number;
  65743. subdivisions?: number;
  65744. subdivisionsX?: number;
  65745. subdivisionsY?: number;
  65746. updatable?: boolean;
  65747. }, scene?: Nullable<Scene>): Mesh;
  65748. /**
  65749. * Creates a tiled ground mesh
  65750. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65751. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65752. * * 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
  65753. * * 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
  65754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65755. * @param name defines the name of the mesh
  65756. * @param options defines the options used to create the mesh
  65757. * @param scene defines the hosting scene
  65758. * @returns the tiled ground mesh
  65759. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65760. */
  65761. static CreateTiledGround(name: string, options: {
  65762. xmin: number;
  65763. zmin: number;
  65764. xmax: number;
  65765. zmax: number;
  65766. subdivisions?: {
  65767. w: number;
  65768. h: number;
  65769. };
  65770. precision?: {
  65771. w: number;
  65772. h: number;
  65773. };
  65774. updatable?: boolean;
  65775. }, scene?: Nullable<Scene>): Mesh;
  65776. /**
  65777. * Creates a ground mesh from a height map
  65778. * * The parameter `url` sets the URL of the height map image resource.
  65779. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65780. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65781. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65782. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65783. * * 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.
  65784. * * 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).
  65785. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65787. * @param name defines the name of the mesh
  65788. * @param url defines the url to the height map
  65789. * @param options defines the options used to create the mesh
  65790. * @param scene defines the hosting scene
  65791. * @returns the ground mesh
  65792. * @see https://doc.babylonjs.com/babylon101/height_map
  65793. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65794. */
  65795. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65796. width?: number;
  65797. height?: number;
  65798. subdivisions?: number;
  65799. minHeight?: number;
  65800. maxHeight?: number;
  65801. colorFilter?: Color3;
  65802. alphaFilter?: number;
  65803. updatable?: boolean;
  65804. onReady?: (mesh: GroundMesh) => void;
  65805. }, scene?: Nullable<Scene>): GroundMesh;
  65806. /**
  65807. * Creates a polygon mesh
  65808. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65809. * * 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
  65810. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65812. * * 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)
  65813. * * Remember you can only change the shape positions, not their number when updating a polygon
  65814. * @param name defines the name of the mesh
  65815. * @param options defines the options used to create the mesh
  65816. * @param scene defines the hosting scene
  65817. * @param earcutInjection can be used to inject your own earcut reference
  65818. * @returns the polygon mesh
  65819. */
  65820. static CreatePolygon(name: string, options: {
  65821. shape: Vector3[];
  65822. holes?: Vector3[][];
  65823. depth?: number;
  65824. faceUV?: Vector4[];
  65825. faceColors?: Color4[];
  65826. updatable?: boolean;
  65827. sideOrientation?: number;
  65828. frontUVs?: Vector4;
  65829. backUVs?: Vector4;
  65830. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65831. /**
  65832. * Creates an extruded polygon mesh, with depth in the Y direction.
  65833. * * 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)
  65834. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65835. * @param name defines the name of the mesh
  65836. * @param options defines the options used to create the mesh
  65837. * @param scene defines the hosting scene
  65838. * @param earcutInjection can be used to inject your own earcut reference
  65839. * @returns the polygon mesh
  65840. */
  65841. static ExtrudePolygon(name: string, options: {
  65842. shape: Vector3[];
  65843. holes?: Vector3[][];
  65844. depth?: number;
  65845. faceUV?: Vector4[];
  65846. faceColors?: Color4[];
  65847. updatable?: boolean;
  65848. sideOrientation?: number;
  65849. frontUVs?: Vector4;
  65850. backUVs?: Vector4;
  65851. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65852. /**
  65853. * Creates a tube mesh.
  65854. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65855. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65856. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65857. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65858. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65859. * * 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)
  65860. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65861. * * 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
  65862. * * 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
  65863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65864. * * 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
  65865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 tube mesh
  65871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65872. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65873. */
  65874. static CreateTube(name: string, options: {
  65875. path: Vector3[];
  65876. radius?: number;
  65877. tessellation?: number;
  65878. radiusFunction?: {
  65879. (i: number, distance: number): number;
  65880. };
  65881. cap?: number;
  65882. arc?: number;
  65883. updatable?: boolean;
  65884. sideOrientation?: number;
  65885. frontUVs?: Vector4;
  65886. backUVs?: Vector4;
  65887. instance?: Mesh;
  65888. invertUV?: boolean;
  65889. }, scene?: Nullable<Scene>): Mesh;
  65890. /**
  65891. * Creates a polyhedron mesh
  65892. * * 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
  65893. * * The parameter `size` (positive float, default 1) sets the polygon size
  65894. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65895. * * 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`
  65896. * * 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
  65897. * * 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)`)
  65898. * * 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
  65899. * * 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
  65900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65901. * * 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
  65902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65903. * @param name defines the name of the mesh
  65904. * @param options defines the options used to create the mesh
  65905. * @param scene defines the hosting scene
  65906. * @returns the polyhedron mesh
  65907. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65908. */
  65909. static CreatePolyhedron(name: string, options: {
  65910. type?: number;
  65911. size?: number;
  65912. sizeX?: number;
  65913. sizeY?: number;
  65914. sizeZ?: number;
  65915. custom?: any;
  65916. faceUV?: Vector4[];
  65917. faceColors?: Color4[];
  65918. flat?: boolean;
  65919. updatable?: boolean;
  65920. sideOrientation?: number;
  65921. frontUVs?: Vector4;
  65922. backUVs?: Vector4;
  65923. }, scene?: Nullable<Scene>): Mesh;
  65924. /**
  65925. * Creates a decal mesh.
  65926. * 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
  65927. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65928. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65929. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65930. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65931. * @param name defines the name of the mesh
  65932. * @param sourceMesh defines the mesh where the decal must be applied
  65933. * @param options defines the options used to create the mesh
  65934. * @param scene defines the hosting scene
  65935. * @returns the decal mesh
  65936. * @see https://doc.babylonjs.com/how_to/decals
  65937. */
  65938. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65939. position?: Vector3;
  65940. normal?: Vector3;
  65941. size?: Vector3;
  65942. angle?: number;
  65943. }): Mesh;
  65944. }
  65945. }
  65946. declare module BABYLON {
  65947. /**
  65948. * A simplifier interface for future simplification implementations
  65949. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65950. */
  65951. export interface ISimplifier {
  65952. /**
  65953. * Simplification of a given mesh according to the given settings.
  65954. * Since this requires computation, it is assumed that the function runs async.
  65955. * @param settings The settings of the simplification, including quality and distance
  65956. * @param successCallback A callback that will be called after the mesh was simplified.
  65957. * @param errorCallback in case of an error, this callback will be called. optional.
  65958. */
  65959. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65960. }
  65961. /**
  65962. * Expected simplification settings.
  65963. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65964. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65965. */
  65966. export interface ISimplificationSettings {
  65967. /**
  65968. * Gets or sets the expected quality
  65969. */
  65970. quality: number;
  65971. /**
  65972. * Gets or sets the distance when this optimized version should be used
  65973. */
  65974. distance: number;
  65975. /**
  65976. * Gets an already optimized mesh
  65977. */
  65978. optimizeMesh?: boolean;
  65979. }
  65980. /**
  65981. * Class used to specify simplification options
  65982. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65983. */
  65984. export class SimplificationSettings implements ISimplificationSettings {
  65985. /** expected quality */
  65986. quality: number;
  65987. /** distance when this optimized version should be used */
  65988. distance: number;
  65989. /** already optimized mesh */
  65990. optimizeMesh?: boolean | undefined;
  65991. /**
  65992. * Creates a SimplificationSettings
  65993. * @param quality expected quality
  65994. * @param distance distance when this optimized version should be used
  65995. * @param optimizeMesh already optimized mesh
  65996. */
  65997. constructor(
  65998. /** expected quality */
  65999. quality: number,
  66000. /** distance when this optimized version should be used */
  66001. distance: number,
  66002. /** already optimized mesh */
  66003. optimizeMesh?: boolean | undefined);
  66004. }
  66005. /**
  66006. * Interface used to define a simplification task
  66007. */
  66008. export interface ISimplificationTask {
  66009. /**
  66010. * Array of settings
  66011. */
  66012. settings: Array<ISimplificationSettings>;
  66013. /**
  66014. * Simplification type
  66015. */
  66016. simplificationType: SimplificationType;
  66017. /**
  66018. * Mesh to simplify
  66019. */
  66020. mesh: Mesh;
  66021. /**
  66022. * Callback called on success
  66023. */
  66024. successCallback?: () => void;
  66025. /**
  66026. * Defines if parallel processing can be used
  66027. */
  66028. parallelProcessing: boolean;
  66029. }
  66030. /**
  66031. * Queue used to order the simplification tasks
  66032. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66033. */
  66034. export class SimplificationQueue {
  66035. private _simplificationArray;
  66036. /**
  66037. * Gets a boolean indicating that the process is still running
  66038. */
  66039. running: boolean;
  66040. /**
  66041. * Creates a new queue
  66042. */
  66043. constructor();
  66044. /**
  66045. * Adds a new simplification task
  66046. * @param task defines a task to add
  66047. */
  66048. addTask(task: ISimplificationTask): void;
  66049. /**
  66050. * Execute next task
  66051. */
  66052. executeNext(): void;
  66053. /**
  66054. * Execute a simplification task
  66055. * @param task defines the task to run
  66056. */
  66057. runSimplification(task: ISimplificationTask): void;
  66058. private getSimplifier;
  66059. }
  66060. /**
  66061. * The implemented types of simplification
  66062. * At the moment only Quadratic Error Decimation is implemented
  66063. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66064. */
  66065. export enum SimplificationType {
  66066. /** Quadratic error decimation */
  66067. QUADRATIC = 0
  66068. }
  66069. /**
  66070. * An implementation of the Quadratic Error simplification algorithm.
  66071. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66072. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66073. * @author RaananW
  66074. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66075. */
  66076. export class QuadraticErrorSimplification implements ISimplifier {
  66077. private _mesh;
  66078. private triangles;
  66079. private vertices;
  66080. private references;
  66081. private _reconstructedMesh;
  66082. /** Gets or sets the number pf sync interations */
  66083. syncIterations: number;
  66084. /** Gets or sets the aggressiveness of the simplifier */
  66085. aggressiveness: number;
  66086. /** Gets or sets the number of allowed iterations for decimation */
  66087. decimationIterations: number;
  66088. /** Gets or sets the espilon to use for bounding box computation */
  66089. boundingBoxEpsilon: number;
  66090. /**
  66091. * Creates a new QuadraticErrorSimplification
  66092. * @param _mesh defines the target mesh
  66093. */
  66094. constructor(_mesh: Mesh);
  66095. /**
  66096. * Simplification of a given mesh according to the given settings.
  66097. * Since this requires computation, it is assumed that the function runs async.
  66098. * @param settings The settings of the simplification, including quality and distance
  66099. * @param successCallback A callback that will be called after the mesh was simplified.
  66100. */
  66101. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66102. private runDecimation;
  66103. private initWithMesh;
  66104. private init;
  66105. private reconstructMesh;
  66106. private initDecimatedMesh;
  66107. private isFlipped;
  66108. private updateTriangles;
  66109. private identifyBorder;
  66110. private updateMesh;
  66111. private vertexError;
  66112. private calculateError;
  66113. }
  66114. }
  66115. declare module BABYLON {
  66116. interface Scene {
  66117. /** @hidden (Backing field) */
  66118. _simplificationQueue: SimplificationQueue;
  66119. /**
  66120. * Gets or sets the simplification queue attached to the scene
  66121. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66122. */
  66123. simplificationQueue: SimplificationQueue;
  66124. }
  66125. interface Mesh {
  66126. /**
  66127. * Simplify the mesh according to the given array of settings.
  66128. * Function will return immediately and will simplify async
  66129. * @param settings a collection of simplification settings
  66130. * @param parallelProcessing should all levels calculate parallel or one after the other
  66131. * @param simplificationType the type of simplification to run
  66132. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66133. * @returns the current mesh
  66134. */
  66135. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66136. }
  66137. /**
  66138. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66139. * created in a scene
  66140. */
  66141. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66142. /**
  66143. * The component name helpfull to identify the component in the list of scene components.
  66144. */
  66145. readonly name: string;
  66146. /**
  66147. * The scene the component belongs to.
  66148. */
  66149. scene: Scene;
  66150. /**
  66151. * Creates a new instance of the component for the given scene
  66152. * @param scene Defines the scene to register the component in
  66153. */
  66154. constructor(scene: Scene);
  66155. /**
  66156. * Registers the component in a given scene
  66157. */
  66158. register(): void;
  66159. /**
  66160. * Rebuilds the elements related to this component in case of
  66161. * context lost for instance.
  66162. */
  66163. rebuild(): void;
  66164. /**
  66165. * Disposes the component and the associated ressources
  66166. */
  66167. dispose(): void;
  66168. private _beforeCameraUpdate;
  66169. }
  66170. }
  66171. declare module BABYLON {
  66172. interface Mesh {
  66173. /**
  66174. * Creates a new thin instance
  66175. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66176. * @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
  66177. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66178. */
  66179. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66180. /**
  66181. * Adds the transformation (matrix) of the current mesh as a thin instance
  66182. * @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
  66183. * @returns the thin instance index number
  66184. */
  66185. thinInstanceAddSelf(refresh: boolean): number;
  66186. /**
  66187. * Registers a custom attribute to be used with thin instances
  66188. * @param kind name of the attribute
  66189. * @param stride size in floats of the attribute
  66190. */
  66191. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66192. /**
  66193. * Sets the matrix of a thin instance
  66194. * @param index index of the thin instance
  66195. * @param matrix matrix to set
  66196. * @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
  66197. */
  66198. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66199. /**
  66200. * Sets the value of a custom attribute for a thin instance
  66201. * @param kind name of the attribute
  66202. * @param index index of the thin instance
  66203. * @param value value to set
  66204. * @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
  66205. */
  66206. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66207. /**
  66208. * 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.
  66209. */
  66210. thinInstanceCount: number;
  66211. /**
  66212. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66213. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66214. * @param buffer buffer to set
  66215. * @param stride size in floats of each value of the buffer
  66216. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66217. */
  66218. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66219. /**
  66220. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66221. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66222. */
  66223. thinInstanceBufferUpdated(kind: string): void;
  66224. /**
  66225. * Refreshes the bounding info, taking into account all the thin instances defined
  66226. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66227. */
  66228. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66229. /** @hidden */
  66230. _thinInstanceInitializeUserStorage(): void;
  66231. /** @hidden */
  66232. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66233. /** @hidden */
  66234. _userThinInstanceBuffersStorage: {
  66235. data: {
  66236. [key: string]: Float32Array;
  66237. };
  66238. sizes: {
  66239. [key: string]: number;
  66240. };
  66241. vertexBuffers: {
  66242. [key: string]: Nullable<VertexBuffer>;
  66243. };
  66244. strides: {
  66245. [key: string]: number;
  66246. };
  66247. };
  66248. }
  66249. }
  66250. declare module BABYLON {
  66251. /**
  66252. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66253. */
  66254. export interface INavigationEnginePlugin {
  66255. /**
  66256. * plugin name
  66257. */
  66258. name: string;
  66259. /**
  66260. * Creates a navigation mesh
  66261. * @param meshes array of all the geometry used to compute the navigatio mesh
  66262. * @param parameters bunch of parameters used to filter geometry
  66263. */
  66264. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66265. /**
  66266. * Create a navigation mesh debug mesh
  66267. * @param scene is where the mesh will be added
  66268. * @returns debug display mesh
  66269. */
  66270. createDebugNavMesh(scene: Scene): Mesh;
  66271. /**
  66272. * Get a navigation mesh constrained position, closest to the parameter position
  66273. * @param position world position
  66274. * @returns the closest point to position constrained by the navigation mesh
  66275. */
  66276. getClosestPoint(position: Vector3): Vector3;
  66277. /**
  66278. * Get a navigation mesh constrained position, closest to the parameter position
  66279. * @param position world position
  66280. * @param result output the closest point to position constrained by the navigation mesh
  66281. */
  66282. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66283. /**
  66284. * Get a navigation mesh constrained position, within a particular radius
  66285. * @param position world position
  66286. * @param maxRadius the maximum distance to the constrained world position
  66287. * @returns the closest point to position constrained by the navigation mesh
  66288. */
  66289. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66290. /**
  66291. * Get a navigation mesh constrained position, within a particular radius
  66292. * @param position world position
  66293. * @param maxRadius the maximum distance to the constrained world position
  66294. * @param result output the closest point to position constrained by the navigation mesh
  66295. */
  66296. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66297. /**
  66298. * Compute the final position from a segment made of destination-position
  66299. * @param position world position
  66300. * @param destination world position
  66301. * @returns the resulting point along the navmesh
  66302. */
  66303. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66304. /**
  66305. * Compute the final position from a segment made of destination-position
  66306. * @param position world position
  66307. * @param destination world position
  66308. * @param result output the resulting point along the navmesh
  66309. */
  66310. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66311. /**
  66312. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66313. * @param start world position
  66314. * @param end world position
  66315. * @returns array containing world position composing the path
  66316. */
  66317. computePath(start: Vector3, end: Vector3): Vector3[];
  66318. /**
  66319. * If this plugin is supported
  66320. * @returns true if plugin is supported
  66321. */
  66322. isSupported(): boolean;
  66323. /**
  66324. * Create a new Crowd so you can add agents
  66325. * @param maxAgents the maximum agent count in the crowd
  66326. * @param maxAgentRadius the maximum radius an agent can have
  66327. * @param scene to attach the crowd to
  66328. * @returns the crowd you can add agents to
  66329. */
  66330. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66331. /**
  66332. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66333. * The queries will try to find a solution within those bounds
  66334. * default is (1,1,1)
  66335. * @param extent x,y,z value that define the extent around the queries point of reference
  66336. */
  66337. setDefaultQueryExtent(extent: Vector3): void;
  66338. /**
  66339. * Get the Bounding box extent specified by setDefaultQueryExtent
  66340. * @returns the box extent values
  66341. */
  66342. getDefaultQueryExtent(): Vector3;
  66343. /**
  66344. * build the navmesh from a previously saved state using getNavmeshData
  66345. * @param data the Uint8Array returned by getNavmeshData
  66346. */
  66347. buildFromNavmeshData(data: Uint8Array): void;
  66348. /**
  66349. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66350. * @returns data the Uint8Array that can be saved and reused
  66351. */
  66352. getNavmeshData(): Uint8Array;
  66353. /**
  66354. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66355. * @param result output the box extent values
  66356. */
  66357. getDefaultQueryExtentToRef(result: Vector3): void;
  66358. /**
  66359. * Release all resources
  66360. */
  66361. dispose(): void;
  66362. }
  66363. /**
  66364. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66365. */
  66366. export interface ICrowd {
  66367. /**
  66368. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66369. * You can attach anything to that node. The node position is updated in the scene update tick.
  66370. * @param pos world position that will be constrained by the navigation mesh
  66371. * @param parameters agent parameters
  66372. * @param transform hooked to the agent that will be update by the scene
  66373. * @returns agent index
  66374. */
  66375. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66376. /**
  66377. * Returns the agent position in world space
  66378. * @param index agent index returned by addAgent
  66379. * @returns world space position
  66380. */
  66381. getAgentPosition(index: number): Vector3;
  66382. /**
  66383. * Gets the agent position result in world space
  66384. * @param index agent index returned by addAgent
  66385. * @param result output world space position
  66386. */
  66387. getAgentPositionToRef(index: number, result: Vector3): void;
  66388. /**
  66389. * Gets the agent velocity in world space
  66390. * @param index agent index returned by addAgent
  66391. * @returns world space velocity
  66392. */
  66393. getAgentVelocity(index: number): Vector3;
  66394. /**
  66395. * Gets the agent velocity result in world space
  66396. * @param index agent index returned by addAgent
  66397. * @param result output world space velocity
  66398. */
  66399. getAgentVelocityToRef(index: number, result: Vector3): void;
  66400. /**
  66401. * remove a particular agent previously created
  66402. * @param index agent index returned by addAgent
  66403. */
  66404. removeAgent(index: number): void;
  66405. /**
  66406. * get the list of all agents attached to this crowd
  66407. * @returns list of agent indices
  66408. */
  66409. getAgents(): number[];
  66410. /**
  66411. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66412. * @param deltaTime in seconds
  66413. */
  66414. update(deltaTime: number): void;
  66415. /**
  66416. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66417. * @param index agent index returned by addAgent
  66418. * @param destination targeted world position
  66419. */
  66420. agentGoto(index: number, destination: Vector3): void;
  66421. /**
  66422. * Teleport the agent to a new position
  66423. * @param index agent index returned by addAgent
  66424. * @param destination targeted world position
  66425. */
  66426. agentTeleport(index: number, destination: Vector3): void;
  66427. /**
  66428. * Update agent parameters
  66429. * @param index agent index returned by addAgent
  66430. * @param parameters agent parameters
  66431. */
  66432. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66433. /**
  66434. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66435. * The queries will try to find a solution within those bounds
  66436. * default is (1,1,1)
  66437. * @param extent x,y,z value that define the extent around the queries point of reference
  66438. */
  66439. setDefaultQueryExtent(extent: Vector3): void;
  66440. /**
  66441. * Get the Bounding box extent specified by setDefaultQueryExtent
  66442. * @returns the box extent values
  66443. */
  66444. getDefaultQueryExtent(): Vector3;
  66445. /**
  66446. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66447. * @param result output the box extent values
  66448. */
  66449. getDefaultQueryExtentToRef(result: Vector3): void;
  66450. /**
  66451. * Release all resources
  66452. */
  66453. dispose(): void;
  66454. }
  66455. /**
  66456. * Configures an agent
  66457. */
  66458. export interface IAgentParameters {
  66459. /**
  66460. * Agent radius. [Limit: >= 0]
  66461. */
  66462. radius: number;
  66463. /**
  66464. * Agent height. [Limit: > 0]
  66465. */
  66466. height: number;
  66467. /**
  66468. * Maximum allowed acceleration. [Limit: >= 0]
  66469. */
  66470. maxAcceleration: number;
  66471. /**
  66472. * Maximum allowed speed. [Limit: >= 0]
  66473. */
  66474. maxSpeed: number;
  66475. /**
  66476. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66477. */
  66478. collisionQueryRange: number;
  66479. /**
  66480. * The path visibility optimization range. [Limit: > 0]
  66481. */
  66482. pathOptimizationRange: number;
  66483. /**
  66484. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66485. */
  66486. separationWeight: number;
  66487. }
  66488. /**
  66489. * Configures the navigation mesh creation
  66490. */
  66491. export interface INavMeshParameters {
  66492. /**
  66493. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66494. */
  66495. cs: number;
  66496. /**
  66497. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66498. */
  66499. ch: number;
  66500. /**
  66501. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66502. */
  66503. walkableSlopeAngle: number;
  66504. /**
  66505. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66506. * be considered walkable. [Limit: >= 3] [Units: vx]
  66507. */
  66508. walkableHeight: number;
  66509. /**
  66510. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66511. */
  66512. walkableClimb: number;
  66513. /**
  66514. * The distance to erode/shrink the walkable area of the heightfield away from
  66515. * obstructions. [Limit: >=0] [Units: vx]
  66516. */
  66517. walkableRadius: number;
  66518. /**
  66519. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66520. */
  66521. maxEdgeLen: number;
  66522. /**
  66523. * The maximum distance a simplfied contour's border edges should deviate
  66524. * the original raw contour. [Limit: >=0] [Units: vx]
  66525. */
  66526. maxSimplificationError: number;
  66527. /**
  66528. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66529. */
  66530. minRegionArea: number;
  66531. /**
  66532. * Any regions with a span count smaller than this value will, if possible,
  66533. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66534. */
  66535. mergeRegionArea: number;
  66536. /**
  66537. * The maximum number of vertices allowed for polygons generated during the
  66538. * contour to polygon conversion process. [Limit: >= 3]
  66539. */
  66540. maxVertsPerPoly: number;
  66541. /**
  66542. * Sets the sampling distance to use when generating the detail mesh.
  66543. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66544. */
  66545. detailSampleDist: number;
  66546. /**
  66547. * The maximum distance the detail mesh surface should deviate from heightfield
  66548. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66549. */
  66550. detailSampleMaxError: number;
  66551. }
  66552. }
  66553. declare module BABYLON {
  66554. /**
  66555. * RecastJS navigation plugin
  66556. */
  66557. export class RecastJSPlugin implements INavigationEnginePlugin {
  66558. /**
  66559. * Reference to the Recast library
  66560. */
  66561. bjsRECAST: any;
  66562. /**
  66563. * plugin name
  66564. */
  66565. name: string;
  66566. /**
  66567. * the first navmesh created. We might extend this to support multiple navmeshes
  66568. */
  66569. navMesh: any;
  66570. /**
  66571. * Initializes the recastJS plugin
  66572. * @param recastInjection can be used to inject your own recast reference
  66573. */
  66574. constructor(recastInjection?: any);
  66575. /**
  66576. * Creates a navigation mesh
  66577. * @param meshes array of all the geometry used to compute the navigatio mesh
  66578. * @param parameters bunch of parameters used to filter geometry
  66579. */
  66580. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66581. /**
  66582. * Create a navigation mesh debug mesh
  66583. * @param scene is where the mesh will be added
  66584. * @returns debug display mesh
  66585. */
  66586. createDebugNavMesh(scene: Scene): Mesh;
  66587. /**
  66588. * Get a navigation mesh constrained position, closest to the parameter position
  66589. * @param position world position
  66590. * @returns the closest point to position constrained by the navigation mesh
  66591. */
  66592. getClosestPoint(position: Vector3): Vector3;
  66593. /**
  66594. * Get a navigation mesh constrained position, closest to the parameter position
  66595. * @param position world position
  66596. * @param result output the closest point to position constrained by the navigation mesh
  66597. */
  66598. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66599. /**
  66600. * Get a navigation mesh constrained position, within a particular radius
  66601. * @param position world position
  66602. * @param maxRadius the maximum distance to the constrained world position
  66603. * @returns the closest point to position constrained by the navigation mesh
  66604. */
  66605. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66606. /**
  66607. * Get a navigation mesh constrained position, within a particular radius
  66608. * @param position world position
  66609. * @param maxRadius the maximum distance to the constrained world position
  66610. * @param result output the closest point to position constrained by the navigation mesh
  66611. */
  66612. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66613. /**
  66614. * Compute the final position from a segment made of destination-position
  66615. * @param position world position
  66616. * @param destination world position
  66617. * @returns the resulting point along the navmesh
  66618. */
  66619. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66620. /**
  66621. * Compute the final position from a segment made of destination-position
  66622. * @param position world position
  66623. * @param destination world position
  66624. * @param result output the resulting point along the navmesh
  66625. */
  66626. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66627. /**
  66628. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66629. * @param start world position
  66630. * @param end world position
  66631. * @returns array containing world position composing the path
  66632. */
  66633. computePath(start: Vector3, end: Vector3): Vector3[];
  66634. /**
  66635. * Create a new Crowd so you can add agents
  66636. * @param maxAgents the maximum agent count in the crowd
  66637. * @param maxAgentRadius the maximum radius an agent can have
  66638. * @param scene to attach the crowd to
  66639. * @returns the crowd you can add agents to
  66640. */
  66641. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66642. /**
  66643. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66644. * The queries will try to find a solution within those bounds
  66645. * default is (1,1,1)
  66646. * @param extent x,y,z value that define the extent around the queries point of reference
  66647. */
  66648. setDefaultQueryExtent(extent: Vector3): void;
  66649. /**
  66650. * Get the Bounding box extent specified by setDefaultQueryExtent
  66651. * @returns the box extent values
  66652. */
  66653. getDefaultQueryExtent(): Vector3;
  66654. /**
  66655. * build the navmesh from a previously saved state using getNavmeshData
  66656. * @param data the Uint8Array returned by getNavmeshData
  66657. */
  66658. buildFromNavmeshData(data: Uint8Array): void;
  66659. /**
  66660. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66661. * @returns data the Uint8Array that can be saved and reused
  66662. */
  66663. getNavmeshData(): Uint8Array;
  66664. /**
  66665. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66666. * @param result output the box extent values
  66667. */
  66668. getDefaultQueryExtentToRef(result: Vector3): void;
  66669. /**
  66670. * Disposes
  66671. */
  66672. dispose(): void;
  66673. /**
  66674. * If this plugin is supported
  66675. * @returns true if plugin is supported
  66676. */
  66677. isSupported(): boolean;
  66678. }
  66679. /**
  66680. * Recast detour crowd implementation
  66681. */
  66682. export class RecastJSCrowd implements ICrowd {
  66683. /**
  66684. * Recast/detour plugin
  66685. */
  66686. bjsRECASTPlugin: RecastJSPlugin;
  66687. /**
  66688. * Link to the detour crowd
  66689. */
  66690. recastCrowd: any;
  66691. /**
  66692. * One transform per agent
  66693. */
  66694. transforms: TransformNode[];
  66695. /**
  66696. * All agents created
  66697. */
  66698. agents: number[];
  66699. /**
  66700. * Link to the scene is kept to unregister the crowd from the scene
  66701. */
  66702. private _scene;
  66703. /**
  66704. * Observer for crowd updates
  66705. */
  66706. private _onBeforeAnimationsObserver;
  66707. /**
  66708. * Constructor
  66709. * @param plugin recastJS plugin
  66710. * @param maxAgents the maximum agent count in the crowd
  66711. * @param maxAgentRadius the maximum radius an agent can have
  66712. * @param scene to attach the crowd to
  66713. * @returns the crowd you can add agents to
  66714. */
  66715. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66716. /**
  66717. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66718. * You can attach anything to that node. The node position is updated in the scene update tick.
  66719. * @param pos world position that will be constrained by the navigation mesh
  66720. * @param parameters agent parameters
  66721. * @param transform hooked to the agent that will be update by the scene
  66722. * @returns agent index
  66723. */
  66724. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66725. /**
  66726. * Returns the agent position in world space
  66727. * @param index agent index returned by addAgent
  66728. * @returns world space position
  66729. */
  66730. getAgentPosition(index: number): Vector3;
  66731. /**
  66732. * Returns the agent position result in world space
  66733. * @param index agent index returned by addAgent
  66734. * @param result output world space position
  66735. */
  66736. getAgentPositionToRef(index: number, result: Vector3): void;
  66737. /**
  66738. * Returns the agent velocity in world space
  66739. * @param index agent index returned by addAgent
  66740. * @returns world space velocity
  66741. */
  66742. getAgentVelocity(index: number): Vector3;
  66743. /**
  66744. * Returns the agent velocity result in world space
  66745. * @param index agent index returned by addAgent
  66746. * @param result output world space velocity
  66747. */
  66748. getAgentVelocityToRef(index: number, result: Vector3): void;
  66749. /**
  66750. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66751. * @param index agent index returned by addAgent
  66752. * @param destination targeted world position
  66753. */
  66754. agentGoto(index: number, destination: Vector3): void;
  66755. /**
  66756. * Teleport the agent to a new position
  66757. * @param index agent index returned by addAgent
  66758. * @param destination targeted world position
  66759. */
  66760. agentTeleport(index: number, destination: Vector3): void;
  66761. /**
  66762. * Update agent parameters
  66763. * @param index agent index returned by addAgent
  66764. * @param parameters agent parameters
  66765. */
  66766. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66767. /**
  66768. * remove a particular agent previously created
  66769. * @param index agent index returned by addAgent
  66770. */
  66771. removeAgent(index: number): void;
  66772. /**
  66773. * get the list of all agents attached to this crowd
  66774. * @returns list of agent indices
  66775. */
  66776. getAgents(): number[];
  66777. /**
  66778. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66779. * @param deltaTime in seconds
  66780. */
  66781. update(deltaTime: number): void;
  66782. /**
  66783. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66784. * The queries will try to find a solution within those bounds
  66785. * default is (1,1,1)
  66786. * @param extent x,y,z value that define the extent around the queries point of reference
  66787. */
  66788. setDefaultQueryExtent(extent: Vector3): void;
  66789. /**
  66790. * Get the Bounding box extent specified by setDefaultQueryExtent
  66791. * @returns the box extent values
  66792. */
  66793. getDefaultQueryExtent(): Vector3;
  66794. /**
  66795. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66796. * @param result output the box extent values
  66797. */
  66798. getDefaultQueryExtentToRef(result: Vector3): void;
  66799. /**
  66800. * Release all resources
  66801. */
  66802. dispose(): void;
  66803. }
  66804. }
  66805. declare module BABYLON {
  66806. /**
  66807. * Class used to enable access to IndexedDB
  66808. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66809. */
  66810. export class Database implements IOfflineProvider {
  66811. private _callbackManifestChecked;
  66812. private _currentSceneUrl;
  66813. private _db;
  66814. private _enableSceneOffline;
  66815. private _enableTexturesOffline;
  66816. private _manifestVersionFound;
  66817. private _mustUpdateRessources;
  66818. private _hasReachedQuota;
  66819. private _isSupported;
  66820. private _idbFactory;
  66821. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66822. private static IsUASupportingBlobStorage;
  66823. /**
  66824. * Gets a boolean indicating if Database storate is enabled (off by default)
  66825. */
  66826. static IDBStorageEnabled: boolean;
  66827. /**
  66828. * Gets a boolean indicating if scene must be saved in the database
  66829. */
  66830. get enableSceneOffline(): boolean;
  66831. /**
  66832. * Gets a boolean indicating if textures must be saved in the database
  66833. */
  66834. get enableTexturesOffline(): boolean;
  66835. /**
  66836. * Creates a new Database
  66837. * @param urlToScene defines the url to load the scene
  66838. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66839. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66840. */
  66841. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66842. private static _ParseURL;
  66843. private static _ReturnFullUrlLocation;
  66844. private _checkManifestFile;
  66845. /**
  66846. * Open the database and make it available
  66847. * @param successCallback defines the callback to call on success
  66848. * @param errorCallback defines the callback to call on error
  66849. */
  66850. open(successCallback: () => void, errorCallback: () => void): void;
  66851. /**
  66852. * Loads an image from the database
  66853. * @param url defines the url to load from
  66854. * @param image defines the target DOM image
  66855. */
  66856. loadImage(url: string, image: HTMLImageElement): void;
  66857. private _loadImageFromDBAsync;
  66858. private _saveImageIntoDBAsync;
  66859. private _checkVersionFromDB;
  66860. private _loadVersionFromDBAsync;
  66861. private _saveVersionIntoDBAsync;
  66862. /**
  66863. * Loads a file from database
  66864. * @param url defines the URL to load from
  66865. * @param sceneLoaded defines a callback to call on success
  66866. * @param progressCallBack defines a callback to call when progress changed
  66867. * @param errorCallback defines a callback to call on error
  66868. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66869. */
  66870. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66871. private _loadFileAsync;
  66872. private _saveFileAsync;
  66873. /**
  66874. * Validates if xhr data is correct
  66875. * @param xhr defines the request to validate
  66876. * @param dataType defines the expected data type
  66877. * @returns true if data is correct
  66878. */
  66879. private static _ValidateXHRData;
  66880. }
  66881. }
  66882. declare module BABYLON {
  66883. /** @hidden */
  66884. export var gpuUpdateParticlesPixelShader: {
  66885. name: string;
  66886. shader: string;
  66887. };
  66888. }
  66889. declare module BABYLON {
  66890. /** @hidden */
  66891. export var gpuUpdateParticlesVertexShader: {
  66892. name: string;
  66893. shader: string;
  66894. };
  66895. }
  66896. declare module BABYLON {
  66897. /** @hidden */
  66898. export var clipPlaneFragmentDeclaration2: {
  66899. name: string;
  66900. shader: string;
  66901. };
  66902. }
  66903. declare module BABYLON {
  66904. /** @hidden */
  66905. export var gpuRenderParticlesPixelShader: {
  66906. name: string;
  66907. shader: string;
  66908. };
  66909. }
  66910. declare module BABYLON {
  66911. /** @hidden */
  66912. export var clipPlaneVertexDeclaration2: {
  66913. name: string;
  66914. shader: string;
  66915. };
  66916. }
  66917. declare module BABYLON {
  66918. /** @hidden */
  66919. export var gpuRenderParticlesVertexShader: {
  66920. name: string;
  66921. shader: string;
  66922. };
  66923. }
  66924. declare module BABYLON {
  66925. /**
  66926. * This represents a GPU particle system in Babylon
  66927. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66928. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66929. */
  66930. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66931. /**
  66932. * The layer mask we are rendering the particles through.
  66933. */
  66934. layerMask: number;
  66935. private _capacity;
  66936. private _activeCount;
  66937. private _currentActiveCount;
  66938. private _accumulatedCount;
  66939. private _renderEffect;
  66940. private _updateEffect;
  66941. private _buffer0;
  66942. private _buffer1;
  66943. private _spriteBuffer;
  66944. private _updateVAO;
  66945. private _renderVAO;
  66946. private _targetIndex;
  66947. private _sourceBuffer;
  66948. private _targetBuffer;
  66949. private _engine;
  66950. private _currentRenderId;
  66951. private _started;
  66952. private _stopped;
  66953. private _timeDelta;
  66954. private _randomTexture;
  66955. private _randomTexture2;
  66956. private _attributesStrideSize;
  66957. private _updateEffectOptions;
  66958. private _randomTextureSize;
  66959. private _actualFrame;
  66960. private _customEffect;
  66961. private readonly _rawTextureWidth;
  66962. /**
  66963. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66964. */
  66965. static get IsSupported(): boolean;
  66966. /**
  66967. * An event triggered when the system is disposed.
  66968. */
  66969. onDisposeObservable: Observable<IParticleSystem>;
  66970. /**
  66971. * Gets the maximum number of particles active at the same time.
  66972. * @returns The max number of active particles.
  66973. */
  66974. getCapacity(): number;
  66975. /**
  66976. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66977. * to override the particles.
  66978. */
  66979. forceDepthWrite: boolean;
  66980. /**
  66981. * Gets or set the number of active particles
  66982. */
  66983. get activeParticleCount(): number;
  66984. set activeParticleCount(value: number);
  66985. private _preWarmDone;
  66986. /**
  66987. * Specifies if the particles are updated in emitter local space or world space.
  66988. */
  66989. isLocal: boolean;
  66990. /**
  66991. * Is this system ready to be used/rendered
  66992. * @return true if the system is ready
  66993. */
  66994. isReady(): boolean;
  66995. /**
  66996. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66997. * @returns True if it has been started, otherwise false.
  66998. */
  66999. isStarted(): boolean;
  67000. /**
  67001. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67002. * @returns True if it has been stopped, otherwise false.
  67003. */
  67004. isStopped(): boolean;
  67005. /**
  67006. * Gets a boolean indicating that the system is stopping
  67007. * @returns true if the system is currently stopping
  67008. */
  67009. isStopping(): boolean;
  67010. /**
  67011. * Gets the number of particles active at the same time.
  67012. * @returns The number of active particles.
  67013. */
  67014. getActiveCount(): number;
  67015. /**
  67016. * Starts the particle system and begins to emit
  67017. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67018. */
  67019. start(delay?: number): void;
  67020. /**
  67021. * Stops the particle system.
  67022. */
  67023. stop(): void;
  67024. /**
  67025. * Remove all active particles
  67026. */
  67027. reset(): void;
  67028. /**
  67029. * Returns the string "GPUParticleSystem"
  67030. * @returns a string containing the class name
  67031. */
  67032. getClassName(): string;
  67033. /**
  67034. * Gets the custom effect used to render the particles
  67035. * @param blendMode Blend mode for which the effect should be retrieved
  67036. * @returns The effect
  67037. */
  67038. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67039. /**
  67040. * Sets the custom effect used to render the particles
  67041. * @param effect The effect to set
  67042. * @param blendMode Blend mode for which the effect should be set
  67043. */
  67044. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67045. /** @hidden */
  67046. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67047. /**
  67048. * Observable that will be called just before the particles are drawn
  67049. */
  67050. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67051. /**
  67052. * Gets the name of the particle vertex shader
  67053. */
  67054. get vertexShaderName(): string;
  67055. private _colorGradientsTexture;
  67056. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67057. /**
  67058. * Adds a new color gradient
  67059. * @param gradient defines the gradient to use (between 0 and 1)
  67060. * @param color1 defines the color to affect to the specified gradient
  67061. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67062. * @returns the current particle system
  67063. */
  67064. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67065. private _refreshColorGradient;
  67066. /** Force the system to rebuild all gradients that need to be resync */
  67067. forceRefreshGradients(): void;
  67068. /**
  67069. * Remove a specific color gradient
  67070. * @param gradient defines the gradient to remove
  67071. * @returns the current particle system
  67072. */
  67073. removeColorGradient(gradient: number): GPUParticleSystem;
  67074. private _angularSpeedGradientsTexture;
  67075. private _sizeGradientsTexture;
  67076. private _velocityGradientsTexture;
  67077. private _limitVelocityGradientsTexture;
  67078. private _dragGradientsTexture;
  67079. private _addFactorGradient;
  67080. /**
  67081. * Adds a new size gradient
  67082. * @param gradient defines the gradient to use (between 0 and 1)
  67083. * @param factor defines the size factor to affect to the specified gradient
  67084. * @returns the current particle system
  67085. */
  67086. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67087. /**
  67088. * Remove a specific size gradient
  67089. * @param gradient defines the gradient to remove
  67090. * @returns the current particle system
  67091. */
  67092. removeSizeGradient(gradient: number): GPUParticleSystem;
  67093. private _refreshFactorGradient;
  67094. /**
  67095. * Adds a new angular speed gradient
  67096. * @param gradient defines the gradient to use (between 0 and 1)
  67097. * @param factor defines the angular speed to affect to the specified gradient
  67098. * @returns the current particle system
  67099. */
  67100. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67101. /**
  67102. * Remove a specific angular speed gradient
  67103. * @param gradient defines the gradient to remove
  67104. * @returns the current particle system
  67105. */
  67106. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67107. /**
  67108. * Adds a new velocity gradient
  67109. * @param gradient defines the gradient to use (between 0 and 1)
  67110. * @param factor defines the velocity to affect to the specified gradient
  67111. * @returns the current particle system
  67112. */
  67113. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67114. /**
  67115. * Remove a specific velocity gradient
  67116. * @param gradient defines the gradient to remove
  67117. * @returns the current particle system
  67118. */
  67119. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67120. /**
  67121. * Adds a new limit velocity gradient
  67122. * @param gradient defines the gradient to use (between 0 and 1)
  67123. * @param factor defines the limit velocity value to affect to the specified gradient
  67124. * @returns the current particle system
  67125. */
  67126. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67127. /**
  67128. * Remove a specific limit velocity gradient
  67129. * @param gradient defines the gradient to remove
  67130. * @returns the current particle system
  67131. */
  67132. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67133. /**
  67134. * Adds a new drag gradient
  67135. * @param gradient defines the gradient to use (between 0 and 1)
  67136. * @param factor defines the drag value to affect to the specified gradient
  67137. * @returns the current particle system
  67138. */
  67139. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67140. /**
  67141. * Remove a specific drag gradient
  67142. * @param gradient defines the gradient to remove
  67143. * @returns the current particle system
  67144. */
  67145. removeDragGradient(gradient: number): GPUParticleSystem;
  67146. /**
  67147. * Not supported by GPUParticleSystem
  67148. * @param gradient defines the gradient to use (between 0 and 1)
  67149. * @param factor defines the emit rate value to affect to the specified gradient
  67150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67151. * @returns the current particle system
  67152. */
  67153. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67154. /**
  67155. * Not supported by GPUParticleSystem
  67156. * @param gradient defines the gradient to remove
  67157. * @returns the current particle system
  67158. */
  67159. removeEmitRateGradient(gradient: number): IParticleSystem;
  67160. /**
  67161. * Not supported by GPUParticleSystem
  67162. * @param gradient defines the gradient to use (between 0 and 1)
  67163. * @param factor defines the start size value to affect to the specified gradient
  67164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67165. * @returns the current particle system
  67166. */
  67167. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67168. /**
  67169. * Not supported by GPUParticleSystem
  67170. * @param gradient defines the gradient to remove
  67171. * @returns the current particle system
  67172. */
  67173. removeStartSizeGradient(gradient: number): IParticleSystem;
  67174. /**
  67175. * Not supported by GPUParticleSystem
  67176. * @param gradient defines the gradient to use (between 0 and 1)
  67177. * @param min defines the color remap minimal range
  67178. * @param max defines the color remap maximal range
  67179. * @returns the current particle system
  67180. */
  67181. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67182. /**
  67183. * Not supported by GPUParticleSystem
  67184. * @param gradient defines the gradient to remove
  67185. * @returns the current particle system
  67186. */
  67187. removeColorRemapGradient(): IParticleSystem;
  67188. /**
  67189. * Not supported by GPUParticleSystem
  67190. * @param gradient defines the gradient to use (between 0 and 1)
  67191. * @param min defines the alpha remap minimal range
  67192. * @param max defines the alpha remap maximal range
  67193. * @returns the current particle system
  67194. */
  67195. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67196. /**
  67197. * Not supported by GPUParticleSystem
  67198. * @param gradient defines the gradient to remove
  67199. * @returns the current particle system
  67200. */
  67201. removeAlphaRemapGradient(): IParticleSystem;
  67202. /**
  67203. * Not supported by GPUParticleSystem
  67204. * @param gradient defines the gradient to use (between 0 and 1)
  67205. * @param color defines the color to affect to the specified gradient
  67206. * @returns the current particle system
  67207. */
  67208. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67209. /**
  67210. * Not supported by GPUParticleSystem
  67211. * @param gradient defines the gradient to remove
  67212. * @returns the current particle system
  67213. */
  67214. removeRampGradient(): IParticleSystem;
  67215. /**
  67216. * Not supported by GPUParticleSystem
  67217. * @returns the list of ramp gradients
  67218. */
  67219. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67220. /**
  67221. * Not supported by GPUParticleSystem
  67222. * Gets or sets a boolean indicating that ramp gradients must be used
  67223. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67224. */
  67225. get useRampGradients(): boolean;
  67226. set useRampGradients(value: boolean);
  67227. /**
  67228. * Not supported by GPUParticleSystem
  67229. * @param gradient defines the gradient to use (between 0 and 1)
  67230. * @param factor defines the life time factor to affect to the specified gradient
  67231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67232. * @returns the current particle system
  67233. */
  67234. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67235. /**
  67236. * Not supported by GPUParticleSystem
  67237. * @param gradient defines the gradient to remove
  67238. * @returns the current particle system
  67239. */
  67240. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67241. /**
  67242. * Instantiates a GPU particle system.
  67243. * 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.
  67244. * @param name The name of the particle system
  67245. * @param options The options used to create the system
  67246. * @param scene The scene the particle system belongs to
  67247. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67248. * @param customEffect a custom effect used to change the way particles are rendered by default
  67249. */
  67250. constructor(name: string, options: Partial<{
  67251. capacity: number;
  67252. randomTextureSize: number;
  67253. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67254. protected _reset(): void;
  67255. private _createUpdateVAO;
  67256. private _createRenderVAO;
  67257. private _initialize;
  67258. /** @hidden */
  67259. _recreateUpdateEffect(): void;
  67260. private _getEffect;
  67261. /**
  67262. * Fill the defines array according to the current settings of the particle system
  67263. * @param defines Array to be updated
  67264. * @param blendMode blend mode to take into account when updating the array
  67265. */
  67266. fillDefines(defines: Array<string>, blendMode?: number): void;
  67267. /**
  67268. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67269. * @param uniforms Uniforms array to fill
  67270. * @param attributes Attributes array to fill
  67271. * @param samplers Samplers array to fill
  67272. */
  67273. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67274. /** @hidden */
  67275. _recreateRenderEffect(): Effect;
  67276. /**
  67277. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67278. * @param preWarm defines if we are in the pre-warmimg phase
  67279. */
  67280. animate(preWarm?: boolean): void;
  67281. private _createFactorGradientTexture;
  67282. private _createSizeGradientTexture;
  67283. private _createAngularSpeedGradientTexture;
  67284. private _createVelocityGradientTexture;
  67285. private _createLimitVelocityGradientTexture;
  67286. private _createDragGradientTexture;
  67287. private _createColorGradientTexture;
  67288. /**
  67289. * Renders the particle system in its current state
  67290. * @param preWarm defines if the system should only update the particles but not render them
  67291. * @returns the current number of particles
  67292. */
  67293. render(preWarm?: boolean): number;
  67294. /**
  67295. * Rebuilds the particle system
  67296. */
  67297. rebuild(): void;
  67298. private _releaseBuffers;
  67299. private _releaseVAOs;
  67300. /**
  67301. * Disposes the particle system and free the associated resources
  67302. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67303. */
  67304. dispose(disposeTexture?: boolean): void;
  67305. /**
  67306. * Clones the particle system.
  67307. * @param name The name of the cloned object
  67308. * @param newEmitter The new emitter to use
  67309. * @returns the cloned particle system
  67310. */
  67311. clone(name: string, newEmitter: any): GPUParticleSystem;
  67312. /**
  67313. * Serializes the particle system to a JSON object
  67314. * @param serializeTexture defines if the texture must be serialized as well
  67315. * @returns the JSON object
  67316. */
  67317. serialize(serializeTexture?: boolean): any;
  67318. /**
  67319. * Parses a JSON object to create a GPU particle system.
  67320. * @param parsedParticleSystem The JSON object to parse
  67321. * @param scene The scene to create the particle system in
  67322. * @param rootUrl The root url to use to load external dependencies like texture
  67323. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67324. * @returns the parsed GPU particle system
  67325. */
  67326. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67327. }
  67328. }
  67329. declare module BABYLON {
  67330. /**
  67331. * Represents a set of particle systems working together to create a specific effect
  67332. */
  67333. export class ParticleSystemSet implements IDisposable {
  67334. /**
  67335. * Gets or sets base Assets URL
  67336. */
  67337. static BaseAssetsUrl: string;
  67338. private _emitterCreationOptions;
  67339. private _emitterNode;
  67340. /**
  67341. * Gets the particle system list
  67342. */
  67343. systems: IParticleSystem[];
  67344. /**
  67345. * Gets the emitter node used with this set
  67346. */
  67347. get emitterNode(): Nullable<TransformNode>;
  67348. /**
  67349. * Creates a new emitter mesh as a sphere
  67350. * @param options defines the options used to create the sphere
  67351. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67352. * @param scene defines the hosting scene
  67353. */
  67354. setEmitterAsSphere(options: {
  67355. diameter: number;
  67356. segments: number;
  67357. color: Color3;
  67358. }, renderingGroupId: number, scene: Scene): void;
  67359. /**
  67360. * Starts all particle systems of the set
  67361. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67362. */
  67363. start(emitter?: AbstractMesh): void;
  67364. /**
  67365. * Release all associated resources
  67366. */
  67367. dispose(): void;
  67368. /**
  67369. * Serialize the set into a JSON compatible object
  67370. * @param serializeTexture defines if the texture must be serialized as well
  67371. * @returns a JSON compatible representation of the set
  67372. */
  67373. serialize(serializeTexture?: boolean): any;
  67374. /**
  67375. * Parse a new ParticleSystemSet from a serialized source
  67376. * @param data defines a JSON compatible representation of the set
  67377. * @param scene defines the hosting scene
  67378. * @param gpu defines if we want GPU particles or CPU particles
  67379. * @returns a new ParticleSystemSet
  67380. */
  67381. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67382. }
  67383. }
  67384. declare module BABYLON {
  67385. /**
  67386. * This class is made for on one-liner static method to help creating particle system set.
  67387. */
  67388. export class ParticleHelper {
  67389. /**
  67390. * Gets or sets base Assets URL
  67391. */
  67392. static BaseAssetsUrl: string;
  67393. /** Define the Url to load snippets */
  67394. static SnippetUrl: string;
  67395. /**
  67396. * Create a default particle system that you can tweak
  67397. * @param emitter defines the emitter to use
  67398. * @param capacity defines the system capacity (default is 500 particles)
  67399. * @param scene defines the hosting scene
  67400. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67401. * @returns the new Particle system
  67402. */
  67403. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67404. /**
  67405. * This is the main static method (one-liner) of this helper to create different particle systems
  67406. * @param type This string represents the type to the particle system to create
  67407. * @param scene The scene where the particle system should live
  67408. * @param gpu If the system will use gpu
  67409. * @returns the ParticleSystemSet created
  67410. */
  67411. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67412. /**
  67413. * Static function used to export a particle system to a ParticleSystemSet variable.
  67414. * Please note that the emitter shape is not exported
  67415. * @param systems defines the particle systems to export
  67416. * @returns the created particle system set
  67417. */
  67418. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67419. /**
  67420. * Creates a particle system from a snippet saved in a remote file
  67421. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67422. * @param url defines the url to load from
  67423. * @param scene defines the hosting scene
  67424. * @param gpu If the system will use gpu
  67425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67426. * @returns a promise that will resolve to the new particle system
  67427. */
  67428. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67429. /**
  67430. * Creates a particle system from a snippet saved by the particle system editor
  67431. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67432. * @param scene defines the hosting scene
  67433. * @param gpu If the system will use gpu
  67434. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67435. * @returns a promise that will resolve to the new particle system
  67436. */
  67437. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67438. }
  67439. }
  67440. declare module BABYLON {
  67441. interface Engine {
  67442. /**
  67443. * Create an effect to use with particle systems.
  67444. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67445. * the particle system for which you want to create a custom effect in the last parameter
  67446. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67447. * @param uniformsNames defines a list of attribute names
  67448. * @param samplers defines an array of string used to represent textures
  67449. * @param defines defines the string containing the defines to use to compile the shaders
  67450. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67451. * @param onCompiled defines a function to call when the effect creation is successful
  67452. * @param onError defines a function to call when the effect creation has failed
  67453. * @param particleSystem the particle system you want to create the effect for
  67454. * @returns the new Effect
  67455. */
  67456. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67457. }
  67458. interface Mesh {
  67459. /**
  67460. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67461. * @returns an array of IParticleSystem
  67462. */
  67463. getEmittedParticleSystems(): IParticleSystem[];
  67464. /**
  67465. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67466. * @returns an array of IParticleSystem
  67467. */
  67468. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67469. }
  67470. }
  67471. declare module BABYLON {
  67472. /** Defines the 4 color options */
  67473. export enum PointColor {
  67474. /** color value */
  67475. Color = 2,
  67476. /** uv value */
  67477. UV = 1,
  67478. /** random value */
  67479. Random = 0,
  67480. /** stated value */
  67481. Stated = 3
  67482. }
  67483. /**
  67484. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67485. * 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.
  67486. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67487. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67488. *
  67489. * Full documentation here : TO BE ENTERED
  67490. */
  67491. export class PointsCloudSystem implements IDisposable {
  67492. /**
  67493. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67494. * Example : var p = SPS.particles[i];
  67495. */
  67496. particles: CloudPoint[];
  67497. /**
  67498. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67499. */
  67500. nbParticles: number;
  67501. /**
  67502. * This a counter for your own usage. It's not set by any SPS functions.
  67503. */
  67504. counter: number;
  67505. /**
  67506. * The PCS name. This name is also given to the underlying mesh.
  67507. */
  67508. name: string;
  67509. /**
  67510. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67511. */
  67512. mesh: Mesh;
  67513. /**
  67514. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67515. * Please read :
  67516. */
  67517. vars: any;
  67518. /**
  67519. * @hidden
  67520. */
  67521. _size: number;
  67522. private _scene;
  67523. private _promises;
  67524. private _positions;
  67525. private _indices;
  67526. private _normals;
  67527. private _colors;
  67528. private _uvs;
  67529. private _indices32;
  67530. private _positions32;
  67531. private _colors32;
  67532. private _uvs32;
  67533. private _updatable;
  67534. private _isVisibilityBoxLocked;
  67535. private _alwaysVisible;
  67536. private _groups;
  67537. private _groupCounter;
  67538. private _computeParticleColor;
  67539. private _computeParticleTexture;
  67540. private _computeParticleRotation;
  67541. private _computeBoundingBox;
  67542. private _isReady;
  67543. /**
  67544. * Creates a PCS (Points Cloud System) object
  67545. * @param name (String) is the PCS name, this will be the underlying mesh name
  67546. * @param pointSize (number) is the size for each point
  67547. * @param scene (Scene) is the scene in which the PCS is added
  67548. * @param options defines the options of the PCS e.g.
  67549. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67550. */
  67551. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67552. updatable?: boolean;
  67553. });
  67554. /**
  67555. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67556. * If no points were added to the PCS, the returned mesh is just a single point.
  67557. * @returns a promise for the created mesh
  67558. */
  67559. buildMeshAsync(): Promise<Mesh>;
  67560. /**
  67561. * @hidden
  67562. */
  67563. private _buildMesh;
  67564. private _addParticle;
  67565. private _randomUnitVector;
  67566. private _getColorIndicesForCoord;
  67567. private _setPointsColorOrUV;
  67568. private _colorFromTexture;
  67569. private _calculateDensity;
  67570. /**
  67571. * Adds points to the PCS in random positions within a unit sphere
  67572. * @param nb (positive integer) the number of particles to be created from this model
  67573. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67574. * @returns the number of groups in the system
  67575. */
  67576. addPoints(nb: number, pointFunction?: any): number;
  67577. /**
  67578. * Adds points to the PCS from the surface of the model shape
  67579. * @param mesh is any Mesh object that will be used as a surface model for the points
  67580. * @param nb (positive integer) the number of particles to be created from this model
  67581. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67582. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67583. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67584. * @returns the number of groups in the system
  67585. */
  67586. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67587. /**
  67588. * Adds points to the PCS inside the model shape
  67589. * @param mesh is any Mesh object that will be used as a surface model for the points
  67590. * @param nb (positive integer) the number of particles to be created from this model
  67591. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67592. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67593. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67594. * @returns the number of groups in the system
  67595. */
  67596. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67597. /**
  67598. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67599. * This method calls `updateParticle()` for each particle of the SPS.
  67600. * For an animated SPS, it is usually called within the render loop.
  67601. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67602. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67603. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67604. * @returns the PCS.
  67605. */
  67606. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67607. /**
  67608. * Disposes the PCS.
  67609. */
  67610. dispose(): void;
  67611. /**
  67612. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67613. * doc :
  67614. * @returns the PCS.
  67615. */
  67616. refreshVisibleSize(): PointsCloudSystem;
  67617. /**
  67618. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67619. * @param size the size (float) of the visibility box
  67620. * note : this doesn't lock the PCS mesh bounding box.
  67621. * doc :
  67622. */
  67623. setVisibilityBox(size: number): void;
  67624. /**
  67625. * Gets whether the PCS is always visible or not
  67626. * doc :
  67627. */
  67628. get isAlwaysVisible(): boolean;
  67629. /**
  67630. * Sets the PCS as always visible or not
  67631. * doc :
  67632. */
  67633. set isAlwaysVisible(val: boolean);
  67634. /**
  67635. * Tells to `setParticles()` to compute the particle rotations or not
  67636. * Default value : false. The PCS is faster when it's set to false
  67637. * Note : particle rotations are only applied to parent particles
  67638. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67639. */
  67640. set computeParticleRotation(val: boolean);
  67641. /**
  67642. * Tells to `setParticles()` to compute the particle colors or not.
  67643. * Default value : true. The PCS is faster when it's set to false.
  67644. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67645. */
  67646. set computeParticleColor(val: boolean);
  67647. set computeParticleTexture(val: boolean);
  67648. /**
  67649. * Gets if `setParticles()` computes the particle colors or not.
  67650. * Default value : false. The PCS is faster when it's set to false.
  67651. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67652. */
  67653. get computeParticleColor(): boolean;
  67654. /**
  67655. * Gets if `setParticles()` computes the particle textures or not.
  67656. * Default value : false. The PCS is faster when it's set to false.
  67657. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67658. */
  67659. get computeParticleTexture(): boolean;
  67660. /**
  67661. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67662. */
  67663. set computeBoundingBox(val: boolean);
  67664. /**
  67665. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67666. */
  67667. get computeBoundingBox(): boolean;
  67668. /**
  67669. * This function does nothing. It may be overwritten to set all the particle first values.
  67670. * The PCS doesn't call this function, you may have to call it by your own.
  67671. * doc :
  67672. */
  67673. initParticles(): void;
  67674. /**
  67675. * This function does nothing. It may be overwritten to recycle a particle
  67676. * The PCS doesn't call this function, you can to call it
  67677. * doc :
  67678. * @param particle The particle to recycle
  67679. * @returns the recycled particle
  67680. */
  67681. recycleParticle(particle: CloudPoint): CloudPoint;
  67682. /**
  67683. * Updates a particle : this function should be overwritten by the user.
  67684. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67685. * doc :
  67686. * @example : just set a particle position or velocity and recycle conditions
  67687. * @param particle The particle to update
  67688. * @returns the updated particle
  67689. */
  67690. updateParticle(particle: CloudPoint): CloudPoint;
  67691. /**
  67692. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67693. * This does nothing and may be overwritten by the user.
  67694. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67695. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67696. * @param update the boolean update value actually passed to setParticles()
  67697. */
  67698. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67699. /**
  67700. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67701. * This will be passed three parameters.
  67702. * This does nothing and may be overwritten by the user.
  67703. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67704. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67705. * @param update the boolean update value actually passed to setParticles()
  67706. */
  67707. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67708. }
  67709. }
  67710. declare module BABYLON {
  67711. /**
  67712. * Represents one particle of a points cloud system.
  67713. */
  67714. export class CloudPoint {
  67715. /**
  67716. * particle global index
  67717. */
  67718. idx: number;
  67719. /**
  67720. * The color of the particle
  67721. */
  67722. color: Nullable<Color4>;
  67723. /**
  67724. * The world space position of the particle.
  67725. */
  67726. position: Vector3;
  67727. /**
  67728. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67729. */
  67730. rotation: Vector3;
  67731. /**
  67732. * The world space rotation quaternion of the particle.
  67733. */
  67734. rotationQuaternion: Nullable<Quaternion>;
  67735. /**
  67736. * The uv of the particle.
  67737. */
  67738. uv: Nullable<Vector2>;
  67739. /**
  67740. * The current speed of the particle.
  67741. */
  67742. velocity: Vector3;
  67743. /**
  67744. * The pivot point in the particle local space.
  67745. */
  67746. pivot: Vector3;
  67747. /**
  67748. * Must the particle be translated from its pivot point in its local space ?
  67749. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67750. * Default : false
  67751. */
  67752. translateFromPivot: boolean;
  67753. /**
  67754. * Index of this particle in the global "positions" array (Internal use)
  67755. * @hidden
  67756. */
  67757. _pos: number;
  67758. /**
  67759. * @hidden Index of this particle in the global "indices" array (Internal use)
  67760. */
  67761. _ind: number;
  67762. /**
  67763. * Group this particle belongs to
  67764. */
  67765. _group: PointsGroup;
  67766. /**
  67767. * Group id of this particle
  67768. */
  67769. groupId: number;
  67770. /**
  67771. * Index of the particle in its group id (Internal use)
  67772. */
  67773. idxInGroup: number;
  67774. /**
  67775. * @hidden Particle BoundingInfo object (Internal use)
  67776. */
  67777. _boundingInfo: BoundingInfo;
  67778. /**
  67779. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67780. */
  67781. _pcs: PointsCloudSystem;
  67782. /**
  67783. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67784. */
  67785. _stillInvisible: boolean;
  67786. /**
  67787. * @hidden Last computed particle rotation matrix
  67788. */
  67789. _rotationMatrix: number[];
  67790. /**
  67791. * Parent particle Id, if any.
  67792. * Default null.
  67793. */
  67794. parentId: Nullable<number>;
  67795. /**
  67796. * @hidden Internal global position in the PCS.
  67797. */
  67798. _globalPosition: Vector3;
  67799. /**
  67800. * Creates a Point Cloud object.
  67801. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67802. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67803. * @param group (PointsGroup) is the group the particle belongs to
  67804. * @param groupId (integer) is the group identifier in the PCS.
  67805. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67806. * @param pcs defines the PCS it is associated to
  67807. */
  67808. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67809. /**
  67810. * get point size
  67811. */
  67812. get size(): Vector3;
  67813. /**
  67814. * Set point size
  67815. */
  67816. set size(scale: Vector3);
  67817. /**
  67818. * Legacy support, changed quaternion to rotationQuaternion
  67819. */
  67820. get quaternion(): Nullable<Quaternion>;
  67821. /**
  67822. * Legacy support, changed quaternion to rotationQuaternion
  67823. */
  67824. set quaternion(q: Nullable<Quaternion>);
  67825. /**
  67826. * Returns a boolean. True if the particle intersects a mesh, else false
  67827. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67828. * @param target is the object (point or mesh) what the intersection is computed against
  67829. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67830. * @returns true if it intersects
  67831. */
  67832. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67833. /**
  67834. * get the rotation matrix of the particle
  67835. * @hidden
  67836. */
  67837. getRotationMatrix(m: Matrix): void;
  67838. }
  67839. /**
  67840. * Represents a group of points in a points cloud system
  67841. * * PCS internal tool, don't use it manually.
  67842. */
  67843. export class PointsGroup {
  67844. /**
  67845. * The group id
  67846. * @hidden
  67847. */
  67848. groupID: number;
  67849. /**
  67850. * image data for group (internal use)
  67851. * @hidden
  67852. */
  67853. _groupImageData: Nullable<ArrayBufferView>;
  67854. /**
  67855. * Image Width (internal use)
  67856. * @hidden
  67857. */
  67858. _groupImgWidth: number;
  67859. /**
  67860. * Image Height (internal use)
  67861. * @hidden
  67862. */
  67863. _groupImgHeight: number;
  67864. /**
  67865. * Custom position function (internal use)
  67866. * @hidden
  67867. */
  67868. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67869. /**
  67870. * density per facet for surface points
  67871. * @hidden
  67872. */
  67873. _groupDensity: number[];
  67874. /**
  67875. * Only when points are colored by texture carries pointer to texture list array
  67876. * @hidden
  67877. */
  67878. _textureNb: number;
  67879. /**
  67880. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67881. * PCS internal tool, don't use it manually.
  67882. * @hidden
  67883. */
  67884. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67885. }
  67886. }
  67887. declare module BABYLON {
  67888. interface Scene {
  67889. /** @hidden (Backing field) */
  67890. _physicsEngine: Nullable<IPhysicsEngine>;
  67891. /** @hidden */
  67892. _physicsTimeAccumulator: number;
  67893. /**
  67894. * Gets the current physics engine
  67895. * @returns a IPhysicsEngine or null if none attached
  67896. */
  67897. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67898. /**
  67899. * Enables physics to the current scene
  67900. * @param gravity defines the scene's gravity for the physics engine
  67901. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67902. * @return a boolean indicating if the physics engine was initialized
  67903. */
  67904. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67905. /**
  67906. * Disables and disposes the physics engine associated with the scene
  67907. */
  67908. disablePhysicsEngine(): void;
  67909. /**
  67910. * Gets a boolean indicating if there is an active physics engine
  67911. * @returns a boolean indicating if there is an active physics engine
  67912. */
  67913. isPhysicsEnabled(): boolean;
  67914. /**
  67915. * Deletes a physics compound impostor
  67916. * @param compound defines the compound to delete
  67917. */
  67918. deleteCompoundImpostor(compound: any): void;
  67919. /**
  67920. * An event triggered when physic simulation is about to be run
  67921. */
  67922. onBeforePhysicsObservable: Observable<Scene>;
  67923. /**
  67924. * An event triggered when physic simulation has been done
  67925. */
  67926. onAfterPhysicsObservable: Observable<Scene>;
  67927. }
  67928. interface AbstractMesh {
  67929. /** @hidden */
  67930. _physicsImpostor: Nullable<PhysicsImpostor>;
  67931. /**
  67932. * Gets or sets impostor used for physic simulation
  67933. * @see https://doc.babylonjs.com/features/physics_engine
  67934. */
  67935. physicsImpostor: Nullable<PhysicsImpostor>;
  67936. /**
  67937. * Gets the current physics impostor
  67938. * @see https://doc.babylonjs.com/features/physics_engine
  67939. * @returns a physics impostor or null
  67940. */
  67941. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67942. /** Apply a physic impulse to the mesh
  67943. * @param force defines the force to apply
  67944. * @param contactPoint defines where to apply the force
  67945. * @returns the current mesh
  67946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67947. */
  67948. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67949. /**
  67950. * Creates a physic joint between two meshes
  67951. * @param otherMesh defines the other mesh to use
  67952. * @param pivot1 defines the pivot to use on this mesh
  67953. * @param pivot2 defines the pivot to use on the other mesh
  67954. * @param options defines additional options (can be plugin dependent)
  67955. * @returns the current mesh
  67956. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67957. */
  67958. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67959. /** @hidden */
  67960. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67961. }
  67962. /**
  67963. * Defines the physics engine scene component responsible to manage a physics engine
  67964. */
  67965. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67966. /**
  67967. * The component name helpful to identify the component in the list of scene components.
  67968. */
  67969. readonly name: string;
  67970. /**
  67971. * The scene the component belongs to.
  67972. */
  67973. scene: Scene;
  67974. /**
  67975. * Creates a new instance of the component for the given scene
  67976. * @param scene Defines the scene to register the component in
  67977. */
  67978. constructor(scene: Scene);
  67979. /**
  67980. * Registers the component in a given scene
  67981. */
  67982. register(): void;
  67983. /**
  67984. * Rebuilds the elements related to this component in case of
  67985. * context lost for instance.
  67986. */
  67987. rebuild(): void;
  67988. /**
  67989. * Disposes the component and the associated ressources
  67990. */
  67991. dispose(): void;
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /**
  67996. * A helper for physics simulations
  67997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67998. */
  67999. export class PhysicsHelper {
  68000. private _scene;
  68001. private _physicsEngine;
  68002. /**
  68003. * Initializes the Physics helper
  68004. * @param scene Babylon.js scene
  68005. */
  68006. constructor(scene: Scene);
  68007. /**
  68008. * Applies a radial explosion impulse
  68009. * @param origin the origin of the explosion
  68010. * @param radiusOrEventOptions the radius or the options of radial explosion
  68011. * @param strength the explosion strength
  68012. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68013. * @returns A physics radial explosion event, or null
  68014. */
  68015. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68016. /**
  68017. * Applies a radial explosion force
  68018. * @param origin the origin of the explosion
  68019. * @param radiusOrEventOptions the radius or the options of radial explosion
  68020. * @param strength the explosion strength
  68021. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68022. * @returns A physics radial explosion event, or null
  68023. */
  68024. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68025. /**
  68026. * Creates a gravitational field
  68027. * @param origin the origin of the explosion
  68028. * @param radiusOrEventOptions the radius or the options of radial explosion
  68029. * @param strength the explosion strength
  68030. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68031. * @returns A physics gravitational field event, or null
  68032. */
  68033. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68034. /**
  68035. * Creates a physics updraft event
  68036. * @param origin the origin of the updraft
  68037. * @param radiusOrEventOptions the radius or the options of the updraft
  68038. * @param strength the strength of the updraft
  68039. * @param height the height of the updraft
  68040. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68041. * @returns A physics updraft event, or null
  68042. */
  68043. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68044. /**
  68045. * Creates a physics vortex event
  68046. * @param origin the of the vortex
  68047. * @param radiusOrEventOptions the radius or the options of the vortex
  68048. * @param strength the strength of the vortex
  68049. * @param height the height of the vortex
  68050. * @returns a Physics vortex event, or null
  68051. * A physics vortex event or null
  68052. */
  68053. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68054. }
  68055. /**
  68056. * Represents a physics radial explosion event
  68057. */
  68058. class PhysicsRadialExplosionEvent {
  68059. private _scene;
  68060. private _options;
  68061. private _sphere;
  68062. private _dataFetched;
  68063. /**
  68064. * Initializes a radial explosioin event
  68065. * @param _scene BabylonJS scene
  68066. * @param _options The options for the vortex event
  68067. */
  68068. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68069. /**
  68070. * Returns the data related to the radial explosion event (sphere).
  68071. * @returns The radial explosion event data
  68072. */
  68073. getData(): PhysicsRadialExplosionEventData;
  68074. /**
  68075. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68076. * @param impostor A physics imposter
  68077. * @param origin the origin of the explosion
  68078. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68079. */
  68080. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68081. /**
  68082. * Triggers affecterd impostors callbacks
  68083. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68084. */
  68085. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68086. /**
  68087. * Disposes the sphere.
  68088. * @param force Specifies if the sphere should be disposed by force
  68089. */
  68090. dispose(force?: boolean): void;
  68091. /*** Helpers ***/
  68092. private _prepareSphere;
  68093. private _intersectsWithSphere;
  68094. }
  68095. /**
  68096. * Represents a gravitational field event
  68097. */
  68098. class PhysicsGravitationalFieldEvent {
  68099. private _physicsHelper;
  68100. private _scene;
  68101. private _origin;
  68102. private _options;
  68103. private _tickCallback;
  68104. private _sphere;
  68105. private _dataFetched;
  68106. /**
  68107. * Initializes the physics gravitational field event
  68108. * @param _physicsHelper A physics helper
  68109. * @param _scene BabylonJS scene
  68110. * @param _origin The origin position of the gravitational field event
  68111. * @param _options The options for the vortex event
  68112. */
  68113. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68114. /**
  68115. * Returns the data related to the gravitational field event (sphere).
  68116. * @returns A gravitational field event
  68117. */
  68118. getData(): PhysicsGravitationalFieldEventData;
  68119. /**
  68120. * Enables the gravitational field.
  68121. */
  68122. enable(): void;
  68123. /**
  68124. * Disables the gravitational field.
  68125. */
  68126. disable(): void;
  68127. /**
  68128. * Disposes the sphere.
  68129. * @param force The force to dispose from the gravitational field event
  68130. */
  68131. dispose(force?: boolean): void;
  68132. private _tick;
  68133. }
  68134. /**
  68135. * Represents a physics updraft event
  68136. */
  68137. class PhysicsUpdraftEvent {
  68138. private _scene;
  68139. private _origin;
  68140. private _options;
  68141. private _physicsEngine;
  68142. private _originTop;
  68143. private _originDirection;
  68144. private _tickCallback;
  68145. private _cylinder;
  68146. private _cylinderPosition;
  68147. private _dataFetched;
  68148. /**
  68149. * Initializes the physics updraft event
  68150. * @param _scene BabylonJS scene
  68151. * @param _origin The origin position of the updraft
  68152. * @param _options The options for the updraft event
  68153. */
  68154. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68155. /**
  68156. * Returns the data related to the updraft event (cylinder).
  68157. * @returns A physics updraft event
  68158. */
  68159. getData(): PhysicsUpdraftEventData;
  68160. /**
  68161. * Enables the updraft.
  68162. */
  68163. enable(): void;
  68164. /**
  68165. * Disables the updraft.
  68166. */
  68167. disable(): void;
  68168. /**
  68169. * Disposes the cylinder.
  68170. * @param force Specifies if the updraft should be disposed by force
  68171. */
  68172. dispose(force?: boolean): void;
  68173. private getImpostorHitData;
  68174. private _tick;
  68175. /*** Helpers ***/
  68176. private _prepareCylinder;
  68177. private _intersectsWithCylinder;
  68178. }
  68179. /**
  68180. * Represents a physics vortex event
  68181. */
  68182. class PhysicsVortexEvent {
  68183. private _scene;
  68184. private _origin;
  68185. private _options;
  68186. private _physicsEngine;
  68187. private _originTop;
  68188. private _tickCallback;
  68189. private _cylinder;
  68190. private _cylinderPosition;
  68191. private _dataFetched;
  68192. /**
  68193. * Initializes the physics vortex event
  68194. * @param _scene The BabylonJS scene
  68195. * @param _origin The origin position of the vortex
  68196. * @param _options The options for the vortex event
  68197. */
  68198. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68199. /**
  68200. * Returns the data related to the vortex event (cylinder).
  68201. * @returns The physics vortex event data
  68202. */
  68203. getData(): PhysicsVortexEventData;
  68204. /**
  68205. * Enables the vortex.
  68206. */
  68207. enable(): void;
  68208. /**
  68209. * Disables the cortex.
  68210. */
  68211. disable(): void;
  68212. /**
  68213. * Disposes the sphere.
  68214. * @param force
  68215. */
  68216. dispose(force?: boolean): void;
  68217. private getImpostorHitData;
  68218. private _tick;
  68219. /*** Helpers ***/
  68220. private _prepareCylinder;
  68221. private _intersectsWithCylinder;
  68222. }
  68223. /**
  68224. * Options fot the radial explosion event
  68225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68226. */
  68227. export class PhysicsRadialExplosionEventOptions {
  68228. /**
  68229. * The radius of the sphere for the radial explosion.
  68230. */
  68231. radius: number;
  68232. /**
  68233. * The strenth of the explosion.
  68234. */
  68235. strength: number;
  68236. /**
  68237. * The strenght of the force in correspondence to the distance of the affected object
  68238. */
  68239. falloff: PhysicsRadialImpulseFalloff;
  68240. /**
  68241. * Sphere options for the radial explosion.
  68242. */
  68243. sphere: {
  68244. segments: number;
  68245. diameter: number;
  68246. };
  68247. /**
  68248. * Sphere options for the radial explosion.
  68249. */
  68250. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68251. }
  68252. /**
  68253. * Options fot the updraft event
  68254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68255. */
  68256. export class PhysicsUpdraftEventOptions {
  68257. /**
  68258. * The radius of the cylinder for the vortex
  68259. */
  68260. radius: number;
  68261. /**
  68262. * The strenth of the updraft.
  68263. */
  68264. strength: number;
  68265. /**
  68266. * The height of the cylinder for the updraft.
  68267. */
  68268. height: number;
  68269. /**
  68270. * The mode for the the updraft.
  68271. */
  68272. updraftMode: PhysicsUpdraftMode;
  68273. }
  68274. /**
  68275. * Options fot the vortex event
  68276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68277. */
  68278. export class PhysicsVortexEventOptions {
  68279. /**
  68280. * The radius of the cylinder for the vortex
  68281. */
  68282. radius: number;
  68283. /**
  68284. * The strenth of the vortex.
  68285. */
  68286. strength: number;
  68287. /**
  68288. * The height of the cylinder for the vortex.
  68289. */
  68290. height: number;
  68291. /**
  68292. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68293. */
  68294. centripetalForceThreshold: number;
  68295. /**
  68296. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68297. */
  68298. centripetalForceMultiplier: number;
  68299. /**
  68300. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68301. */
  68302. centrifugalForceMultiplier: number;
  68303. /**
  68304. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68305. */
  68306. updraftForceMultiplier: number;
  68307. }
  68308. /**
  68309. * The strenght of the force in correspondence to the distance of the affected object
  68310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68311. */
  68312. export enum PhysicsRadialImpulseFalloff {
  68313. /** Defines that impulse is constant in strength across it's whole radius */
  68314. Constant = 0,
  68315. /** Defines that impulse gets weaker if it's further from the origin */
  68316. Linear = 1
  68317. }
  68318. /**
  68319. * The strength of the force in correspondence to the distance of the affected object
  68320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68321. */
  68322. export enum PhysicsUpdraftMode {
  68323. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68324. Center = 0,
  68325. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68326. Perpendicular = 1
  68327. }
  68328. /**
  68329. * Interface for a physics hit data
  68330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68331. */
  68332. export interface PhysicsHitData {
  68333. /**
  68334. * The force applied at the contact point
  68335. */
  68336. force: Vector3;
  68337. /**
  68338. * The contact point
  68339. */
  68340. contactPoint: Vector3;
  68341. /**
  68342. * The distance from the origin to the contact point
  68343. */
  68344. distanceFromOrigin: number;
  68345. }
  68346. /**
  68347. * Interface for radial explosion event data
  68348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68349. */
  68350. export interface PhysicsRadialExplosionEventData {
  68351. /**
  68352. * A sphere used for the radial explosion event
  68353. */
  68354. sphere: Mesh;
  68355. }
  68356. /**
  68357. * Interface for gravitational field event data
  68358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68359. */
  68360. export interface PhysicsGravitationalFieldEventData {
  68361. /**
  68362. * A sphere mesh used for the gravitational field event
  68363. */
  68364. sphere: Mesh;
  68365. }
  68366. /**
  68367. * Interface for updraft event data
  68368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68369. */
  68370. export interface PhysicsUpdraftEventData {
  68371. /**
  68372. * A cylinder used for the updraft event
  68373. */
  68374. cylinder: Mesh;
  68375. }
  68376. /**
  68377. * Interface for vortex event data
  68378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68379. */
  68380. export interface PhysicsVortexEventData {
  68381. /**
  68382. * A cylinder used for the vortex event
  68383. */
  68384. cylinder: Mesh;
  68385. }
  68386. /**
  68387. * Interface for an affected physics impostor
  68388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68389. */
  68390. export interface PhysicsAffectedImpostorWithData {
  68391. /**
  68392. * The impostor affected by the effect
  68393. */
  68394. impostor: PhysicsImpostor;
  68395. /**
  68396. * The data about the hit/horce from the explosion
  68397. */
  68398. hitData: PhysicsHitData;
  68399. }
  68400. }
  68401. declare module BABYLON {
  68402. /** @hidden */
  68403. export var blackAndWhitePixelShader: {
  68404. name: string;
  68405. shader: string;
  68406. };
  68407. }
  68408. declare module BABYLON {
  68409. /**
  68410. * Post process used to render in black and white
  68411. */
  68412. export class BlackAndWhitePostProcess extends PostProcess {
  68413. /**
  68414. * Linear about to convert he result to black and white (default: 1)
  68415. */
  68416. degree: number;
  68417. /**
  68418. * Creates a black and white post process
  68419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68420. * @param name The name of the effect.
  68421. * @param options The required width/height ratio to downsize to before computing the render pass.
  68422. * @param camera The camera to apply the render pass to.
  68423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68424. * @param engine The engine which the post process will be applied. (default: current engine)
  68425. * @param reusable If the post process can be reused on the same frame. (default: false)
  68426. */
  68427. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68428. }
  68429. }
  68430. declare module BABYLON {
  68431. /**
  68432. * This represents a set of one or more post processes in Babylon.
  68433. * A post process can be used to apply a shader to a texture after it is rendered.
  68434. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68435. */
  68436. export class PostProcessRenderEffect {
  68437. private _postProcesses;
  68438. private _getPostProcesses;
  68439. private _singleInstance;
  68440. private _cameras;
  68441. private _indicesForCamera;
  68442. /**
  68443. * Name of the effect
  68444. * @hidden
  68445. */
  68446. _name: string;
  68447. /**
  68448. * Instantiates a post process render effect.
  68449. * A post process can be used to apply a shader to a texture after it is rendered.
  68450. * @param engine The engine the effect is tied to
  68451. * @param name The name of the effect
  68452. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68453. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68454. */
  68455. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68456. /**
  68457. * Checks if all the post processes in the effect are supported.
  68458. */
  68459. get isSupported(): boolean;
  68460. /**
  68461. * Updates the current state of the effect
  68462. * @hidden
  68463. */
  68464. _update(): void;
  68465. /**
  68466. * Attaches the effect on cameras
  68467. * @param cameras The camera to attach to.
  68468. * @hidden
  68469. */
  68470. _attachCameras(cameras: Camera): void;
  68471. /**
  68472. * Attaches the effect on cameras
  68473. * @param cameras The camera to attach to.
  68474. * @hidden
  68475. */
  68476. _attachCameras(cameras: Camera[]): void;
  68477. /**
  68478. * Detaches the effect on cameras
  68479. * @param cameras The camera to detatch from.
  68480. * @hidden
  68481. */
  68482. _detachCameras(cameras: Camera): void;
  68483. /**
  68484. * Detatches the effect on cameras
  68485. * @param cameras The camera to detatch from.
  68486. * @hidden
  68487. */
  68488. _detachCameras(cameras: Camera[]): void;
  68489. /**
  68490. * Enables the effect on given cameras
  68491. * @param cameras The camera to enable.
  68492. * @hidden
  68493. */
  68494. _enable(cameras: Camera): void;
  68495. /**
  68496. * Enables the effect on given cameras
  68497. * @param cameras The camera to enable.
  68498. * @hidden
  68499. */
  68500. _enable(cameras: Nullable<Camera[]>): void;
  68501. /**
  68502. * Disables the effect on the given cameras
  68503. * @param cameras The camera to disable.
  68504. * @hidden
  68505. */
  68506. _disable(cameras: Camera): void;
  68507. /**
  68508. * Disables the effect on the given cameras
  68509. * @param cameras The camera to disable.
  68510. * @hidden
  68511. */
  68512. _disable(cameras: Nullable<Camera[]>): void;
  68513. /**
  68514. * Gets a list of the post processes contained in the effect.
  68515. * @param camera The camera to get the post processes on.
  68516. * @returns The list of the post processes in the effect.
  68517. */
  68518. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68519. }
  68520. }
  68521. declare module BABYLON {
  68522. /** @hidden */
  68523. export var extractHighlightsPixelShader: {
  68524. name: string;
  68525. shader: string;
  68526. };
  68527. }
  68528. declare module BABYLON {
  68529. /**
  68530. * 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.
  68531. */
  68532. export class ExtractHighlightsPostProcess extends PostProcess {
  68533. /**
  68534. * The luminance threshold, pixels below this value will be set to black.
  68535. */
  68536. threshold: number;
  68537. /** @hidden */
  68538. _exposure: number;
  68539. /**
  68540. * Post process which has the input texture to be used when performing highlight extraction
  68541. * @hidden
  68542. */
  68543. _inputPostProcess: Nullable<PostProcess>;
  68544. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68545. }
  68546. }
  68547. declare module BABYLON {
  68548. /** @hidden */
  68549. export var bloomMergePixelShader: {
  68550. name: string;
  68551. shader: string;
  68552. };
  68553. }
  68554. declare module BABYLON {
  68555. /**
  68556. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68557. */
  68558. export class BloomMergePostProcess extends PostProcess {
  68559. /** Weight of the bloom to be added to the original input. */
  68560. weight: number;
  68561. /**
  68562. * Creates a new instance of @see BloomMergePostProcess
  68563. * @param name The name of the effect.
  68564. * @param originalFromInput Post process which's input will be used for the merge.
  68565. * @param blurred Blurred highlights post process which's output will be used.
  68566. * @param weight Weight of the bloom to be added to the original input.
  68567. * @param options The required width/height ratio to downsize to before computing the render pass.
  68568. * @param camera The camera to apply the render pass to.
  68569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68570. * @param engine The engine which the post process will be applied. (default: current engine)
  68571. * @param reusable If the post process can be reused on the same frame. (default: false)
  68572. * @param textureType Type of textures used when performing the post process. (default: 0)
  68573. * @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)
  68574. */
  68575. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68576. /** Weight of the bloom to be added to the original input. */
  68577. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68583. */
  68584. export class BloomEffect extends PostProcessRenderEffect {
  68585. private bloomScale;
  68586. /**
  68587. * @hidden Internal
  68588. */
  68589. _effects: Array<PostProcess>;
  68590. /**
  68591. * @hidden Internal
  68592. */
  68593. _downscale: ExtractHighlightsPostProcess;
  68594. private _blurX;
  68595. private _blurY;
  68596. private _merge;
  68597. /**
  68598. * The luminance threshold to find bright areas of the image to bloom.
  68599. */
  68600. get threshold(): number;
  68601. set threshold(value: number);
  68602. /**
  68603. * The strength of the bloom.
  68604. */
  68605. get weight(): number;
  68606. set weight(value: number);
  68607. /**
  68608. * Specifies the size of the bloom blur kernel, relative to the final output size
  68609. */
  68610. get kernel(): number;
  68611. set kernel(value: number);
  68612. /**
  68613. * Creates a new instance of @see BloomEffect
  68614. * @param scene The scene the effect belongs to.
  68615. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68616. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68617. * @param bloomWeight The the strength of bloom.
  68618. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68619. * @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)
  68620. */
  68621. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68622. /**
  68623. * Disposes each of the internal effects for a given camera.
  68624. * @param camera The camera to dispose the effect on.
  68625. */
  68626. disposeEffects(camera: Camera): void;
  68627. /**
  68628. * @hidden Internal
  68629. */
  68630. _updateEffects(): void;
  68631. /**
  68632. * Internal
  68633. * @returns if all the contained post processes are ready.
  68634. * @hidden
  68635. */
  68636. _isReady(): boolean;
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /** @hidden */
  68641. export var chromaticAberrationPixelShader: {
  68642. name: string;
  68643. shader: string;
  68644. };
  68645. }
  68646. declare module BABYLON {
  68647. /**
  68648. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68649. */
  68650. export class ChromaticAberrationPostProcess extends PostProcess {
  68651. /**
  68652. * The amount of seperation of rgb channels (default: 30)
  68653. */
  68654. aberrationAmount: number;
  68655. /**
  68656. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68657. */
  68658. radialIntensity: number;
  68659. /**
  68660. * 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))
  68661. */
  68662. direction: Vector2;
  68663. /**
  68664. * 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))
  68665. */
  68666. centerPosition: Vector2;
  68667. /**
  68668. * Creates a new instance ChromaticAberrationPostProcess
  68669. * @param name The name of the effect.
  68670. * @param screenWidth The width of the screen to apply the effect on.
  68671. * @param screenHeight The height of the screen to apply the effect on.
  68672. * @param options The required width/height ratio to downsize to before computing the render pass.
  68673. * @param camera The camera to apply the render pass to.
  68674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68675. * @param engine The engine which the post process will be applied. (default: current engine)
  68676. * @param reusable If the post process can be reused on the same frame. (default: false)
  68677. * @param textureType Type of textures used when performing the post process. (default: 0)
  68678. * @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)
  68679. */
  68680. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68681. }
  68682. }
  68683. declare module BABYLON {
  68684. /** @hidden */
  68685. export var circleOfConfusionPixelShader: {
  68686. name: string;
  68687. shader: string;
  68688. };
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68693. */
  68694. export class CircleOfConfusionPostProcess extends PostProcess {
  68695. /**
  68696. * 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.
  68697. */
  68698. lensSize: number;
  68699. /**
  68700. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68701. */
  68702. fStop: number;
  68703. /**
  68704. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68705. */
  68706. focusDistance: number;
  68707. /**
  68708. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68709. */
  68710. focalLength: number;
  68711. private _depthTexture;
  68712. /**
  68713. * Creates a new instance CircleOfConfusionPostProcess
  68714. * @param name The name of the effect.
  68715. * @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.
  68716. * @param options The required width/height ratio to downsize to before computing the render pass.
  68717. * @param camera The camera to apply the render pass to.
  68718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68719. * @param engine The engine which the post process will be applied. (default: current engine)
  68720. * @param reusable If the post process can be reused on the same frame. (default: false)
  68721. * @param textureType Type of textures used when performing the post process. (default: 0)
  68722. * @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)
  68723. */
  68724. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68725. /**
  68726. * 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.
  68727. */
  68728. set depthTexture(value: RenderTargetTexture);
  68729. }
  68730. }
  68731. declare module BABYLON {
  68732. /** @hidden */
  68733. export var colorCorrectionPixelShader: {
  68734. name: string;
  68735. shader: string;
  68736. };
  68737. }
  68738. declare module BABYLON {
  68739. /**
  68740. *
  68741. * This post-process allows the modification of rendered colors by using
  68742. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68743. *
  68744. * The object needs to be provided an url to a texture containing the color
  68745. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68746. * Use an image editing software to tweak the LUT to match your needs.
  68747. *
  68748. * For an example of a color LUT, see here:
  68749. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68750. * For explanations on color grading, see here:
  68751. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68752. *
  68753. */
  68754. export class ColorCorrectionPostProcess extends PostProcess {
  68755. private _colorTableTexture;
  68756. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68757. }
  68758. }
  68759. declare module BABYLON {
  68760. /** @hidden */
  68761. export var convolutionPixelShader: {
  68762. name: string;
  68763. shader: string;
  68764. };
  68765. }
  68766. declare module BABYLON {
  68767. /**
  68768. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68769. * input texture to perform effects such as edge detection or sharpening
  68770. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68771. */
  68772. export class ConvolutionPostProcess extends PostProcess {
  68773. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68774. kernel: number[];
  68775. /**
  68776. * Creates a new instance ConvolutionPostProcess
  68777. * @param name The name of the effect.
  68778. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68779. * @param options The required width/height ratio to downsize to before computing the render pass.
  68780. * @param camera The camera to apply the render pass to.
  68781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68782. * @param engine The engine which the post process will be applied. (default: current engine)
  68783. * @param reusable If the post process can be reused on the same frame. (default: false)
  68784. * @param textureType Type of textures used when performing the post process. (default: 0)
  68785. */
  68786. constructor(name: string,
  68787. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68788. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68789. /**
  68790. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68791. */
  68792. static EdgeDetect0Kernel: number[];
  68793. /**
  68794. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68795. */
  68796. static EdgeDetect1Kernel: number[];
  68797. /**
  68798. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68799. */
  68800. static EdgeDetect2Kernel: number[];
  68801. /**
  68802. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68803. */
  68804. static SharpenKernel: number[];
  68805. /**
  68806. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68807. */
  68808. static EmbossKernel: number[];
  68809. /**
  68810. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68811. */
  68812. static GaussianKernel: number[];
  68813. }
  68814. }
  68815. declare module BABYLON {
  68816. /**
  68817. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68818. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68819. * based on samples that have a large difference in distance than the center pixel.
  68820. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68821. */
  68822. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68823. direction: Vector2;
  68824. /**
  68825. * Creates a new instance CircleOfConfusionPostProcess
  68826. * @param name The name of the effect.
  68827. * @param scene The scene the effect belongs to.
  68828. * @param direction The direction the blur should be applied.
  68829. * @param kernel The size of the kernel used to blur.
  68830. * @param options The required width/height ratio to downsize to before computing the render pass.
  68831. * @param camera The camera to apply the render pass to.
  68832. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68833. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68835. * @param engine The engine which the post process will be applied. (default: current engine)
  68836. * @param reusable If the post process can be reused on the same frame. (default: false)
  68837. * @param textureType Type of textures used when performing the post process. (default: 0)
  68838. * @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)
  68839. */
  68840. 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);
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /** @hidden */
  68845. export var depthOfFieldMergePixelShader: {
  68846. name: string;
  68847. shader: string;
  68848. };
  68849. }
  68850. declare module BABYLON {
  68851. /**
  68852. * Options to be set when merging outputs from the default pipeline.
  68853. */
  68854. export class DepthOfFieldMergePostProcessOptions {
  68855. /**
  68856. * The original image to merge on top of
  68857. */
  68858. originalFromInput: PostProcess;
  68859. /**
  68860. * Parameters to perform the merge of the depth of field effect
  68861. */
  68862. depthOfField?: {
  68863. circleOfConfusion: PostProcess;
  68864. blurSteps: Array<PostProcess>;
  68865. };
  68866. /**
  68867. * Parameters to perform the merge of bloom effect
  68868. */
  68869. bloom?: {
  68870. blurred: PostProcess;
  68871. weight: number;
  68872. };
  68873. }
  68874. /**
  68875. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68876. */
  68877. export class DepthOfFieldMergePostProcess extends PostProcess {
  68878. private blurSteps;
  68879. /**
  68880. * Creates a new instance of DepthOfFieldMergePostProcess
  68881. * @param name The name of the effect.
  68882. * @param originalFromInput Post process which's input will be used for the merge.
  68883. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68884. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68885. * @param options The required width/height ratio to downsize to before computing the render pass.
  68886. * @param camera The camera to apply the render pass to.
  68887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68888. * @param engine The engine which the post process will be applied. (default: current engine)
  68889. * @param reusable If the post process can be reused on the same frame. (default: false)
  68890. * @param textureType Type of textures used when performing the post process. (default: 0)
  68891. * @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)
  68892. */
  68893. 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);
  68894. /**
  68895. * Updates the effect with the current post process compile time values and recompiles the shader.
  68896. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68897. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68898. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68899. * @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
  68900. * @param onCompiled Called when the shader has been compiled.
  68901. * @param onError Called if there is an error when compiling a shader.
  68902. */
  68903. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68904. }
  68905. }
  68906. declare module BABYLON {
  68907. /**
  68908. * Specifies the level of max blur that should be applied when using the depth of field effect
  68909. */
  68910. export enum DepthOfFieldEffectBlurLevel {
  68911. /**
  68912. * Subtle blur
  68913. */
  68914. Low = 0,
  68915. /**
  68916. * Medium blur
  68917. */
  68918. Medium = 1,
  68919. /**
  68920. * Large blur
  68921. */
  68922. High = 2
  68923. }
  68924. /**
  68925. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68926. */
  68927. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68928. private _circleOfConfusion;
  68929. /**
  68930. * @hidden Internal, blurs from high to low
  68931. */
  68932. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68933. private _depthOfFieldBlurY;
  68934. private _dofMerge;
  68935. /**
  68936. * @hidden Internal post processes in depth of field effect
  68937. */
  68938. _effects: Array<PostProcess>;
  68939. /**
  68940. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68941. */
  68942. set focalLength(value: number);
  68943. get focalLength(): number;
  68944. /**
  68945. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68946. */
  68947. set fStop(value: number);
  68948. get fStop(): number;
  68949. /**
  68950. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68951. */
  68952. set focusDistance(value: number);
  68953. get focusDistance(): number;
  68954. /**
  68955. * 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.
  68956. */
  68957. set lensSize(value: number);
  68958. get lensSize(): number;
  68959. /**
  68960. * Creates a new instance DepthOfFieldEffect
  68961. * @param scene The scene the effect belongs to.
  68962. * @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.
  68963. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68964. * @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)
  68965. */
  68966. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68967. /**
  68968. * Get the current class name of the current effet
  68969. * @returns "DepthOfFieldEffect"
  68970. */
  68971. getClassName(): string;
  68972. /**
  68973. * 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.
  68974. */
  68975. set depthTexture(value: RenderTargetTexture);
  68976. /**
  68977. * Disposes each of the internal effects for a given camera.
  68978. * @param camera The camera to dispose the effect on.
  68979. */
  68980. disposeEffects(camera: Camera): void;
  68981. /**
  68982. * @hidden Internal
  68983. */
  68984. _updateEffects(): void;
  68985. /**
  68986. * Internal
  68987. * @returns if all the contained post processes are ready.
  68988. * @hidden
  68989. */
  68990. _isReady(): boolean;
  68991. }
  68992. }
  68993. declare module BABYLON {
  68994. /** @hidden */
  68995. export var displayPassPixelShader: {
  68996. name: string;
  68997. shader: string;
  68998. };
  68999. }
  69000. declare module BABYLON {
  69001. /**
  69002. * DisplayPassPostProcess which produces an output the same as it's input
  69003. */
  69004. export class DisplayPassPostProcess extends PostProcess {
  69005. /**
  69006. * Creates the DisplayPassPostProcess
  69007. * @param name The name of the effect.
  69008. * @param options The required width/height ratio to downsize to before computing the render pass.
  69009. * @param camera The camera to apply the render pass to.
  69010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69011. * @param engine The engine which the post process will be applied. (default: current engine)
  69012. * @param reusable If the post process can be reused on the same frame. (default: false)
  69013. */
  69014. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69015. }
  69016. }
  69017. declare module BABYLON {
  69018. /** @hidden */
  69019. export var filterPixelShader: {
  69020. name: string;
  69021. shader: string;
  69022. };
  69023. }
  69024. declare module BABYLON {
  69025. /**
  69026. * Applies a kernel filter to the image
  69027. */
  69028. export class FilterPostProcess extends PostProcess {
  69029. /** The matrix to be applied to the image */
  69030. kernelMatrix: Matrix;
  69031. /**
  69032. *
  69033. * @param name The name of the effect.
  69034. * @param kernelMatrix The matrix to be applied to the image
  69035. * @param options The required width/height ratio to downsize to before computing the render pass.
  69036. * @param camera The camera to apply the render pass to.
  69037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69038. * @param engine The engine which the post process will be applied. (default: current engine)
  69039. * @param reusable If the post process can be reused on the same frame. (default: false)
  69040. */
  69041. constructor(name: string,
  69042. /** The matrix to be applied to the image */
  69043. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69044. }
  69045. }
  69046. declare module BABYLON {
  69047. /** @hidden */
  69048. export var fxaaPixelShader: {
  69049. name: string;
  69050. shader: string;
  69051. };
  69052. }
  69053. declare module BABYLON {
  69054. /** @hidden */
  69055. export var fxaaVertexShader: {
  69056. name: string;
  69057. shader: string;
  69058. };
  69059. }
  69060. declare module BABYLON {
  69061. /**
  69062. * Fxaa post process
  69063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69064. */
  69065. export class FxaaPostProcess extends PostProcess {
  69066. /** @hidden */
  69067. texelWidth: number;
  69068. /** @hidden */
  69069. texelHeight: number;
  69070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69071. private _getDefines;
  69072. }
  69073. }
  69074. declare module BABYLON {
  69075. /** @hidden */
  69076. export var grainPixelShader: {
  69077. name: string;
  69078. shader: string;
  69079. };
  69080. }
  69081. declare module BABYLON {
  69082. /**
  69083. * The GrainPostProcess adds noise to the image at mid luminance levels
  69084. */
  69085. export class GrainPostProcess extends PostProcess {
  69086. /**
  69087. * The intensity of the grain added (default: 30)
  69088. */
  69089. intensity: number;
  69090. /**
  69091. * If the grain should be randomized on every frame
  69092. */
  69093. animated: boolean;
  69094. /**
  69095. * Creates a new instance of @see GrainPostProcess
  69096. * @param name The name of the effect.
  69097. * @param options The required width/height ratio to downsize to before computing the render pass.
  69098. * @param camera The camera to apply the render pass to.
  69099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69100. * @param engine The engine which the post process will be applied. (default: current engine)
  69101. * @param reusable If the post process can be reused on the same frame. (default: false)
  69102. * @param textureType Type of textures used when performing the post process. (default: 0)
  69103. * @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)
  69104. */
  69105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69106. }
  69107. }
  69108. declare module BABYLON {
  69109. /** @hidden */
  69110. export var highlightsPixelShader: {
  69111. name: string;
  69112. shader: string;
  69113. };
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * Extracts highlights from the image
  69118. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69119. */
  69120. export class HighlightsPostProcess extends PostProcess {
  69121. /**
  69122. * Extracts highlights from the image
  69123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69124. * @param name The name of the effect.
  69125. * @param options The required width/height ratio to downsize to before computing the render pass.
  69126. * @param camera The camera to apply the render pass to.
  69127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69128. * @param engine The engine which the post process will be applied. (default: current engine)
  69129. * @param reusable If the post process can be reused on the same frame. (default: false)
  69130. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69131. */
  69132. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69133. }
  69134. }
  69135. declare module BABYLON {
  69136. /** @hidden */
  69137. export var mrtFragmentDeclaration: {
  69138. name: string;
  69139. shader: string;
  69140. };
  69141. }
  69142. declare module BABYLON {
  69143. /** @hidden */
  69144. export var geometryPixelShader: {
  69145. name: string;
  69146. shader: string;
  69147. };
  69148. }
  69149. declare module BABYLON {
  69150. /** @hidden */
  69151. export var geometryVertexShader: {
  69152. name: string;
  69153. shader: string;
  69154. };
  69155. }
  69156. declare module BABYLON {
  69157. /** @hidden */
  69158. interface ISavedTransformationMatrix {
  69159. world: Matrix;
  69160. viewProjection: Matrix;
  69161. }
  69162. /**
  69163. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69164. */
  69165. export class GeometryBufferRenderer {
  69166. /**
  69167. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69168. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69169. */
  69170. static readonly POSITION_TEXTURE_TYPE: number;
  69171. /**
  69172. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69173. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69174. */
  69175. static readonly VELOCITY_TEXTURE_TYPE: number;
  69176. /**
  69177. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69178. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69179. */
  69180. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69181. /**
  69182. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69183. * in order to compute objects velocities when enableVelocity is set to "true"
  69184. * @hidden
  69185. */
  69186. _previousTransformationMatrices: {
  69187. [index: number]: ISavedTransformationMatrix;
  69188. };
  69189. /**
  69190. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69191. * in order to compute objects velocities when enableVelocity is set to "true"
  69192. * @hidden
  69193. */
  69194. _previousBonesTransformationMatrices: {
  69195. [index: number]: Float32Array;
  69196. };
  69197. /**
  69198. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69199. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69200. */
  69201. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69202. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69203. renderTransparentMeshes: boolean;
  69204. private _scene;
  69205. private _resizeObserver;
  69206. private _multiRenderTarget;
  69207. private _ratio;
  69208. private _enablePosition;
  69209. private _enableVelocity;
  69210. private _enableReflectivity;
  69211. private _positionIndex;
  69212. private _velocityIndex;
  69213. private _reflectivityIndex;
  69214. protected _effect: Effect;
  69215. protected _cachedDefines: string;
  69216. /**
  69217. * Set the render list (meshes to be rendered) used in the G buffer.
  69218. */
  69219. set renderList(meshes: Mesh[]);
  69220. /**
  69221. * Gets wether or not G buffer are supported by the running hardware.
  69222. * This requires draw buffer supports
  69223. */
  69224. get isSupported(): boolean;
  69225. /**
  69226. * Returns the index of the given texture type in the G-Buffer textures array
  69227. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69228. * @returns the index of the given texture type in the G-Buffer textures array
  69229. */
  69230. getTextureIndex(textureType: number): number;
  69231. /**
  69232. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69233. */
  69234. get enablePosition(): boolean;
  69235. /**
  69236. * Sets whether or not objects positions are enabled for the G buffer.
  69237. */
  69238. set enablePosition(enable: boolean);
  69239. /**
  69240. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69241. */
  69242. get enableVelocity(): boolean;
  69243. /**
  69244. * Sets wether or not objects velocities are enabled for the G buffer.
  69245. */
  69246. set enableVelocity(enable: boolean);
  69247. /**
  69248. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69249. */
  69250. get enableReflectivity(): boolean;
  69251. /**
  69252. * Sets wether or not objects roughness are enabled for the G buffer.
  69253. */
  69254. set enableReflectivity(enable: boolean);
  69255. /**
  69256. * Gets the scene associated with the buffer.
  69257. */
  69258. get scene(): Scene;
  69259. /**
  69260. * Gets the ratio used by the buffer during its creation.
  69261. * How big is the buffer related to the main canvas.
  69262. */
  69263. get ratio(): number;
  69264. /** @hidden */
  69265. static _SceneComponentInitialization: (scene: Scene) => void;
  69266. /**
  69267. * Creates a new G Buffer for the scene
  69268. * @param scene The scene the buffer belongs to
  69269. * @param ratio How big is the buffer related to the main canvas.
  69270. */
  69271. constructor(scene: Scene, ratio?: number);
  69272. /**
  69273. * Checks wether everything is ready to render a submesh to the G buffer.
  69274. * @param subMesh the submesh to check readiness for
  69275. * @param useInstances is the mesh drawn using instance or not
  69276. * @returns true if ready otherwise false
  69277. */
  69278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69279. /**
  69280. * Gets the current underlying G Buffer.
  69281. * @returns the buffer
  69282. */
  69283. getGBuffer(): MultiRenderTarget;
  69284. /**
  69285. * Gets the number of samples used to render the buffer (anti aliasing).
  69286. */
  69287. get samples(): number;
  69288. /**
  69289. * Sets the number of samples used to render the buffer (anti aliasing).
  69290. */
  69291. set samples(value: number);
  69292. /**
  69293. * Disposes the renderer and frees up associated resources.
  69294. */
  69295. dispose(): void;
  69296. protected _createRenderTargets(): void;
  69297. private _copyBonesTransformationMatrices;
  69298. }
  69299. }
  69300. declare module BABYLON {
  69301. interface Scene {
  69302. /** @hidden (Backing field) */
  69303. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69304. /**
  69305. * Gets or Sets the current geometry buffer associated to the scene.
  69306. */
  69307. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69308. /**
  69309. * Enables a GeometryBufferRender and associates it with the scene
  69310. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69311. * @returns the GeometryBufferRenderer
  69312. */
  69313. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69314. /**
  69315. * Disables the GeometryBufferRender associated with the scene
  69316. */
  69317. disableGeometryBufferRenderer(): void;
  69318. }
  69319. /**
  69320. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69321. * in several rendering techniques.
  69322. */
  69323. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69324. /**
  69325. * The component name helpful to identify the component in the list of scene components.
  69326. */
  69327. readonly name: string;
  69328. /**
  69329. * The scene the component belongs to.
  69330. */
  69331. scene: Scene;
  69332. /**
  69333. * Creates a new instance of the component for the given scene
  69334. * @param scene Defines the scene to register the component in
  69335. */
  69336. constructor(scene: Scene);
  69337. /**
  69338. * Registers the component in a given scene
  69339. */
  69340. register(): void;
  69341. /**
  69342. * Rebuilds the elements related to this component in case of
  69343. * context lost for instance.
  69344. */
  69345. rebuild(): void;
  69346. /**
  69347. * Disposes the component and the associated ressources
  69348. */
  69349. dispose(): void;
  69350. private _gatherRenderTargets;
  69351. }
  69352. }
  69353. declare module BABYLON {
  69354. /** @hidden */
  69355. export var motionBlurPixelShader: {
  69356. name: string;
  69357. shader: string;
  69358. };
  69359. }
  69360. declare module BABYLON {
  69361. /**
  69362. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69363. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69364. * As an example, all you have to do is to create the post-process:
  69365. * var mb = new BABYLON.MotionBlurPostProcess(
  69366. * 'mb', // The name of the effect.
  69367. * scene, // The scene containing the objects to blur according to their velocity.
  69368. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69369. * camera // The camera to apply the render pass to.
  69370. * );
  69371. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69372. */
  69373. export class MotionBlurPostProcess extends PostProcess {
  69374. /**
  69375. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69376. */
  69377. motionStrength: number;
  69378. /**
  69379. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69380. */
  69381. get motionBlurSamples(): number;
  69382. /**
  69383. * Sets the number of iterations to be used for motion blur quality
  69384. */
  69385. set motionBlurSamples(samples: number);
  69386. private _motionBlurSamples;
  69387. private _geometryBufferRenderer;
  69388. /**
  69389. * Creates a new instance MotionBlurPostProcess
  69390. * @param name The name of the effect.
  69391. * @param scene The scene containing the objects to blur according to their velocity.
  69392. * @param options The required width/height ratio to downsize to before computing the render pass.
  69393. * @param camera The camera to apply the render pass to.
  69394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69395. * @param engine The engine which the post process will be applied. (default: current engine)
  69396. * @param reusable If the post process can be reused on the same frame. (default: false)
  69397. * @param textureType Type of textures used when performing the post process. (default: 0)
  69398. * @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)
  69399. */
  69400. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69401. /**
  69402. * Excludes the given skinned mesh from computing bones velocities.
  69403. * 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.
  69404. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69405. */
  69406. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69407. /**
  69408. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69409. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69410. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69411. */
  69412. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69413. /**
  69414. * Disposes the post process.
  69415. * @param camera The camera to dispose the post process on.
  69416. */
  69417. dispose(camera?: Camera): void;
  69418. }
  69419. }
  69420. declare module BABYLON {
  69421. /** @hidden */
  69422. export var refractionPixelShader: {
  69423. name: string;
  69424. shader: string;
  69425. };
  69426. }
  69427. declare module BABYLON {
  69428. /**
  69429. * Post process which applies a refractin texture
  69430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69431. */
  69432. export class RefractionPostProcess extends PostProcess {
  69433. /** the base color of the refraction (used to taint the rendering) */
  69434. color: Color3;
  69435. /** simulated refraction depth */
  69436. depth: number;
  69437. /** the coefficient of the base color (0 to remove base color tainting) */
  69438. colorLevel: number;
  69439. private _refTexture;
  69440. private _ownRefractionTexture;
  69441. /**
  69442. * Gets or sets the refraction texture
  69443. * Please note that you are responsible for disposing the texture if you set it manually
  69444. */
  69445. get refractionTexture(): Texture;
  69446. set refractionTexture(value: Texture);
  69447. /**
  69448. * Initializes the RefractionPostProcess
  69449. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69450. * @param name The name of the effect.
  69451. * @param refractionTextureUrl Url of the refraction texture to use
  69452. * @param color the base color of the refraction (used to taint the rendering)
  69453. * @param depth simulated refraction depth
  69454. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69455. * @param camera The camera to apply the render pass to.
  69456. * @param options The required width/height ratio to downsize to before computing the render pass.
  69457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69458. * @param engine The engine which the post process will be applied. (default: current engine)
  69459. * @param reusable If the post process can be reused on the same frame. (default: false)
  69460. */
  69461. constructor(name: string, refractionTextureUrl: string,
  69462. /** the base color of the refraction (used to taint the rendering) */
  69463. color: Color3,
  69464. /** simulated refraction depth */
  69465. depth: number,
  69466. /** the coefficient of the base color (0 to remove base color tainting) */
  69467. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69468. /**
  69469. * Disposes of the post process
  69470. * @param camera Camera to dispose post process on
  69471. */
  69472. dispose(camera: Camera): void;
  69473. }
  69474. }
  69475. declare module BABYLON {
  69476. /** @hidden */
  69477. export var sharpenPixelShader: {
  69478. name: string;
  69479. shader: string;
  69480. };
  69481. }
  69482. declare module BABYLON {
  69483. /**
  69484. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69485. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69486. */
  69487. export class SharpenPostProcess extends PostProcess {
  69488. /**
  69489. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69490. */
  69491. colorAmount: number;
  69492. /**
  69493. * How much sharpness should be applied (default: 0.3)
  69494. */
  69495. edgeAmount: number;
  69496. /**
  69497. * Creates a new instance ConvolutionPostProcess
  69498. * @param name The name of the effect.
  69499. * @param options The required width/height ratio to downsize to before computing the render pass.
  69500. * @param camera The camera to apply the render pass to.
  69501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69502. * @param engine The engine which the post process will be applied. (default: current engine)
  69503. * @param reusable If the post process can be reused on the same frame. (default: false)
  69504. * @param textureType Type of textures used when performing the post process. (default: 0)
  69505. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69506. */
  69507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69508. }
  69509. }
  69510. declare module BABYLON {
  69511. /**
  69512. * PostProcessRenderPipeline
  69513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69514. */
  69515. export class PostProcessRenderPipeline {
  69516. private engine;
  69517. private _renderEffects;
  69518. private _renderEffectsForIsolatedPass;
  69519. /**
  69520. * List of inspectable custom properties (used by the Inspector)
  69521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69522. */
  69523. inspectableCustomProperties: IInspectable[];
  69524. /**
  69525. * @hidden
  69526. */
  69527. protected _cameras: Camera[];
  69528. /** @hidden */
  69529. _name: string;
  69530. /**
  69531. * Gets pipeline name
  69532. */
  69533. get name(): string;
  69534. /** Gets the list of attached cameras */
  69535. get cameras(): Camera[];
  69536. /**
  69537. * Initializes a PostProcessRenderPipeline
  69538. * @param engine engine to add the pipeline to
  69539. * @param name name of the pipeline
  69540. */
  69541. constructor(engine: Engine, name: string);
  69542. /**
  69543. * Gets the class name
  69544. * @returns "PostProcessRenderPipeline"
  69545. */
  69546. getClassName(): string;
  69547. /**
  69548. * If all the render effects in the pipeline are supported
  69549. */
  69550. get isSupported(): boolean;
  69551. /**
  69552. * Adds an effect to the pipeline
  69553. * @param renderEffect the effect to add
  69554. */
  69555. addEffect(renderEffect: PostProcessRenderEffect): void;
  69556. /** @hidden */
  69557. _rebuild(): void;
  69558. /** @hidden */
  69559. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69560. /** @hidden */
  69561. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69562. /** @hidden */
  69563. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69564. /** @hidden */
  69565. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69566. /** @hidden */
  69567. _attachCameras(cameras: Camera, unique: boolean): void;
  69568. /** @hidden */
  69569. _attachCameras(cameras: Camera[], unique: boolean): void;
  69570. /** @hidden */
  69571. _detachCameras(cameras: Camera): void;
  69572. /** @hidden */
  69573. _detachCameras(cameras: Nullable<Camera[]>): void;
  69574. /** @hidden */
  69575. _update(): void;
  69576. /** @hidden */
  69577. _reset(): void;
  69578. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69579. /**
  69580. * Sets the required values to the prepass renderer.
  69581. * @param prePassRenderer defines the prepass renderer to setup.
  69582. * @returns true if the pre pass is needed.
  69583. */
  69584. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69585. /**
  69586. * Disposes of the pipeline
  69587. */
  69588. dispose(): void;
  69589. }
  69590. }
  69591. declare module BABYLON {
  69592. /**
  69593. * PostProcessRenderPipelineManager class
  69594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69595. */
  69596. export class PostProcessRenderPipelineManager {
  69597. private _renderPipelines;
  69598. /**
  69599. * Initializes a PostProcessRenderPipelineManager
  69600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69601. */
  69602. constructor();
  69603. /**
  69604. * Gets the list of supported render pipelines
  69605. */
  69606. get supportedPipelines(): PostProcessRenderPipeline[];
  69607. /**
  69608. * Adds a pipeline to the manager
  69609. * @param renderPipeline The pipeline to add
  69610. */
  69611. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69612. /**
  69613. * Attaches a camera to the pipeline
  69614. * @param renderPipelineName The name of the pipeline to attach to
  69615. * @param cameras the camera to attach
  69616. * @param unique if the camera can be attached multiple times to the pipeline
  69617. */
  69618. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69619. /**
  69620. * Detaches a camera from the pipeline
  69621. * @param renderPipelineName The name of the pipeline to detach from
  69622. * @param cameras the camera to detach
  69623. */
  69624. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69625. /**
  69626. * Enables an effect by name on a pipeline
  69627. * @param renderPipelineName the name of the pipeline to enable the effect in
  69628. * @param renderEffectName the name of the effect to enable
  69629. * @param cameras the cameras that the effect should be enabled on
  69630. */
  69631. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69632. /**
  69633. * Disables an effect by name on a pipeline
  69634. * @param renderPipelineName the name of the pipeline to disable the effect in
  69635. * @param renderEffectName the name of the effect to disable
  69636. * @param cameras the cameras that the effect should be disabled on
  69637. */
  69638. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69639. /**
  69640. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69641. */
  69642. update(): void;
  69643. /** @hidden */
  69644. _rebuild(): void;
  69645. /**
  69646. * Disposes of the manager and pipelines
  69647. */
  69648. dispose(): void;
  69649. }
  69650. }
  69651. declare module BABYLON {
  69652. interface Scene {
  69653. /** @hidden (Backing field) */
  69654. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69655. /**
  69656. * Gets the postprocess render pipeline manager
  69657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69658. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69659. */
  69660. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69661. }
  69662. /**
  69663. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69664. */
  69665. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69666. /**
  69667. * The component name helpfull to identify the component in the list of scene components.
  69668. */
  69669. readonly name: string;
  69670. /**
  69671. * The scene the component belongs to.
  69672. */
  69673. scene: Scene;
  69674. /**
  69675. * Creates a new instance of the component for the given scene
  69676. * @param scene Defines the scene to register the component in
  69677. */
  69678. constructor(scene: Scene);
  69679. /**
  69680. * Registers the component in a given scene
  69681. */
  69682. register(): void;
  69683. /**
  69684. * Rebuilds the elements related to this component in case of
  69685. * context lost for instance.
  69686. */
  69687. rebuild(): void;
  69688. /**
  69689. * Disposes the component and the associated ressources
  69690. */
  69691. dispose(): void;
  69692. private _gatherRenderTargets;
  69693. }
  69694. }
  69695. declare module BABYLON {
  69696. /**
  69697. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69698. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69699. */
  69700. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69701. private _scene;
  69702. private _camerasToBeAttached;
  69703. /**
  69704. * ID of the sharpen post process,
  69705. */
  69706. private readonly SharpenPostProcessId;
  69707. /**
  69708. * @ignore
  69709. * ID of the image processing post process;
  69710. */
  69711. readonly ImageProcessingPostProcessId: string;
  69712. /**
  69713. * @ignore
  69714. * ID of the Fast Approximate Anti-Aliasing post process;
  69715. */
  69716. readonly FxaaPostProcessId: string;
  69717. /**
  69718. * ID of the chromatic aberration post process,
  69719. */
  69720. private readonly ChromaticAberrationPostProcessId;
  69721. /**
  69722. * ID of the grain post process
  69723. */
  69724. private readonly GrainPostProcessId;
  69725. /**
  69726. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69727. */
  69728. sharpen: SharpenPostProcess;
  69729. private _sharpenEffect;
  69730. private bloom;
  69731. /**
  69732. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69733. */
  69734. depthOfField: DepthOfFieldEffect;
  69735. /**
  69736. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69737. */
  69738. fxaa: FxaaPostProcess;
  69739. /**
  69740. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69741. */
  69742. imageProcessing: ImageProcessingPostProcess;
  69743. /**
  69744. * Chromatic aberration post process which will shift rgb colors in the image
  69745. */
  69746. chromaticAberration: ChromaticAberrationPostProcess;
  69747. private _chromaticAberrationEffect;
  69748. /**
  69749. * Grain post process which add noise to the image
  69750. */
  69751. grain: GrainPostProcess;
  69752. private _grainEffect;
  69753. /**
  69754. * Glow post process which adds a glow to emissive areas of the image
  69755. */
  69756. private _glowLayer;
  69757. /**
  69758. * Animations which can be used to tweak settings over a period of time
  69759. */
  69760. animations: Animation[];
  69761. private _imageProcessingConfigurationObserver;
  69762. private _sharpenEnabled;
  69763. private _bloomEnabled;
  69764. private _depthOfFieldEnabled;
  69765. private _depthOfFieldBlurLevel;
  69766. private _fxaaEnabled;
  69767. private _imageProcessingEnabled;
  69768. private _defaultPipelineTextureType;
  69769. private _bloomScale;
  69770. private _chromaticAberrationEnabled;
  69771. private _grainEnabled;
  69772. private _buildAllowed;
  69773. /**
  69774. * Gets active scene
  69775. */
  69776. get scene(): Scene;
  69777. /**
  69778. * Enable or disable the sharpen process from the pipeline
  69779. */
  69780. set sharpenEnabled(enabled: boolean);
  69781. get sharpenEnabled(): boolean;
  69782. private _resizeObserver;
  69783. private _hardwareScaleLevel;
  69784. private _bloomKernel;
  69785. /**
  69786. * Specifies the size of the bloom blur kernel, relative to the final output size
  69787. */
  69788. get bloomKernel(): number;
  69789. set bloomKernel(value: number);
  69790. /**
  69791. * Specifies the weight of the bloom in the final rendering
  69792. */
  69793. private _bloomWeight;
  69794. /**
  69795. * Specifies the luma threshold for the area that will be blurred by the bloom
  69796. */
  69797. private _bloomThreshold;
  69798. private _hdr;
  69799. /**
  69800. * The strength of the bloom.
  69801. */
  69802. set bloomWeight(value: number);
  69803. get bloomWeight(): number;
  69804. /**
  69805. * The strength of the bloom.
  69806. */
  69807. set bloomThreshold(value: number);
  69808. get bloomThreshold(): number;
  69809. /**
  69810. * The scale of the bloom, lower value will provide better performance.
  69811. */
  69812. set bloomScale(value: number);
  69813. get bloomScale(): number;
  69814. /**
  69815. * Enable or disable the bloom from the pipeline
  69816. */
  69817. set bloomEnabled(enabled: boolean);
  69818. get bloomEnabled(): boolean;
  69819. private _rebuildBloom;
  69820. /**
  69821. * If the depth of field is enabled.
  69822. */
  69823. get depthOfFieldEnabled(): boolean;
  69824. set depthOfFieldEnabled(enabled: boolean);
  69825. /**
  69826. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69827. */
  69828. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69829. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69830. /**
  69831. * If the anti aliasing is enabled.
  69832. */
  69833. set fxaaEnabled(enabled: boolean);
  69834. get fxaaEnabled(): boolean;
  69835. private _samples;
  69836. /**
  69837. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69838. */
  69839. set samples(sampleCount: number);
  69840. get samples(): number;
  69841. /**
  69842. * If image processing is enabled.
  69843. */
  69844. set imageProcessingEnabled(enabled: boolean);
  69845. get imageProcessingEnabled(): boolean;
  69846. /**
  69847. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69848. */
  69849. set glowLayerEnabled(enabled: boolean);
  69850. get glowLayerEnabled(): boolean;
  69851. /**
  69852. * Gets the glow layer (or null if not defined)
  69853. */
  69854. get glowLayer(): Nullable<GlowLayer>;
  69855. /**
  69856. * Enable or disable the chromaticAberration process from the pipeline
  69857. */
  69858. set chromaticAberrationEnabled(enabled: boolean);
  69859. get chromaticAberrationEnabled(): boolean;
  69860. /**
  69861. * Enable or disable the grain process from the pipeline
  69862. */
  69863. set grainEnabled(enabled: boolean);
  69864. get grainEnabled(): boolean;
  69865. /**
  69866. * @constructor
  69867. * @param name - The rendering pipeline name (default: "")
  69868. * @param hdr - If high dynamic range textures should be used (default: true)
  69869. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69870. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69871. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69872. */
  69873. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69874. /**
  69875. * Get the class name
  69876. * @returns "DefaultRenderingPipeline"
  69877. */
  69878. getClassName(): string;
  69879. /**
  69880. * Force the compilation of the entire pipeline.
  69881. */
  69882. prepare(): void;
  69883. private _hasCleared;
  69884. private _prevPostProcess;
  69885. private _prevPrevPostProcess;
  69886. private _setAutoClearAndTextureSharing;
  69887. private _depthOfFieldSceneObserver;
  69888. private _buildPipeline;
  69889. private _disposePostProcesses;
  69890. /**
  69891. * Adds a camera to the pipeline
  69892. * @param camera the camera to be added
  69893. */
  69894. addCamera(camera: Camera): void;
  69895. /**
  69896. * Removes a camera from the pipeline
  69897. * @param camera the camera to remove
  69898. */
  69899. removeCamera(camera: Camera): void;
  69900. /**
  69901. * Dispose of the pipeline and stop all post processes
  69902. */
  69903. dispose(): void;
  69904. /**
  69905. * Serialize the rendering pipeline (Used when exporting)
  69906. * @returns the serialized object
  69907. */
  69908. serialize(): any;
  69909. /**
  69910. * Parse the serialized pipeline
  69911. * @param source Source pipeline.
  69912. * @param scene The scene to load the pipeline to.
  69913. * @param rootUrl The URL of the serialized pipeline.
  69914. * @returns An instantiated pipeline from the serialized object.
  69915. */
  69916. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. /** @hidden */
  69921. export var lensHighlightsPixelShader: {
  69922. name: string;
  69923. shader: string;
  69924. };
  69925. }
  69926. declare module BABYLON {
  69927. /** @hidden */
  69928. export var depthOfFieldPixelShader: {
  69929. name: string;
  69930. shader: string;
  69931. };
  69932. }
  69933. declare module BABYLON {
  69934. /**
  69935. * BABYLON.JS Chromatic Aberration GLSL Shader
  69936. * Author: Olivier Guyot
  69937. * Separates very slightly R, G and B colors on the edges of the screen
  69938. * Inspired by Francois Tarlier & Martins Upitis
  69939. */
  69940. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69941. /**
  69942. * @ignore
  69943. * The chromatic aberration PostProcess id in the pipeline
  69944. */
  69945. LensChromaticAberrationEffect: string;
  69946. /**
  69947. * @ignore
  69948. * The highlights enhancing PostProcess id in the pipeline
  69949. */
  69950. HighlightsEnhancingEffect: string;
  69951. /**
  69952. * @ignore
  69953. * The depth-of-field PostProcess id in the pipeline
  69954. */
  69955. LensDepthOfFieldEffect: string;
  69956. private _scene;
  69957. private _depthTexture;
  69958. private _grainTexture;
  69959. private _chromaticAberrationPostProcess;
  69960. private _highlightsPostProcess;
  69961. private _depthOfFieldPostProcess;
  69962. private _edgeBlur;
  69963. private _grainAmount;
  69964. private _chromaticAberration;
  69965. private _distortion;
  69966. private _highlightsGain;
  69967. private _highlightsThreshold;
  69968. private _dofDistance;
  69969. private _dofAperture;
  69970. private _dofDarken;
  69971. private _dofPentagon;
  69972. private _blurNoise;
  69973. /**
  69974. * @constructor
  69975. *
  69976. * Effect parameters are as follow:
  69977. * {
  69978. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69979. * edge_blur: number; // from 0 to x (1 for realism)
  69980. * distortion: number; // from 0 to x (1 for realism)
  69981. * grain_amount: number; // from 0 to 1
  69982. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69983. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69984. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69985. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69986. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69987. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69988. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69989. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69990. * }
  69991. * Note: if an effect parameter is unset, effect is disabled
  69992. *
  69993. * @param name The rendering pipeline name
  69994. * @param parameters - An object containing all parameters (see above)
  69995. * @param scene The scene linked to this pipeline
  69996. * @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)
  69997. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69998. */
  69999. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70000. /**
  70001. * Get the class name
  70002. * @returns "LensRenderingPipeline"
  70003. */
  70004. getClassName(): string;
  70005. /**
  70006. * Gets associated scene
  70007. */
  70008. get scene(): Scene;
  70009. /**
  70010. * Gets or sets the edge blur
  70011. */
  70012. get edgeBlur(): number;
  70013. set edgeBlur(value: number);
  70014. /**
  70015. * Gets or sets the grain amount
  70016. */
  70017. get grainAmount(): number;
  70018. set grainAmount(value: number);
  70019. /**
  70020. * Gets or sets the chromatic aberration amount
  70021. */
  70022. get chromaticAberration(): number;
  70023. set chromaticAberration(value: number);
  70024. /**
  70025. * Gets or sets the depth of field aperture
  70026. */
  70027. get dofAperture(): number;
  70028. set dofAperture(value: number);
  70029. /**
  70030. * Gets or sets the edge distortion
  70031. */
  70032. get edgeDistortion(): number;
  70033. set edgeDistortion(value: number);
  70034. /**
  70035. * Gets or sets the depth of field distortion
  70036. */
  70037. get dofDistortion(): number;
  70038. set dofDistortion(value: number);
  70039. /**
  70040. * Gets or sets the darken out of focus amount
  70041. */
  70042. get darkenOutOfFocus(): number;
  70043. set darkenOutOfFocus(value: number);
  70044. /**
  70045. * Gets or sets a boolean indicating if blur noise is enabled
  70046. */
  70047. get blurNoise(): boolean;
  70048. set blurNoise(value: boolean);
  70049. /**
  70050. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70051. */
  70052. get pentagonBokeh(): boolean;
  70053. set pentagonBokeh(value: boolean);
  70054. /**
  70055. * Gets or sets the highlight grain amount
  70056. */
  70057. get highlightsGain(): number;
  70058. set highlightsGain(value: number);
  70059. /**
  70060. * Gets or sets the highlight threshold
  70061. */
  70062. get highlightsThreshold(): number;
  70063. set highlightsThreshold(value: number);
  70064. /**
  70065. * Sets the amount of blur at the edges
  70066. * @param amount blur amount
  70067. */
  70068. setEdgeBlur(amount: number): void;
  70069. /**
  70070. * Sets edge blur to 0
  70071. */
  70072. disableEdgeBlur(): void;
  70073. /**
  70074. * Sets the amout of grain
  70075. * @param amount Amount of grain
  70076. */
  70077. setGrainAmount(amount: number): void;
  70078. /**
  70079. * Set grain amount to 0
  70080. */
  70081. disableGrain(): void;
  70082. /**
  70083. * Sets the chromatic aberration amount
  70084. * @param amount amount of chromatic aberration
  70085. */
  70086. setChromaticAberration(amount: number): void;
  70087. /**
  70088. * Sets chromatic aberration amount to 0
  70089. */
  70090. disableChromaticAberration(): void;
  70091. /**
  70092. * Sets the EdgeDistortion amount
  70093. * @param amount amount of EdgeDistortion
  70094. */
  70095. setEdgeDistortion(amount: number): void;
  70096. /**
  70097. * Sets edge distortion to 0
  70098. */
  70099. disableEdgeDistortion(): void;
  70100. /**
  70101. * Sets the FocusDistance amount
  70102. * @param amount amount of FocusDistance
  70103. */
  70104. setFocusDistance(amount: number): void;
  70105. /**
  70106. * Disables depth of field
  70107. */
  70108. disableDepthOfField(): void;
  70109. /**
  70110. * Sets the Aperture amount
  70111. * @param amount amount of Aperture
  70112. */
  70113. setAperture(amount: number): void;
  70114. /**
  70115. * Sets the DarkenOutOfFocus amount
  70116. * @param amount amount of DarkenOutOfFocus
  70117. */
  70118. setDarkenOutOfFocus(amount: number): void;
  70119. private _pentagonBokehIsEnabled;
  70120. /**
  70121. * Creates a pentagon bokeh effect
  70122. */
  70123. enablePentagonBokeh(): void;
  70124. /**
  70125. * Disables the pentagon bokeh effect
  70126. */
  70127. disablePentagonBokeh(): void;
  70128. /**
  70129. * Enables noise blur
  70130. */
  70131. enableNoiseBlur(): void;
  70132. /**
  70133. * Disables noise blur
  70134. */
  70135. disableNoiseBlur(): void;
  70136. /**
  70137. * Sets the HighlightsGain amount
  70138. * @param amount amount of HighlightsGain
  70139. */
  70140. setHighlightsGain(amount: number): void;
  70141. /**
  70142. * Sets the HighlightsThreshold amount
  70143. * @param amount amount of HighlightsThreshold
  70144. */
  70145. setHighlightsThreshold(amount: number): void;
  70146. /**
  70147. * Disables highlights
  70148. */
  70149. disableHighlights(): void;
  70150. /**
  70151. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70152. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70153. */
  70154. dispose(disableDepthRender?: boolean): void;
  70155. private _createChromaticAberrationPostProcess;
  70156. private _createHighlightsPostProcess;
  70157. private _createDepthOfFieldPostProcess;
  70158. private _createGrainTexture;
  70159. }
  70160. }
  70161. declare module BABYLON {
  70162. /** @hidden */
  70163. export var ssao2PixelShader: {
  70164. name: string;
  70165. shader: string;
  70166. };
  70167. }
  70168. declare module BABYLON {
  70169. /** @hidden */
  70170. export var ssaoCombinePixelShader: {
  70171. name: string;
  70172. shader: string;
  70173. };
  70174. }
  70175. declare module BABYLON {
  70176. /**
  70177. * Render pipeline to produce ssao effect
  70178. */
  70179. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70180. /**
  70181. * @ignore
  70182. * The PassPostProcess id in the pipeline that contains the original scene color
  70183. */
  70184. SSAOOriginalSceneColorEffect: string;
  70185. /**
  70186. * @ignore
  70187. * The SSAO PostProcess id in the pipeline
  70188. */
  70189. SSAORenderEffect: string;
  70190. /**
  70191. * @ignore
  70192. * The horizontal blur PostProcess id in the pipeline
  70193. */
  70194. SSAOBlurHRenderEffect: string;
  70195. /**
  70196. * @ignore
  70197. * The vertical blur PostProcess id in the pipeline
  70198. */
  70199. SSAOBlurVRenderEffect: string;
  70200. /**
  70201. * @ignore
  70202. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70203. */
  70204. SSAOCombineRenderEffect: string;
  70205. /**
  70206. * The output strength of the SSAO post-process. Default value is 1.0.
  70207. */
  70208. totalStrength: number;
  70209. /**
  70210. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70211. */
  70212. maxZ: number;
  70213. /**
  70214. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70215. */
  70216. minZAspect: number;
  70217. private _samples;
  70218. /**
  70219. * Number of samples used for the SSAO calculations. Default value is 8
  70220. */
  70221. set samples(n: number);
  70222. get samples(): number;
  70223. private _textureSamples;
  70224. /**
  70225. * Number of samples to use for antialiasing
  70226. */
  70227. set textureSamples(n: number);
  70228. get textureSamples(): number;
  70229. /**
  70230. * Force rendering the geometry through geometry buffer
  70231. */
  70232. private _forceGeometryBuffer;
  70233. /**
  70234. * Ratio object used for SSAO ratio and blur ratio
  70235. */
  70236. private _ratio;
  70237. /**
  70238. * Dynamically generated sphere sampler.
  70239. */
  70240. private _sampleSphere;
  70241. /**
  70242. * Blur filter offsets
  70243. */
  70244. private _samplerOffsets;
  70245. private _expensiveBlur;
  70246. /**
  70247. * If bilateral blur should be used
  70248. */
  70249. set expensiveBlur(b: boolean);
  70250. get expensiveBlur(): boolean;
  70251. /**
  70252. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70253. */
  70254. radius: number;
  70255. /**
  70256. * The base color of the SSAO post-process
  70257. * The final result is "base + ssao" between [0, 1]
  70258. */
  70259. base: number;
  70260. /**
  70261. * Support test.
  70262. */
  70263. static get IsSupported(): boolean;
  70264. private _scene;
  70265. private _randomTexture;
  70266. private _originalColorPostProcess;
  70267. private _ssaoPostProcess;
  70268. private _blurHPostProcess;
  70269. private _blurVPostProcess;
  70270. private _ssaoCombinePostProcess;
  70271. private _prePassRenderer;
  70272. /**
  70273. * Gets active scene
  70274. */
  70275. get scene(): Scene;
  70276. /**
  70277. * @constructor
  70278. * @param name The rendering pipeline name
  70279. * @param scene The scene linked to this pipeline
  70280. * @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 }
  70281. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70282. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70283. */
  70284. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70285. /**
  70286. * Get the class name
  70287. * @returns "SSAO2RenderingPipeline"
  70288. */
  70289. getClassName(): string;
  70290. /**
  70291. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70292. */
  70293. dispose(disableGeometryBufferRenderer?: boolean): void;
  70294. private _createBlurPostProcess;
  70295. /** @hidden */
  70296. _rebuild(): void;
  70297. private _bits;
  70298. private _radicalInverse_VdC;
  70299. private _hammersley;
  70300. private _hemisphereSample_uniform;
  70301. private _generateHemisphere;
  70302. private _getDefinesForSSAO;
  70303. private _createSSAOPostProcess;
  70304. private _createSSAOCombinePostProcess;
  70305. private _createRandomTexture;
  70306. /**
  70307. * Serialize the rendering pipeline (Used when exporting)
  70308. * @returns the serialized object
  70309. */
  70310. serialize(): any;
  70311. /**
  70312. * Parse the serialized pipeline
  70313. * @param source Source pipeline.
  70314. * @param scene The scene to load the pipeline to.
  70315. * @param rootUrl The URL of the serialized pipeline.
  70316. * @returns An instantiated pipeline from the serialized object.
  70317. */
  70318. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70319. /**
  70320. * Sets the required values to the prepass renderer.
  70321. * @param prePassRenderer defines the prepass renderer to setup
  70322. * @returns true if the pre pass is needed.
  70323. */
  70324. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70325. }
  70326. }
  70327. declare module BABYLON {
  70328. /** @hidden */
  70329. export var ssaoPixelShader: {
  70330. name: string;
  70331. shader: string;
  70332. };
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * Render pipeline to produce ssao effect
  70337. */
  70338. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70339. /**
  70340. * @ignore
  70341. * The PassPostProcess id in the pipeline that contains the original scene color
  70342. */
  70343. SSAOOriginalSceneColorEffect: string;
  70344. /**
  70345. * @ignore
  70346. * The SSAO PostProcess id in the pipeline
  70347. */
  70348. SSAORenderEffect: string;
  70349. /**
  70350. * @ignore
  70351. * The horizontal blur PostProcess id in the pipeline
  70352. */
  70353. SSAOBlurHRenderEffect: string;
  70354. /**
  70355. * @ignore
  70356. * The vertical blur PostProcess id in the pipeline
  70357. */
  70358. SSAOBlurVRenderEffect: string;
  70359. /**
  70360. * @ignore
  70361. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70362. */
  70363. SSAOCombineRenderEffect: string;
  70364. /**
  70365. * The output strength of the SSAO post-process. Default value is 1.0.
  70366. */
  70367. totalStrength: number;
  70368. /**
  70369. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70370. */
  70371. radius: number;
  70372. /**
  70373. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70374. * Must not be equal to fallOff and superior to fallOff.
  70375. * Default value is 0.0075
  70376. */
  70377. area: number;
  70378. /**
  70379. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70380. * Must not be equal to area and inferior to area.
  70381. * Default value is 0.000001
  70382. */
  70383. fallOff: number;
  70384. /**
  70385. * The base color of the SSAO post-process
  70386. * The final result is "base + ssao" between [0, 1]
  70387. */
  70388. base: number;
  70389. private _scene;
  70390. private _depthTexture;
  70391. private _randomTexture;
  70392. private _originalColorPostProcess;
  70393. private _ssaoPostProcess;
  70394. private _blurHPostProcess;
  70395. private _blurVPostProcess;
  70396. private _ssaoCombinePostProcess;
  70397. private _firstUpdate;
  70398. /**
  70399. * Gets active scene
  70400. */
  70401. get scene(): Scene;
  70402. /**
  70403. * @constructor
  70404. * @param name - The rendering pipeline name
  70405. * @param scene - The scene linked to this pipeline
  70406. * @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 }
  70407. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70408. */
  70409. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70410. /**
  70411. * Get the class name
  70412. * @returns "SSAORenderingPipeline"
  70413. */
  70414. getClassName(): string;
  70415. /**
  70416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70417. */
  70418. dispose(disableDepthRender?: boolean): void;
  70419. private _createBlurPostProcess;
  70420. /** @hidden */
  70421. _rebuild(): void;
  70422. private _createSSAOPostProcess;
  70423. private _createSSAOCombinePostProcess;
  70424. private _createRandomTexture;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /** @hidden */
  70429. export var screenSpaceReflectionPixelShader: {
  70430. name: string;
  70431. shader: string;
  70432. };
  70433. }
  70434. declare module BABYLON {
  70435. /**
  70436. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70437. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70438. */
  70439. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70440. /**
  70441. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70442. */
  70443. threshold: number;
  70444. /**
  70445. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70446. */
  70447. strength: number;
  70448. /**
  70449. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70450. */
  70451. reflectionSpecularFalloffExponent: number;
  70452. /**
  70453. * 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]
  70454. */
  70455. step: number;
  70456. /**
  70457. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70458. */
  70459. roughnessFactor: number;
  70460. private _geometryBufferRenderer;
  70461. private _enableSmoothReflections;
  70462. private _reflectionSamples;
  70463. private _smoothSteps;
  70464. /**
  70465. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70466. * @param name The name of the effect.
  70467. * @param scene The scene containing the objects to calculate reflections.
  70468. * @param options The required width/height ratio to downsize to before computing the render pass.
  70469. * @param camera The camera to apply the render pass to.
  70470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70471. * @param engine The engine which the post process will be applied. (default: current engine)
  70472. * @param reusable If the post process can be reused on the same frame. (default: false)
  70473. * @param textureType Type of textures used when performing the post process. (default: 0)
  70474. * @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)
  70475. */
  70476. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70477. /**
  70478. * Gets wether or not smoothing reflections is enabled.
  70479. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70480. */
  70481. get enableSmoothReflections(): boolean;
  70482. /**
  70483. * Sets wether or not smoothing reflections is enabled.
  70484. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70485. */
  70486. set enableSmoothReflections(enabled: boolean);
  70487. /**
  70488. * Gets the number of samples taken while computing reflections. More samples count is high,
  70489. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70490. */
  70491. get reflectionSamples(): number;
  70492. /**
  70493. * Sets the number of samples taken while computing reflections. More samples count is high,
  70494. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70495. */
  70496. set reflectionSamples(samples: number);
  70497. /**
  70498. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70499. * more the post-process will require GPU power and can generate a drop in FPS.
  70500. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70501. */
  70502. get smoothSteps(): number;
  70503. set smoothSteps(steps: number);
  70504. private _updateEffectDefines;
  70505. }
  70506. }
  70507. declare module BABYLON {
  70508. /** @hidden */
  70509. export var standardPixelShader: {
  70510. name: string;
  70511. shader: string;
  70512. };
  70513. }
  70514. declare module BABYLON {
  70515. /**
  70516. * Standard rendering pipeline
  70517. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70518. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70519. */
  70520. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70521. /**
  70522. * Public members
  70523. */
  70524. /**
  70525. * Post-process which contains the original scene color before the pipeline applies all the effects
  70526. */
  70527. originalPostProcess: Nullable<PostProcess>;
  70528. /**
  70529. * Post-process used to down scale an image x4
  70530. */
  70531. downSampleX4PostProcess: Nullable<PostProcess>;
  70532. /**
  70533. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70534. */
  70535. brightPassPostProcess: Nullable<PostProcess>;
  70536. /**
  70537. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70538. */
  70539. blurHPostProcesses: PostProcess[];
  70540. /**
  70541. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70542. */
  70543. blurVPostProcesses: PostProcess[];
  70544. /**
  70545. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70546. */
  70547. textureAdderPostProcess: Nullable<PostProcess>;
  70548. /**
  70549. * Post-process used to create volumetric lighting effect
  70550. */
  70551. volumetricLightPostProcess: Nullable<PostProcess>;
  70552. /**
  70553. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70554. */
  70555. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70556. /**
  70557. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70558. */
  70559. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70560. /**
  70561. * Post-process used to merge the volumetric light effect and the real scene color
  70562. */
  70563. volumetricLightMergePostProces: Nullable<PostProcess>;
  70564. /**
  70565. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70566. */
  70567. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70568. /**
  70569. * Base post-process used to calculate the average luminance of the final image for HDR
  70570. */
  70571. luminancePostProcess: Nullable<PostProcess>;
  70572. /**
  70573. * Post-processes used to create down sample post-processes in order to get
  70574. * the average luminance of the final image for HDR
  70575. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70576. */
  70577. luminanceDownSamplePostProcesses: PostProcess[];
  70578. /**
  70579. * Post-process used to create a HDR effect (light adaptation)
  70580. */
  70581. hdrPostProcess: Nullable<PostProcess>;
  70582. /**
  70583. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70584. */
  70585. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70586. /**
  70587. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70588. */
  70589. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70590. /**
  70591. * Post-process used to merge the final HDR post-process and the real scene color
  70592. */
  70593. hdrFinalPostProcess: Nullable<PostProcess>;
  70594. /**
  70595. * Post-process used to create a lens flare effect
  70596. */
  70597. lensFlarePostProcess: Nullable<PostProcess>;
  70598. /**
  70599. * Post-process that merges the result of the lens flare post-process and the real scene color
  70600. */
  70601. lensFlareComposePostProcess: Nullable<PostProcess>;
  70602. /**
  70603. * Post-process used to create a motion blur effect
  70604. */
  70605. motionBlurPostProcess: Nullable<PostProcess>;
  70606. /**
  70607. * Post-process used to create a depth of field effect
  70608. */
  70609. depthOfFieldPostProcess: Nullable<PostProcess>;
  70610. /**
  70611. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70612. */
  70613. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70614. /**
  70615. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70616. */
  70617. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70618. /**
  70619. * Represents the brightness threshold in order to configure the illuminated surfaces
  70620. */
  70621. brightThreshold: number;
  70622. /**
  70623. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70624. */
  70625. blurWidth: number;
  70626. /**
  70627. * Sets if the blur for highlighted surfaces must be only horizontal
  70628. */
  70629. horizontalBlur: boolean;
  70630. /**
  70631. * Gets the overall exposure used by the pipeline
  70632. */
  70633. get exposure(): number;
  70634. /**
  70635. * Sets the overall exposure used by the pipeline
  70636. */
  70637. set exposure(value: number);
  70638. /**
  70639. * Texture used typically to simulate "dirty" on camera lens
  70640. */
  70641. lensTexture: Nullable<Texture>;
  70642. /**
  70643. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70644. */
  70645. volumetricLightCoefficient: number;
  70646. /**
  70647. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70648. */
  70649. volumetricLightPower: number;
  70650. /**
  70651. * Used the set the blur intensity to smooth the volumetric lights
  70652. */
  70653. volumetricLightBlurScale: number;
  70654. /**
  70655. * Light (spot or directional) used to generate the volumetric lights rays
  70656. * The source light must have a shadow generate so the pipeline can get its
  70657. * depth map
  70658. */
  70659. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70660. /**
  70661. * For eye adaptation, represents the minimum luminance the eye can see
  70662. */
  70663. hdrMinimumLuminance: number;
  70664. /**
  70665. * For eye adaptation, represents the decrease luminance speed
  70666. */
  70667. hdrDecreaseRate: number;
  70668. /**
  70669. * For eye adaptation, represents the increase luminance speed
  70670. */
  70671. hdrIncreaseRate: number;
  70672. /**
  70673. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70674. */
  70675. get hdrAutoExposure(): boolean;
  70676. /**
  70677. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70678. */
  70679. set hdrAutoExposure(value: boolean);
  70680. /**
  70681. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70682. */
  70683. lensColorTexture: Nullable<Texture>;
  70684. /**
  70685. * The overall strengh for the lens flare effect
  70686. */
  70687. lensFlareStrength: number;
  70688. /**
  70689. * Dispersion coefficient for lens flare ghosts
  70690. */
  70691. lensFlareGhostDispersal: number;
  70692. /**
  70693. * Main lens flare halo width
  70694. */
  70695. lensFlareHaloWidth: number;
  70696. /**
  70697. * Based on the lens distortion effect, defines how much the lens flare result
  70698. * is distorted
  70699. */
  70700. lensFlareDistortionStrength: number;
  70701. /**
  70702. * Configures the blur intensity used for for lens flare (halo)
  70703. */
  70704. lensFlareBlurWidth: number;
  70705. /**
  70706. * Lens star texture must be used to simulate rays on the flares and is available
  70707. * in the documentation
  70708. */
  70709. lensStarTexture: Nullable<Texture>;
  70710. /**
  70711. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70712. * flare effect by taking account of the dirt texture
  70713. */
  70714. lensFlareDirtTexture: Nullable<Texture>;
  70715. /**
  70716. * Represents the focal length for the depth of field effect
  70717. */
  70718. depthOfFieldDistance: number;
  70719. /**
  70720. * Represents the blur intensity for the blurred part of the depth of field effect
  70721. */
  70722. depthOfFieldBlurWidth: number;
  70723. /**
  70724. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70725. */
  70726. get motionStrength(): number;
  70727. /**
  70728. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70729. */
  70730. set motionStrength(strength: number);
  70731. /**
  70732. * Gets wether or not the motion blur post-process is object based or screen based.
  70733. */
  70734. get objectBasedMotionBlur(): boolean;
  70735. /**
  70736. * Sets wether or not the motion blur post-process should be object based or screen based
  70737. */
  70738. set objectBasedMotionBlur(value: boolean);
  70739. /**
  70740. * List of animations for the pipeline (IAnimatable implementation)
  70741. */
  70742. animations: Animation[];
  70743. /**
  70744. * Private members
  70745. */
  70746. private _scene;
  70747. private _currentDepthOfFieldSource;
  70748. private _basePostProcess;
  70749. private _fixedExposure;
  70750. private _currentExposure;
  70751. private _hdrAutoExposure;
  70752. private _hdrCurrentLuminance;
  70753. private _motionStrength;
  70754. private _isObjectBasedMotionBlur;
  70755. private _floatTextureType;
  70756. private _camerasToBeAttached;
  70757. private _ratio;
  70758. private _bloomEnabled;
  70759. private _depthOfFieldEnabled;
  70760. private _vlsEnabled;
  70761. private _lensFlareEnabled;
  70762. private _hdrEnabled;
  70763. private _motionBlurEnabled;
  70764. private _fxaaEnabled;
  70765. private _screenSpaceReflectionsEnabled;
  70766. private _motionBlurSamples;
  70767. private _volumetricLightStepsCount;
  70768. private _samples;
  70769. /**
  70770. * @ignore
  70771. * Specifies if the bloom pipeline is enabled
  70772. */
  70773. get BloomEnabled(): boolean;
  70774. set BloomEnabled(enabled: boolean);
  70775. /**
  70776. * @ignore
  70777. * Specifies if the depth of field pipeline is enabed
  70778. */
  70779. get DepthOfFieldEnabled(): boolean;
  70780. set DepthOfFieldEnabled(enabled: boolean);
  70781. /**
  70782. * @ignore
  70783. * Specifies if the lens flare pipeline is enabed
  70784. */
  70785. get LensFlareEnabled(): boolean;
  70786. set LensFlareEnabled(enabled: boolean);
  70787. /**
  70788. * @ignore
  70789. * Specifies if the HDR pipeline is enabled
  70790. */
  70791. get HDREnabled(): boolean;
  70792. set HDREnabled(enabled: boolean);
  70793. /**
  70794. * @ignore
  70795. * Specifies if the volumetric lights scattering effect is enabled
  70796. */
  70797. get VLSEnabled(): boolean;
  70798. set VLSEnabled(enabled: boolean);
  70799. /**
  70800. * @ignore
  70801. * Specifies if the motion blur effect is enabled
  70802. */
  70803. get MotionBlurEnabled(): boolean;
  70804. set MotionBlurEnabled(enabled: boolean);
  70805. /**
  70806. * Specifies if anti-aliasing is enabled
  70807. */
  70808. get fxaaEnabled(): boolean;
  70809. set fxaaEnabled(enabled: boolean);
  70810. /**
  70811. * Specifies if screen space reflections are enabled.
  70812. */
  70813. get screenSpaceReflectionsEnabled(): boolean;
  70814. set screenSpaceReflectionsEnabled(enabled: boolean);
  70815. /**
  70816. * Specifies the number of steps used to calculate the volumetric lights
  70817. * Typically in interval [50, 200]
  70818. */
  70819. get volumetricLightStepsCount(): number;
  70820. set volumetricLightStepsCount(count: number);
  70821. /**
  70822. * Specifies the number of samples used for the motion blur effect
  70823. * Typically in interval [16, 64]
  70824. */
  70825. get motionBlurSamples(): number;
  70826. set motionBlurSamples(samples: number);
  70827. /**
  70828. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70829. */
  70830. get samples(): number;
  70831. set samples(sampleCount: number);
  70832. /**
  70833. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70834. * @constructor
  70835. * @param name The rendering pipeline name
  70836. * @param scene The scene linked to this pipeline
  70837. * @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)
  70838. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70840. */
  70841. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70842. private _buildPipeline;
  70843. private _createDownSampleX4PostProcess;
  70844. private _createBrightPassPostProcess;
  70845. private _createBlurPostProcesses;
  70846. private _createTextureAdderPostProcess;
  70847. private _createVolumetricLightPostProcess;
  70848. private _createLuminancePostProcesses;
  70849. private _createHdrPostProcess;
  70850. private _createLensFlarePostProcess;
  70851. private _createDepthOfFieldPostProcess;
  70852. private _createMotionBlurPostProcess;
  70853. private _getDepthTexture;
  70854. private _disposePostProcesses;
  70855. /**
  70856. * Dispose of the pipeline and stop all post processes
  70857. */
  70858. dispose(): void;
  70859. /**
  70860. * Serialize the rendering pipeline (Used when exporting)
  70861. * @returns the serialized object
  70862. */
  70863. serialize(): any;
  70864. /**
  70865. * Parse the serialized pipeline
  70866. * @param source Source pipeline.
  70867. * @param scene The scene to load the pipeline to.
  70868. * @param rootUrl The URL of the serialized pipeline.
  70869. * @returns An instantiated pipeline from the serialized object.
  70870. */
  70871. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70872. /**
  70873. * Luminance steps
  70874. */
  70875. static LuminanceSteps: number;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /** @hidden */
  70880. export var stereoscopicInterlacePixelShader: {
  70881. name: string;
  70882. shader: string;
  70883. };
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70888. */
  70889. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70890. private _stepSize;
  70891. private _passedProcess;
  70892. /**
  70893. * Initializes a StereoscopicInterlacePostProcessI
  70894. * @param name The name of the effect.
  70895. * @param rigCameras The rig cameras to be appled to the post process
  70896. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70897. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70899. * @param engine The engine which the post process will be applied. (default: current engine)
  70900. * @param reusable If the post process can be reused on the same frame. (default: false)
  70901. */
  70902. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70903. }
  70904. /**
  70905. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70906. */
  70907. export class StereoscopicInterlacePostProcess extends PostProcess {
  70908. private _stepSize;
  70909. private _passedProcess;
  70910. /**
  70911. * Initializes a StereoscopicInterlacePostProcess
  70912. * @param name The name of the effect.
  70913. * @param rigCameras The rig cameras to be appled to the post process
  70914. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70916. * @param engine The engine which the post process will be applied. (default: current engine)
  70917. * @param reusable If the post process can be reused on the same frame. (default: false)
  70918. */
  70919. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70920. }
  70921. }
  70922. declare module BABYLON {
  70923. /** @hidden */
  70924. export var tonemapPixelShader: {
  70925. name: string;
  70926. shader: string;
  70927. };
  70928. }
  70929. declare module BABYLON {
  70930. /** Defines operator used for tonemapping */
  70931. export enum TonemappingOperator {
  70932. /** Hable */
  70933. Hable = 0,
  70934. /** Reinhard */
  70935. Reinhard = 1,
  70936. /** HejiDawson */
  70937. HejiDawson = 2,
  70938. /** Photographic */
  70939. Photographic = 3
  70940. }
  70941. /**
  70942. * Defines a post process to apply tone mapping
  70943. */
  70944. export class TonemapPostProcess extends PostProcess {
  70945. private _operator;
  70946. /** Defines the required exposure adjustement */
  70947. exposureAdjustment: number;
  70948. /**
  70949. * Creates a new TonemapPostProcess
  70950. * @param name defines the name of the postprocess
  70951. * @param _operator defines the operator to use
  70952. * @param exposureAdjustment defines the required exposure adjustement
  70953. * @param camera defines the camera to use (can be null)
  70954. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70955. * @param engine defines the hosting engine (can be ignore if camera is set)
  70956. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70957. */
  70958. constructor(name: string, _operator: TonemappingOperator,
  70959. /** Defines the required exposure adjustement */
  70960. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70961. }
  70962. }
  70963. declare module BABYLON {
  70964. /** @hidden */
  70965. export var volumetricLightScatteringPixelShader: {
  70966. name: string;
  70967. shader: string;
  70968. };
  70969. }
  70970. declare module BABYLON {
  70971. /** @hidden */
  70972. export var volumetricLightScatteringPassVertexShader: {
  70973. name: string;
  70974. shader: string;
  70975. };
  70976. }
  70977. declare module BABYLON {
  70978. /** @hidden */
  70979. export var volumetricLightScatteringPassPixelShader: {
  70980. name: string;
  70981. shader: string;
  70982. };
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70987. */
  70988. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70989. private _volumetricLightScatteringPass;
  70990. private _volumetricLightScatteringRTT;
  70991. private _viewPort;
  70992. private _screenCoordinates;
  70993. private _cachedDefines;
  70994. /**
  70995. * If not undefined, the mesh position is computed from the attached node position
  70996. */
  70997. attachedNode: {
  70998. position: Vector3;
  70999. };
  71000. /**
  71001. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71002. */
  71003. customMeshPosition: Vector3;
  71004. /**
  71005. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71006. */
  71007. useCustomMeshPosition: boolean;
  71008. /**
  71009. * If the post-process should inverse the light scattering direction
  71010. */
  71011. invert: boolean;
  71012. /**
  71013. * The internal mesh used by the post-process
  71014. */
  71015. mesh: Mesh;
  71016. /**
  71017. * @hidden
  71018. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71019. */
  71020. get useDiffuseColor(): boolean;
  71021. set useDiffuseColor(useDiffuseColor: boolean);
  71022. /**
  71023. * Array containing the excluded meshes not rendered in the internal pass
  71024. */
  71025. excludedMeshes: AbstractMesh[];
  71026. /**
  71027. * Controls the overall intensity of the post-process
  71028. */
  71029. exposure: number;
  71030. /**
  71031. * Dissipates each sample's contribution in range [0, 1]
  71032. */
  71033. decay: number;
  71034. /**
  71035. * Controls the overall intensity of each sample
  71036. */
  71037. weight: number;
  71038. /**
  71039. * Controls the density of each sample
  71040. */
  71041. density: number;
  71042. /**
  71043. * @constructor
  71044. * @param name The post-process name
  71045. * @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)
  71046. * @param camera The camera that the post-process will be attached to
  71047. * @param mesh The mesh used to create the light scattering
  71048. * @param samples The post-process quality, default 100
  71049. * @param samplingModeThe post-process filtering mode
  71050. * @param engine The babylon engine
  71051. * @param reusable If the post-process is reusable
  71052. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71053. */
  71054. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71055. /**
  71056. * Returns the string "VolumetricLightScatteringPostProcess"
  71057. * @returns "VolumetricLightScatteringPostProcess"
  71058. */
  71059. getClassName(): string;
  71060. private _isReady;
  71061. /**
  71062. * Sets the new light position for light scattering effect
  71063. * @param position The new custom light position
  71064. */
  71065. setCustomMeshPosition(position: Vector3): void;
  71066. /**
  71067. * Returns the light position for light scattering effect
  71068. * @return Vector3 The custom light position
  71069. */
  71070. getCustomMeshPosition(): Vector3;
  71071. /**
  71072. * Disposes the internal assets and detaches the post-process from the camera
  71073. */
  71074. dispose(camera: Camera): void;
  71075. /**
  71076. * Returns the render target texture used by the post-process
  71077. * @return the render target texture used by the post-process
  71078. */
  71079. getPass(): RenderTargetTexture;
  71080. private _meshExcluded;
  71081. private _createPass;
  71082. private _updateMeshScreenCoordinates;
  71083. /**
  71084. * Creates a default mesh for the Volumeric Light Scattering post-process
  71085. * @param name The mesh name
  71086. * @param scene The scene where to create the mesh
  71087. * @return the default mesh
  71088. */
  71089. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71090. }
  71091. }
  71092. declare module BABYLON {
  71093. /** @hidden */
  71094. export var screenSpaceCurvaturePixelShader: {
  71095. name: string;
  71096. shader: string;
  71097. };
  71098. }
  71099. declare module BABYLON {
  71100. /**
  71101. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71102. */
  71103. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71104. /**
  71105. * Defines how much ridge the curvature effect displays.
  71106. */
  71107. ridge: number;
  71108. /**
  71109. * Defines how much valley the curvature effect displays.
  71110. */
  71111. valley: number;
  71112. private _geometryBufferRenderer;
  71113. /**
  71114. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71115. * @param name The name of the effect.
  71116. * @param scene The scene containing the objects to blur according to their velocity.
  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. * Support test.
  71128. */
  71129. static get IsSupported(): boolean;
  71130. }
  71131. }
  71132. declare module BABYLON {
  71133. interface Scene {
  71134. /** @hidden (Backing field) */
  71135. _boundingBoxRenderer: BoundingBoxRenderer;
  71136. /** @hidden (Backing field) */
  71137. _forceShowBoundingBoxes: boolean;
  71138. /**
  71139. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71140. */
  71141. forceShowBoundingBoxes: boolean;
  71142. /**
  71143. * Gets the bounding box renderer associated with the scene
  71144. * @returns a BoundingBoxRenderer
  71145. */
  71146. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71147. }
  71148. interface AbstractMesh {
  71149. /** @hidden (Backing field) */
  71150. _showBoundingBox: boolean;
  71151. /**
  71152. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71153. */
  71154. showBoundingBox: boolean;
  71155. }
  71156. /**
  71157. * Component responsible of rendering the bounding box of the meshes in a scene.
  71158. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71159. */
  71160. export class BoundingBoxRenderer implements ISceneComponent {
  71161. /**
  71162. * The component name helpfull to identify the component in the list of scene components.
  71163. */
  71164. readonly name: string;
  71165. /**
  71166. * The scene the component belongs to.
  71167. */
  71168. scene: Scene;
  71169. /**
  71170. * Color of the bounding box lines placed in front of an object
  71171. */
  71172. frontColor: Color3;
  71173. /**
  71174. * Color of the bounding box lines placed behind an object
  71175. */
  71176. backColor: Color3;
  71177. /**
  71178. * Defines if the renderer should show the back lines or not
  71179. */
  71180. showBackLines: boolean;
  71181. /**
  71182. * Observable raised before rendering a bounding box
  71183. */
  71184. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71185. /**
  71186. * Observable raised after rendering a bounding box
  71187. */
  71188. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71189. /**
  71190. * @hidden
  71191. */
  71192. renderList: SmartArray<BoundingBox>;
  71193. private _colorShader;
  71194. private _vertexBuffers;
  71195. private _indexBuffer;
  71196. private _fillIndexBuffer;
  71197. private _fillIndexData;
  71198. /**
  71199. * Instantiates a new bounding box renderer in a scene.
  71200. * @param scene the scene the renderer renders in
  71201. */
  71202. constructor(scene: Scene);
  71203. /**
  71204. * Registers the component in a given scene
  71205. */
  71206. register(): void;
  71207. private _evaluateSubMesh;
  71208. private _activeMesh;
  71209. private _prepareRessources;
  71210. private _createIndexBuffer;
  71211. /**
  71212. * Rebuilds the elements related to this component in case of
  71213. * context lost for instance.
  71214. */
  71215. rebuild(): void;
  71216. /**
  71217. * @hidden
  71218. */
  71219. reset(): void;
  71220. /**
  71221. * Render the bounding boxes of a specific rendering group
  71222. * @param renderingGroupId defines the rendering group to render
  71223. */
  71224. render(renderingGroupId: number): void;
  71225. /**
  71226. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71227. * @param mesh Define the mesh to render the occlusion bounding box for
  71228. */
  71229. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71230. /**
  71231. * Dispose and release the resources attached to this renderer.
  71232. */
  71233. dispose(): void;
  71234. }
  71235. }
  71236. declare module BABYLON {
  71237. interface Scene {
  71238. /** @hidden (Backing field) */
  71239. _depthRenderer: {
  71240. [id: string]: DepthRenderer;
  71241. };
  71242. /**
  71243. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71244. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71245. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71246. * @returns the created depth renderer
  71247. */
  71248. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71249. /**
  71250. * Disables a depth renderer for a given camera
  71251. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71252. */
  71253. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71254. }
  71255. /**
  71256. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71257. * in several rendering techniques.
  71258. */
  71259. export class DepthRendererSceneComponent implements ISceneComponent {
  71260. /**
  71261. * The component name helpfull to identify the component in the list of scene components.
  71262. */
  71263. readonly name: string;
  71264. /**
  71265. * The scene the component belongs to.
  71266. */
  71267. scene: Scene;
  71268. /**
  71269. * Creates a new instance of the component for the given scene
  71270. * @param scene Defines the scene to register the component in
  71271. */
  71272. constructor(scene: Scene);
  71273. /**
  71274. * Registers the component in a given scene
  71275. */
  71276. register(): void;
  71277. /**
  71278. * Rebuilds the elements related to this component in case of
  71279. * context lost for instance.
  71280. */
  71281. rebuild(): void;
  71282. /**
  71283. * Disposes the component and the associated ressources
  71284. */
  71285. dispose(): void;
  71286. private _gatherRenderTargets;
  71287. private _gatherActiveCameraRenderTargets;
  71288. }
  71289. }
  71290. declare module BABYLON {
  71291. interface AbstractScene {
  71292. /** @hidden (Backing field) */
  71293. _prePassRenderer: Nullable<PrePassRenderer>;
  71294. /**
  71295. * Gets or Sets the current prepass renderer associated to the scene.
  71296. */
  71297. prePassRenderer: Nullable<PrePassRenderer>;
  71298. /**
  71299. * Enables the prepass and associates it with the scene
  71300. * @returns the PrePassRenderer
  71301. */
  71302. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71303. /**
  71304. * Disables the prepass associated with the scene
  71305. */
  71306. disablePrePassRenderer(): void;
  71307. }
  71308. /**
  71309. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71310. * in several rendering techniques.
  71311. */
  71312. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71313. /**
  71314. * The component name helpful to identify the component in the list of scene components.
  71315. */
  71316. readonly name: string;
  71317. /**
  71318. * The scene the component belongs to.
  71319. */
  71320. scene: Scene;
  71321. /**
  71322. * Creates a new instance of the component for the given scene
  71323. * @param scene Defines the scene to register the component in
  71324. */
  71325. constructor(scene: Scene);
  71326. /**
  71327. * Registers the component in a given scene
  71328. */
  71329. register(): void;
  71330. private _beforeCameraDraw;
  71331. private _afterCameraDraw;
  71332. private _beforeClearStage;
  71333. /**
  71334. * Serializes the component data to the specified json object
  71335. * @param serializationObject The object to serialize to
  71336. */
  71337. serialize(serializationObject: any): void;
  71338. /**
  71339. * Adds all the elements from the container to the scene
  71340. * @param container the container holding the elements
  71341. */
  71342. addFromContainer(container: AbstractScene): void;
  71343. /**
  71344. * Removes all the elements in the container from the scene
  71345. * @param container contains the elements to remove
  71346. * @param dispose if the removed element should be disposed (default: false)
  71347. */
  71348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71349. /**
  71350. * Rebuilds the elements related to this component in case of
  71351. * context lost for instance.
  71352. */
  71353. rebuild(): void;
  71354. /**
  71355. * Disposes the component and the associated ressources
  71356. */
  71357. dispose(): void;
  71358. }
  71359. }
  71360. declare module BABYLON {
  71361. /** @hidden */
  71362. export var outlinePixelShader: {
  71363. name: string;
  71364. shader: string;
  71365. };
  71366. }
  71367. declare module BABYLON {
  71368. /** @hidden */
  71369. export var outlineVertexShader: {
  71370. name: string;
  71371. shader: string;
  71372. };
  71373. }
  71374. declare module BABYLON {
  71375. interface Scene {
  71376. /** @hidden */
  71377. _outlineRenderer: OutlineRenderer;
  71378. /**
  71379. * Gets the outline renderer associated with the scene
  71380. * @returns a OutlineRenderer
  71381. */
  71382. getOutlineRenderer(): OutlineRenderer;
  71383. }
  71384. interface AbstractMesh {
  71385. /** @hidden (Backing field) */
  71386. _renderOutline: boolean;
  71387. /**
  71388. * Gets or sets a boolean indicating if the outline must be rendered as well
  71389. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71390. */
  71391. renderOutline: boolean;
  71392. /** @hidden (Backing field) */
  71393. _renderOverlay: boolean;
  71394. /**
  71395. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71396. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71397. */
  71398. renderOverlay: boolean;
  71399. }
  71400. /**
  71401. * This class is responsible to draw bothe outline/overlay of meshes.
  71402. * It should not be used directly but through the available method on mesh.
  71403. */
  71404. export class OutlineRenderer implements ISceneComponent {
  71405. /**
  71406. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71407. */
  71408. private static _StencilReference;
  71409. /**
  71410. * The name of the component. Each component must have a unique name.
  71411. */
  71412. name: string;
  71413. /**
  71414. * The scene the component belongs to.
  71415. */
  71416. scene: Scene;
  71417. /**
  71418. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71419. */
  71420. zOffset: number;
  71421. private _engine;
  71422. private _effect;
  71423. private _cachedDefines;
  71424. private _savedDepthWrite;
  71425. /**
  71426. * Instantiates a new outline renderer. (There could be only one per scene).
  71427. * @param scene Defines the scene it belongs to
  71428. */
  71429. constructor(scene: Scene);
  71430. /**
  71431. * Register the component to one instance of a scene.
  71432. */
  71433. register(): void;
  71434. /**
  71435. * Rebuilds the elements related to this component in case of
  71436. * context lost for instance.
  71437. */
  71438. rebuild(): void;
  71439. /**
  71440. * Disposes the component and the associated ressources.
  71441. */
  71442. dispose(): void;
  71443. /**
  71444. * Renders the outline in the canvas.
  71445. * @param subMesh Defines the sumesh to render
  71446. * @param batch Defines the batch of meshes in case of instances
  71447. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71448. */
  71449. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71450. /**
  71451. * Returns whether or not the outline renderer is ready for a given submesh.
  71452. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71453. * @param subMesh Defines the submesh to check readyness for
  71454. * @param useInstances Defines wheter wee are trying to render instances or not
  71455. * @returns true if ready otherwise false
  71456. */
  71457. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71458. private _beforeRenderingMesh;
  71459. private _afterRenderingMesh;
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /**
  71464. * Defines the basic options interface of a Sprite Frame Source Size.
  71465. */
  71466. export interface ISpriteJSONSpriteSourceSize {
  71467. /**
  71468. * number of the original width of the Frame
  71469. */
  71470. w: number;
  71471. /**
  71472. * number of the original height of the Frame
  71473. */
  71474. h: number;
  71475. }
  71476. /**
  71477. * Defines the basic options interface of a Sprite Frame Data.
  71478. */
  71479. export interface ISpriteJSONSpriteFrameData {
  71480. /**
  71481. * number of the x offset of the Frame
  71482. */
  71483. x: number;
  71484. /**
  71485. * number of the y offset of the Frame
  71486. */
  71487. y: number;
  71488. /**
  71489. * number of the width of the Frame
  71490. */
  71491. w: number;
  71492. /**
  71493. * number of the height of the Frame
  71494. */
  71495. h: number;
  71496. }
  71497. /**
  71498. * Defines the basic options interface of a JSON Sprite.
  71499. */
  71500. export interface ISpriteJSONSprite {
  71501. /**
  71502. * string name of the Frame
  71503. */
  71504. filename: string;
  71505. /**
  71506. * ISpriteJSONSpriteFrame basic object of the frame data
  71507. */
  71508. frame: ISpriteJSONSpriteFrameData;
  71509. /**
  71510. * boolean to flag is the frame was rotated.
  71511. */
  71512. rotated: boolean;
  71513. /**
  71514. * boolean to flag is the frame was trimmed.
  71515. */
  71516. trimmed: boolean;
  71517. /**
  71518. * ISpriteJSONSpriteFrame basic object of the source data
  71519. */
  71520. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71521. /**
  71522. * ISpriteJSONSpriteFrame basic object of the source data
  71523. */
  71524. sourceSize: ISpriteJSONSpriteSourceSize;
  71525. }
  71526. /**
  71527. * Defines the basic options interface of a JSON atlas.
  71528. */
  71529. export interface ISpriteJSONAtlas {
  71530. /**
  71531. * Array of objects that contain the frame data.
  71532. */
  71533. frames: Array<ISpriteJSONSprite>;
  71534. /**
  71535. * object basic object containing the sprite meta data.
  71536. */
  71537. meta?: object;
  71538. }
  71539. }
  71540. declare module BABYLON {
  71541. /** @hidden */
  71542. export var spriteMapPixelShader: {
  71543. name: string;
  71544. shader: string;
  71545. };
  71546. }
  71547. declare module BABYLON {
  71548. /** @hidden */
  71549. export var spriteMapVertexShader: {
  71550. name: string;
  71551. shader: string;
  71552. };
  71553. }
  71554. declare module BABYLON {
  71555. /**
  71556. * Defines the basic options interface of a SpriteMap
  71557. */
  71558. export interface ISpriteMapOptions {
  71559. /**
  71560. * Vector2 of the number of cells in the grid.
  71561. */
  71562. stageSize?: Vector2;
  71563. /**
  71564. * Vector2 of the size of the output plane in World Units.
  71565. */
  71566. outputSize?: Vector2;
  71567. /**
  71568. * Vector3 of the position of the output plane in World Units.
  71569. */
  71570. outputPosition?: Vector3;
  71571. /**
  71572. * Vector3 of the rotation of the output plane.
  71573. */
  71574. outputRotation?: Vector3;
  71575. /**
  71576. * number of layers that the system will reserve in resources.
  71577. */
  71578. layerCount?: number;
  71579. /**
  71580. * number of max animation frames a single cell will reserve in resources.
  71581. */
  71582. maxAnimationFrames?: number;
  71583. /**
  71584. * number cell index of the base tile when the system compiles.
  71585. */
  71586. baseTile?: number;
  71587. /**
  71588. * boolean flip the sprite after its been repositioned by the framing data.
  71589. */
  71590. flipU?: boolean;
  71591. /**
  71592. * Vector3 scalar of the global RGB values of the SpriteMap.
  71593. */
  71594. colorMultiply?: Vector3;
  71595. }
  71596. /**
  71597. * Defines the IDisposable interface in order to be cleanable from resources.
  71598. */
  71599. export interface ISpriteMap extends IDisposable {
  71600. /**
  71601. * String name of the SpriteMap.
  71602. */
  71603. name: string;
  71604. /**
  71605. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71606. */
  71607. atlasJSON: ISpriteJSONAtlas;
  71608. /**
  71609. * Texture of the SpriteMap.
  71610. */
  71611. spriteSheet: Texture;
  71612. /**
  71613. * The parameters to initialize the SpriteMap with.
  71614. */
  71615. options: ISpriteMapOptions;
  71616. }
  71617. /**
  71618. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71619. */
  71620. export class SpriteMap implements ISpriteMap {
  71621. /** The Name of the spriteMap */
  71622. name: string;
  71623. /** The JSON file with the frame and meta data */
  71624. atlasJSON: ISpriteJSONAtlas;
  71625. /** The systems Sprite Sheet Texture */
  71626. spriteSheet: Texture;
  71627. /** Arguments passed with the Constructor */
  71628. options: ISpriteMapOptions;
  71629. /** Public Sprite Storage array, parsed from atlasJSON */
  71630. sprites: Array<ISpriteJSONSprite>;
  71631. /** Returns the Number of Sprites in the System */
  71632. get spriteCount(): number;
  71633. /** Returns the Position of Output Plane*/
  71634. get position(): Vector3;
  71635. /** Returns the Position of Output Plane*/
  71636. set position(v: Vector3);
  71637. /** Returns the Rotation of Output Plane*/
  71638. get rotation(): Vector3;
  71639. /** Returns the Rotation of Output Plane*/
  71640. set rotation(v: Vector3);
  71641. /** Sets the AnimationMap*/
  71642. get animationMap(): RawTexture;
  71643. /** Sets the AnimationMap*/
  71644. set animationMap(v: RawTexture);
  71645. /** Scene that the SpriteMap was created in */
  71646. private _scene;
  71647. /** Texture Buffer of Float32 that holds tile frame data*/
  71648. private _frameMap;
  71649. /** Texture Buffers of Float32 that holds tileMap data*/
  71650. private _tileMaps;
  71651. /** Texture Buffer of Float32 that holds Animation Data*/
  71652. private _animationMap;
  71653. /** Custom ShaderMaterial Central to the System*/
  71654. private _material;
  71655. /** Custom ShaderMaterial Central to the System*/
  71656. private _output;
  71657. /** Systems Time Ticker*/
  71658. private _time;
  71659. /**
  71660. * Creates a new SpriteMap
  71661. * @param name defines the SpriteMaps Name
  71662. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71663. * @param spriteSheet is the Texture that the Sprites are on.
  71664. * @param options a basic deployment configuration
  71665. * @param scene The Scene that the map is deployed on
  71666. */
  71667. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71668. /**
  71669. * Returns tileID location
  71670. * @returns Vector2 the cell position ID
  71671. */
  71672. getTileID(): Vector2;
  71673. /**
  71674. * Gets the UV location of the mouse over the SpriteMap.
  71675. * @returns Vector2 the UV position of the mouse interaction
  71676. */
  71677. getMousePosition(): Vector2;
  71678. /**
  71679. * Creates the "frame" texture Buffer
  71680. * -------------------------------------
  71681. * Structure of frames
  71682. * "filename": "Falling-Water-2.png",
  71683. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71684. * "rotated": true,
  71685. * "trimmed": true,
  71686. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71687. * "sourceSize": {"w":32,"h":32}
  71688. * @returns RawTexture of the frameMap
  71689. */
  71690. private _createFrameBuffer;
  71691. /**
  71692. * Creates the tileMap texture Buffer
  71693. * @param buffer normally and array of numbers, or a false to generate from scratch
  71694. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71695. * @returns RawTexture of the tileMap
  71696. */
  71697. private _createTileBuffer;
  71698. /**
  71699. * Modifies the data of the tileMaps
  71700. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71701. * @param pos is the iVector2 Coordinates of the Tile
  71702. * @param tile The SpriteIndex of the new Tile
  71703. */
  71704. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71705. /**
  71706. * Creates the animationMap texture Buffer
  71707. * @param buffer normally and array of numbers, or a false to generate from scratch
  71708. * @returns RawTexture of the animationMap
  71709. */
  71710. private _createTileAnimationBuffer;
  71711. /**
  71712. * Modifies the data of the animationMap
  71713. * @param cellID is the Index of the Sprite
  71714. * @param _frame is the target Animation frame
  71715. * @param toCell is the Target Index of the next frame of the animation
  71716. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71717. * @param speed is a global scalar of the time variable on the map.
  71718. */
  71719. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71720. /**
  71721. * Exports the .tilemaps file
  71722. */
  71723. saveTileMaps(): void;
  71724. /**
  71725. * Imports the .tilemaps file
  71726. * @param url of the .tilemaps file
  71727. */
  71728. loadTileMaps(url: string): void;
  71729. /**
  71730. * Release associated resources
  71731. */
  71732. dispose(): void;
  71733. }
  71734. }
  71735. declare module BABYLON {
  71736. /**
  71737. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71738. * @see https://doc.babylonjs.com/babylon101/sprites
  71739. */
  71740. export class SpritePackedManager extends SpriteManager {
  71741. /** defines the packed manager's name */
  71742. name: string;
  71743. /**
  71744. * Creates a new sprite manager from a packed sprite sheet
  71745. * @param name defines the manager's name
  71746. * @param imgUrl defines the sprite sheet url
  71747. * @param capacity defines the maximum allowed number of sprites
  71748. * @param scene defines the hosting scene
  71749. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71750. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71751. * @param samplingMode defines the smapling mode to use with spritesheet
  71752. * @param fromPacked set to true; do not alter
  71753. */
  71754. constructor(
  71755. /** defines the packed manager's name */
  71756. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71757. }
  71758. }
  71759. declare module BABYLON {
  71760. /**
  71761. * Defines the list of states available for a task inside a AssetsManager
  71762. */
  71763. export enum AssetTaskState {
  71764. /**
  71765. * Initialization
  71766. */
  71767. INIT = 0,
  71768. /**
  71769. * Running
  71770. */
  71771. RUNNING = 1,
  71772. /**
  71773. * Done
  71774. */
  71775. DONE = 2,
  71776. /**
  71777. * Error
  71778. */
  71779. ERROR = 3
  71780. }
  71781. /**
  71782. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71783. */
  71784. export abstract class AbstractAssetTask {
  71785. /**
  71786. * Task name
  71787. */ name: string;
  71788. /**
  71789. * Callback called when the task is successful
  71790. */
  71791. onSuccess: (task: any) => void;
  71792. /**
  71793. * Callback called when the task is not successful
  71794. */
  71795. onError: (task: any, message?: string, exception?: any) => void;
  71796. /**
  71797. * Creates a new AssetsManager
  71798. * @param name defines the name of the task
  71799. */
  71800. constructor(
  71801. /**
  71802. * Task name
  71803. */ name: string);
  71804. private _isCompleted;
  71805. private _taskState;
  71806. private _errorObject;
  71807. /**
  71808. * Get if the task is completed
  71809. */
  71810. get isCompleted(): boolean;
  71811. /**
  71812. * Gets the current state of the task
  71813. */
  71814. get taskState(): AssetTaskState;
  71815. /**
  71816. * Gets the current error object (if task is in error)
  71817. */
  71818. get errorObject(): {
  71819. message?: string;
  71820. exception?: any;
  71821. };
  71822. /**
  71823. * Internal only
  71824. * @hidden
  71825. */
  71826. _setErrorObject(message?: string, exception?: any): void;
  71827. /**
  71828. * Execute the current task
  71829. * @param scene defines the scene where you want your assets to be loaded
  71830. * @param onSuccess is a callback called when the task is successfully executed
  71831. * @param onError is a callback called if an error occurs
  71832. */
  71833. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71834. /**
  71835. * Execute the current task
  71836. * @param scene defines the scene where you want your assets to be loaded
  71837. * @param onSuccess is a callback called when the task is successfully executed
  71838. * @param onError is a callback called if an error occurs
  71839. */
  71840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71841. /**
  71842. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71843. * This can be used with failed tasks that have the reason for failure fixed.
  71844. */
  71845. reset(): void;
  71846. private onErrorCallback;
  71847. private onDoneCallback;
  71848. }
  71849. /**
  71850. * Define the interface used by progress events raised during assets loading
  71851. */
  71852. export interface IAssetsProgressEvent {
  71853. /**
  71854. * Defines the number of remaining tasks to process
  71855. */
  71856. remainingCount: number;
  71857. /**
  71858. * Defines the total number of tasks
  71859. */
  71860. totalCount: number;
  71861. /**
  71862. * Defines the task that was just processed
  71863. */
  71864. task: AbstractAssetTask;
  71865. }
  71866. /**
  71867. * Class used to share progress information about assets loading
  71868. */
  71869. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71870. /**
  71871. * Defines the number of remaining tasks to process
  71872. */
  71873. remainingCount: number;
  71874. /**
  71875. * Defines the total number of tasks
  71876. */
  71877. totalCount: number;
  71878. /**
  71879. * Defines the task that was just processed
  71880. */
  71881. task: AbstractAssetTask;
  71882. /**
  71883. * Creates a AssetsProgressEvent
  71884. * @param remainingCount defines the number of remaining tasks to process
  71885. * @param totalCount defines the total number of tasks
  71886. * @param task defines the task that was just processed
  71887. */
  71888. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71889. }
  71890. /**
  71891. * Define a task used by AssetsManager to load meshes
  71892. */
  71893. export class MeshAssetTask extends AbstractAssetTask {
  71894. /**
  71895. * Defines the name of the task
  71896. */
  71897. name: string;
  71898. /**
  71899. * Defines the list of mesh's names you want to load
  71900. */
  71901. meshesNames: any;
  71902. /**
  71903. * Defines the root url to use as a base to load your meshes and associated resources
  71904. */
  71905. rootUrl: string;
  71906. /**
  71907. * Defines the filename or File of the scene to load from
  71908. */
  71909. sceneFilename: string | File;
  71910. /**
  71911. * Gets the list of loaded meshes
  71912. */
  71913. loadedMeshes: Array<AbstractMesh>;
  71914. /**
  71915. * Gets the list of loaded particle systems
  71916. */
  71917. loadedParticleSystems: Array<IParticleSystem>;
  71918. /**
  71919. * Gets the list of loaded skeletons
  71920. */
  71921. loadedSkeletons: Array<Skeleton>;
  71922. /**
  71923. * Gets the list of loaded animation groups
  71924. */
  71925. loadedAnimationGroups: Array<AnimationGroup>;
  71926. /**
  71927. * Callback called when the task is successful
  71928. */
  71929. onSuccess: (task: MeshAssetTask) => void;
  71930. /**
  71931. * Callback called when the task is successful
  71932. */
  71933. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71934. /**
  71935. * Creates a new MeshAssetTask
  71936. * @param name defines the name of the task
  71937. * @param meshesNames defines the list of mesh's names you want to load
  71938. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71939. * @param sceneFilename defines the filename or File of the scene to load from
  71940. */
  71941. constructor(
  71942. /**
  71943. * Defines the name of the task
  71944. */
  71945. name: string,
  71946. /**
  71947. * Defines the list of mesh's names you want to load
  71948. */
  71949. meshesNames: any,
  71950. /**
  71951. * Defines the root url to use as a base to load your meshes and associated resources
  71952. */
  71953. rootUrl: string,
  71954. /**
  71955. * Defines the filename or File of the scene to load from
  71956. */
  71957. sceneFilename: string | File);
  71958. /**
  71959. * Execute the current task
  71960. * @param scene defines the scene where you want your assets to be loaded
  71961. * @param onSuccess is a callback called when the task is successfully executed
  71962. * @param onError is a callback called if an error occurs
  71963. */
  71964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71965. }
  71966. /**
  71967. * Define a task used by AssetsManager to load text content
  71968. */
  71969. export class TextFileAssetTask extends AbstractAssetTask {
  71970. /**
  71971. * Defines the name of the task
  71972. */
  71973. name: string;
  71974. /**
  71975. * Defines the location of the file to load
  71976. */
  71977. url: string;
  71978. /**
  71979. * Gets the loaded text string
  71980. */
  71981. text: string;
  71982. /**
  71983. * Callback called when the task is successful
  71984. */
  71985. onSuccess: (task: TextFileAssetTask) => void;
  71986. /**
  71987. * Callback called when the task is successful
  71988. */
  71989. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71990. /**
  71991. * Creates a new TextFileAssetTask object
  71992. * @param name defines the name of the task
  71993. * @param url defines the location of the file to load
  71994. */
  71995. constructor(
  71996. /**
  71997. * Defines the name of the task
  71998. */
  71999. name: string,
  72000. /**
  72001. * Defines the location of the file to load
  72002. */
  72003. url: string);
  72004. /**
  72005. * Execute the current task
  72006. * @param scene defines the scene where you want your assets to be loaded
  72007. * @param onSuccess is a callback called when the task is successfully executed
  72008. * @param onError is a callback called if an error occurs
  72009. */
  72010. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72011. }
  72012. /**
  72013. * Define a task used by AssetsManager to load binary data
  72014. */
  72015. export class BinaryFileAssetTask extends AbstractAssetTask {
  72016. /**
  72017. * Defines the name of the task
  72018. */
  72019. name: string;
  72020. /**
  72021. * Defines the location of the file to load
  72022. */
  72023. url: string;
  72024. /**
  72025. * Gets the lodaded data (as an array buffer)
  72026. */
  72027. data: ArrayBuffer;
  72028. /**
  72029. * Callback called when the task is successful
  72030. */
  72031. onSuccess: (task: BinaryFileAssetTask) => void;
  72032. /**
  72033. * Callback called when the task is successful
  72034. */
  72035. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72036. /**
  72037. * Creates a new BinaryFileAssetTask object
  72038. * @param name defines the name of the new task
  72039. * @param url defines the location of the file to load
  72040. */
  72041. constructor(
  72042. /**
  72043. * Defines the name of the task
  72044. */
  72045. name: string,
  72046. /**
  72047. * Defines the location of the file to load
  72048. */
  72049. url: string);
  72050. /**
  72051. * Execute the current task
  72052. * @param scene defines the scene where you want your assets to be loaded
  72053. * @param onSuccess is a callback called when the task is successfully executed
  72054. * @param onError is a callback called if an error occurs
  72055. */
  72056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72057. }
  72058. /**
  72059. * Define a task used by AssetsManager to load images
  72060. */
  72061. export class ImageAssetTask extends AbstractAssetTask {
  72062. /**
  72063. * Defines the name of the task
  72064. */
  72065. name: string;
  72066. /**
  72067. * Defines the location of the image to load
  72068. */
  72069. url: string;
  72070. /**
  72071. * Gets the loaded images
  72072. */
  72073. image: HTMLImageElement;
  72074. /**
  72075. * Callback called when the task is successful
  72076. */
  72077. onSuccess: (task: ImageAssetTask) => void;
  72078. /**
  72079. * Callback called when the task is successful
  72080. */
  72081. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72082. /**
  72083. * Creates a new ImageAssetTask
  72084. * @param name defines the name of the task
  72085. * @param url defines the location of the image to load
  72086. */
  72087. constructor(
  72088. /**
  72089. * Defines the name of the task
  72090. */
  72091. name: string,
  72092. /**
  72093. * Defines the location of the image to load
  72094. */
  72095. url: string);
  72096. /**
  72097. * Execute the current task
  72098. * @param scene defines the scene where you want your assets to be loaded
  72099. * @param onSuccess is a callback called when the task is successfully executed
  72100. * @param onError is a callback called if an error occurs
  72101. */
  72102. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72103. }
  72104. /**
  72105. * Defines the interface used by texture loading tasks
  72106. */
  72107. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72108. /**
  72109. * Gets the loaded texture
  72110. */
  72111. texture: TEX;
  72112. }
  72113. /**
  72114. * Define a task used by AssetsManager to load 2D textures
  72115. */
  72116. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72117. /**
  72118. * Defines the name of the task
  72119. */
  72120. name: string;
  72121. /**
  72122. * Defines the location of the file to load
  72123. */
  72124. url: string;
  72125. /**
  72126. * Defines if mipmap should not be generated (default is false)
  72127. */
  72128. noMipmap?: boolean | undefined;
  72129. /**
  72130. * Defines if texture must be inverted on Y axis (default is true)
  72131. */
  72132. invertY: boolean;
  72133. /**
  72134. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72135. */
  72136. samplingMode: number;
  72137. /**
  72138. * Gets the loaded texture
  72139. */
  72140. texture: Texture;
  72141. /**
  72142. * Callback called when the task is successful
  72143. */
  72144. onSuccess: (task: TextureAssetTask) => void;
  72145. /**
  72146. * Callback called when the task is successful
  72147. */
  72148. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72149. /**
  72150. * Creates a new TextureAssetTask object
  72151. * @param name defines the name of the task
  72152. * @param url defines the location of the file to load
  72153. * @param noMipmap defines if mipmap should not be generated (default is false)
  72154. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72155. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72156. */
  72157. constructor(
  72158. /**
  72159. * Defines the name of the task
  72160. */
  72161. name: string,
  72162. /**
  72163. * Defines the location of the file to load
  72164. */
  72165. url: string,
  72166. /**
  72167. * Defines if mipmap should not be generated (default is false)
  72168. */
  72169. noMipmap?: boolean | undefined,
  72170. /**
  72171. * Defines if texture must be inverted on Y axis (default is true)
  72172. */
  72173. invertY?: boolean,
  72174. /**
  72175. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72176. */
  72177. samplingMode?: number);
  72178. /**
  72179. * Execute the current task
  72180. * @param scene defines the scene where you want your assets to be loaded
  72181. * @param onSuccess is a callback called when the task is successfully executed
  72182. * @param onError is a callback called if an error occurs
  72183. */
  72184. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72185. }
  72186. /**
  72187. * Define a task used by AssetsManager to load cube textures
  72188. */
  72189. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72190. /**
  72191. * Defines the name of the task
  72192. */
  72193. name: string;
  72194. /**
  72195. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72196. */
  72197. url: string;
  72198. /**
  72199. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72200. */
  72201. extensions?: string[] | undefined;
  72202. /**
  72203. * Defines if mipmaps should not be generated (default is false)
  72204. */
  72205. noMipmap?: boolean | undefined;
  72206. /**
  72207. * Defines the explicit list of files (undefined by default)
  72208. */
  72209. files?: string[] | undefined;
  72210. /**
  72211. * Gets the loaded texture
  72212. */
  72213. texture: CubeTexture;
  72214. /**
  72215. * Callback called when the task is successful
  72216. */
  72217. onSuccess: (task: CubeTextureAssetTask) => void;
  72218. /**
  72219. * Callback called when the task is successful
  72220. */
  72221. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72222. /**
  72223. * Creates a new CubeTextureAssetTask
  72224. * @param name defines the name of the task
  72225. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72226. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72227. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72228. * @param files defines the explicit list of files (undefined by default)
  72229. */
  72230. constructor(
  72231. /**
  72232. * Defines the name of the task
  72233. */
  72234. name: string,
  72235. /**
  72236. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72237. */
  72238. url: string,
  72239. /**
  72240. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72241. */
  72242. extensions?: string[] | undefined,
  72243. /**
  72244. * Defines if mipmaps should not be generated (default is false)
  72245. */
  72246. noMipmap?: boolean | undefined,
  72247. /**
  72248. * Defines the explicit list of files (undefined by default)
  72249. */
  72250. files?: string[] | undefined);
  72251. /**
  72252. * Execute the current task
  72253. * @param scene defines the scene where you want your assets to be loaded
  72254. * @param onSuccess is a callback called when the task is successfully executed
  72255. * @param onError is a callback called if an error occurs
  72256. */
  72257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72258. }
  72259. /**
  72260. * Define a task used by AssetsManager to load HDR cube textures
  72261. */
  72262. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72263. /**
  72264. * Defines the name of the task
  72265. */
  72266. name: string;
  72267. /**
  72268. * Defines the location of the file to load
  72269. */
  72270. url: string;
  72271. /**
  72272. * Defines the desired size (the more it increases the longer the generation will be)
  72273. */
  72274. size: number;
  72275. /**
  72276. * Defines if mipmaps should not be generated (default is false)
  72277. */
  72278. noMipmap: boolean;
  72279. /**
  72280. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72281. */
  72282. generateHarmonics: boolean;
  72283. /**
  72284. * 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)
  72285. */
  72286. gammaSpace: boolean;
  72287. /**
  72288. * Internal Use Only
  72289. */
  72290. reserved: boolean;
  72291. /**
  72292. * Gets the loaded texture
  72293. */
  72294. texture: HDRCubeTexture;
  72295. /**
  72296. * Callback called when the task is successful
  72297. */
  72298. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72299. /**
  72300. * Callback called when the task is successful
  72301. */
  72302. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72303. /**
  72304. * Creates a new HDRCubeTextureAssetTask object
  72305. * @param name defines the name of the task
  72306. * @param url defines the location of the file to load
  72307. * @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.
  72308. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72309. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72310. * @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)
  72311. * @param reserved Internal use only
  72312. */
  72313. constructor(
  72314. /**
  72315. * Defines the name of the task
  72316. */
  72317. name: string,
  72318. /**
  72319. * Defines the location of the file to load
  72320. */
  72321. url: string,
  72322. /**
  72323. * Defines the desired size (the more it increases the longer the generation will be)
  72324. */
  72325. size: number,
  72326. /**
  72327. * Defines if mipmaps should not be generated (default is false)
  72328. */
  72329. noMipmap?: boolean,
  72330. /**
  72331. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72332. */
  72333. generateHarmonics?: boolean,
  72334. /**
  72335. * 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)
  72336. */
  72337. gammaSpace?: boolean,
  72338. /**
  72339. * Internal Use Only
  72340. */
  72341. reserved?: boolean);
  72342. /**
  72343. * Execute the current task
  72344. * @param scene defines the scene where you want your assets to be loaded
  72345. * @param onSuccess is a callback called when the task is successfully executed
  72346. * @param onError is a callback called if an error occurs
  72347. */
  72348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72349. }
  72350. /**
  72351. * Define a task used by AssetsManager to load Equirectangular cube textures
  72352. */
  72353. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72354. /**
  72355. * Defines the name of the task
  72356. */
  72357. name: string;
  72358. /**
  72359. * Defines the location of the file to load
  72360. */
  72361. url: string;
  72362. /**
  72363. * Defines the desired size (the more it increases the longer the generation will be)
  72364. */
  72365. size: number;
  72366. /**
  72367. * Defines if mipmaps should not be generated (default is false)
  72368. */
  72369. noMipmap: boolean;
  72370. /**
  72371. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72372. * but the standard material would require them in Gamma space) (default is true)
  72373. */
  72374. gammaSpace: boolean;
  72375. /**
  72376. * Gets the loaded texture
  72377. */
  72378. texture: EquiRectangularCubeTexture;
  72379. /**
  72380. * Callback called when the task is successful
  72381. */
  72382. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72383. /**
  72384. * Callback called when the task is successful
  72385. */
  72386. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72387. /**
  72388. * Creates a new EquiRectangularCubeTextureAssetTask object
  72389. * @param name defines the name of the task
  72390. * @param url defines the location of the file to load
  72391. * @param size defines the desired size (the more it increases the longer the generation will be)
  72392. * If the size is omitted this implies you are using a preprocessed cubemap.
  72393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72394. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72395. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72396. * (default is true)
  72397. */
  72398. constructor(
  72399. /**
  72400. * Defines the name of the task
  72401. */
  72402. name: string,
  72403. /**
  72404. * Defines the location of the file to load
  72405. */
  72406. url: string,
  72407. /**
  72408. * Defines the desired size (the more it increases the longer the generation will be)
  72409. */
  72410. size: number,
  72411. /**
  72412. * Defines if mipmaps should not be generated (default is false)
  72413. */
  72414. noMipmap?: boolean,
  72415. /**
  72416. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72417. * but the standard material would require them in Gamma space) (default is true)
  72418. */
  72419. gammaSpace?: boolean);
  72420. /**
  72421. * Execute the current task
  72422. * @param scene defines the scene where you want your assets to be loaded
  72423. * @param onSuccess is a callback called when the task is successfully executed
  72424. * @param onError is a callback called if an error occurs
  72425. */
  72426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72427. }
  72428. /**
  72429. * This class can be used to easily import assets into a scene
  72430. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72431. */
  72432. export class AssetsManager {
  72433. private _scene;
  72434. private _isLoading;
  72435. protected _tasks: AbstractAssetTask[];
  72436. protected _waitingTasksCount: number;
  72437. protected _totalTasksCount: number;
  72438. /**
  72439. * Callback called when all tasks are processed
  72440. */
  72441. onFinish: (tasks: AbstractAssetTask[]) => void;
  72442. /**
  72443. * Callback called when a task is successful
  72444. */
  72445. onTaskSuccess: (task: AbstractAssetTask) => void;
  72446. /**
  72447. * Callback called when a task had an error
  72448. */
  72449. onTaskError: (task: AbstractAssetTask) => void;
  72450. /**
  72451. * Callback called when a task is done (whatever the result is)
  72452. */
  72453. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72454. /**
  72455. * Observable called when all tasks are processed
  72456. */
  72457. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72458. /**
  72459. * Observable called when a task had an error
  72460. */
  72461. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72462. /**
  72463. * Observable called when all tasks were executed
  72464. */
  72465. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72466. /**
  72467. * Observable called when a task is done (whatever the result is)
  72468. */
  72469. onProgressObservable: Observable<IAssetsProgressEvent>;
  72470. /**
  72471. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72472. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72473. */
  72474. useDefaultLoadingScreen: boolean;
  72475. /**
  72476. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72477. * when all assets have been downloaded.
  72478. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72479. */
  72480. autoHideLoadingUI: boolean;
  72481. /**
  72482. * Creates a new AssetsManager
  72483. * @param scene defines the scene to work on
  72484. */
  72485. constructor(scene: Scene);
  72486. /**
  72487. * Add a MeshAssetTask to the list of active tasks
  72488. * @param taskName defines the name of the new task
  72489. * @param meshesNames defines the name of meshes to load
  72490. * @param rootUrl defines the root url to use to locate files
  72491. * @param sceneFilename defines the filename of the scene file
  72492. * @returns a new MeshAssetTask object
  72493. */
  72494. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72495. /**
  72496. * Add a TextFileAssetTask to the list of active tasks
  72497. * @param taskName defines the name of the new task
  72498. * @param url defines the url of the file to load
  72499. * @returns a new TextFileAssetTask object
  72500. */
  72501. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72502. /**
  72503. * Add a BinaryFileAssetTask to the list of active tasks
  72504. * @param taskName defines the name of the new task
  72505. * @param url defines the url of the file to load
  72506. * @returns a new BinaryFileAssetTask object
  72507. */
  72508. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72509. /**
  72510. * Add a ImageAssetTask to the list of active tasks
  72511. * @param taskName defines the name of the new task
  72512. * @param url defines the url of the file to load
  72513. * @returns a new ImageAssetTask object
  72514. */
  72515. addImageTask(taskName: string, url: string): ImageAssetTask;
  72516. /**
  72517. * Add a TextureAssetTask to the list of active tasks
  72518. * @param taskName defines the name of the new task
  72519. * @param url defines the url of the file to load
  72520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72521. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72522. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72523. * @returns a new TextureAssetTask object
  72524. */
  72525. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72526. /**
  72527. * Add a CubeTextureAssetTask to the list of active tasks
  72528. * @param taskName defines the name of the new task
  72529. * @param url defines the url of the file to load
  72530. * @param extensions defines the extension to use to load the cube map (can be null)
  72531. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72532. * @param files defines the list of files to load (can be null)
  72533. * @returns a new CubeTextureAssetTask object
  72534. */
  72535. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72536. /**
  72537. *
  72538. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72539. * @param taskName defines the name of the new task
  72540. * @param url defines the url of the file to load
  72541. * @param size defines the size you want for the cubemap (can be null)
  72542. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72543. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72544. * @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)
  72545. * @param reserved Internal use only
  72546. * @returns a new HDRCubeTextureAssetTask object
  72547. */
  72548. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72549. /**
  72550. *
  72551. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72552. * @param taskName defines the name of the new task
  72553. * @param url defines the url of the file to load
  72554. * @param size defines the size you want for the cubemap (can be null)
  72555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72556. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72557. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72558. * @returns a new EquiRectangularCubeTextureAssetTask object
  72559. */
  72560. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72561. /**
  72562. * Remove a task from the assets manager.
  72563. * @param task the task to remove
  72564. */
  72565. removeTask(task: AbstractAssetTask): void;
  72566. private _decreaseWaitingTasksCount;
  72567. private _runTask;
  72568. /**
  72569. * Reset the AssetsManager and remove all tasks
  72570. * @return the current instance of the AssetsManager
  72571. */
  72572. reset(): AssetsManager;
  72573. /**
  72574. * Start the loading process
  72575. * @return the current instance of the AssetsManager
  72576. */
  72577. load(): AssetsManager;
  72578. /**
  72579. * Start the loading process as an async operation
  72580. * @return a promise returning the list of failed tasks
  72581. */
  72582. loadAsync(): Promise<void>;
  72583. }
  72584. }
  72585. declare module BABYLON {
  72586. /**
  72587. * Wrapper class for promise with external resolve and reject.
  72588. */
  72589. export class Deferred<T> {
  72590. /**
  72591. * The promise associated with this deferred object.
  72592. */
  72593. readonly promise: Promise<T>;
  72594. private _resolve;
  72595. private _reject;
  72596. /**
  72597. * The resolve method of the promise associated with this deferred object.
  72598. */
  72599. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72600. /**
  72601. * The reject method of the promise associated with this deferred object.
  72602. */
  72603. get reject(): (reason?: any) => void;
  72604. /**
  72605. * Constructor for this deferred object.
  72606. */
  72607. constructor();
  72608. }
  72609. }
  72610. declare module BABYLON {
  72611. /**
  72612. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72613. */
  72614. export class MeshExploder {
  72615. private _centerMesh;
  72616. private _meshes;
  72617. private _meshesOrigins;
  72618. private _toCenterVectors;
  72619. private _scaledDirection;
  72620. private _newPosition;
  72621. private _centerPosition;
  72622. /**
  72623. * Explodes meshes from a center mesh.
  72624. * @param meshes The meshes to explode.
  72625. * @param centerMesh The mesh to be center of explosion.
  72626. */
  72627. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72628. private _setCenterMesh;
  72629. /**
  72630. * Get class name
  72631. * @returns "MeshExploder"
  72632. */
  72633. getClassName(): string;
  72634. /**
  72635. * "Exploded meshes"
  72636. * @returns Array of meshes with the centerMesh at index 0.
  72637. */
  72638. getMeshes(): Array<Mesh>;
  72639. /**
  72640. * Explodes meshes giving a specific direction
  72641. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72642. */
  72643. explode(direction?: number): void;
  72644. }
  72645. }
  72646. declare module BABYLON {
  72647. /**
  72648. * Class used to help managing file picking and drag'n'drop
  72649. */
  72650. export class FilesInput {
  72651. /**
  72652. * List of files ready to be loaded
  72653. */
  72654. static get FilesToLoad(): {
  72655. [key: string]: File;
  72656. };
  72657. /**
  72658. * Callback called when a file is processed
  72659. */
  72660. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72661. private _engine;
  72662. private _currentScene;
  72663. private _sceneLoadedCallback;
  72664. private _progressCallback;
  72665. private _additionalRenderLoopLogicCallback;
  72666. private _textureLoadingCallback;
  72667. private _startingProcessingFilesCallback;
  72668. private _onReloadCallback;
  72669. private _errorCallback;
  72670. private _elementToMonitor;
  72671. private _sceneFileToLoad;
  72672. private _filesToLoad;
  72673. /**
  72674. * Creates a new FilesInput
  72675. * @param engine defines the rendering engine
  72676. * @param scene defines the hosting scene
  72677. * @param sceneLoadedCallback callback called when scene is loaded
  72678. * @param progressCallback callback called to track progress
  72679. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72680. * @param textureLoadingCallback callback called when a texture is loading
  72681. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72682. * @param onReloadCallback callback called when a reload is requested
  72683. * @param errorCallback callback call if an error occurs
  72684. */
  72685. 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>);
  72686. private _dragEnterHandler;
  72687. private _dragOverHandler;
  72688. private _dropHandler;
  72689. /**
  72690. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72691. * @param elementToMonitor defines the DOM element to track
  72692. */
  72693. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72694. /** Gets the current list of files to load */
  72695. get filesToLoad(): File[];
  72696. /**
  72697. * Release all associated resources
  72698. */
  72699. dispose(): void;
  72700. private renderFunction;
  72701. private drag;
  72702. private drop;
  72703. private _traverseFolder;
  72704. private _processFiles;
  72705. /**
  72706. * Load files from a drop event
  72707. * @param event defines the drop event to use as source
  72708. */
  72709. loadFiles(event: any): void;
  72710. private _processReload;
  72711. /**
  72712. * Reload the current scene from the loaded files
  72713. */
  72714. reload(): void;
  72715. }
  72716. }
  72717. declare module BABYLON {
  72718. /**
  72719. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72720. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72721. */
  72722. export class SceneOptimization {
  72723. /**
  72724. * Defines the priority of this optimization (0 by default which means first in the list)
  72725. */
  72726. priority: number;
  72727. /**
  72728. * Gets a string describing the action executed by the current optimization
  72729. * @returns description string
  72730. */
  72731. getDescription(): string;
  72732. /**
  72733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72734. * @param scene defines the current scene where to apply this optimization
  72735. * @param optimizer defines the current optimizer
  72736. * @returns true if everything that can be done was applied
  72737. */
  72738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72739. /**
  72740. * Creates the SceneOptimization object
  72741. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72742. * @param desc defines the description associated with the optimization
  72743. */
  72744. constructor(
  72745. /**
  72746. * Defines the priority of this optimization (0 by default which means first in the list)
  72747. */
  72748. priority?: number);
  72749. }
  72750. /**
  72751. * Defines an optimization used to reduce the size of render target textures
  72752. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72753. */
  72754. export class TextureOptimization extends SceneOptimization {
  72755. /**
  72756. * Defines the priority of this optimization (0 by default which means first in the list)
  72757. */
  72758. priority: number;
  72759. /**
  72760. * 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
  72761. */
  72762. maximumSize: number;
  72763. /**
  72764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72765. */
  72766. step: number;
  72767. /**
  72768. * Gets a string describing the action executed by the current optimization
  72769. * @returns description string
  72770. */
  72771. getDescription(): string;
  72772. /**
  72773. * Creates the TextureOptimization object
  72774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72775. * @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
  72776. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72777. */
  72778. constructor(
  72779. /**
  72780. * Defines the priority of this optimization (0 by default which means first in the list)
  72781. */
  72782. priority?: number,
  72783. /**
  72784. * 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
  72785. */
  72786. maximumSize?: number,
  72787. /**
  72788. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72789. */
  72790. step?: number);
  72791. /**
  72792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72793. * @param scene defines the current scene where to apply this optimization
  72794. * @param optimizer defines the current optimizer
  72795. * @returns true if everything that can be done was applied
  72796. */
  72797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72798. }
  72799. /**
  72800. * Defines an optimization used to increase or decrease the rendering resolution
  72801. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72802. */
  72803. export class HardwareScalingOptimization extends SceneOptimization {
  72804. /**
  72805. * Defines the priority of this optimization (0 by default which means first in the list)
  72806. */
  72807. priority: number;
  72808. /**
  72809. * Defines the maximum scale to use (2 by default)
  72810. */
  72811. maximumScale: number;
  72812. /**
  72813. * Defines the step to use between two passes (0.5 by default)
  72814. */
  72815. step: number;
  72816. private _currentScale;
  72817. private _directionOffset;
  72818. /**
  72819. * Gets a string describing the action executed by the current optimization
  72820. * @return description string
  72821. */
  72822. getDescription(): string;
  72823. /**
  72824. * Creates the HardwareScalingOptimization object
  72825. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72826. * @param maximumScale defines the maximum scale to use (2 by default)
  72827. * @param step defines the step to use between two passes (0.5 by default)
  72828. */
  72829. constructor(
  72830. /**
  72831. * Defines the priority of this optimization (0 by default which means first in the list)
  72832. */
  72833. priority?: number,
  72834. /**
  72835. * Defines the maximum scale to use (2 by default)
  72836. */
  72837. maximumScale?: number,
  72838. /**
  72839. * Defines the step to use between two passes (0.5 by default)
  72840. */
  72841. step?: number);
  72842. /**
  72843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72844. * @param scene defines the current scene where to apply this optimization
  72845. * @param optimizer defines the current optimizer
  72846. * @returns true if everything that can be done was applied
  72847. */
  72848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72849. }
  72850. /**
  72851. * Defines an optimization used to remove shadows
  72852. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72853. */
  72854. export class ShadowsOptimization extends SceneOptimization {
  72855. /**
  72856. * Gets a string describing the action executed by the current optimization
  72857. * @return description string
  72858. */
  72859. getDescription(): string;
  72860. /**
  72861. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72862. * @param scene defines the current scene where to apply this optimization
  72863. * @param optimizer defines the current optimizer
  72864. * @returns true if everything that can be done was applied
  72865. */
  72866. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72867. }
  72868. /**
  72869. * Defines an optimization used to turn post-processes off
  72870. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72871. */
  72872. export class PostProcessesOptimization extends SceneOptimization {
  72873. /**
  72874. * Gets a string describing the action executed by the current optimization
  72875. * @return description string
  72876. */
  72877. getDescription(): string;
  72878. /**
  72879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72880. * @param scene defines the current scene where to apply this optimization
  72881. * @param optimizer defines the current optimizer
  72882. * @returns true if everything that can be done was applied
  72883. */
  72884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72885. }
  72886. /**
  72887. * Defines an optimization used to turn lens flares off
  72888. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72889. */
  72890. export class LensFlaresOptimization extends SceneOptimization {
  72891. /**
  72892. * Gets a string describing the action executed by the current optimization
  72893. * @return description string
  72894. */
  72895. getDescription(): string;
  72896. /**
  72897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72898. * @param scene defines the current scene where to apply this optimization
  72899. * @param optimizer defines the current optimizer
  72900. * @returns true if everything that can be done was applied
  72901. */
  72902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72903. }
  72904. /**
  72905. * Defines an optimization based on user defined callback.
  72906. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72907. */
  72908. export class CustomOptimization extends SceneOptimization {
  72909. /**
  72910. * Callback called to apply the custom optimization.
  72911. */
  72912. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72913. /**
  72914. * Callback called to get custom description
  72915. */
  72916. onGetDescription: () => string;
  72917. /**
  72918. * Gets a string describing the action executed by the current optimization
  72919. * @returns description string
  72920. */
  72921. getDescription(): string;
  72922. /**
  72923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72924. * @param scene defines the current scene where to apply this optimization
  72925. * @param optimizer defines the current optimizer
  72926. * @returns true if everything that can be done was applied
  72927. */
  72928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72929. }
  72930. /**
  72931. * Defines an optimization used to turn particles off
  72932. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72933. */
  72934. export class ParticlesOptimization extends SceneOptimization {
  72935. /**
  72936. * Gets a string describing the action executed by the current optimization
  72937. * @return description string
  72938. */
  72939. getDescription(): string;
  72940. /**
  72941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72942. * @param scene defines the current scene where to apply this optimization
  72943. * @param optimizer defines the current optimizer
  72944. * @returns true if everything that can be done was applied
  72945. */
  72946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72947. }
  72948. /**
  72949. * Defines an optimization used to turn render targets off
  72950. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72951. */
  72952. export class RenderTargetsOptimization extends SceneOptimization {
  72953. /**
  72954. * Gets a string describing the action executed by the current optimization
  72955. * @return description string
  72956. */
  72957. getDescription(): string;
  72958. /**
  72959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72960. * @param scene defines the current scene where to apply this optimization
  72961. * @param optimizer defines the current optimizer
  72962. * @returns true if everything that can be done was applied
  72963. */
  72964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72965. }
  72966. /**
  72967. * Defines an optimization used to merge meshes with compatible materials
  72968. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72969. */
  72970. export class MergeMeshesOptimization extends SceneOptimization {
  72971. private static _UpdateSelectionTree;
  72972. /**
  72973. * Gets or sets a boolean which defines if optimization octree has to be updated
  72974. */
  72975. static get UpdateSelectionTree(): boolean;
  72976. /**
  72977. * Gets or sets a boolean which defines if optimization octree has to be updated
  72978. */
  72979. static set UpdateSelectionTree(value: boolean);
  72980. /**
  72981. * Gets a string describing the action executed by the current optimization
  72982. * @return description string
  72983. */
  72984. getDescription(): string;
  72985. private _canBeMerged;
  72986. /**
  72987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72988. * @param scene defines the current scene where to apply this optimization
  72989. * @param optimizer defines the current optimizer
  72990. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72991. * @returns true if everything that can be done was applied
  72992. */
  72993. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72994. }
  72995. /**
  72996. * Defines a list of options used by SceneOptimizer
  72997. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72998. */
  72999. export class SceneOptimizerOptions {
  73000. /**
  73001. * Defines the target frame rate to reach (60 by default)
  73002. */
  73003. targetFrameRate: number;
  73004. /**
  73005. * Defines the interval between two checkes (2000ms by default)
  73006. */
  73007. trackerDuration: number;
  73008. /**
  73009. * Gets the list of optimizations to apply
  73010. */
  73011. optimizations: SceneOptimization[];
  73012. /**
  73013. * Creates a new list of options used by SceneOptimizer
  73014. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73015. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73016. */
  73017. constructor(
  73018. /**
  73019. * Defines the target frame rate to reach (60 by default)
  73020. */
  73021. targetFrameRate?: number,
  73022. /**
  73023. * Defines the interval between two checkes (2000ms by default)
  73024. */
  73025. trackerDuration?: number);
  73026. /**
  73027. * Add a new optimization
  73028. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73029. * @returns the current SceneOptimizerOptions
  73030. */
  73031. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73032. /**
  73033. * Add a new custom optimization
  73034. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73035. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73037. * @returns the current SceneOptimizerOptions
  73038. */
  73039. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73040. /**
  73041. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73042. * @param targetFrameRate defines the target frame rate (60 by default)
  73043. * @returns a SceneOptimizerOptions object
  73044. */
  73045. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73046. /**
  73047. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73048. * @param targetFrameRate defines the target frame rate (60 by default)
  73049. * @returns a SceneOptimizerOptions object
  73050. */
  73051. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73052. /**
  73053. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73054. * @param targetFrameRate defines the target frame rate (60 by default)
  73055. * @returns a SceneOptimizerOptions object
  73056. */
  73057. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73058. }
  73059. /**
  73060. * Class used to run optimizations in order to reach a target frame rate
  73061. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73062. */
  73063. export class SceneOptimizer implements IDisposable {
  73064. private _isRunning;
  73065. private _options;
  73066. private _scene;
  73067. private _currentPriorityLevel;
  73068. private _targetFrameRate;
  73069. private _trackerDuration;
  73070. private _currentFrameRate;
  73071. private _sceneDisposeObserver;
  73072. private _improvementMode;
  73073. /**
  73074. * Defines an observable called when the optimizer reaches the target frame rate
  73075. */
  73076. onSuccessObservable: Observable<SceneOptimizer>;
  73077. /**
  73078. * Defines an observable called when the optimizer enables an optimization
  73079. */
  73080. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73081. /**
  73082. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73083. */
  73084. onFailureObservable: Observable<SceneOptimizer>;
  73085. /**
  73086. * Gets a boolean indicating if the optimizer is in improvement mode
  73087. */
  73088. get isInImprovementMode(): boolean;
  73089. /**
  73090. * Gets the current priority level (0 at start)
  73091. */
  73092. get currentPriorityLevel(): number;
  73093. /**
  73094. * Gets the current frame rate checked by the SceneOptimizer
  73095. */
  73096. get currentFrameRate(): number;
  73097. /**
  73098. * Gets or sets the current target frame rate (60 by default)
  73099. */
  73100. get targetFrameRate(): number;
  73101. /**
  73102. * Gets or sets the current target frame rate (60 by default)
  73103. */
  73104. set targetFrameRate(value: number);
  73105. /**
  73106. * Gets or sets the current interval between two checks (every 2000ms by default)
  73107. */
  73108. get trackerDuration(): number;
  73109. /**
  73110. * Gets or sets the current interval between two checks (every 2000ms by default)
  73111. */
  73112. set trackerDuration(value: number);
  73113. /**
  73114. * Gets the list of active optimizations
  73115. */
  73116. get optimizations(): SceneOptimization[];
  73117. /**
  73118. * Creates a new SceneOptimizer
  73119. * @param scene defines the scene to work on
  73120. * @param options defines the options to use with the SceneOptimizer
  73121. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73122. * @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)
  73123. */
  73124. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73125. /**
  73126. * Stops the current optimizer
  73127. */
  73128. stop(): void;
  73129. /**
  73130. * Reset the optimizer to initial step (current priority level = 0)
  73131. */
  73132. reset(): void;
  73133. /**
  73134. * Start the optimizer. By default it will try to reach a specific framerate
  73135. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73136. */
  73137. start(): void;
  73138. private _checkCurrentState;
  73139. /**
  73140. * Release all resources
  73141. */
  73142. dispose(): void;
  73143. /**
  73144. * Helper function to create a SceneOptimizer with one single line of code
  73145. * @param scene defines the scene to work on
  73146. * @param options defines the options to use with the SceneOptimizer
  73147. * @param onSuccess defines a callback to call on success
  73148. * @param onFailure defines a callback to call on failure
  73149. * @returns the new SceneOptimizer object
  73150. */
  73151. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73152. }
  73153. }
  73154. declare module BABYLON {
  73155. /**
  73156. * Class used to serialize a scene into a string
  73157. */
  73158. export class SceneSerializer {
  73159. /**
  73160. * Clear cache used by a previous serialization
  73161. */
  73162. static ClearCache(): void;
  73163. /**
  73164. * Serialize a scene into a JSON compatible object
  73165. * @param scene defines the scene to serialize
  73166. * @returns a JSON compatible object
  73167. */
  73168. static Serialize(scene: Scene): any;
  73169. /**
  73170. * Serialize a mesh into a JSON compatible object
  73171. * @param toSerialize defines the mesh to serialize
  73172. * @param withParents defines if parents must be serialized as well
  73173. * @param withChildren defines if children must be serialized as well
  73174. * @returns a JSON compatible object
  73175. */
  73176. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73177. }
  73178. }
  73179. declare module BABYLON {
  73180. /**
  73181. * Class used to host texture specific utilities
  73182. */
  73183. export class TextureTools {
  73184. /**
  73185. * Uses the GPU to create a copy texture rescaled at a given size
  73186. * @param texture Texture to copy from
  73187. * @param width defines the desired width
  73188. * @param height defines the desired height
  73189. * @param useBilinearMode defines if bilinear mode has to be used
  73190. * @return the generated texture
  73191. */
  73192. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73193. }
  73194. }
  73195. declare module BABYLON {
  73196. /**
  73197. * This represents the different options available for the video capture.
  73198. */
  73199. export interface VideoRecorderOptions {
  73200. /** Defines the mime type of the video. */
  73201. mimeType: string;
  73202. /** Defines the FPS the video should be recorded at. */
  73203. fps: number;
  73204. /** Defines the chunk size for the recording data. */
  73205. recordChunckSize: number;
  73206. /** The audio tracks to attach to the recording. */
  73207. audioTracks?: MediaStreamTrack[];
  73208. }
  73209. /**
  73210. * This can help with recording videos from BabylonJS.
  73211. * This is based on the available WebRTC functionalities of the browser.
  73212. *
  73213. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73214. */
  73215. export class VideoRecorder {
  73216. private static readonly _defaultOptions;
  73217. /**
  73218. * Returns whether or not the VideoRecorder is available in your browser.
  73219. * @param engine Defines the Babylon Engine.
  73220. * @returns true if supported otherwise false.
  73221. */
  73222. static IsSupported(engine: Engine): boolean;
  73223. private readonly _options;
  73224. private _canvas;
  73225. private _mediaRecorder;
  73226. private _recordedChunks;
  73227. private _fileName;
  73228. private _resolve;
  73229. private _reject;
  73230. /**
  73231. * True when a recording is already in progress.
  73232. */
  73233. get isRecording(): boolean;
  73234. /**
  73235. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73236. * @param engine Defines the BabylonJS Engine you wish to record.
  73237. * @param options Defines options that can be used to customize the capture.
  73238. */
  73239. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73240. /**
  73241. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73242. */
  73243. stopRecording(): void;
  73244. /**
  73245. * Starts recording the canvas for a max duration specified in parameters.
  73246. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73247. * If null no automatic download will start and you can rely on the promise to get the data back.
  73248. * @param maxDuration Defines the maximum recording time in seconds.
  73249. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73250. * @return A promise callback at the end of the recording with the video data in Blob.
  73251. */
  73252. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73253. /**
  73254. * Releases internal resources used during the recording.
  73255. */
  73256. dispose(): void;
  73257. private _handleDataAvailable;
  73258. private _handleError;
  73259. private _handleStop;
  73260. }
  73261. }
  73262. declare module BABYLON {
  73263. /**
  73264. * Class containing a set of static utilities functions for screenshots
  73265. */
  73266. export class ScreenshotTools {
  73267. /**
  73268. * Captures a screenshot of the current rendering
  73269. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73270. * @param engine defines the rendering engine
  73271. * @param camera defines the source camera
  73272. * @param size This parameter can be set to a single number or to an object with the
  73273. * following (optional) properties: precision, width, height. If a single number is passed,
  73274. * it will be used for both width and height. If an object is passed, the screenshot size
  73275. * will be derived from the parameters. The precision property is a multiplier allowing
  73276. * rendering at a higher or lower resolution
  73277. * @param successCallback defines the callback receives a single parameter which contains the
  73278. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73279. * src parameter of an <img> to display it
  73280. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73281. * Check your browser for supported MIME types
  73282. */
  73283. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73284. /**
  73285. * Captures a screenshot of the current rendering
  73286. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73287. * @param engine defines the rendering engine
  73288. * @param camera defines the source camera
  73289. * @param size This parameter can be set to a single number or to an object with the
  73290. * following (optional) properties: precision, width, height. If a single number is passed,
  73291. * it will be used for both width and height. If an object is passed, the screenshot size
  73292. * will be derived from the parameters. The precision property is a multiplier allowing
  73293. * rendering at a higher or lower resolution
  73294. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73295. * Check your browser for supported MIME types
  73296. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73297. * to the src parameter of an <img> to display it
  73298. */
  73299. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73300. /**
  73301. * Generates an image screenshot from the specified camera.
  73302. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73303. * @param engine The engine to use for rendering
  73304. * @param camera The camera to use for rendering
  73305. * @param size This parameter can be set to a single number or to an object with the
  73306. * following (optional) properties: precision, width, height. If a single number is passed,
  73307. * it will be used for both width and height. If an object is passed, the screenshot size
  73308. * will be derived from the parameters. The precision property is a multiplier allowing
  73309. * rendering at a higher or lower resolution
  73310. * @param successCallback The callback receives a single parameter which contains the
  73311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73312. * src parameter of an <img> to display it
  73313. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73314. * Check your browser for supported MIME types
  73315. * @param samples Texture samples (default: 1)
  73316. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73317. * @param fileName A name for for the downloaded file.
  73318. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73319. */
  73320. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73321. /**
  73322. * Generates an image screenshot from the specified camera.
  73323. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73324. * @param engine The engine to use for rendering
  73325. * @param camera The camera to use for rendering
  73326. * @param size This parameter can be set to a single number or to an object with the
  73327. * following (optional) properties: precision, width, height. If a single number is passed,
  73328. * it will be used for both width and height. If an object is passed, the screenshot size
  73329. * will be derived from the parameters. The precision property is a multiplier allowing
  73330. * rendering at a higher or lower resolution
  73331. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73332. * Check your browser for supported MIME types
  73333. * @param samples Texture samples (default: 1)
  73334. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73335. * @param fileName A name for for the downloaded file.
  73336. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73337. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73338. * to the src parameter of an <img> to display it
  73339. */
  73340. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73341. /**
  73342. * Gets height and width for screenshot size
  73343. * @private
  73344. */
  73345. private static _getScreenshotSize;
  73346. }
  73347. }
  73348. declare module BABYLON {
  73349. /**
  73350. * Interface for a data buffer
  73351. */
  73352. export interface IDataBuffer {
  73353. /**
  73354. * Reads bytes from the data buffer.
  73355. * @param byteOffset The byte offset to read
  73356. * @param byteLength The byte length to read
  73357. * @returns A promise that resolves when the bytes are read
  73358. */
  73359. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73360. /**
  73361. * The byte length of the buffer.
  73362. */
  73363. readonly byteLength: number;
  73364. }
  73365. /**
  73366. * Utility class for reading from a data buffer
  73367. */
  73368. export class DataReader {
  73369. /**
  73370. * The data buffer associated with this data reader.
  73371. */
  73372. readonly buffer: IDataBuffer;
  73373. /**
  73374. * The current byte offset from the beginning of the data buffer.
  73375. */
  73376. byteOffset: number;
  73377. private _dataView;
  73378. private _dataByteOffset;
  73379. /**
  73380. * Constructor
  73381. * @param buffer The buffer to read
  73382. */
  73383. constructor(buffer: IDataBuffer);
  73384. /**
  73385. * Loads the given byte length.
  73386. * @param byteLength The byte length to load
  73387. * @returns A promise that resolves when the load is complete
  73388. */
  73389. loadAsync(byteLength: number): Promise<void>;
  73390. /**
  73391. * Read a unsigned 32-bit integer from the currently loaded data range.
  73392. * @returns The 32-bit integer read
  73393. */
  73394. readUint32(): number;
  73395. /**
  73396. * Read a byte array from the currently loaded data range.
  73397. * @param byteLength The byte length to read
  73398. * @returns The byte array read
  73399. */
  73400. readUint8Array(byteLength: number): Uint8Array;
  73401. /**
  73402. * Read a string from the currently loaded data range.
  73403. * @param byteLength The byte length to read
  73404. * @returns The string read
  73405. */
  73406. readString(byteLength: number): string;
  73407. /**
  73408. * Skips the given byte length the currently loaded data range.
  73409. * @param byteLength The byte length to skip
  73410. */
  73411. skipBytes(byteLength: number): void;
  73412. }
  73413. }
  73414. declare module BABYLON {
  73415. /**
  73416. * Class for storing data to local storage if available or in-memory storage otherwise
  73417. */
  73418. export class DataStorage {
  73419. private static _Storage;
  73420. private static _GetStorage;
  73421. /**
  73422. * Reads a string from the data storage
  73423. * @param key The key to read
  73424. * @param defaultValue The value if the key doesn't exist
  73425. * @returns The string value
  73426. */
  73427. static ReadString(key: string, defaultValue: string): string;
  73428. /**
  73429. * Writes a string to the data storage
  73430. * @param key The key to write
  73431. * @param value The value to write
  73432. */
  73433. static WriteString(key: string, value: string): void;
  73434. /**
  73435. * Reads a boolean from the data storage
  73436. * @param key The key to read
  73437. * @param defaultValue The value if the key doesn't exist
  73438. * @returns The boolean value
  73439. */
  73440. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73441. /**
  73442. * Writes a boolean to the data storage
  73443. * @param key The key to write
  73444. * @param value The value to write
  73445. */
  73446. static WriteBoolean(key: string, value: boolean): void;
  73447. /**
  73448. * Reads a number from the data storage
  73449. * @param key The key to read
  73450. * @param defaultValue The value if the key doesn't exist
  73451. * @returns The number value
  73452. */
  73453. static ReadNumber(key: string, defaultValue: number): number;
  73454. /**
  73455. * Writes a number to the data storage
  73456. * @param key The key to write
  73457. * @param value The value to write
  73458. */
  73459. static WriteNumber(key: string, value: number): void;
  73460. }
  73461. }
  73462. declare module BABYLON {
  73463. /**
  73464. * Class used to record delta files between 2 scene states
  73465. */
  73466. export class SceneRecorder {
  73467. private _trackedScene;
  73468. private _savedJSON;
  73469. /**
  73470. * Track a given scene. This means the current scene state will be considered the original state
  73471. * @param scene defines the scene to track
  73472. */
  73473. track(scene: Scene): void;
  73474. /**
  73475. * Get the delta between current state and original state
  73476. * @returns a string containing the delta
  73477. */
  73478. getDelta(): any;
  73479. private _compareArray;
  73480. private _compareObjects;
  73481. private _compareCollections;
  73482. /**
  73483. * Apply a given delta to a given scene
  73484. * @param deltaJSON defines the JSON containing the delta
  73485. * @param scene defines the scene to apply the delta to
  73486. */
  73487. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73488. private static _ApplyPropertiesToEntity;
  73489. private static _ApplyDeltaForEntity;
  73490. }
  73491. }
  73492. declare module BABYLON {
  73493. /**
  73494. * An interface for all Hit test features
  73495. */
  73496. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73497. /**
  73498. * Triggered when new babylon (transformed) hit test results are available
  73499. */
  73500. onHitTestResultObservable: Observable<T[]>;
  73501. }
  73502. /**
  73503. * Options used for hit testing
  73504. */
  73505. export interface IWebXRLegacyHitTestOptions {
  73506. /**
  73507. * Only test when user interacted with the scene. Default - hit test every frame
  73508. */
  73509. testOnPointerDownOnly?: boolean;
  73510. /**
  73511. * The node to use to transform the local results to world coordinates
  73512. */
  73513. worldParentNode?: TransformNode;
  73514. }
  73515. /**
  73516. * Interface defining the babylon result of raycasting/hit-test
  73517. */
  73518. export interface IWebXRLegacyHitResult {
  73519. /**
  73520. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73521. */
  73522. transformationMatrix: Matrix;
  73523. /**
  73524. * The native hit test result
  73525. */
  73526. xrHitResult: XRHitResult | XRHitTestResult;
  73527. }
  73528. /**
  73529. * The currently-working hit-test module.
  73530. * Hit test (or Ray-casting) is used to interact with the real world.
  73531. * For further information read here - https://github.com/immersive-web/hit-test
  73532. */
  73533. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73534. /**
  73535. * options to use when constructing this feature
  73536. */
  73537. readonly options: IWebXRLegacyHitTestOptions;
  73538. private _direction;
  73539. private _mat;
  73540. private _onSelectEnabled;
  73541. private _origin;
  73542. /**
  73543. * The module's name
  73544. */
  73545. static readonly Name: string;
  73546. /**
  73547. * The (Babylon) version of this module.
  73548. * This is an integer representing the implementation version.
  73549. * This number does not correspond to the WebXR specs version
  73550. */
  73551. static readonly Version: number;
  73552. /**
  73553. * Populated with the last native XR Hit Results
  73554. */
  73555. lastNativeXRHitResults: XRHitResult[];
  73556. /**
  73557. * Triggered when new babylon (transformed) hit test results are available
  73558. */
  73559. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73560. /**
  73561. * Creates a new instance of the (legacy version) hit test feature
  73562. * @param _xrSessionManager an instance of WebXRSessionManager
  73563. * @param options options to use when constructing this feature
  73564. */
  73565. constructor(_xrSessionManager: WebXRSessionManager,
  73566. /**
  73567. * options to use when constructing this feature
  73568. */
  73569. options?: IWebXRLegacyHitTestOptions);
  73570. /**
  73571. * execute a hit test with an XR Ray
  73572. *
  73573. * @param xrSession a native xrSession that will execute this hit test
  73574. * @param xrRay the ray (position and direction) to use for ray-casting
  73575. * @param referenceSpace native XR reference space to use for the hit-test
  73576. * @param filter filter function that will filter the results
  73577. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73578. */
  73579. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73580. /**
  73581. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73582. * @param event the (select) event to use to select with
  73583. * @param referenceSpace the reference space to use for this hit test
  73584. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73585. */
  73586. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73587. /**
  73588. * attach this feature
  73589. * Will usually be called by the features manager
  73590. *
  73591. * @returns true if successful.
  73592. */
  73593. attach(): boolean;
  73594. /**
  73595. * detach this feature.
  73596. * Will usually be called by the features manager
  73597. *
  73598. * @returns true if successful.
  73599. */
  73600. detach(): boolean;
  73601. /**
  73602. * Dispose this feature and all of the resources attached
  73603. */
  73604. dispose(): void;
  73605. protected _onXRFrame(frame: XRFrame): void;
  73606. private _onHitTestResults;
  73607. private _onSelect;
  73608. }
  73609. }
  73610. declare module BABYLON {
  73611. /**
  73612. * Options used for hit testing (version 2)
  73613. */
  73614. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73615. /**
  73616. * Do not create a permanent hit test. Will usually be used when only
  73617. * transient inputs are needed.
  73618. */
  73619. disablePermanentHitTest?: boolean;
  73620. /**
  73621. * Enable transient (for example touch-based) hit test inspections
  73622. */
  73623. enableTransientHitTest?: boolean;
  73624. /**
  73625. * Offset ray for the permanent hit test
  73626. */
  73627. offsetRay?: Vector3;
  73628. /**
  73629. * Offset ray for the transient hit test
  73630. */
  73631. transientOffsetRay?: Vector3;
  73632. /**
  73633. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73634. */
  73635. useReferenceSpace?: boolean;
  73636. }
  73637. /**
  73638. * Interface defining the babylon result of hit-test
  73639. */
  73640. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73641. /**
  73642. * The input source that generated this hit test (if transient)
  73643. */
  73644. inputSource?: XRInputSource;
  73645. /**
  73646. * Is this a transient hit test
  73647. */
  73648. isTransient?: boolean;
  73649. /**
  73650. * Position of the hit test result
  73651. */
  73652. position: Vector3;
  73653. /**
  73654. * Rotation of the hit test result
  73655. */
  73656. rotationQuaternion: Quaternion;
  73657. /**
  73658. * The native hit test result
  73659. */
  73660. xrHitResult: XRHitTestResult;
  73661. }
  73662. /**
  73663. * The currently-working hit-test module.
  73664. * Hit test (or Ray-casting) is used to interact with the real world.
  73665. * For further information read here - https://github.com/immersive-web/hit-test
  73666. *
  73667. * Tested on chrome (mobile) 80.
  73668. */
  73669. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73670. /**
  73671. * options to use when constructing this feature
  73672. */
  73673. readonly options: IWebXRHitTestOptions;
  73674. private _tmpMat;
  73675. private _tmpPos;
  73676. private _tmpQuat;
  73677. private _transientXrHitTestSource;
  73678. private _xrHitTestSource;
  73679. private initHitTestSource;
  73680. /**
  73681. * The module's name
  73682. */
  73683. static readonly Name: string;
  73684. /**
  73685. * The (Babylon) version of this module.
  73686. * This is an integer representing the implementation version.
  73687. * This number does not correspond to the WebXR specs version
  73688. */
  73689. static readonly Version: number;
  73690. /**
  73691. * When set to true, each hit test will have its own position/rotation objects
  73692. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73693. * the developers will clone them or copy them as they see fit.
  73694. */
  73695. autoCloneTransformation: boolean;
  73696. /**
  73697. * Triggered when new babylon (transformed) hit test results are available
  73698. */
  73699. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73700. /**
  73701. * Use this to temporarily pause hit test checks.
  73702. */
  73703. paused: boolean;
  73704. /**
  73705. * Creates a new instance of the hit test feature
  73706. * @param _xrSessionManager an instance of WebXRSessionManager
  73707. * @param options options to use when constructing this feature
  73708. */
  73709. constructor(_xrSessionManager: WebXRSessionManager,
  73710. /**
  73711. * options to use when constructing this feature
  73712. */
  73713. options?: IWebXRHitTestOptions);
  73714. /**
  73715. * attach this feature
  73716. * Will usually be called by the features manager
  73717. *
  73718. * @returns true if successful.
  73719. */
  73720. attach(): boolean;
  73721. /**
  73722. * detach this feature.
  73723. * Will usually be called by the features manager
  73724. *
  73725. * @returns true if successful.
  73726. */
  73727. detach(): boolean;
  73728. /**
  73729. * Dispose this feature and all of the resources attached
  73730. */
  73731. dispose(): void;
  73732. protected _onXRFrame(frame: XRFrame): void;
  73733. private _processWebXRHitTestResult;
  73734. }
  73735. }
  73736. declare module BABYLON {
  73737. /**
  73738. * Configuration options of the anchor system
  73739. */
  73740. export interface IWebXRAnchorSystemOptions {
  73741. /**
  73742. * a node that will be used to convert local to world coordinates
  73743. */
  73744. worldParentNode?: TransformNode;
  73745. /**
  73746. * If set to true a reference of the created anchors will be kept until the next session starts
  73747. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73748. */
  73749. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73750. }
  73751. /**
  73752. * A babylon container for an XR Anchor
  73753. */
  73754. export interface IWebXRAnchor {
  73755. /**
  73756. * A babylon-assigned ID for this anchor
  73757. */
  73758. id: number;
  73759. /**
  73760. * Transformation matrix to apply to an object attached to this anchor
  73761. */
  73762. transformationMatrix: Matrix;
  73763. /**
  73764. * The native anchor object
  73765. */
  73766. xrAnchor: XRAnchor;
  73767. /**
  73768. * if defined, this object will be constantly updated by the anchor's position and rotation
  73769. */
  73770. attachedNode?: TransformNode;
  73771. }
  73772. /**
  73773. * An implementation of the anchor system for WebXR.
  73774. * For further information see https://github.com/immersive-web/anchors/
  73775. */
  73776. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73777. private _options;
  73778. private _lastFrameDetected;
  73779. private _trackedAnchors;
  73780. private _referenceSpaceForFrameAnchors;
  73781. private _futureAnchors;
  73782. /**
  73783. * The module's name
  73784. */
  73785. static readonly Name: string;
  73786. /**
  73787. * The (Babylon) version of this module.
  73788. * This is an integer representing the implementation version.
  73789. * This number does not correspond to the WebXR specs version
  73790. */
  73791. static readonly Version: number;
  73792. /**
  73793. * Observers registered here will be executed when a new anchor was added to the session
  73794. */
  73795. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73796. /**
  73797. * Observers registered here will be executed when an anchor was removed from the session
  73798. */
  73799. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73800. /**
  73801. * Observers registered here will be executed when an existing anchor updates
  73802. * This can execute N times every frame
  73803. */
  73804. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73805. /**
  73806. * Set the reference space to use for anchor creation, when not using a hit test.
  73807. * Will default to the session's reference space if not defined
  73808. */
  73809. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73810. /**
  73811. * constructs a new anchor system
  73812. * @param _xrSessionManager an instance of WebXRSessionManager
  73813. * @param _options configuration object for this feature
  73814. */
  73815. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73816. private _tmpVector;
  73817. private _tmpQuaternion;
  73818. private _populateTmpTransformation;
  73819. /**
  73820. * Create a new anchor point using a hit test result at a specific point in the scene
  73821. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73822. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73823. *
  73824. * @param hitTestResult The hit test result to use for this anchor creation
  73825. * @param position an optional position offset for this anchor
  73826. * @param rotationQuaternion an optional rotation offset for this anchor
  73827. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73828. */
  73829. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73830. /**
  73831. * Add a new anchor at a specific position and rotation
  73832. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73833. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73834. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73835. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73836. *
  73837. * @param position the position in which to add an anchor
  73838. * @param rotationQuaternion an optional rotation for the anchor transformation
  73839. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73840. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73841. */
  73842. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73843. /**
  73844. * detach this feature.
  73845. * Will usually be called by the features manager
  73846. *
  73847. * @returns true if successful.
  73848. */
  73849. detach(): boolean;
  73850. /**
  73851. * Dispose this feature and all of the resources attached
  73852. */
  73853. dispose(): void;
  73854. protected _onXRFrame(frame: XRFrame): void;
  73855. /**
  73856. * avoiding using Array.find for global support.
  73857. * @param xrAnchor the plane to find in the array
  73858. */
  73859. private _findIndexInAnchorArray;
  73860. private _updateAnchorWithXRFrame;
  73861. private _createAnchorAtTransformation;
  73862. }
  73863. }
  73864. declare module BABYLON {
  73865. /**
  73866. * Options used in the plane detector module
  73867. */
  73868. export interface IWebXRPlaneDetectorOptions {
  73869. /**
  73870. * The node to use to transform the local results to world coordinates
  73871. */
  73872. worldParentNode?: TransformNode;
  73873. /**
  73874. * If set to true a reference of the created planes will be kept until the next session starts
  73875. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73876. */
  73877. doNotRemovePlanesOnSessionEnded?: boolean;
  73878. }
  73879. /**
  73880. * A babylon interface for a WebXR plane.
  73881. * A Plane is actually a polygon, built from N points in space
  73882. *
  73883. * Supported in chrome 79, not supported in canary 81 ATM
  73884. */
  73885. export interface IWebXRPlane {
  73886. /**
  73887. * a babylon-assigned ID for this polygon
  73888. */
  73889. id: number;
  73890. /**
  73891. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73892. */
  73893. polygonDefinition: Array<Vector3>;
  73894. /**
  73895. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73896. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73897. */
  73898. transformationMatrix: Matrix;
  73899. /**
  73900. * the native xr-plane object
  73901. */
  73902. xrPlane: XRPlane;
  73903. }
  73904. /**
  73905. * The plane detector is used to detect planes in the real world when in AR
  73906. * For more information see https://github.com/immersive-web/real-world-geometry/
  73907. */
  73908. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73909. private _options;
  73910. private _detectedPlanes;
  73911. private _enabled;
  73912. private _lastFrameDetected;
  73913. /**
  73914. * The module's name
  73915. */
  73916. static readonly Name: string;
  73917. /**
  73918. * The (Babylon) version of this module.
  73919. * This is an integer representing the implementation version.
  73920. * This number does not correspond to the WebXR specs version
  73921. */
  73922. static readonly Version: number;
  73923. /**
  73924. * Observers registered here will be executed when a new plane was added to the session
  73925. */
  73926. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73927. /**
  73928. * Observers registered here will be executed when a plane is no longer detected in the session
  73929. */
  73930. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73931. /**
  73932. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73933. * This can execute N times every frame
  73934. */
  73935. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73936. /**
  73937. * construct a new Plane Detector
  73938. * @param _xrSessionManager an instance of xr Session manager
  73939. * @param _options configuration to use when constructing this feature
  73940. */
  73941. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73942. /**
  73943. * detach this feature.
  73944. * Will usually be called by the features manager
  73945. *
  73946. * @returns true if successful.
  73947. */
  73948. detach(): boolean;
  73949. /**
  73950. * Dispose this feature and all of the resources attached
  73951. */
  73952. dispose(): void;
  73953. protected _onXRFrame(frame: XRFrame): void;
  73954. private _init;
  73955. private _updatePlaneWithXRPlane;
  73956. /**
  73957. * avoiding using Array.find for global support.
  73958. * @param xrPlane the plane to find in the array
  73959. */
  73960. private findIndexInPlaneArray;
  73961. }
  73962. }
  73963. declare module BABYLON {
  73964. /**
  73965. * Options interface for the background remover plugin
  73966. */
  73967. export interface IWebXRBackgroundRemoverOptions {
  73968. /**
  73969. * Further background meshes to disable when entering AR
  73970. */
  73971. backgroundMeshes?: AbstractMesh[];
  73972. /**
  73973. * flags to configure the removal of the environment helper.
  73974. * If not set, the entire background will be removed. If set, flags should be set as well.
  73975. */
  73976. environmentHelperRemovalFlags?: {
  73977. /**
  73978. * Should the skybox be removed (default false)
  73979. */
  73980. skyBox?: boolean;
  73981. /**
  73982. * Should the ground be removed (default false)
  73983. */
  73984. ground?: boolean;
  73985. };
  73986. /**
  73987. * don't disable the environment helper
  73988. */
  73989. ignoreEnvironmentHelper?: boolean;
  73990. }
  73991. /**
  73992. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73993. */
  73994. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73995. /**
  73996. * read-only options to be used in this module
  73997. */
  73998. readonly options: IWebXRBackgroundRemoverOptions;
  73999. /**
  74000. * The module's name
  74001. */
  74002. static readonly Name: string;
  74003. /**
  74004. * The (Babylon) version of this module.
  74005. * This is an integer representing the implementation version.
  74006. * This number does not correspond to the WebXR specs version
  74007. */
  74008. static readonly Version: number;
  74009. /**
  74010. * registered observers will be triggered when the background state changes
  74011. */
  74012. onBackgroundStateChangedObservable: Observable<boolean>;
  74013. /**
  74014. * constructs a new background remover module
  74015. * @param _xrSessionManager the session manager for this module
  74016. * @param options read-only options to be used in this module
  74017. */
  74018. constructor(_xrSessionManager: WebXRSessionManager,
  74019. /**
  74020. * read-only options to be used in this module
  74021. */
  74022. options?: IWebXRBackgroundRemoverOptions);
  74023. /**
  74024. * attach this feature
  74025. * Will usually be called by the features manager
  74026. *
  74027. * @returns true if successful.
  74028. */
  74029. attach(): boolean;
  74030. /**
  74031. * detach this feature.
  74032. * Will usually be called by the features manager
  74033. *
  74034. * @returns true if successful.
  74035. */
  74036. detach(): boolean;
  74037. /**
  74038. * Dispose this feature and all of the resources attached
  74039. */
  74040. dispose(): void;
  74041. protected _onXRFrame(_xrFrame: XRFrame): void;
  74042. private _setBackgroundState;
  74043. }
  74044. }
  74045. declare module BABYLON {
  74046. /**
  74047. * Options for the controller physics feature
  74048. */
  74049. export class IWebXRControllerPhysicsOptions {
  74050. /**
  74051. * Should the headset get its own impostor
  74052. */
  74053. enableHeadsetImpostor?: boolean;
  74054. /**
  74055. * Optional parameters for the headset impostor
  74056. */
  74057. headsetImpostorParams?: {
  74058. /**
  74059. * The type of impostor to create. Default is sphere
  74060. */
  74061. impostorType: number;
  74062. /**
  74063. * the size of the impostor. Defaults to 10cm
  74064. */
  74065. impostorSize?: number | {
  74066. width: number;
  74067. height: number;
  74068. depth: number;
  74069. };
  74070. /**
  74071. * Friction definitions
  74072. */
  74073. friction?: number;
  74074. /**
  74075. * Restitution
  74076. */
  74077. restitution?: number;
  74078. };
  74079. /**
  74080. * The physics properties of the future impostors
  74081. */
  74082. physicsProperties?: {
  74083. /**
  74084. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74085. * Note that this requires a physics engine that supports mesh impostors!
  74086. */
  74087. useControllerMesh?: boolean;
  74088. /**
  74089. * The type of impostor to create. Default is sphere
  74090. */
  74091. impostorType?: number;
  74092. /**
  74093. * the size of the impostor. Defaults to 10cm
  74094. */
  74095. impostorSize?: number | {
  74096. width: number;
  74097. height: number;
  74098. depth: number;
  74099. };
  74100. /**
  74101. * Friction definitions
  74102. */
  74103. friction?: number;
  74104. /**
  74105. * Restitution
  74106. */
  74107. restitution?: number;
  74108. };
  74109. /**
  74110. * the xr input to use with this pointer selection
  74111. */
  74112. xrInput: WebXRInput;
  74113. }
  74114. /**
  74115. * Add physics impostor to your webxr controllers,
  74116. * including naive calculation of their linear and angular velocity
  74117. */
  74118. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74119. private readonly _options;
  74120. private _attachController;
  74121. private _controllers;
  74122. private _debugMode;
  74123. private _delta;
  74124. private _headsetImpostor?;
  74125. private _headsetMesh?;
  74126. private _lastTimestamp;
  74127. private _tmpQuaternion;
  74128. private _tmpVector;
  74129. /**
  74130. * The module's name
  74131. */
  74132. static readonly Name: string;
  74133. /**
  74134. * The (Babylon) version of this module.
  74135. * This is an integer representing the implementation version.
  74136. * This number does not correspond to the webxr specs version
  74137. */
  74138. static readonly Version: number;
  74139. /**
  74140. * Construct a new Controller Physics Feature
  74141. * @param _xrSessionManager the corresponding xr session manager
  74142. * @param _options options to create this feature with
  74143. */
  74144. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74145. /**
  74146. * @hidden
  74147. * enable debugging - will show console outputs and the impostor mesh
  74148. */
  74149. _enablePhysicsDebug(): void;
  74150. /**
  74151. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74152. * @param xrController the controller to add
  74153. */
  74154. addController(xrController: WebXRInputSource): void;
  74155. /**
  74156. * attach this feature
  74157. * Will usually be called by the features manager
  74158. *
  74159. * @returns true if successful.
  74160. */
  74161. attach(): boolean;
  74162. /**
  74163. * detach this feature.
  74164. * Will usually be called by the features manager
  74165. *
  74166. * @returns true if successful.
  74167. */
  74168. detach(): boolean;
  74169. /**
  74170. * Get the headset impostor, if enabled
  74171. * @returns the impostor
  74172. */
  74173. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74174. /**
  74175. * Get the physics impostor of a specific controller.
  74176. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74177. * @param controller the controller or the controller id of which to get the impostor
  74178. * @returns the impostor or null
  74179. */
  74180. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74181. /**
  74182. * Update the physics properties provided in the constructor
  74183. * @param newProperties the new properties object
  74184. */
  74185. setPhysicsProperties(newProperties: {
  74186. impostorType?: number;
  74187. impostorSize?: number | {
  74188. width: number;
  74189. height: number;
  74190. depth: number;
  74191. };
  74192. friction?: number;
  74193. restitution?: number;
  74194. }): void;
  74195. protected _onXRFrame(_xrFrame: any): void;
  74196. private _detachController;
  74197. }
  74198. }
  74199. declare module BABYLON {
  74200. /**
  74201. * The motion controller class for all microsoft mixed reality controllers
  74202. */
  74203. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74204. protected readonly _mapping: {
  74205. defaultButton: {
  74206. valueNodeName: string;
  74207. unpressedNodeName: string;
  74208. pressedNodeName: string;
  74209. };
  74210. defaultAxis: {
  74211. valueNodeName: string;
  74212. minNodeName: string;
  74213. maxNodeName: string;
  74214. };
  74215. buttons: {
  74216. "xr-standard-trigger": {
  74217. rootNodeName: string;
  74218. componentProperty: string;
  74219. states: string[];
  74220. };
  74221. "xr-standard-squeeze": {
  74222. rootNodeName: string;
  74223. componentProperty: string;
  74224. states: string[];
  74225. };
  74226. "xr-standard-touchpad": {
  74227. rootNodeName: string;
  74228. labelAnchorNodeName: string;
  74229. touchPointNodeName: string;
  74230. };
  74231. "xr-standard-thumbstick": {
  74232. rootNodeName: string;
  74233. componentProperty: string;
  74234. states: string[];
  74235. };
  74236. };
  74237. axes: {
  74238. "xr-standard-touchpad": {
  74239. "x-axis": {
  74240. rootNodeName: string;
  74241. };
  74242. "y-axis": {
  74243. rootNodeName: string;
  74244. };
  74245. };
  74246. "xr-standard-thumbstick": {
  74247. "x-axis": {
  74248. rootNodeName: string;
  74249. };
  74250. "y-axis": {
  74251. rootNodeName: string;
  74252. };
  74253. };
  74254. };
  74255. };
  74256. /**
  74257. * The base url used to load the left and right controller models
  74258. */
  74259. static MODEL_BASE_URL: string;
  74260. /**
  74261. * The name of the left controller model file
  74262. */
  74263. static MODEL_LEFT_FILENAME: string;
  74264. /**
  74265. * The name of the right controller model file
  74266. */
  74267. static MODEL_RIGHT_FILENAME: string;
  74268. profileId: string;
  74269. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74270. protected _getFilenameAndPath(): {
  74271. filename: string;
  74272. path: string;
  74273. };
  74274. protected _getModelLoadingConstraints(): boolean;
  74275. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74276. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74277. protected _updateModel(): void;
  74278. }
  74279. }
  74280. declare module BABYLON {
  74281. /**
  74282. * The motion controller class for oculus touch (quest, rift).
  74283. * This class supports legacy mapping as well the standard xr mapping
  74284. */
  74285. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74286. private _forceLegacyControllers;
  74287. private _modelRootNode;
  74288. /**
  74289. * The base url used to load the left and right controller models
  74290. */
  74291. static MODEL_BASE_URL: string;
  74292. /**
  74293. * The name of the left controller model file
  74294. */
  74295. static MODEL_LEFT_FILENAME: string;
  74296. /**
  74297. * The name of the right controller model file
  74298. */
  74299. static MODEL_RIGHT_FILENAME: string;
  74300. /**
  74301. * Base Url for the Quest controller model.
  74302. */
  74303. static QUEST_MODEL_BASE_URL: string;
  74304. profileId: string;
  74305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74306. protected _getFilenameAndPath(): {
  74307. filename: string;
  74308. path: string;
  74309. };
  74310. protected _getModelLoadingConstraints(): boolean;
  74311. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74312. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74313. protected _updateModel(): void;
  74314. /**
  74315. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74316. * between the touch and touch 2.
  74317. */
  74318. private _isQuest;
  74319. }
  74320. }
  74321. declare module BABYLON {
  74322. /**
  74323. * The motion controller class for the standard HTC-Vive controllers
  74324. */
  74325. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74326. private _modelRootNode;
  74327. /**
  74328. * The base url used to load the left and right controller models
  74329. */
  74330. static MODEL_BASE_URL: string;
  74331. /**
  74332. * File name for the controller model.
  74333. */
  74334. static MODEL_FILENAME: string;
  74335. profileId: string;
  74336. /**
  74337. * Create a new Vive motion controller object
  74338. * @param scene the scene to use to create this controller
  74339. * @param gamepadObject the corresponding gamepad object
  74340. * @param handedness the handedness of the controller
  74341. */
  74342. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74343. protected _getFilenameAndPath(): {
  74344. filename: string;
  74345. path: string;
  74346. };
  74347. protected _getModelLoadingConstraints(): boolean;
  74348. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74349. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74350. protected _updateModel(): void;
  74351. }
  74352. }
  74353. declare module BABYLON {
  74354. /**
  74355. * A cursor which tracks a point on a path
  74356. */
  74357. export class PathCursor {
  74358. private path;
  74359. /**
  74360. * Stores path cursor callbacks for when an onchange event is triggered
  74361. */
  74362. private _onchange;
  74363. /**
  74364. * The value of the path cursor
  74365. */
  74366. value: number;
  74367. /**
  74368. * The animation array of the path cursor
  74369. */
  74370. animations: Animation[];
  74371. /**
  74372. * Initializes the path cursor
  74373. * @param path The path to track
  74374. */
  74375. constructor(path: Path2);
  74376. /**
  74377. * Gets the cursor point on the path
  74378. * @returns A point on the path cursor at the cursor location
  74379. */
  74380. getPoint(): Vector3;
  74381. /**
  74382. * Moves the cursor ahead by the step amount
  74383. * @param step The amount to move the cursor forward
  74384. * @returns This path cursor
  74385. */
  74386. moveAhead(step?: number): PathCursor;
  74387. /**
  74388. * Moves the cursor behind by the step amount
  74389. * @param step The amount to move the cursor back
  74390. * @returns This path cursor
  74391. */
  74392. moveBack(step?: number): PathCursor;
  74393. /**
  74394. * Moves the cursor by the step amount
  74395. * If the step amount is greater than one, an exception is thrown
  74396. * @param step The amount to move the cursor
  74397. * @returns This path cursor
  74398. */
  74399. move(step: number): PathCursor;
  74400. /**
  74401. * Ensures that the value is limited between zero and one
  74402. * @returns This path cursor
  74403. */
  74404. private ensureLimits;
  74405. /**
  74406. * Runs onchange callbacks on change (used by the animation engine)
  74407. * @returns This path cursor
  74408. */
  74409. private raiseOnChange;
  74410. /**
  74411. * Executes a function on change
  74412. * @param f A path cursor onchange callback
  74413. * @returns This path cursor
  74414. */
  74415. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74416. }
  74417. }
  74418. declare module BABYLON {
  74419. /** @hidden */
  74420. export var blurPixelShader: {
  74421. name: string;
  74422. shader: string;
  74423. };
  74424. }
  74425. declare module BABYLON {
  74426. /** @hidden */
  74427. export var pointCloudVertexDeclaration: {
  74428. name: string;
  74429. shader: string;
  74430. };
  74431. }
  74432. // Mixins
  74433. interface Window {
  74434. mozIndexedDB: IDBFactory;
  74435. webkitIndexedDB: IDBFactory;
  74436. msIndexedDB: IDBFactory;
  74437. webkitURL: typeof URL;
  74438. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74439. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74440. WebGLRenderingContext: WebGLRenderingContext;
  74441. MSGesture: MSGesture;
  74442. CANNON: any;
  74443. AudioContext: AudioContext;
  74444. webkitAudioContext: AudioContext;
  74445. PointerEvent: any;
  74446. Math: Math;
  74447. Uint8Array: Uint8ArrayConstructor;
  74448. Float32Array: Float32ArrayConstructor;
  74449. mozURL: typeof URL;
  74450. msURL: typeof URL;
  74451. VRFrameData: any; // WebVR, from specs 1.1
  74452. DracoDecoderModule: any;
  74453. setImmediate(handler: (...args: any[]) => void): number;
  74454. }
  74455. interface HTMLCanvasElement {
  74456. requestPointerLock(): void;
  74457. msRequestPointerLock?(): void;
  74458. mozRequestPointerLock?(): void;
  74459. webkitRequestPointerLock?(): void;
  74460. /** Track wether a record is in progress */
  74461. isRecording: boolean;
  74462. /** Capture Stream method defined by some browsers */
  74463. captureStream(fps?: number): MediaStream;
  74464. }
  74465. interface CanvasRenderingContext2D {
  74466. msImageSmoothingEnabled: boolean;
  74467. }
  74468. interface MouseEvent {
  74469. mozMovementX: number;
  74470. mozMovementY: number;
  74471. webkitMovementX: number;
  74472. webkitMovementY: number;
  74473. msMovementX: number;
  74474. msMovementY: number;
  74475. }
  74476. interface Navigator {
  74477. mozGetVRDevices: (any: any) => any;
  74478. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74479. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74480. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74481. webkitGetGamepads(): Gamepad[];
  74482. msGetGamepads(): Gamepad[];
  74483. webkitGamepads(): Gamepad[];
  74484. }
  74485. interface HTMLVideoElement {
  74486. mozSrcObject: any;
  74487. }
  74488. interface Math {
  74489. fround(x: number): number;
  74490. imul(a: number, b: number): number;
  74491. }
  74492. interface WebGLRenderingContext {
  74493. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74494. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74495. vertexAttribDivisor(index: number, divisor: number): void;
  74496. createVertexArray(): any;
  74497. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74498. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74499. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74500. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74501. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74502. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74503. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74504. // Queries
  74505. createQuery(): WebGLQuery;
  74506. deleteQuery(query: WebGLQuery): void;
  74507. beginQuery(target: number, query: WebGLQuery): void;
  74508. endQuery(target: number): void;
  74509. getQueryParameter(query: WebGLQuery, pname: number): any;
  74510. getQuery(target: number, pname: number): any;
  74511. MAX_SAMPLES: number;
  74512. RGBA8: number;
  74513. READ_FRAMEBUFFER: number;
  74514. DRAW_FRAMEBUFFER: number;
  74515. UNIFORM_BUFFER: number;
  74516. HALF_FLOAT_OES: number;
  74517. RGBA16F: number;
  74518. RGBA32F: number;
  74519. R32F: number;
  74520. RG32F: number;
  74521. RGB32F: number;
  74522. R16F: number;
  74523. RG16F: number;
  74524. RGB16F: number;
  74525. RED: number;
  74526. RG: number;
  74527. R8: number;
  74528. RG8: number;
  74529. UNSIGNED_INT_24_8: number;
  74530. DEPTH24_STENCIL8: number;
  74531. MIN: number;
  74532. MAX: number;
  74533. /* Multiple Render Targets */
  74534. drawBuffers(buffers: number[]): void;
  74535. readBuffer(src: number): void;
  74536. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74537. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74538. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74539. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74540. // Occlusion Query
  74541. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74542. ANY_SAMPLES_PASSED: number;
  74543. QUERY_RESULT_AVAILABLE: number;
  74544. QUERY_RESULT: number;
  74545. }
  74546. interface WebGLProgram {
  74547. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74548. }
  74549. interface EXT_disjoint_timer_query {
  74550. QUERY_COUNTER_BITS_EXT: number;
  74551. TIME_ELAPSED_EXT: number;
  74552. TIMESTAMP_EXT: number;
  74553. GPU_DISJOINT_EXT: number;
  74554. QUERY_RESULT_EXT: number;
  74555. QUERY_RESULT_AVAILABLE_EXT: number;
  74556. queryCounterEXT(query: WebGLQuery, target: number): void;
  74557. createQueryEXT(): WebGLQuery;
  74558. beginQueryEXT(target: number, query: WebGLQuery): void;
  74559. endQueryEXT(target: number): void;
  74560. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74561. deleteQueryEXT(query: WebGLQuery): void;
  74562. }
  74563. interface WebGLUniformLocation {
  74564. _currentState: any;
  74565. }
  74566. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74567. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74568. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74569. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74570. interface WebGLRenderingContext {
  74571. readonly RASTERIZER_DISCARD: number;
  74572. readonly DEPTH_COMPONENT24: number;
  74573. readonly TEXTURE_3D: number;
  74574. readonly TEXTURE_2D_ARRAY: number;
  74575. readonly TEXTURE_COMPARE_FUNC: number;
  74576. readonly TEXTURE_COMPARE_MODE: number;
  74577. readonly COMPARE_REF_TO_TEXTURE: number;
  74578. readonly TEXTURE_WRAP_R: number;
  74579. readonly HALF_FLOAT: number;
  74580. readonly RGB8: number;
  74581. readonly RED_INTEGER: number;
  74582. readonly RG_INTEGER: number;
  74583. readonly RGB_INTEGER: number;
  74584. readonly RGBA_INTEGER: number;
  74585. readonly R8_SNORM: number;
  74586. readonly RG8_SNORM: number;
  74587. readonly RGB8_SNORM: number;
  74588. readonly RGBA8_SNORM: number;
  74589. readonly R8I: number;
  74590. readonly RG8I: number;
  74591. readonly RGB8I: number;
  74592. readonly RGBA8I: number;
  74593. readonly R8UI: number;
  74594. readonly RG8UI: number;
  74595. readonly RGB8UI: number;
  74596. readonly RGBA8UI: number;
  74597. readonly R16I: number;
  74598. readonly RG16I: number;
  74599. readonly RGB16I: number;
  74600. readonly RGBA16I: number;
  74601. readonly R16UI: number;
  74602. readonly RG16UI: number;
  74603. readonly RGB16UI: number;
  74604. readonly RGBA16UI: number;
  74605. readonly R32I: number;
  74606. readonly RG32I: number;
  74607. readonly RGB32I: number;
  74608. readonly RGBA32I: number;
  74609. readonly R32UI: number;
  74610. readonly RG32UI: number;
  74611. readonly RGB32UI: number;
  74612. readonly RGBA32UI: number;
  74613. readonly RGB10_A2UI: number;
  74614. readonly R11F_G11F_B10F: number;
  74615. readonly RGB9_E5: number;
  74616. readonly RGB10_A2: number;
  74617. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74618. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74619. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74620. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74621. readonly DEPTH_COMPONENT32F: number;
  74622. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74623. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74624. 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;
  74625. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74626. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74627. readonly TRANSFORM_FEEDBACK: number;
  74628. readonly INTERLEAVED_ATTRIBS: number;
  74629. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74630. createTransformFeedback(): WebGLTransformFeedback;
  74631. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74632. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74633. beginTransformFeedback(primitiveMode: number): void;
  74634. endTransformFeedback(): void;
  74635. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74636. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74637. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74638. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74639. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74640. }
  74641. interface ImageBitmap {
  74642. readonly width: number;
  74643. readonly height: number;
  74644. close(): void;
  74645. }
  74646. interface WebGLQuery extends WebGLObject {
  74647. }
  74648. declare var WebGLQuery: {
  74649. prototype: WebGLQuery;
  74650. new(): WebGLQuery;
  74651. };
  74652. interface WebGLSampler extends WebGLObject {
  74653. }
  74654. declare var WebGLSampler: {
  74655. prototype: WebGLSampler;
  74656. new(): WebGLSampler;
  74657. };
  74658. interface WebGLSync extends WebGLObject {
  74659. }
  74660. declare var WebGLSync: {
  74661. prototype: WebGLSync;
  74662. new(): WebGLSync;
  74663. };
  74664. interface WebGLTransformFeedback extends WebGLObject {
  74665. }
  74666. declare var WebGLTransformFeedback: {
  74667. prototype: WebGLTransformFeedback;
  74668. new(): WebGLTransformFeedback;
  74669. };
  74670. interface WebGLVertexArrayObject extends WebGLObject {
  74671. }
  74672. declare var WebGLVertexArrayObject: {
  74673. prototype: WebGLVertexArrayObject;
  74674. new(): WebGLVertexArrayObject;
  74675. };
  74676. // Type definitions for WebVR API
  74677. // Project: https://w3c.github.io/webvr/
  74678. // Definitions by: six a <https://github.com/lostfictions>
  74679. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74680. interface VRDisplay extends EventTarget {
  74681. /**
  74682. * Dictionary of capabilities describing the VRDisplay.
  74683. */
  74684. readonly capabilities: VRDisplayCapabilities;
  74685. /**
  74686. * z-depth defining the far plane of the eye view frustum
  74687. * enables mapping of values in the render target depth
  74688. * attachment to scene coordinates. Initially set to 10000.0.
  74689. */
  74690. depthFar: number;
  74691. /**
  74692. * z-depth defining the near plane of the eye view frustum
  74693. * enables mapping of values in the render target depth
  74694. * attachment to scene coordinates. Initially set to 0.01.
  74695. */
  74696. depthNear: number;
  74697. /**
  74698. * An identifier for this distinct VRDisplay. Used as an
  74699. * association point in the Gamepad API.
  74700. */
  74701. readonly displayId: number;
  74702. /**
  74703. * A display name, a user-readable name identifying it.
  74704. */
  74705. readonly displayName: string;
  74706. readonly isConnected: boolean;
  74707. readonly isPresenting: boolean;
  74708. /**
  74709. * If this VRDisplay supports room-scale experiences, the optional
  74710. * stage attribute contains details on the room-scale parameters.
  74711. */
  74712. readonly stageParameters: VRStageParameters | null;
  74713. /**
  74714. * Passing the value returned by `requestAnimationFrame` to
  74715. * `cancelAnimationFrame` will unregister the callback.
  74716. * @param handle Define the hanle of the request to cancel
  74717. */
  74718. cancelAnimationFrame(handle: number): void;
  74719. /**
  74720. * Stops presenting to the VRDisplay.
  74721. * @returns a promise to know when it stopped
  74722. */
  74723. exitPresent(): Promise<void>;
  74724. /**
  74725. * Return the current VREyeParameters for the given eye.
  74726. * @param whichEye Define the eye we want the parameter for
  74727. * @returns the eye parameters
  74728. */
  74729. getEyeParameters(whichEye: string): VREyeParameters;
  74730. /**
  74731. * Populates the passed VRFrameData with the information required to render
  74732. * the current frame.
  74733. * @param frameData Define the data structure to populate
  74734. * @returns true if ok otherwise false
  74735. */
  74736. getFrameData(frameData: VRFrameData): boolean;
  74737. /**
  74738. * Get the layers currently being presented.
  74739. * @returns the list of VR layers
  74740. */
  74741. getLayers(): VRLayer[];
  74742. /**
  74743. * Return a VRPose containing the future predicted pose of the VRDisplay
  74744. * when the current frame will be presented. The value returned will not
  74745. * change until JavaScript has returned control to the browser.
  74746. *
  74747. * The VRPose will contain the position, orientation, velocity,
  74748. * and acceleration of each of these properties.
  74749. * @returns the pose object
  74750. */
  74751. getPose(): VRPose;
  74752. /**
  74753. * Return the current instantaneous pose of the VRDisplay, with no
  74754. * prediction applied.
  74755. * @returns the current instantaneous pose
  74756. */
  74757. getImmediatePose(): VRPose;
  74758. /**
  74759. * The callback passed to `requestAnimationFrame` will be called
  74760. * any time a new frame should be rendered. When the VRDisplay is
  74761. * presenting the callback will be called at the native refresh
  74762. * rate of the HMD. When not presenting this function acts
  74763. * identically to how window.requestAnimationFrame acts. Content should
  74764. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74765. * asynchronously from other displays and at differing refresh rates.
  74766. * @param callback Define the eaction to run next frame
  74767. * @returns the request handle it
  74768. */
  74769. requestAnimationFrame(callback: FrameRequestCallback): number;
  74770. /**
  74771. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74772. * Repeat calls while already presenting will update the VRLayers being displayed.
  74773. * @param layers Define the list of layer to present
  74774. * @returns a promise to know when the request has been fulfilled
  74775. */
  74776. requestPresent(layers: VRLayer[]): Promise<void>;
  74777. /**
  74778. * Reset the pose for this display, treating its current position and
  74779. * orientation as the "origin/zero" values. VRPose.position,
  74780. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74781. * updated when calling resetPose(). This should be called in only
  74782. * sitting-space experiences.
  74783. */
  74784. resetPose(): void;
  74785. /**
  74786. * The VRLayer provided to the VRDisplay will be captured and presented
  74787. * in the HMD. Calling this function has the same effect on the source
  74788. * canvas as any other operation that uses its source image, and canvases
  74789. * created without preserveDrawingBuffer set to true will be cleared.
  74790. * @param pose Define the pose to submit
  74791. */
  74792. submitFrame(pose?: VRPose): void;
  74793. }
  74794. declare var VRDisplay: {
  74795. prototype: VRDisplay;
  74796. new(): VRDisplay;
  74797. };
  74798. interface VRLayer {
  74799. leftBounds?: number[] | Float32Array | null;
  74800. rightBounds?: number[] | Float32Array | null;
  74801. source?: HTMLCanvasElement | null;
  74802. }
  74803. interface VRDisplayCapabilities {
  74804. readonly canPresent: boolean;
  74805. readonly hasExternalDisplay: boolean;
  74806. readonly hasOrientation: boolean;
  74807. readonly hasPosition: boolean;
  74808. readonly maxLayers: number;
  74809. }
  74810. interface VREyeParameters {
  74811. /** @deprecated */
  74812. readonly fieldOfView: VRFieldOfView;
  74813. readonly offset: Float32Array;
  74814. readonly renderHeight: number;
  74815. readonly renderWidth: number;
  74816. }
  74817. interface VRFieldOfView {
  74818. readonly downDegrees: number;
  74819. readonly leftDegrees: number;
  74820. readonly rightDegrees: number;
  74821. readonly upDegrees: number;
  74822. }
  74823. interface VRFrameData {
  74824. readonly leftProjectionMatrix: Float32Array;
  74825. readonly leftViewMatrix: Float32Array;
  74826. readonly pose: VRPose;
  74827. readonly rightProjectionMatrix: Float32Array;
  74828. readonly rightViewMatrix: Float32Array;
  74829. readonly timestamp: number;
  74830. }
  74831. interface VRPose {
  74832. readonly angularAcceleration: Float32Array | null;
  74833. readonly angularVelocity: Float32Array | null;
  74834. readonly linearAcceleration: Float32Array | null;
  74835. readonly linearVelocity: Float32Array | null;
  74836. readonly orientation: Float32Array | null;
  74837. readonly position: Float32Array | null;
  74838. readonly timestamp: number;
  74839. }
  74840. interface VRStageParameters {
  74841. sittingToStandingTransform?: Float32Array;
  74842. sizeX?: number;
  74843. sizeY?: number;
  74844. }
  74845. interface Navigator {
  74846. getVRDisplays(): Promise<VRDisplay[]>;
  74847. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74848. }
  74849. interface Window {
  74850. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74851. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74852. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74853. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74854. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74855. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74856. }
  74857. interface Gamepad {
  74858. readonly displayId: number;
  74859. }
  74860. type XRSessionMode =
  74861. | "inline"
  74862. | "immersive-vr"
  74863. | "immersive-ar";
  74864. type XRReferenceSpaceType =
  74865. | "viewer"
  74866. | "local"
  74867. | "local-floor"
  74868. | "bounded-floor"
  74869. | "unbounded";
  74870. type XREnvironmentBlendMode =
  74871. | "opaque"
  74872. | "additive"
  74873. | "alpha-blend";
  74874. type XRVisibilityState =
  74875. | "visible"
  74876. | "visible-blurred"
  74877. | "hidden";
  74878. type XRHandedness =
  74879. | "none"
  74880. | "left"
  74881. | "right";
  74882. type XRTargetRayMode =
  74883. | "gaze"
  74884. | "tracked-pointer"
  74885. | "screen";
  74886. type XREye =
  74887. | "none"
  74888. | "left"
  74889. | "right";
  74890. type XREventType =
  74891. | "devicechange"
  74892. | "visibilitychange"
  74893. | "end"
  74894. | "inputsourceschange"
  74895. | "select"
  74896. | "selectstart"
  74897. | "selectend"
  74898. | "squeeze"
  74899. | "squeezestart"
  74900. | "squeezeend"
  74901. | "reset";
  74902. interface XRSpace extends EventTarget {
  74903. }
  74904. interface XRRenderState {
  74905. depthNear?: number;
  74906. depthFar?: number;
  74907. inlineVerticalFieldOfView?: number;
  74908. baseLayer?: XRWebGLLayer;
  74909. }
  74910. interface XRInputSource {
  74911. handedness: XRHandedness;
  74912. targetRayMode: XRTargetRayMode;
  74913. targetRaySpace: XRSpace;
  74914. gripSpace: XRSpace | undefined;
  74915. gamepad: Gamepad | undefined;
  74916. profiles: Array<string>;
  74917. }
  74918. interface XRSessionInit {
  74919. optionalFeatures?: string[];
  74920. requiredFeatures?: string[];
  74921. }
  74922. interface XRSession {
  74923. addEventListener: Function;
  74924. removeEventListener: Function;
  74925. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74926. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74927. requestAnimationFrame: Function;
  74928. end(): Promise<void>;
  74929. renderState: XRRenderState;
  74930. inputSources: Array<XRInputSource>;
  74931. // hit test
  74932. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74933. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74934. // legacy AR hit test
  74935. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74936. // legacy plane detection
  74937. updateWorldTrackingState(options: {
  74938. planeDetectionState?: { enabled: boolean; }
  74939. }): void;
  74940. }
  74941. interface XRReferenceSpace extends XRSpace {
  74942. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74943. onreset: any;
  74944. }
  74945. type XRPlaneSet = Set<XRPlane>;
  74946. type XRAnchorSet = Set<XRAnchor>;
  74947. interface XRFrame {
  74948. session: XRSession;
  74949. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74950. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74951. // AR
  74952. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74953. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74954. // Anchors
  74955. trackedAnchors?: XRAnchorSet;
  74956. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74957. // Planes
  74958. worldInformation: {
  74959. detectedPlanes?: XRPlaneSet;
  74960. };
  74961. }
  74962. interface XRViewerPose extends XRPose {
  74963. views: Array<XRView>;
  74964. }
  74965. interface XRPose {
  74966. transform: XRRigidTransform;
  74967. emulatedPosition: boolean;
  74968. }
  74969. interface XRWebGLLayerOptions {
  74970. antialias?: boolean;
  74971. depth?: boolean;
  74972. stencil?: boolean;
  74973. alpha?: boolean;
  74974. multiview?: boolean;
  74975. framebufferScaleFactor?: number;
  74976. }
  74977. declare var XRWebGLLayer: {
  74978. prototype: XRWebGLLayer;
  74979. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74980. };
  74981. interface XRWebGLLayer {
  74982. framebuffer: WebGLFramebuffer;
  74983. framebufferWidth: number;
  74984. framebufferHeight: number;
  74985. getViewport: Function;
  74986. }
  74987. declare class XRRigidTransform {
  74988. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74989. position: DOMPointReadOnly;
  74990. orientation: DOMPointReadOnly;
  74991. matrix: Float32Array;
  74992. inverse: XRRigidTransform;
  74993. }
  74994. interface XRView {
  74995. eye: XREye;
  74996. projectionMatrix: Float32Array;
  74997. transform: XRRigidTransform;
  74998. }
  74999. interface XRInputSourceChangeEvent {
  75000. session: XRSession;
  75001. removed: Array<XRInputSource>;
  75002. added: Array<XRInputSource>;
  75003. }
  75004. interface XRInputSourceEvent extends Event {
  75005. readonly frame: XRFrame;
  75006. readonly inputSource: XRInputSource;
  75007. }
  75008. // Experimental(er) features
  75009. declare class XRRay {
  75010. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75011. origin: DOMPointReadOnly;
  75012. direction: DOMPointReadOnly;
  75013. matrix: Float32Array;
  75014. }
  75015. declare enum XRHitTestTrackableType {
  75016. "point",
  75017. "plane"
  75018. }
  75019. interface XRHitResult {
  75020. hitMatrix: Float32Array;
  75021. }
  75022. interface XRTransientInputHitTestResult {
  75023. readonly inputSource: XRInputSource;
  75024. readonly results: Array<XRHitTestResult>;
  75025. }
  75026. interface XRHitTestResult {
  75027. getPose(baseSpace: XRSpace): XRPose | undefined;
  75028. // When anchor system is enabled
  75029. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75030. }
  75031. interface XRHitTestSource {
  75032. cancel(): void;
  75033. }
  75034. interface XRTransientInputHitTestSource {
  75035. cancel(): void;
  75036. }
  75037. interface XRHitTestOptionsInit {
  75038. space: XRSpace;
  75039. entityTypes?: Array<XRHitTestTrackableType>;
  75040. offsetRay?: XRRay;
  75041. }
  75042. interface XRTransientInputHitTestOptionsInit {
  75043. profile: string;
  75044. entityTypes?: Array<XRHitTestTrackableType>;
  75045. offsetRay?: XRRay;
  75046. }
  75047. interface XRAnchor {
  75048. anchorSpace: XRSpace;
  75049. delete(): void;
  75050. }
  75051. interface XRPlane {
  75052. orientation: "Horizontal" | "Vertical";
  75053. planeSpace: XRSpace;
  75054. polygon: Array<DOMPointReadOnly>;
  75055. lastChangedTime: number;
  75056. }
  75057. /**
  75058. * @ignore
  75059. */
  75060. declare module BABYLON.GLTF2.Exporter {
  75061. }
  75062. /**
  75063. * @ignore
  75064. */
  75065. declare module BABYLON.GLTF1 {
  75066. }
  75067. declare module BABYLON.GUI {
  75068. /**
  75069. * Class used to specific a value and its associated unit
  75070. */
  75071. export class ValueAndUnit {
  75072. /** defines the unit to store */
  75073. unit: number;
  75074. /** defines a boolean indicating if the value can be negative */
  75075. negativeValueAllowed: boolean;
  75076. private _value;
  75077. private _originalUnit;
  75078. /**
  75079. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75080. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75081. */
  75082. ignoreAdaptiveScaling: boolean;
  75083. /**
  75084. * Creates a new ValueAndUnit
  75085. * @param value defines the value to store
  75086. * @param unit defines the unit to store
  75087. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75088. */
  75089. constructor(value: number,
  75090. /** defines the unit to store */
  75091. unit?: number,
  75092. /** defines a boolean indicating if the value can be negative */
  75093. negativeValueAllowed?: boolean);
  75094. /** Gets a boolean indicating if the value is a percentage */
  75095. get isPercentage(): boolean;
  75096. /** Gets a boolean indicating if the value is store as pixel */
  75097. get isPixel(): boolean;
  75098. /** Gets direct internal value */
  75099. get internalValue(): number;
  75100. /**
  75101. * Gets value as pixel
  75102. * @param host defines the root host
  75103. * @param refValue defines the reference value for percentages
  75104. * @returns the value as pixel
  75105. */
  75106. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75107. /**
  75108. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75109. * @param value defines the value to store
  75110. * @param unit defines the unit to store
  75111. * @returns the current ValueAndUnit
  75112. */
  75113. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75114. /**
  75115. * Gets the value accordingly to its unit
  75116. * @param host defines the root host
  75117. * @returns the value
  75118. */
  75119. getValue(host: AdvancedDynamicTexture): number;
  75120. /**
  75121. * Gets a string representation of the value
  75122. * @param host defines the root host
  75123. * @param decimals defines an optional number of decimals to display
  75124. * @returns a string
  75125. */
  75126. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75127. /**
  75128. * Store a value parsed from a string
  75129. * @param source defines the source string
  75130. * @returns true if the value was successfully parsed
  75131. */
  75132. fromString(source: string | number): boolean;
  75133. private static _Regex;
  75134. private static _UNITMODE_PERCENTAGE;
  75135. private static _UNITMODE_PIXEL;
  75136. /** UNITMODE_PERCENTAGE */
  75137. static get UNITMODE_PERCENTAGE(): number;
  75138. /** UNITMODE_PIXEL */
  75139. static get UNITMODE_PIXEL(): number;
  75140. }
  75141. }
  75142. declare module BABYLON.GUI {
  75143. /**
  75144. * Define a style used by control to automatically setup properties based on a template.
  75145. * Only support font related properties so far
  75146. */
  75147. export class Style implements BABYLON.IDisposable {
  75148. private _fontFamily;
  75149. private _fontStyle;
  75150. private _fontWeight;
  75151. /** @hidden */
  75152. _host: AdvancedDynamicTexture;
  75153. /** @hidden */
  75154. _fontSize: ValueAndUnit;
  75155. /**
  75156. * BABYLON.Observable raised when the style values are changed
  75157. */
  75158. onChangedObservable: BABYLON.Observable<Style>;
  75159. /**
  75160. * Creates a new style object
  75161. * @param host defines the AdvancedDynamicTexture which hosts this style
  75162. */
  75163. constructor(host: AdvancedDynamicTexture);
  75164. /**
  75165. * Gets or sets the font size
  75166. */
  75167. get fontSize(): string | number;
  75168. set fontSize(value: string | number);
  75169. /**
  75170. * Gets or sets the font family
  75171. */
  75172. get fontFamily(): string;
  75173. set fontFamily(value: string);
  75174. /**
  75175. * Gets or sets the font style
  75176. */
  75177. get fontStyle(): string;
  75178. set fontStyle(value: string);
  75179. /** Gets or sets font weight */
  75180. get fontWeight(): string;
  75181. set fontWeight(value: string);
  75182. /** Dispose all associated resources */
  75183. dispose(): void;
  75184. }
  75185. }
  75186. declare module BABYLON.GUI {
  75187. /**
  75188. * Class used to transport BABYLON.Vector2 information for pointer events
  75189. */
  75190. export class Vector2WithInfo extends BABYLON.Vector2 {
  75191. /** defines the current mouse button index */
  75192. buttonIndex: number;
  75193. /**
  75194. * Creates a new Vector2WithInfo
  75195. * @param source defines the vector2 data to transport
  75196. * @param buttonIndex defines the current mouse button index
  75197. */
  75198. constructor(source: BABYLON.Vector2,
  75199. /** defines the current mouse button index */
  75200. buttonIndex?: number);
  75201. }
  75202. /** Class used to provide 2D matrix features */
  75203. export class Matrix2D {
  75204. /** Gets the internal array of 6 floats used to store matrix data */
  75205. m: Float32Array;
  75206. /**
  75207. * Creates a new matrix
  75208. * @param m00 defines value for (0, 0)
  75209. * @param m01 defines value for (0, 1)
  75210. * @param m10 defines value for (1, 0)
  75211. * @param m11 defines value for (1, 1)
  75212. * @param m20 defines value for (2, 0)
  75213. * @param m21 defines value for (2, 1)
  75214. */
  75215. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75216. /**
  75217. * Fills the matrix from direct values
  75218. * @param m00 defines value for (0, 0)
  75219. * @param m01 defines value for (0, 1)
  75220. * @param m10 defines value for (1, 0)
  75221. * @param m11 defines value for (1, 1)
  75222. * @param m20 defines value for (2, 0)
  75223. * @param m21 defines value for (2, 1)
  75224. * @returns the current modified matrix
  75225. */
  75226. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75227. /**
  75228. * Gets matrix determinant
  75229. * @returns the determinant
  75230. */
  75231. determinant(): number;
  75232. /**
  75233. * Inverses the matrix and stores it in a target matrix
  75234. * @param result defines the target matrix
  75235. * @returns the current matrix
  75236. */
  75237. invertToRef(result: Matrix2D): Matrix2D;
  75238. /**
  75239. * Multiplies the current matrix with another one
  75240. * @param other defines the second operand
  75241. * @param result defines the target matrix
  75242. * @returns the current matrix
  75243. */
  75244. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75245. /**
  75246. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75247. * @param x defines the x coordinate to transform
  75248. * @param y defines the x coordinate to transform
  75249. * @param result defines the target vector2
  75250. * @returns the current matrix
  75251. */
  75252. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75253. /**
  75254. * Creates an identity matrix
  75255. * @returns a new matrix
  75256. */
  75257. static Identity(): Matrix2D;
  75258. /**
  75259. * Creates a translation matrix and stores it in a target matrix
  75260. * @param x defines the x coordinate of the translation
  75261. * @param y defines the y coordinate of the translation
  75262. * @param result defines the target matrix
  75263. */
  75264. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75265. /**
  75266. * Creates a scaling matrix and stores it in a target matrix
  75267. * @param x defines the x coordinate of the scaling
  75268. * @param y defines the y coordinate of the scaling
  75269. * @param result defines the target matrix
  75270. */
  75271. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75272. /**
  75273. * Creates a rotation matrix and stores it in a target matrix
  75274. * @param angle defines the rotation angle
  75275. * @param result defines the target matrix
  75276. */
  75277. static RotationToRef(angle: number, result: Matrix2D): void;
  75278. private static _TempPreTranslationMatrix;
  75279. private static _TempPostTranslationMatrix;
  75280. private static _TempRotationMatrix;
  75281. private static _TempScalingMatrix;
  75282. private static _TempCompose0;
  75283. private static _TempCompose1;
  75284. private static _TempCompose2;
  75285. /**
  75286. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75287. * @param tx defines the x coordinate of the translation
  75288. * @param ty defines the y coordinate of the translation
  75289. * @param angle defines the rotation angle
  75290. * @param scaleX defines the x coordinate of the scaling
  75291. * @param scaleY defines the y coordinate of the scaling
  75292. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75293. * @param result defines the target matrix
  75294. */
  75295. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75296. }
  75297. }
  75298. declare module BABYLON.GUI {
  75299. /**
  75300. * Class used to store 2D control sizes
  75301. */
  75302. export class Measure {
  75303. /** defines left coordinate */
  75304. left: number;
  75305. /** defines top coordinate */
  75306. top: number;
  75307. /** defines width dimension */
  75308. width: number;
  75309. /** defines height dimension */
  75310. height: number;
  75311. /**
  75312. * Creates a new measure
  75313. * @param left defines left coordinate
  75314. * @param top defines top coordinate
  75315. * @param width defines width dimension
  75316. * @param height defines height dimension
  75317. */
  75318. constructor(
  75319. /** defines left coordinate */
  75320. left: number,
  75321. /** defines top coordinate */
  75322. top: number,
  75323. /** defines width dimension */
  75324. width: number,
  75325. /** defines height dimension */
  75326. height: number);
  75327. /**
  75328. * Copy from another measure
  75329. * @param other defines the other measure to copy from
  75330. */
  75331. copyFrom(other: Measure): void;
  75332. /**
  75333. * Copy from a group of 4 floats
  75334. * @param left defines left coordinate
  75335. * @param top defines top coordinate
  75336. * @param width defines width dimension
  75337. * @param height defines height dimension
  75338. */
  75339. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75340. /**
  75341. * Computes the axis aligned bounding box measure for two given measures
  75342. * @param a Input measure
  75343. * @param b Input measure
  75344. * @param result the resulting bounding measure
  75345. */
  75346. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75347. /**
  75348. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75349. * @param transform the matrix to transform the measure before computing the AABB
  75350. * @param result the resulting AABB
  75351. */
  75352. transformToRef(transform: Matrix2D, result: Measure): void;
  75353. /**
  75354. * Check equality between this measure and another one
  75355. * @param other defines the other measures
  75356. * @returns true if both measures are equals
  75357. */
  75358. isEqualsTo(other: Measure): boolean;
  75359. /**
  75360. * Creates an empty measure
  75361. * @returns a new measure
  75362. */
  75363. static Empty(): Measure;
  75364. }
  75365. }
  75366. declare module BABYLON.GUI {
  75367. /**
  75368. * Interface used to define a control that can receive focus
  75369. */
  75370. export interface IFocusableControl {
  75371. /**
  75372. * Function called when the control receives the focus
  75373. */
  75374. onFocus(): void;
  75375. /**
  75376. * Function called when the control loses the focus
  75377. */
  75378. onBlur(): void;
  75379. /**
  75380. * Function called to let the control handle keyboard events
  75381. * @param evt defines the current keyboard event
  75382. */
  75383. processKeyboard(evt: KeyboardEvent): void;
  75384. /**
  75385. * Function called to get the list of controls that should not steal the focus from this control
  75386. * @returns an array of controls
  75387. */
  75388. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75389. }
  75390. /**
  75391. * Class used to create texture to support 2D GUI elements
  75392. * @see https://doc.babylonjs.com/how_to/gui
  75393. */
  75394. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75395. private _isDirty;
  75396. private _renderObserver;
  75397. private _resizeObserver;
  75398. private _preKeyboardObserver;
  75399. private _pointerMoveObserver;
  75400. private _pointerObserver;
  75401. private _canvasPointerOutObserver;
  75402. private _background;
  75403. /** @hidden */
  75404. _rootContainer: Container;
  75405. /** @hidden */
  75406. _lastPickedControl: Control;
  75407. /** @hidden */
  75408. _lastControlOver: {
  75409. [pointerId: number]: Control;
  75410. };
  75411. /** @hidden */
  75412. _lastControlDown: {
  75413. [pointerId: number]: Control;
  75414. };
  75415. /** @hidden */
  75416. _capturingControl: {
  75417. [pointerId: number]: Control;
  75418. };
  75419. /** @hidden */
  75420. _shouldBlockPointer: boolean;
  75421. /** @hidden */
  75422. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75423. /** @hidden */
  75424. _linkedControls: Control[];
  75425. private _isFullscreen;
  75426. private _fullscreenViewport;
  75427. private _idealWidth;
  75428. private _idealHeight;
  75429. private _useSmallestIdeal;
  75430. private _renderAtIdealSize;
  75431. private _focusedControl;
  75432. private _blockNextFocusCheck;
  75433. private _renderScale;
  75434. private _rootElement;
  75435. private _cursorChanged;
  75436. private _defaultMousePointerId;
  75437. /** @hidden */
  75438. _numLayoutCalls: number;
  75439. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75440. get numLayoutCalls(): number;
  75441. /** @hidden */
  75442. _numRenderCalls: number;
  75443. /** Gets the number of render calls made the last time the ADT has been rendered */
  75444. get numRenderCalls(): number;
  75445. /**
  75446. * Define type to string to ensure compatibility across browsers
  75447. * Safari doesn't support DataTransfer constructor
  75448. */
  75449. private _clipboardData;
  75450. /**
  75451. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75452. */
  75453. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75454. /**
  75455. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75456. */
  75457. onControlPickedObservable: BABYLON.Observable<Control>;
  75458. /**
  75459. * BABYLON.Observable event triggered before layout is evaluated
  75460. */
  75461. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75462. /**
  75463. * BABYLON.Observable event triggered after the layout was evaluated
  75464. */
  75465. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75466. /**
  75467. * BABYLON.Observable event triggered before the texture is rendered
  75468. */
  75469. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75470. /**
  75471. * BABYLON.Observable event triggered after the texture was rendered
  75472. */
  75473. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75474. /**
  75475. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75476. */
  75477. premulAlpha: boolean;
  75478. /**
  75479. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75480. * Useful when you want more antialiasing
  75481. */
  75482. get renderScale(): number;
  75483. set renderScale(value: number);
  75484. /** Gets or sets the background color */
  75485. get background(): string;
  75486. set background(value: string);
  75487. /**
  75488. * Gets or sets the ideal width used to design controls.
  75489. * The GUI will then rescale everything accordingly
  75490. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75491. */
  75492. get idealWidth(): number;
  75493. set idealWidth(value: number);
  75494. /**
  75495. * Gets or sets the ideal height used to design controls.
  75496. * The GUI will then rescale everything accordingly
  75497. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75498. */
  75499. get idealHeight(): number;
  75500. set idealHeight(value: number);
  75501. /**
  75502. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75503. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75504. */
  75505. get useSmallestIdeal(): boolean;
  75506. set useSmallestIdeal(value: boolean);
  75507. /**
  75508. * Gets or sets a boolean indicating if adaptive scaling must be used
  75509. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75510. */
  75511. get renderAtIdealSize(): boolean;
  75512. set renderAtIdealSize(value: boolean);
  75513. /**
  75514. * Gets the ratio used when in "ideal mode"
  75515. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75516. * */
  75517. get idealRatio(): number;
  75518. /**
  75519. * Gets the underlying layer used to render the texture when in fullscreen mode
  75520. */
  75521. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75522. /**
  75523. * Gets the root container control
  75524. */
  75525. get rootContainer(): Container;
  75526. /**
  75527. * Returns an array containing the root container.
  75528. * This is mostly used to let the Inspector introspects the ADT
  75529. * @returns an array containing the rootContainer
  75530. */
  75531. getChildren(): Array<Container>;
  75532. /**
  75533. * Will return all controls that are inside this texture
  75534. * @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
  75535. * @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
  75536. * @return all child controls
  75537. */
  75538. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75539. /**
  75540. * Gets or sets the current focused control
  75541. */
  75542. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75543. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75544. /**
  75545. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75546. */
  75547. get isForeground(): boolean;
  75548. set isForeground(value: boolean);
  75549. /**
  75550. * Gets or set information about clipboardData
  75551. */
  75552. get clipboardData(): string;
  75553. set clipboardData(value: string);
  75554. /**
  75555. * Creates a new AdvancedDynamicTexture
  75556. * @param name defines the name of the texture
  75557. * @param width defines the width of the texture
  75558. * @param height defines the height of the texture
  75559. * @param scene defines the hosting scene
  75560. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75561. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75562. */
  75563. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75564. /**
  75565. * Get the current class name of the texture useful for serialization or dynamic coding.
  75566. * @returns "AdvancedDynamicTexture"
  75567. */
  75568. getClassName(): string;
  75569. /**
  75570. * Function used to execute a function on all controls
  75571. * @param func defines the function to execute
  75572. * @param container defines the container where controls belong. If null the root container will be used
  75573. */
  75574. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75575. private _useInvalidateRectOptimization;
  75576. /**
  75577. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75578. */
  75579. get useInvalidateRectOptimization(): boolean;
  75580. set useInvalidateRectOptimization(value: boolean);
  75581. private _invalidatedRectangle;
  75582. /**
  75583. * Invalidates a rectangle area on the gui texture
  75584. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75585. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75586. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75587. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75588. */
  75589. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75590. /**
  75591. * Marks the texture as dirty forcing a complete update
  75592. */
  75593. markAsDirty(): void;
  75594. /**
  75595. * Helper function used to create a new style
  75596. * @returns a new style
  75597. * @see https://doc.babylonjs.com/how_to/gui#styles
  75598. */
  75599. createStyle(): Style;
  75600. /**
  75601. * Adds a new control to the root container
  75602. * @param control defines the control to add
  75603. * @returns the current texture
  75604. */
  75605. addControl(control: Control): AdvancedDynamicTexture;
  75606. /**
  75607. * Removes a control from the root container
  75608. * @param control defines the control to remove
  75609. * @returns the current texture
  75610. */
  75611. removeControl(control: Control): AdvancedDynamicTexture;
  75612. /**
  75613. * Release all resources
  75614. */
  75615. dispose(): void;
  75616. private _onResize;
  75617. /** @hidden */
  75618. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75619. /**
  75620. * Get screen coordinates for a vector3
  75621. * @param position defines the position to project
  75622. * @param worldMatrix defines the world matrix to use
  75623. * @returns the projected position
  75624. */
  75625. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75626. private _checkUpdate;
  75627. private _clearMeasure;
  75628. private _render;
  75629. /** @hidden */
  75630. _changeCursor(cursor: string): void;
  75631. /** @hidden */
  75632. _registerLastControlDown(control: Control, pointerId: number): void;
  75633. private _doPicking;
  75634. /** @hidden */
  75635. _cleanControlAfterRemovalFromList(list: {
  75636. [pointerId: number]: Control;
  75637. }, control: Control): void;
  75638. /** @hidden */
  75639. _cleanControlAfterRemoval(control: Control): void;
  75640. /** Attach to all scene events required to support pointer events */
  75641. attach(): void;
  75642. /** @hidden */
  75643. private onClipboardCopy;
  75644. /** @hidden */
  75645. private onClipboardCut;
  75646. /** @hidden */
  75647. private onClipboardPaste;
  75648. /**
  75649. * Register the clipboard Events onto the canvas
  75650. */
  75651. registerClipboardEvents(): void;
  75652. /**
  75653. * Unregister the clipboard Events from the canvas
  75654. */
  75655. unRegisterClipboardEvents(): void;
  75656. /**
  75657. * Connect the texture to a hosting mesh to enable interactions
  75658. * @param mesh defines the mesh to attach to
  75659. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75660. */
  75661. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75662. /**
  75663. * Move the focus to a specific control
  75664. * @param control defines the control which will receive the focus
  75665. */
  75666. moveFocusToControl(control: IFocusableControl): void;
  75667. private _manageFocus;
  75668. private _attachToOnPointerOut;
  75669. /**
  75670. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75671. * @param mesh defines the mesh which will receive the texture
  75672. * @param width defines the texture width (1024 by default)
  75673. * @param height defines the texture height (1024 by default)
  75674. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75675. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75676. * @returns a new AdvancedDynamicTexture
  75677. */
  75678. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75679. /**
  75680. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75681. * In this mode the texture will rely on a layer for its rendering.
  75682. * This allows it to be treated like any other layer.
  75683. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75684. * LayerMask is set through advancedTexture.layer.layerMask
  75685. * @param name defines name for the texture
  75686. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75687. * @param scene defines the hsoting scene
  75688. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75689. * @returns a new AdvancedDynamicTexture
  75690. */
  75691. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75692. }
  75693. }
  75694. declare module BABYLON.GUI {
  75695. /**
  75696. * Root class used for all 2D controls
  75697. * @see https://doc.babylonjs.com/how_to/gui#controls
  75698. */
  75699. export class Control {
  75700. /** defines the name of the control */
  75701. name?: string | undefined;
  75702. /**
  75703. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75704. */
  75705. static AllowAlphaInheritance: boolean;
  75706. private _alpha;
  75707. private _alphaSet;
  75708. private _zIndex;
  75709. /** @hidden */
  75710. _host: AdvancedDynamicTexture;
  75711. /** Gets or sets the control parent */
  75712. parent: BABYLON.Nullable<Container>;
  75713. /** @hidden */
  75714. _currentMeasure: Measure;
  75715. private _fontFamily;
  75716. private _fontStyle;
  75717. private _fontWeight;
  75718. private _fontSize;
  75719. private _font;
  75720. /** @hidden */
  75721. _width: ValueAndUnit;
  75722. /** @hidden */
  75723. _height: ValueAndUnit;
  75724. /** @hidden */
  75725. protected _fontOffset: {
  75726. ascent: number;
  75727. height: number;
  75728. descent: number;
  75729. };
  75730. private _color;
  75731. private _style;
  75732. private _styleObserver;
  75733. /** @hidden */
  75734. protected _horizontalAlignment: number;
  75735. /** @hidden */
  75736. protected _verticalAlignment: number;
  75737. /** @hidden */
  75738. protected _isDirty: boolean;
  75739. /** @hidden */
  75740. protected _wasDirty: boolean;
  75741. /** @hidden */
  75742. _tempParentMeasure: Measure;
  75743. /** @hidden */
  75744. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75745. /** @hidden */
  75746. protected _cachedParentMeasure: Measure;
  75747. private _paddingLeft;
  75748. private _paddingRight;
  75749. private _paddingTop;
  75750. private _paddingBottom;
  75751. /** @hidden */
  75752. _left: ValueAndUnit;
  75753. /** @hidden */
  75754. _top: ValueAndUnit;
  75755. private _scaleX;
  75756. private _scaleY;
  75757. private _rotation;
  75758. private _transformCenterX;
  75759. private _transformCenterY;
  75760. /** @hidden */
  75761. _transformMatrix: Matrix2D;
  75762. /** @hidden */
  75763. protected _invertTransformMatrix: Matrix2D;
  75764. /** @hidden */
  75765. protected _transformedPosition: BABYLON.Vector2;
  75766. private _isMatrixDirty;
  75767. private _cachedOffsetX;
  75768. private _cachedOffsetY;
  75769. private _isVisible;
  75770. private _isHighlighted;
  75771. /** @hidden */
  75772. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75773. private _fontSet;
  75774. private _dummyVector2;
  75775. private _downCount;
  75776. private _enterCount;
  75777. private _doNotRender;
  75778. private _downPointerIds;
  75779. protected _isEnabled: boolean;
  75780. protected _disabledColor: string;
  75781. protected _disabledColorItem: string;
  75782. /** @hidden */
  75783. protected _rebuildLayout: boolean;
  75784. /** @hidden */
  75785. _customData: any;
  75786. /** @hidden */
  75787. _isClipped: boolean;
  75788. /** @hidden */
  75789. _automaticSize: boolean;
  75790. /** @hidden */
  75791. _tag: any;
  75792. /**
  75793. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  75794. */
  75795. uniqueId: number;
  75796. /**
  75797. * Gets or sets an object used to store user defined information for the node
  75798. */
  75799. metadata: any;
  75800. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75801. isHitTestVisible: boolean;
  75802. /** Gets or sets a boolean indicating if the control can block pointer events */
  75803. isPointerBlocker: boolean;
  75804. /** Gets or sets a boolean indicating if the control can be focusable */
  75805. isFocusInvisible: boolean;
  75806. /**
  75807. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75808. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  75809. */
  75810. clipChildren: boolean;
  75811. /**
  75812. * Gets or sets a boolean indicating that control content must be clipped
  75813. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  75814. */
  75815. clipContent: boolean;
  75816. /**
  75817. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75818. */
  75819. useBitmapCache: boolean;
  75820. private _cacheData;
  75821. private _shadowOffsetX;
  75822. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75823. get shadowOffsetX(): number;
  75824. set shadowOffsetX(value: number);
  75825. private _shadowOffsetY;
  75826. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75827. get shadowOffsetY(): number;
  75828. set shadowOffsetY(value: number);
  75829. private _shadowBlur;
  75830. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75831. get shadowBlur(): number;
  75832. set shadowBlur(value: number);
  75833. private _shadowColor;
  75834. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75835. get shadowColor(): string;
  75836. set shadowColor(value: string);
  75837. /** Gets or sets the cursor to use when the control is hovered */
  75838. hoverCursor: string;
  75839. /** @hidden */
  75840. protected _linkOffsetX: ValueAndUnit;
  75841. /** @hidden */
  75842. protected _linkOffsetY: ValueAndUnit;
  75843. /** Gets the control type name */
  75844. get typeName(): string;
  75845. /**
  75846. * Get the current class name of the control.
  75847. * @returns current class name
  75848. */
  75849. getClassName(): string;
  75850. /**
  75851. * An event triggered when pointer wheel is scrolled
  75852. */
  75853. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75854. /**
  75855. * An event triggered when the pointer move over the control.
  75856. */
  75857. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75858. /**
  75859. * An event triggered when the pointer move out of the control.
  75860. */
  75861. onPointerOutObservable: BABYLON.Observable<Control>;
  75862. /**
  75863. * An event triggered when the pointer taps the control
  75864. */
  75865. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75866. /**
  75867. * An event triggered when pointer up
  75868. */
  75869. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75870. /**
  75871. * An event triggered when a control is clicked on
  75872. */
  75873. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75874. /**
  75875. * An event triggered when pointer enters the control
  75876. */
  75877. onPointerEnterObservable: BABYLON.Observable<Control>;
  75878. /**
  75879. * An event triggered when the control is marked as dirty
  75880. */
  75881. onDirtyObservable: BABYLON.Observable<Control>;
  75882. /**
  75883. * An event triggered before drawing the control
  75884. */
  75885. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75886. /**
  75887. * An event triggered after the control was drawn
  75888. */
  75889. onAfterDrawObservable: BABYLON.Observable<Control>;
  75890. /**
  75891. * An event triggered when the control has been disposed
  75892. */
  75893. onDisposeObservable: BABYLON.Observable<Control>;
  75894. /**
  75895. * Get the hosting AdvancedDynamicTexture
  75896. */
  75897. get host(): AdvancedDynamicTexture;
  75898. /** Gets or set information about font offsets (used to render and align text) */
  75899. get fontOffset(): {
  75900. ascent: number;
  75901. height: number;
  75902. descent: number;
  75903. };
  75904. set fontOffset(offset: {
  75905. ascent: number;
  75906. height: number;
  75907. descent: number;
  75908. });
  75909. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75910. get alpha(): number;
  75911. set alpha(value: number);
  75912. /**
  75913. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75914. */
  75915. get isHighlighted(): boolean;
  75916. set isHighlighted(value: boolean);
  75917. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75918. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75919. */
  75920. get scaleX(): number;
  75921. set scaleX(value: number);
  75922. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75923. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75924. */
  75925. get scaleY(): number;
  75926. set scaleY(value: number);
  75927. /** Gets or sets the rotation angle (0 by default)
  75928. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75929. */
  75930. get rotation(): number;
  75931. set rotation(value: number);
  75932. /** Gets or sets the transformation center on Y axis (0 by default)
  75933. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75934. */
  75935. get transformCenterY(): number;
  75936. set transformCenterY(value: number);
  75937. /** Gets or sets the transformation center on X axis (0 by default)
  75938. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75939. */
  75940. get transformCenterX(): number;
  75941. set transformCenterX(value: number);
  75942. /**
  75943. * Gets or sets the horizontal alignment
  75944. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75945. */
  75946. get horizontalAlignment(): number;
  75947. set horizontalAlignment(value: number);
  75948. /**
  75949. * Gets or sets the vertical alignment
  75950. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75951. */
  75952. get verticalAlignment(): number;
  75953. set verticalAlignment(value: number);
  75954. /**
  75955. * Gets or sets control width
  75956. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75957. */
  75958. get width(): string | number;
  75959. set width(value: string | number);
  75960. /**
  75961. * Gets or sets the control width in pixel
  75962. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75963. */
  75964. get widthInPixels(): number;
  75965. set widthInPixels(value: number);
  75966. /**
  75967. * Gets or sets control height
  75968. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75969. */
  75970. get height(): string | number;
  75971. set height(value: string | number);
  75972. /**
  75973. * Gets or sets control height in pixel
  75974. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75975. */
  75976. get heightInPixels(): number;
  75977. set heightInPixels(value: number);
  75978. /** Gets or set font family */
  75979. get fontFamily(): string;
  75980. set fontFamily(value: string);
  75981. /** Gets or sets font style */
  75982. get fontStyle(): string;
  75983. set fontStyle(value: string);
  75984. /** Gets or sets font weight */
  75985. get fontWeight(): string;
  75986. set fontWeight(value: string);
  75987. /**
  75988. * Gets or sets style
  75989. * @see https://doc.babylonjs.com/how_to/gui#styles
  75990. */
  75991. get style(): BABYLON.Nullable<Style>;
  75992. set style(value: BABYLON.Nullable<Style>);
  75993. /** @hidden */
  75994. get _isFontSizeInPercentage(): boolean;
  75995. /** Gets or sets font size in pixels */
  75996. get fontSizeInPixels(): number;
  75997. set fontSizeInPixels(value: number);
  75998. /** Gets or sets font size */
  75999. get fontSize(): string | number;
  76000. set fontSize(value: string | number);
  76001. /** Gets or sets foreground color */
  76002. get color(): string;
  76003. set color(value: string);
  76004. /** Gets or sets z index which is used to reorder controls on the z axis */
  76005. get zIndex(): number;
  76006. set zIndex(value: number);
  76007. /** Gets or sets a boolean indicating if the control can be rendered */
  76008. get notRenderable(): boolean;
  76009. set notRenderable(value: boolean);
  76010. /** Gets or sets a boolean indicating if the control is visible */
  76011. get isVisible(): boolean;
  76012. set isVisible(value: boolean);
  76013. /** Gets a boolean indicating that the control needs to update its rendering */
  76014. get isDirty(): boolean;
  76015. /**
  76016. * Gets the current linked mesh (or null if none)
  76017. */
  76018. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76019. /**
  76020. * Gets or sets a value indicating the padding to use on the left of the control
  76021. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76022. */
  76023. get paddingLeft(): string | number;
  76024. set paddingLeft(value: string | number);
  76025. /**
  76026. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76027. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76028. */
  76029. get paddingLeftInPixels(): number;
  76030. set paddingLeftInPixels(value: number);
  76031. /**
  76032. * Gets or sets a value indicating the padding to use on the right of the control
  76033. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76034. */
  76035. get paddingRight(): string | number;
  76036. set paddingRight(value: string | number);
  76037. /**
  76038. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76039. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76040. */
  76041. get paddingRightInPixels(): number;
  76042. set paddingRightInPixels(value: number);
  76043. /**
  76044. * Gets or sets a value indicating the padding to use on the top of the control
  76045. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76046. */
  76047. get paddingTop(): string | number;
  76048. set paddingTop(value: string | number);
  76049. /**
  76050. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76051. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76052. */
  76053. get paddingTopInPixels(): number;
  76054. set paddingTopInPixels(value: number);
  76055. /**
  76056. * Gets or sets a value indicating the padding to use on the bottom of the control
  76057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76058. */
  76059. get paddingBottom(): string | number;
  76060. set paddingBottom(value: string | number);
  76061. /**
  76062. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76063. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76064. */
  76065. get paddingBottomInPixels(): number;
  76066. set paddingBottomInPixels(value: number);
  76067. /**
  76068. * Gets or sets a value indicating the left coordinate of the control
  76069. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76070. */
  76071. get left(): string | number;
  76072. set left(value: string | number);
  76073. /**
  76074. * Gets or sets a value indicating the left coordinate in pixels of the control
  76075. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76076. */
  76077. get leftInPixels(): number;
  76078. set leftInPixels(value: number);
  76079. /**
  76080. * Gets or sets a value indicating the top coordinate of the control
  76081. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76082. */
  76083. get top(): string | number;
  76084. set top(value: string | number);
  76085. /**
  76086. * Gets or sets a value indicating the top coordinate in pixels of the control
  76087. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76088. */
  76089. get topInPixels(): number;
  76090. set topInPixels(value: number);
  76091. /**
  76092. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76093. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76094. */
  76095. get linkOffsetX(): string | number;
  76096. set linkOffsetX(value: string | number);
  76097. /**
  76098. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76099. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76100. */
  76101. get linkOffsetXInPixels(): number;
  76102. set linkOffsetXInPixels(value: number);
  76103. /**
  76104. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76105. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76106. */
  76107. get linkOffsetY(): string | number;
  76108. set linkOffsetY(value: string | number);
  76109. /**
  76110. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76111. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76112. */
  76113. get linkOffsetYInPixels(): number;
  76114. set linkOffsetYInPixels(value: number);
  76115. /** Gets the center coordinate on X axis */
  76116. get centerX(): number;
  76117. /** Gets the center coordinate on Y axis */
  76118. get centerY(): number;
  76119. /** Gets or sets if control is Enabled*/
  76120. get isEnabled(): boolean;
  76121. set isEnabled(value: boolean);
  76122. /** Gets or sets background color of control if it's disabled*/
  76123. get disabledColor(): string;
  76124. set disabledColor(value: string);
  76125. /** Gets or sets front color of control if it's disabled*/
  76126. get disabledColorItem(): string;
  76127. set disabledColorItem(value: string);
  76128. /**
  76129. * Creates a new control
  76130. * @param name defines the name of the control
  76131. */
  76132. constructor(
  76133. /** defines the name of the control */
  76134. name?: string | undefined);
  76135. /** @hidden */
  76136. protected _getTypeName(): string;
  76137. /**
  76138. * Gets the first ascendant in the hierarchy of the given type
  76139. * @param className defines the required type
  76140. * @returns the ascendant or null if not found
  76141. */
  76142. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76143. /** @hidden */
  76144. _resetFontCache(): void;
  76145. /**
  76146. * Determines if a container is an ascendant of the current control
  76147. * @param container defines the container to look for
  76148. * @returns true if the container is one of the ascendant of the control
  76149. */
  76150. isAscendant(container: Control): boolean;
  76151. /**
  76152. * Gets coordinates in local control space
  76153. * @param globalCoordinates defines the coordinates to transform
  76154. * @returns the new coordinates in local space
  76155. */
  76156. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76157. /**
  76158. * Gets coordinates in local control space
  76159. * @param globalCoordinates defines the coordinates to transform
  76160. * @param result defines the target vector2 where to store the result
  76161. * @returns the current control
  76162. */
  76163. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76164. /**
  76165. * Gets coordinates in parent local control space
  76166. * @param globalCoordinates defines the coordinates to transform
  76167. * @returns the new coordinates in parent local space
  76168. */
  76169. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76170. /**
  76171. * Move the current control to a vector3 position projected onto the screen.
  76172. * @param position defines the target position
  76173. * @param scene defines the hosting scene
  76174. */
  76175. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76176. /**
  76177. * Will store all controls that have this control as ascendant in a given array
  76178. * @param results defines the array where to store the descendants
  76179. * @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
  76180. * @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
  76181. */
  76182. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76183. /**
  76184. * Will return all controls that have this control as ascendant
  76185. * @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
  76186. * @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
  76187. * @return all child controls
  76188. */
  76189. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76190. /**
  76191. * Link current control with a target mesh
  76192. * @param mesh defines the mesh to link with
  76193. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76194. */
  76195. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76196. /** @hidden */
  76197. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76198. /** @hidden */
  76199. _offsetLeft(offset: number): void;
  76200. /** @hidden */
  76201. _offsetTop(offset: number): void;
  76202. /** @hidden */
  76203. _markMatrixAsDirty(): void;
  76204. /** @hidden */
  76205. _flagDescendantsAsMatrixDirty(): void;
  76206. /** @hidden */
  76207. _intersectsRect(rect: Measure): boolean;
  76208. /** @hidden */
  76209. protected invalidateRect(): void;
  76210. /** @hidden */
  76211. _markAsDirty(force?: boolean): void;
  76212. /** @hidden */
  76213. _markAllAsDirty(): void;
  76214. /** @hidden */
  76215. _link(host: AdvancedDynamicTexture): void;
  76216. /** @hidden */
  76217. protected _transform(context?: CanvasRenderingContext2D): void;
  76218. /** @hidden */
  76219. _renderHighlight(context: CanvasRenderingContext2D): void;
  76220. /** @hidden */
  76221. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76222. /** @hidden */
  76223. protected _applyStates(context: CanvasRenderingContext2D): void;
  76224. /** @hidden */
  76225. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76226. /** @hidden */
  76227. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76228. protected _evaluateClippingState(parentMeasure: Measure): void;
  76229. /** @hidden */
  76230. _measure(): void;
  76231. /** @hidden */
  76232. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76233. /** @hidden */
  76234. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76235. /** @hidden */
  76236. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76237. /** @hidden */
  76238. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76239. private static _ClipMeasure;
  76240. private _tmpMeasureA;
  76241. private _clip;
  76242. /** @hidden */
  76243. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76244. /** @hidden */
  76245. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76246. /**
  76247. * Tests if a given coordinates belong to the current control
  76248. * @param x defines x coordinate to test
  76249. * @param y defines y coordinate to test
  76250. * @returns true if the coordinates are inside the control
  76251. */
  76252. contains(x: number, y: number): boolean;
  76253. /** @hidden */
  76254. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76255. /** @hidden */
  76256. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76257. /** @hidden */
  76258. _onPointerEnter(target: Control): boolean;
  76259. /** @hidden */
  76260. _onPointerOut(target: Control, force?: boolean): void;
  76261. /** @hidden */
  76262. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76263. /** @hidden */
  76264. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76265. /** @hidden */
  76266. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76267. /** @hidden */
  76268. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76269. /** @hidden */
  76270. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76271. private _prepareFont;
  76272. /** Releases associated resources */
  76273. dispose(): void;
  76274. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76275. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76276. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76277. private static _VERTICAL_ALIGNMENT_TOP;
  76278. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76279. private static _VERTICAL_ALIGNMENT_CENTER;
  76280. /** HORIZONTAL_ALIGNMENT_LEFT */
  76281. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76282. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76283. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76284. /** HORIZONTAL_ALIGNMENT_CENTER */
  76285. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76286. /** VERTICAL_ALIGNMENT_TOP */
  76287. static get VERTICAL_ALIGNMENT_TOP(): number;
  76288. /** VERTICAL_ALIGNMENT_BOTTOM */
  76289. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76290. /** VERTICAL_ALIGNMENT_CENTER */
  76291. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76292. private static _FontHeightSizes;
  76293. /** @hidden */
  76294. static _GetFontOffset(font: string): {
  76295. ascent: number;
  76296. height: number;
  76297. descent: number;
  76298. };
  76299. /**
  76300. * Creates a stack panel that can be used to render headers
  76301. * @param control defines the control to associate with the header
  76302. * @param text defines the text of the header
  76303. * @param size defines the size of the header
  76304. * @param options defines options used to configure the header
  76305. * @returns a new StackPanel
  76306. * @ignore
  76307. * @hidden
  76308. */
  76309. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76310. isHorizontal: boolean;
  76311. controlFirst: boolean;
  76312. }) => any;
  76313. /** @hidden */
  76314. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76315. }
  76316. }
  76317. declare module BABYLON.GUI {
  76318. /**
  76319. * Root class for 2D containers
  76320. * @see https://doc.babylonjs.com/how_to/gui#containers
  76321. */
  76322. export class Container extends Control {
  76323. name?: string | undefined;
  76324. /** @hidden */
  76325. _children: Control[];
  76326. /** @hidden */
  76327. protected _measureForChildren: Measure;
  76328. /** @hidden */
  76329. protected _background: string;
  76330. /** @hidden */
  76331. protected _adaptWidthToChildren: boolean;
  76332. /** @hidden */
  76333. protected _adaptHeightToChildren: boolean;
  76334. /**
  76335. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76336. */
  76337. logLayoutCycleErrors: boolean;
  76338. /**
  76339. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76340. */
  76341. maxLayoutCycle: number;
  76342. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76343. get adaptHeightToChildren(): boolean;
  76344. set adaptHeightToChildren(value: boolean);
  76345. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76346. get adaptWidthToChildren(): boolean;
  76347. set adaptWidthToChildren(value: boolean);
  76348. /** Gets or sets background color */
  76349. get background(): string;
  76350. set background(value: string);
  76351. /** Gets the list of children */
  76352. get children(): Control[];
  76353. /**
  76354. * Creates a new Container
  76355. * @param name defines the name of the container
  76356. */
  76357. constructor(name?: string | undefined);
  76358. protected _getTypeName(): string;
  76359. _flagDescendantsAsMatrixDirty(): void;
  76360. /**
  76361. * Gets a child using its name
  76362. * @param name defines the child name to look for
  76363. * @returns the child control if found
  76364. */
  76365. getChildByName(name: string): BABYLON.Nullable<Control>;
  76366. /**
  76367. * Gets a child using its type and its name
  76368. * @param name defines the child name to look for
  76369. * @param type defines the child type to look for
  76370. * @returns the child control if found
  76371. */
  76372. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76373. /**
  76374. * Search for a specific control in children
  76375. * @param control defines the control to look for
  76376. * @returns true if the control is in child list
  76377. */
  76378. containsControl(control: Control): boolean;
  76379. /**
  76380. * Adds a new control to the current container
  76381. * @param control defines the control to add
  76382. * @returns the current container
  76383. */
  76384. addControl(control: BABYLON.Nullable<Control>): Container;
  76385. /**
  76386. * Removes all controls from the current container
  76387. * @returns the current container
  76388. */
  76389. clearControls(): Container;
  76390. /**
  76391. * Removes a control from the current container
  76392. * @param control defines the control to remove
  76393. * @returns the current container
  76394. */
  76395. removeControl(control: Control): Container;
  76396. /** @hidden */
  76397. _reOrderControl(control: Control): void;
  76398. /** @hidden */
  76399. _offsetLeft(offset: number): void;
  76400. /** @hidden */
  76401. _offsetTop(offset: number): void;
  76402. /** @hidden */
  76403. _markAllAsDirty(): void;
  76404. /** @hidden */
  76405. protected _localDraw(context: CanvasRenderingContext2D): void;
  76406. /** @hidden */
  76407. _link(host: AdvancedDynamicTexture): void;
  76408. /** @hidden */
  76409. protected _beforeLayout(): void;
  76410. /** @hidden */
  76411. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76412. /** @hidden */
  76413. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76414. protected _postMeasure(): void;
  76415. /** @hidden */
  76416. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76417. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76418. /** @hidden */
  76419. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76420. /** @hidden */
  76421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76422. /** Releases associated resources */
  76423. dispose(): void;
  76424. }
  76425. }
  76426. declare module BABYLON.GUI {
  76427. /** Class used to create rectangle container */
  76428. export class Rectangle extends Container {
  76429. name?: string | undefined;
  76430. private _thickness;
  76431. private _cornerRadius;
  76432. /** Gets or sets border thickness */
  76433. get thickness(): number;
  76434. set thickness(value: number);
  76435. /** Gets or sets the corner radius angle */
  76436. get cornerRadius(): number;
  76437. set cornerRadius(value: number);
  76438. /**
  76439. * Creates a new Rectangle
  76440. * @param name defines the control name
  76441. */
  76442. constructor(name?: string | undefined);
  76443. protected _getTypeName(): string;
  76444. protected _localDraw(context: CanvasRenderingContext2D): void;
  76445. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76446. private _drawRoundedRect;
  76447. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76448. }
  76449. }
  76450. declare module BABYLON.GUI {
  76451. /**
  76452. * Enum that determines the text-wrapping mode to use.
  76453. */
  76454. export enum TextWrapping {
  76455. /**
  76456. * Clip the text when it's larger than Control.width; this is the default mode.
  76457. */
  76458. Clip = 0,
  76459. /**
  76460. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76461. */
  76462. WordWrap = 1,
  76463. /**
  76464. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76465. */
  76466. Ellipsis = 2
  76467. }
  76468. /**
  76469. * Class used to create text block control
  76470. */
  76471. export class TextBlock extends Control {
  76472. /**
  76473. * Defines the name of the control
  76474. */
  76475. name?: string | undefined;
  76476. private _text;
  76477. private _textWrapping;
  76478. private _textHorizontalAlignment;
  76479. private _textVerticalAlignment;
  76480. private _lines;
  76481. private _resizeToFit;
  76482. private _lineSpacing;
  76483. private _outlineWidth;
  76484. private _outlineColor;
  76485. /**
  76486. * An event triggered after the text is changed
  76487. */
  76488. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76489. /**
  76490. * An event triggered after the text was broken up into lines
  76491. */
  76492. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76493. /**
  76494. * Function used to split a string into words. By default, a string is split at each space character found
  76495. */
  76496. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76497. /**
  76498. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76499. */
  76500. get lines(): any[];
  76501. /**
  76502. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76503. */
  76504. get resizeToFit(): boolean;
  76505. /**
  76506. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76507. */
  76508. set resizeToFit(value: boolean);
  76509. /**
  76510. * Gets or sets a boolean indicating if text must be wrapped
  76511. */
  76512. get textWrapping(): TextWrapping | boolean;
  76513. /**
  76514. * Gets or sets a boolean indicating if text must be wrapped
  76515. */
  76516. set textWrapping(value: TextWrapping | boolean);
  76517. /**
  76518. * Gets or sets text to display
  76519. */
  76520. get text(): string;
  76521. /**
  76522. * Gets or sets text to display
  76523. */
  76524. set text(value: string);
  76525. /**
  76526. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76527. */
  76528. get textHorizontalAlignment(): number;
  76529. /**
  76530. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76531. */
  76532. set textHorizontalAlignment(value: number);
  76533. /**
  76534. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76535. */
  76536. get textVerticalAlignment(): number;
  76537. /**
  76538. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76539. */
  76540. set textVerticalAlignment(value: number);
  76541. /**
  76542. * Gets or sets line spacing value
  76543. */
  76544. set lineSpacing(value: string | number);
  76545. /**
  76546. * Gets or sets line spacing value
  76547. */
  76548. get lineSpacing(): string | number;
  76549. /**
  76550. * Gets or sets outlineWidth of the text to display
  76551. */
  76552. get outlineWidth(): number;
  76553. /**
  76554. * Gets or sets outlineWidth of the text to display
  76555. */
  76556. set outlineWidth(value: number);
  76557. /**
  76558. * Gets or sets outlineColor of the text to display
  76559. */
  76560. get outlineColor(): string;
  76561. /**
  76562. * Gets or sets outlineColor of the text to display
  76563. */
  76564. set outlineColor(value: string);
  76565. /**
  76566. * Creates a new TextBlock object
  76567. * @param name defines the name of the control
  76568. * @param text defines the text to display (emptry string by default)
  76569. */
  76570. constructor(
  76571. /**
  76572. * Defines the name of the control
  76573. */
  76574. name?: string | undefined, text?: string);
  76575. protected _getTypeName(): string;
  76576. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76577. private _drawText;
  76578. /** @hidden */
  76579. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76580. protected _applyStates(context: CanvasRenderingContext2D): void;
  76581. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76582. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76583. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76584. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76585. protected _renderLines(context: CanvasRenderingContext2D): void;
  76586. /**
  76587. * Given a width constraint applied on the text block, find the expected height
  76588. * @returns expected height
  76589. */
  76590. computeExpectedHeight(): number;
  76591. dispose(): void;
  76592. }
  76593. }
  76594. declare module BABYLON.GUI {
  76595. /**
  76596. * Class used to create 2D images
  76597. */
  76598. export class Image extends Control {
  76599. name?: string | undefined;
  76600. private _workingCanvas;
  76601. private _domImage;
  76602. private _imageWidth;
  76603. private _imageHeight;
  76604. private _loaded;
  76605. private _stretch;
  76606. private _source;
  76607. private _autoScale;
  76608. private _sourceLeft;
  76609. private _sourceTop;
  76610. private _sourceWidth;
  76611. private _sourceHeight;
  76612. private _svgAttributesComputationCompleted;
  76613. private _isSVG;
  76614. private _cellWidth;
  76615. private _cellHeight;
  76616. private _cellId;
  76617. private _populateNinePatchSlicesFromImage;
  76618. private _sliceLeft;
  76619. private _sliceRight;
  76620. private _sliceTop;
  76621. private _sliceBottom;
  76622. private _detectPointerOnOpaqueOnly;
  76623. /**
  76624. * BABYLON.Observable notified when the content is loaded
  76625. */
  76626. onImageLoadedObservable: BABYLON.Observable<Image>;
  76627. /**
  76628. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76629. */
  76630. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76631. /**
  76632. * Gets a boolean indicating that the content is loaded
  76633. */
  76634. get isLoaded(): boolean;
  76635. /**
  76636. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76637. */
  76638. get populateNinePatchSlicesFromImage(): boolean;
  76639. set populateNinePatchSlicesFromImage(value: boolean);
  76640. /**
  76641. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76642. * Beware using this as this will comsume more memory as the image has to be stored twice
  76643. */
  76644. get detectPointerOnOpaqueOnly(): boolean;
  76645. set detectPointerOnOpaqueOnly(value: boolean);
  76646. /**
  76647. * Gets or sets the left value for slicing (9-patch)
  76648. */
  76649. get sliceLeft(): number;
  76650. set sliceLeft(value: number);
  76651. /**
  76652. * Gets or sets the right value for slicing (9-patch)
  76653. */
  76654. get sliceRight(): number;
  76655. set sliceRight(value: number);
  76656. /**
  76657. * Gets or sets the top value for slicing (9-patch)
  76658. */
  76659. get sliceTop(): number;
  76660. set sliceTop(value: number);
  76661. /**
  76662. * Gets or sets the bottom value for slicing (9-patch)
  76663. */
  76664. get sliceBottom(): number;
  76665. set sliceBottom(value: number);
  76666. /**
  76667. * Gets or sets the left coordinate in the source image
  76668. */
  76669. get sourceLeft(): number;
  76670. set sourceLeft(value: number);
  76671. /**
  76672. * Gets or sets the top coordinate in the source image
  76673. */
  76674. get sourceTop(): number;
  76675. set sourceTop(value: number);
  76676. /**
  76677. * Gets or sets the width to capture in the source image
  76678. */
  76679. get sourceWidth(): number;
  76680. set sourceWidth(value: number);
  76681. /**
  76682. * Gets or sets the height to capture in the source image
  76683. */
  76684. get sourceHeight(): number;
  76685. set sourceHeight(value: number);
  76686. /** Indicates if the format of the image is SVG */
  76687. get isSVG(): boolean;
  76688. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76689. get svgAttributesComputationCompleted(): boolean;
  76690. /**
  76691. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76692. * @see https://doc.babylonjs.com/how_to/gui#image
  76693. */
  76694. get autoScale(): boolean;
  76695. set autoScale(value: boolean);
  76696. /** Gets or sets the streching mode used by the image */
  76697. get stretch(): number;
  76698. set stretch(value: number);
  76699. /** @hidden */
  76700. _rotate90(n: number, preserveProperties?: boolean): Image;
  76701. private _handleRotationForSVGImage;
  76702. private _rotate90SourceProperties;
  76703. /**
  76704. * Gets or sets the internal DOM image used to render the control
  76705. */
  76706. set domImage(value: HTMLImageElement);
  76707. get domImage(): HTMLImageElement;
  76708. private _onImageLoaded;
  76709. private _extractNinePatchSliceDataFromImage;
  76710. /**
  76711. * Gets or sets image source url
  76712. */
  76713. set source(value: BABYLON.Nullable<string>);
  76714. /**
  76715. * Checks for svg document with icon id present
  76716. */
  76717. private _svgCheck;
  76718. /**
  76719. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76720. * given external svg file and icon id
  76721. */
  76722. private _getSVGAttribs;
  76723. /**
  76724. * Gets or sets the cell width to use when animation sheet is enabled
  76725. * @see https://doc.babylonjs.com/how_to/gui#image
  76726. */
  76727. get cellWidth(): number;
  76728. set cellWidth(value: number);
  76729. /**
  76730. * Gets or sets the cell height to use when animation sheet is enabled
  76731. * @see https://doc.babylonjs.com/how_to/gui#image
  76732. */
  76733. get cellHeight(): number;
  76734. set cellHeight(value: number);
  76735. /**
  76736. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76737. * @see https://doc.babylonjs.com/how_to/gui#image
  76738. */
  76739. get cellId(): number;
  76740. set cellId(value: number);
  76741. /**
  76742. * Creates a new Image
  76743. * @param name defines the control name
  76744. * @param url defines the image url
  76745. */
  76746. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76747. /**
  76748. * Tests if a given coordinates belong to the current control
  76749. * @param x defines x coordinate to test
  76750. * @param y defines y coordinate to test
  76751. * @returns true if the coordinates are inside the control
  76752. */
  76753. contains(x: number, y: number): boolean;
  76754. protected _getTypeName(): string;
  76755. /** Force the control to synchronize with its content */
  76756. synchronizeSizeWithContent(): void;
  76757. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76758. private _prepareWorkingCanvasForOpaqueDetection;
  76759. private _drawImage;
  76760. _draw(context: CanvasRenderingContext2D): void;
  76761. private _renderCornerPatch;
  76762. private _renderNinePatch;
  76763. dispose(): void;
  76764. /** STRETCH_NONE */
  76765. static readonly STRETCH_NONE: number;
  76766. /** STRETCH_FILL */
  76767. static readonly STRETCH_FILL: number;
  76768. /** STRETCH_UNIFORM */
  76769. static readonly STRETCH_UNIFORM: number;
  76770. /** STRETCH_EXTEND */
  76771. static readonly STRETCH_EXTEND: number;
  76772. /** NINE_PATCH */
  76773. static readonly STRETCH_NINE_PATCH: number;
  76774. }
  76775. }
  76776. declare module BABYLON.GUI {
  76777. /**
  76778. * Class used to create 2D buttons
  76779. */
  76780. export class Button extends Rectangle {
  76781. name?: string | undefined;
  76782. /**
  76783. * Function called to generate a pointer enter animation
  76784. */
  76785. pointerEnterAnimation: () => void;
  76786. /**
  76787. * Function called to generate a pointer out animation
  76788. */
  76789. pointerOutAnimation: () => void;
  76790. /**
  76791. * Function called to generate a pointer down animation
  76792. */
  76793. pointerDownAnimation: () => void;
  76794. /**
  76795. * Function called to generate a pointer up animation
  76796. */
  76797. pointerUpAnimation: () => void;
  76798. /**
  76799. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76800. */
  76801. delegatePickingToChildren: boolean;
  76802. private _image;
  76803. /**
  76804. * Returns the image part of the button (if any)
  76805. */
  76806. get image(): BABYLON.Nullable<Image>;
  76807. private _textBlock;
  76808. /**
  76809. * Returns the image part of the button (if any)
  76810. */
  76811. get textBlock(): BABYLON.Nullable<TextBlock>;
  76812. /**
  76813. * Creates a new Button
  76814. * @param name defines the name of the button
  76815. */
  76816. constructor(name?: string | undefined);
  76817. protected _getTypeName(): string;
  76818. /** @hidden */
  76819. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76820. /** @hidden */
  76821. _onPointerEnter(target: Control): boolean;
  76822. /** @hidden */
  76823. _onPointerOut(target: Control, force?: boolean): void;
  76824. /** @hidden */
  76825. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76826. /** @hidden */
  76827. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76828. /**
  76829. * Creates a new button made with an image and a text
  76830. * @param name defines the name of the button
  76831. * @param text defines the text of the button
  76832. * @param imageUrl defines the url of the image
  76833. * @returns a new Button
  76834. */
  76835. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76836. /**
  76837. * Creates a new button made with an image
  76838. * @param name defines the name of the button
  76839. * @param imageUrl defines the url of the image
  76840. * @returns a new Button
  76841. */
  76842. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76843. /**
  76844. * Creates a new button made with a text
  76845. * @param name defines the name of the button
  76846. * @param text defines the text of the button
  76847. * @returns a new Button
  76848. */
  76849. static CreateSimpleButton(name: string, text: string): Button;
  76850. /**
  76851. * Creates a new button made with an image and a centered text
  76852. * @param name defines the name of the button
  76853. * @param text defines the text of the button
  76854. * @param imageUrl defines the url of the image
  76855. * @returns a new Button
  76856. */
  76857. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76858. }
  76859. }
  76860. declare module BABYLON.GUI {
  76861. /**
  76862. * Class used to create a 2D stack panel container
  76863. */
  76864. export class StackPanel extends Container {
  76865. name?: string | undefined;
  76866. private _isVertical;
  76867. private _manualWidth;
  76868. private _manualHeight;
  76869. private _doNotTrackManualChanges;
  76870. /**
  76871. * Gets or sets a boolean indicating that layou warnings should be ignored
  76872. */
  76873. ignoreLayoutWarnings: boolean;
  76874. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76875. get isVertical(): boolean;
  76876. set isVertical(value: boolean);
  76877. /**
  76878. * Gets or sets panel width.
  76879. * This value should not be set when in horizontal mode as it will be computed automatically
  76880. */
  76881. set width(value: string | number);
  76882. get width(): string | number;
  76883. /**
  76884. * Gets or sets panel height.
  76885. * This value should not be set when in vertical mode as it will be computed automatically
  76886. */
  76887. set height(value: string | number);
  76888. get height(): string | number;
  76889. /**
  76890. * Creates a new StackPanel
  76891. * @param name defines control name
  76892. */
  76893. constructor(name?: string | undefined);
  76894. protected _getTypeName(): string;
  76895. /** @hidden */
  76896. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76897. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76898. protected _postMeasure(): void;
  76899. }
  76900. }
  76901. declare module BABYLON.GUI {
  76902. /**
  76903. * Class used to represent a 2D checkbox
  76904. */
  76905. export class Checkbox extends Control {
  76906. name?: string | undefined;
  76907. private _isChecked;
  76908. private _background;
  76909. private _checkSizeRatio;
  76910. private _thickness;
  76911. /** Gets or sets border thickness */
  76912. get thickness(): number;
  76913. set thickness(value: number);
  76914. /**
  76915. * BABYLON.Observable raised when isChecked property changes
  76916. */
  76917. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76918. /** Gets or sets a value indicating the ratio between overall size and check size */
  76919. get checkSizeRatio(): number;
  76920. set checkSizeRatio(value: number);
  76921. /** Gets or sets background color */
  76922. get background(): string;
  76923. set background(value: string);
  76924. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76925. get isChecked(): boolean;
  76926. set isChecked(value: boolean);
  76927. /**
  76928. * Creates a new CheckBox
  76929. * @param name defines the control name
  76930. */
  76931. constructor(name?: string | undefined);
  76932. protected _getTypeName(): string;
  76933. /** @hidden */
  76934. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76935. /** @hidden */
  76936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76937. /**
  76938. * Utility function to easily create a checkbox with a header
  76939. * @param title defines the label to use for the header
  76940. * @param onValueChanged defines the callback to call when value changes
  76941. * @returns a StackPanel containing the checkbox and a textBlock
  76942. */
  76943. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76944. }
  76945. }
  76946. declare module BABYLON.GUI {
  76947. /**
  76948. * Class used to store key control properties
  76949. */
  76950. export class KeyPropertySet {
  76951. /** Width */
  76952. width?: string;
  76953. /** Height */
  76954. height?: string;
  76955. /** Left padding */
  76956. paddingLeft?: string;
  76957. /** Right padding */
  76958. paddingRight?: string;
  76959. /** Top padding */
  76960. paddingTop?: string;
  76961. /** Bottom padding */
  76962. paddingBottom?: string;
  76963. /** Foreground color */
  76964. color?: string;
  76965. /** Background color */
  76966. background?: string;
  76967. }
  76968. /**
  76969. * Class used to create virtual keyboard
  76970. */
  76971. export class VirtualKeyboard extends StackPanel {
  76972. /** BABYLON.Observable raised when a key is pressed */
  76973. onKeyPressObservable: BABYLON.Observable<string>;
  76974. /** Gets or sets default key button width */
  76975. defaultButtonWidth: string;
  76976. /** Gets or sets default key button height */
  76977. defaultButtonHeight: string;
  76978. /** Gets or sets default key button left padding */
  76979. defaultButtonPaddingLeft: string;
  76980. /** Gets or sets default key button right padding */
  76981. defaultButtonPaddingRight: string;
  76982. /** Gets or sets default key button top padding */
  76983. defaultButtonPaddingTop: string;
  76984. /** Gets or sets default key button bottom padding */
  76985. defaultButtonPaddingBottom: string;
  76986. /** Gets or sets default key button foreground color */
  76987. defaultButtonColor: string;
  76988. /** Gets or sets default key button background color */
  76989. defaultButtonBackground: string;
  76990. /** Gets or sets shift button foreground color */
  76991. shiftButtonColor: string;
  76992. /** Gets or sets shift button thickness*/
  76993. selectedShiftThickness: number;
  76994. /** Gets shift key state */
  76995. shiftState: number;
  76996. protected _getTypeName(): string;
  76997. private _createKey;
  76998. /**
  76999. * Adds a new row of keys
  77000. * @param keys defines the list of keys to add
  77001. * @param propertySets defines the associated property sets
  77002. */
  77003. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77004. /**
  77005. * Set the shift key to a specific state
  77006. * @param shiftState defines the new shift state
  77007. */
  77008. applyShiftState(shiftState: number): void;
  77009. private _currentlyConnectedInputText;
  77010. private _connectedInputTexts;
  77011. private _onKeyPressObserver;
  77012. /** Gets the input text control currently attached to the keyboard */
  77013. get connectedInputText(): BABYLON.Nullable<InputText>;
  77014. /**
  77015. * Connects the keyboard with an input text control
  77016. *
  77017. * @param input defines the target control
  77018. */
  77019. connect(input: InputText): void;
  77020. /**
  77021. * Disconnects the keyboard from connected InputText controls
  77022. *
  77023. * @param input optionally defines a target control, otherwise all are disconnected
  77024. */
  77025. disconnect(input?: InputText): void;
  77026. private _removeConnectedInputObservables;
  77027. /**
  77028. * Release all resources
  77029. */
  77030. dispose(): void;
  77031. /**
  77032. * Creates a new keyboard using a default layout
  77033. *
  77034. * @param name defines control name
  77035. * @returns a new VirtualKeyboard
  77036. */
  77037. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77038. }
  77039. }
  77040. declare module BABYLON.GUI {
  77041. /**
  77042. * Class used to create input text control
  77043. */
  77044. export class InputText extends Control implements IFocusableControl {
  77045. name?: string | undefined;
  77046. private _text;
  77047. private _placeholderText;
  77048. private _background;
  77049. private _focusedBackground;
  77050. private _focusedColor;
  77051. private _placeholderColor;
  77052. private _thickness;
  77053. private _margin;
  77054. private _autoStretchWidth;
  77055. private _maxWidth;
  77056. private _isFocused;
  77057. private _blinkTimeout;
  77058. private _blinkIsEven;
  77059. private _cursorOffset;
  77060. private _scrollLeft;
  77061. private _textWidth;
  77062. private _clickedCoordinate;
  77063. private _deadKey;
  77064. private _addKey;
  77065. private _currentKey;
  77066. private _isTextHighlightOn;
  77067. private _textHighlightColor;
  77068. private _highligherOpacity;
  77069. private _highlightedText;
  77070. private _startHighlightIndex;
  77071. private _endHighlightIndex;
  77072. private _cursorIndex;
  77073. private _onFocusSelectAll;
  77074. private _isPointerDown;
  77075. private _onClipboardObserver;
  77076. private _onPointerDblTapObserver;
  77077. /** @hidden */
  77078. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77079. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77080. promptMessage: string;
  77081. /** Force disable prompt on mobile device */
  77082. disableMobilePrompt: boolean;
  77083. /** BABYLON.Observable raised when the text changes */
  77084. onTextChangedObservable: BABYLON.Observable<InputText>;
  77085. /** BABYLON.Observable raised just before an entered character is to be added */
  77086. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77087. /** BABYLON.Observable raised when the control gets the focus */
  77088. onFocusObservable: BABYLON.Observable<InputText>;
  77089. /** BABYLON.Observable raised when the control loses the focus */
  77090. onBlurObservable: BABYLON.Observable<InputText>;
  77091. /**Observable raised when the text is highlighted */
  77092. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77093. /**Observable raised when copy event is triggered */
  77094. onTextCopyObservable: BABYLON.Observable<InputText>;
  77095. /** BABYLON.Observable raised when cut event is triggered */
  77096. onTextCutObservable: BABYLON.Observable<InputText>;
  77097. /** BABYLON.Observable raised when paste event is triggered */
  77098. onTextPasteObservable: BABYLON.Observable<InputText>;
  77099. /** BABYLON.Observable raised when a key event was processed */
  77100. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77101. /** Gets or sets the maximum width allowed by the control */
  77102. get maxWidth(): string | number;
  77103. /** Gets the maximum width allowed by the control in pixels */
  77104. get maxWidthInPixels(): number;
  77105. set maxWidth(value: string | number);
  77106. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77107. get highligherOpacity(): number;
  77108. set highligherOpacity(value: number);
  77109. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77110. get onFocusSelectAll(): boolean;
  77111. set onFocusSelectAll(value: boolean);
  77112. /** Gets or sets the text hightlight color */
  77113. get textHighlightColor(): string;
  77114. set textHighlightColor(value: string);
  77115. /** Gets or sets control margin */
  77116. get margin(): string;
  77117. /** Gets control margin in pixels */
  77118. get marginInPixels(): number;
  77119. set margin(value: string);
  77120. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77121. get autoStretchWidth(): boolean;
  77122. set autoStretchWidth(value: boolean);
  77123. /** Gets or sets border thickness */
  77124. get thickness(): number;
  77125. set thickness(value: number);
  77126. /** Gets or sets the background color when focused */
  77127. get focusedBackground(): string;
  77128. set focusedBackground(value: string);
  77129. /** Gets or sets the background color when focused */
  77130. get focusedColor(): string;
  77131. set focusedColor(value: string);
  77132. /** Gets or sets the background color */
  77133. get background(): string;
  77134. set background(value: string);
  77135. /** Gets or sets the placeholder color */
  77136. get placeholderColor(): string;
  77137. set placeholderColor(value: string);
  77138. /** Gets or sets the text displayed when the control is empty */
  77139. get placeholderText(): string;
  77140. set placeholderText(value: string);
  77141. /** Gets or sets the dead key flag */
  77142. get deadKey(): boolean;
  77143. set deadKey(flag: boolean);
  77144. /** Gets or sets the highlight text */
  77145. get highlightedText(): string;
  77146. set highlightedText(text: string);
  77147. /** Gets or sets if the current key should be added */
  77148. get addKey(): boolean;
  77149. set addKey(flag: boolean);
  77150. /** Gets or sets the value of the current key being entered */
  77151. get currentKey(): string;
  77152. set currentKey(key: string);
  77153. /** Gets or sets the text displayed in the control */
  77154. get text(): string;
  77155. set text(value: string);
  77156. /** Gets or sets control width */
  77157. get width(): string | number;
  77158. set width(value: string | number);
  77159. /**
  77160. * Creates a new InputText
  77161. * @param name defines the control name
  77162. * @param text defines the text of the control
  77163. */
  77164. constructor(name?: string | undefined, text?: string);
  77165. /** @hidden */
  77166. onBlur(): void;
  77167. /** @hidden */
  77168. onFocus(): void;
  77169. protected _getTypeName(): string;
  77170. /**
  77171. * Function called to get the list of controls that should not steal the focus from this control
  77172. * @returns an array of controls
  77173. */
  77174. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77175. /** @hidden */
  77176. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77177. /** @hidden */
  77178. private _updateValueFromCursorIndex;
  77179. /** @hidden */
  77180. private _processDblClick;
  77181. /** @hidden */
  77182. private _selectAllText;
  77183. /**
  77184. * Handles the keyboard event
  77185. * @param evt Defines the KeyboardEvent
  77186. */
  77187. processKeyboard(evt: KeyboardEvent): void;
  77188. /** @hidden */
  77189. private _onCopyText;
  77190. /** @hidden */
  77191. private _onCutText;
  77192. /** @hidden */
  77193. private _onPasteText;
  77194. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77195. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77196. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77197. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77198. protected _beforeRenderText(text: string): string;
  77199. dispose(): void;
  77200. }
  77201. }
  77202. declare module BABYLON.GUI {
  77203. /**
  77204. * Class used to create a 2D grid container
  77205. */
  77206. export class Grid extends Container {
  77207. name?: string | undefined;
  77208. private _rowDefinitions;
  77209. private _columnDefinitions;
  77210. private _cells;
  77211. private _childControls;
  77212. /**
  77213. * Gets the number of columns
  77214. */
  77215. get columnCount(): number;
  77216. /**
  77217. * Gets the number of rows
  77218. */
  77219. get rowCount(): number;
  77220. /** Gets the list of children */
  77221. get children(): Control[];
  77222. /** Gets the list of cells (e.g. the containers) */
  77223. get cells(): {
  77224. [key: string]: Container;
  77225. };
  77226. /**
  77227. * Gets the definition of a specific row
  77228. * @param index defines the index of the row
  77229. * @returns the row definition
  77230. */
  77231. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77232. /**
  77233. * Gets the definition of a specific column
  77234. * @param index defines the index of the column
  77235. * @returns the column definition
  77236. */
  77237. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77238. /**
  77239. * Adds a new row to the grid
  77240. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77241. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77242. * @returns the current grid
  77243. */
  77244. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77245. /**
  77246. * Adds a new column to the grid
  77247. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77248. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77249. * @returns the current grid
  77250. */
  77251. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77252. /**
  77253. * Update a row definition
  77254. * @param index defines the index of the row to update
  77255. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77256. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77257. * @returns the current grid
  77258. */
  77259. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77260. /**
  77261. * Update a column definition
  77262. * @param index defines the index of the column to update
  77263. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77264. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77265. * @returns the current grid
  77266. */
  77267. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77268. /**
  77269. * Gets the list of children stored in a specific cell
  77270. * @param row defines the row to check
  77271. * @param column defines the column to check
  77272. * @returns the list of controls
  77273. */
  77274. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77275. /**
  77276. * Gets a string representing the child cell info (row x column)
  77277. * @param child defines the control to get info from
  77278. * @returns a string containing the child cell info (row x column)
  77279. */
  77280. getChildCellInfo(child: Control): string;
  77281. private _removeCell;
  77282. private _offsetCell;
  77283. /**
  77284. * Remove a column definition at specified index
  77285. * @param index defines the index of the column to remove
  77286. * @returns the current grid
  77287. */
  77288. removeColumnDefinition(index: number): Grid;
  77289. /**
  77290. * Remove a row definition at specified index
  77291. * @param index defines the index of the row to remove
  77292. * @returns the current grid
  77293. */
  77294. removeRowDefinition(index: number): Grid;
  77295. /**
  77296. * Adds a new control to the current grid
  77297. * @param control defines the control to add
  77298. * @param row defines the row where to add the control (0 by default)
  77299. * @param column defines the column where to add the control (0 by default)
  77300. * @returns the current grid
  77301. */
  77302. addControl(control: Control, row?: number, column?: number): Grid;
  77303. /**
  77304. * Removes a control from the current container
  77305. * @param control defines the control to remove
  77306. * @returns the current container
  77307. */
  77308. removeControl(control: Control): Container;
  77309. /**
  77310. * Creates a new Grid
  77311. * @param name defines control name
  77312. */
  77313. constructor(name?: string | undefined);
  77314. protected _getTypeName(): string;
  77315. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77316. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77317. _flagDescendantsAsMatrixDirty(): void;
  77318. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77319. /** Releases associated resources */
  77320. dispose(): void;
  77321. }
  77322. }
  77323. declare module BABYLON.GUI {
  77324. /** Class used to create color pickers */
  77325. export class ColorPicker extends Control {
  77326. name?: string | undefined;
  77327. private static _Epsilon;
  77328. private _colorWheelCanvas;
  77329. private _value;
  77330. private _tmpColor;
  77331. private _pointerStartedOnSquare;
  77332. private _pointerStartedOnWheel;
  77333. private _squareLeft;
  77334. private _squareTop;
  77335. private _squareSize;
  77336. private _h;
  77337. private _s;
  77338. private _v;
  77339. private _lastPointerDownID;
  77340. /**
  77341. * BABYLON.Observable raised when the value changes
  77342. */
  77343. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77344. /** Gets or sets the color of the color picker */
  77345. get value(): BABYLON.Color3;
  77346. set value(value: BABYLON.Color3);
  77347. /**
  77348. * Gets or sets control width
  77349. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77350. */
  77351. get width(): string | number;
  77352. set width(value: string | number);
  77353. /**
  77354. * Gets or sets control height
  77355. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77356. */
  77357. get height(): string | number;
  77358. /** Gets or sets control height */
  77359. set height(value: string | number);
  77360. /** Gets or sets control size */
  77361. get size(): string | number;
  77362. set size(value: string | number);
  77363. /**
  77364. * Creates a new ColorPicker
  77365. * @param name defines the control name
  77366. */
  77367. constructor(name?: string | undefined);
  77368. protected _getTypeName(): string;
  77369. /** @hidden */
  77370. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77371. private _updateSquareProps;
  77372. private _drawGradientSquare;
  77373. private _drawCircle;
  77374. private _createColorWheelCanvas;
  77375. /** @hidden */
  77376. _draw(context: CanvasRenderingContext2D): void;
  77377. private _pointerIsDown;
  77378. private _updateValueFromPointer;
  77379. private _isPointOnSquare;
  77380. private _isPointOnWheel;
  77381. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77382. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77383. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77384. /**
  77385. * This function expands the color picker by creating a color picker dialog with manual
  77386. * color value input and the ability to save colors into an array to be used later in
  77387. * subsequent launches of the dialogue.
  77388. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77389. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  77390. * @returns picked color as a hex string and the saved colors array as hex strings.
  77391. */
  77392. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77393. pickerWidth?: string;
  77394. pickerHeight?: string;
  77395. headerHeight?: string;
  77396. lastColor?: string;
  77397. swatchLimit?: number;
  77398. numSwatchesPerLine?: number;
  77399. savedColors?: Array<string>;
  77400. }): Promise<{
  77401. savedColors?: string[];
  77402. pickedColor: string;
  77403. }>;
  77404. }
  77405. }
  77406. declare module BABYLON.GUI {
  77407. /** Class used to create 2D ellipse containers */
  77408. export class Ellipse extends Container {
  77409. name?: string | undefined;
  77410. private _thickness;
  77411. /** Gets or sets border thickness */
  77412. get thickness(): number;
  77413. set thickness(value: number);
  77414. /**
  77415. * Creates a new Ellipse
  77416. * @param name defines the control name
  77417. */
  77418. constructor(name?: string | undefined);
  77419. protected _getTypeName(): string;
  77420. protected _localDraw(context: CanvasRenderingContext2D): void;
  77421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77422. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77423. }
  77424. }
  77425. declare module BABYLON.GUI {
  77426. /**
  77427. * Class used to create a password control
  77428. */
  77429. export class InputPassword extends InputText {
  77430. protected _beforeRenderText(text: string): string;
  77431. }
  77432. }
  77433. declare module BABYLON.GUI {
  77434. /** Class used to render 2D lines */
  77435. export class Line extends Control {
  77436. name?: string | undefined;
  77437. private _lineWidth;
  77438. private _x1;
  77439. private _y1;
  77440. private _x2;
  77441. private _y2;
  77442. private _dash;
  77443. private _connectedControl;
  77444. private _connectedControlDirtyObserver;
  77445. /** Gets or sets the dash pattern */
  77446. get dash(): Array<number>;
  77447. set dash(value: Array<number>);
  77448. /** Gets or sets the control connected with the line end */
  77449. get connectedControl(): Control;
  77450. set connectedControl(value: Control);
  77451. /** Gets or sets start coordinates on X axis */
  77452. get x1(): string | number;
  77453. set x1(value: string | number);
  77454. /** Gets or sets start coordinates on Y axis */
  77455. get y1(): string | number;
  77456. set y1(value: string | number);
  77457. /** Gets or sets end coordinates on X axis */
  77458. get x2(): string | number;
  77459. set x2(value: string | number);
  77460. /** Gets or sets end coordinates on Y axis */
  77461. get y2(): string | number;
  77462. set y2(value: string | number);
  77463. /** Gets or sets line width */
  77464. get lineWidth(): number;
  77465. set lineWidth(value: number);
  77466. /** Gets or sets horizontal alignment */
  77467. set horizontalAlignment(value: number);
  77468. /** Gets or sets vertical alignment */
  77469. set verticalAlignment(value: number);
  77470. private get _effectiveX2();
  77471. private get _effectiveY2();
  77472. /**
  77473. * Creates a new Line
  77474. * @param name defines the control name
  77475. */
  77476. constructor(name?: string | undefined);
  77477. protected _getTypeName(): string;
  77478. _draw(context: CanvasRenderingContext2D): void;
  77479. _measure(): void;
  77480. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77481. /**
  77482. * Move one end of the line given 3D cartesian coordinates.
  77483. * @param position Targeted world position
  77484. * @param scene BABYLON.Scene
  77485. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77486. */
  77487. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77488. /**
  77489. * Move one end of the line to a position in screen absolute space.
  77490. * @param projectedPosition Position in screen absolute space (X, Y)
  77491. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77492. */
  77493. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77494. }
  77495. }
  77496. declare module BABYLON.GUI {
  77497. /**
  77498. * Class used to store a point for a MultiLine object.
  77499. * The point can be pure 2D coordinates, a mesh or a control
  77500. */
  77501. export class MultiLinePoint {
  77502. private _multiLine;
  77503. private _x;
  77504. private _y;
  77505. private _control;
  77506. private _mesh;
  77507. private _controlObserver;
  77508. private _meshObserver;
  77509. /** @hidden */
  77510. _point: BABYLON.Vector2;
  77511. /**
  77512. * Creates a new MultiLinePoint
  77513. * @param multiLine defines the source MultiLine object
  77514. */
  77515. constructor(multiLine: MultiLine);
  77516. /** Gets or sets x coordinate */
  77517. get x(): string | number;
  77518. set x(value: string | number);
  77519. /** Gets or sets y coordinate */
  77520. get y(): string | number;
  77521. set y(value: string | number);
  77522. /** Gets or sets the control associated with this point */
  77523. get control(): BABYLON.Nullable<Control>;
  77524. set control(value: BABYLON.Nullable<Control>);
  77525. /** Gets or sets the mesh associated with this point */
  77526. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77527. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77528. /** Resets links */
  77529. resetLinks(): void;
  77530. /**
  77531. * Gets a translation vector
  77532. * @returns the translation vector
  77533. */
  77534. translate(): BABYLON.Vector2;
  77535. private _translatePoint;
  77536. /** Release associated resources */
  77537. dispose(): void;
  77538. }
  77539. }
  77540. declare module BABYLON.GUI {
  77541. /**
  77542. * Class used to create multi line control
  77543. */
  77544. export class MultiLine extends Control {
  77545. name?: string | undefined;
  77546. private _lineWidth;
  77547. private _dash;
  77548. private _points;
  77549. private _minX;
  77550. private _minY;
  77551. private _maxX;
  77552. private _maxY;
  77553. /**
  77554. * Creates a new MultiLine
  77555. * @param name defines the control name
  77556. */
  77557. constructor(name?: string | undefined);
  77558. /** Gets or sets dash pattern */
  77559. get dash(): Array<number>;
  77560. set dash(value: Array<number>);
  77561. /**
  77562. * Gets point stored at specified index
  77563. * @param index defines the index to look for
  77564. * @returns the requested point if found
  77565. */
  77566. getAt(index: number): MultiLinePoint;
  77567. /** Function called when a point is updated */
  77568. onPointUpdate: () => void;
  77569. /**
  77570. * Adds new points to the point collection
  77571. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77572. * @returns the list of created MultiLinePoint
  77573. */
  77574. add(...items: (AbstractMesh | Control | {
  77575. x: string | number;
  77576. y: string | number;
  77577. })[]): MultiLinePoint[];
  77578. /**
  77579. * Adds a new point to the point collection
  77580. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77581. * @returns the created MultiLinePoint
  77582. */
  77583. push(item?: (AbstractMesh | Control | {
  77584. x: string | number;
  77585. y: string | number;
  77586. })): MultiLinePoint;
  77587. /**
  77588. * Remove a specific value or point from the active point collection
  77589. * @param value defines the value or point to remove
  77590. */
  77591. remove(value: number | MultiLinePoint): void;
  77592. /**
  77593. * Resets this object to initial state (no point)
  77594. */
  77595. reset(): void;
  77596. /**
  77597. * Resets all links
  77598. */
  77599. resetLinks(): void;
  77600. /** Gets or sets line width */
  77601. get lineWidth(): number;
  77602. set lineWidth(value: number);
  77603. set horizontalAlignment(value: number);
  77604. set verticalAlignment(value: number);
  77605. protected _getTypeName(): string;
  77606. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77608. _measure(): void;
  77609. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77610. dispose(): void;
  77611. }
  77612. }
  77613. declare module BABYLON.GUI {
  77614. /**
  77615. * Class used to create radio button controls
  77616. */
  77617. export class RadioButton extends Control {
  77618. name?: string | undefined;
  77619. private _isChecked;
  77620. private _background;
  77621. private _checkSizeRatio;
  77622. private _thickness;
  77623. /** Gets or sets border thickness */
  77624. get thickness(): number;
  77625. set thickness(value: number);
  77626. /** Gets or sets group name */
  77627. group: string;
  77628. /** BABYLON.Observable raised when isChecked is changed */
  77629. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77630. /** Gets or sets a value indicating the ratio between overall size and check size */
  77631. get checkSizeRatio(): number;
  77632. set checkSizeRatio(value: number);
  77633. /** Gets or sets background color */
  77634. get background(): string;
  77635. set background(value: string);
  77636. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77637. get isChecked(): boolean;
  77638. set isChecked(value: boolean);
  77639. /**
  77640. * Creates a new RadioButton
  77641. * @param name defines the control name
  77642. */
  77643. constructor(name?: string | undefined);
  77644. protected _getTypeName(): string;
  77645. _draw(context: CanvasRenderingContext2D): void;
  77646. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77647. /**
  77648. * Utility function to easily create a radio button with a header
  77649. * @param title defines the label to use for the header
  77650. * @param group defines the group to use for the radio button
  77651. * @param isChecked defines the initial state of the radio button
  77652. * @param onValueChanged defines the callback to call when value changes
  77653. * @returns a StackPanel containing the radio button and a textBlock
  77654. */
  77655. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77656. }
  77657. }
  77658. declare module BABYLON.GUI {
  77659. /**
  77660. * Class used to create slider controls
  77661. */
  77662. export class BaseSlider extends Control {
  77663. name?: string | undefined;
  77664. protected _thumbWidth: ValueAndUnit;
  77665. private _minimum;
  77666. private _maximum;
  77667. private _value;
  77668. private _isVertical;
  77669. protected _barOffset: ValueAndUnit;
  77670. private _isThumbClamped;
  77671. protected _displayThumb: boolean;
  77672. private _step;
  77673. private _lastPointerDownID;
  77674. protected _effectiveBarOffset: number;
  77675. protected _renderLeft: number;
  77676. protected _renderTop: number;
  77677. protected _renderWidth: number;
  77678. protected _renderHeight: number;
  77679. protected _backgroundBoxLength: number;
  77680. protected _backgroundBoxThickness: number;
  77681. protected _effectiveThumbThickness: number;
  77682. /** BABYLON.Observable raised when the sldier value changes */
  77683. onValueChangedObservable: BABYLON.Observable<number>;
  77684. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77685. get displayThumb(): boolean;
  77686. set displayThumb(value: boolean);
  77687. /** Gets or sets a step to apply to values (0 by default) */
  77688. get step(): number;
  77689. set step(value: number);
  77690. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77691. get barOffset(): string | number;
  77692. /** Gets main bar offset in pixels*/
  77693. get barOffsetInPixels(): number;
  77694. set barOffset(value: string | number);
  77695. /** Gets or sets thumb width */
  77696. get thumbWidth(): string | number;
  77697. /** Gets thumb width in pixels */
  77698. get thumbWidthInPixels(): number;
  77699. set thumbWidth(value: string | number);
  77700. /** Gets or sets minimum value */
  77701. get minimum(): number;
  77702. set minimum(value: number);
  77703. /** Gets or sets maximum value */
  77704. get maximum(): number;
  77705. set maximum(value: number);
  77706. /** Gets or sets current value */
  77707. get value(): number;
  77708. set value(value: number);
  77709. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77710. get isVertical(): boolean;
  77711. set isVertical(value: boolean);
  77712. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77713. get isThumbClamped(): boolean;
  77714. set isThumbClamped(value: boolean);
  77715. /**
  77716. * Creates a new BaseSlider
  77717. * @param name defines the control name
  77718. */
  77719. constructor(name?: string | undefined);
  77720. protected _getTypeName(): string;
  77721. protected _getThumbPosition(): number;
  77722. protected _getThumbThickness(type: string): number;
  77723. protected _prepareRenderingData(type: string): void;
  77724. private _pointerIsDown;
  77725. /** @hidden */
  77726. protected _updateValueFromPointer(x: number, y: number): void;
  77727. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77728. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77729. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77730. }
  77731. }
  77732. declare module BABYLON.GUI {
  77733. /**
  77734. * Class used to create slider controls
  77735. */
  77736. export class Slider extends BaseSlider {
  77737. name?: string | undefined;
  77738. private _background;
  77739. private _borderColor;
  77740. private _isThumbCircle;
  77741. protected _displayValueBar: boolean;
  77742. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77743. get displayValueBar(): boolean;
  77744. set displayValueBar(value: boolean);
  77745. /** Gets or sets border color */
  77746. get borderColor(): string;
  77747. set borderColor(value: string);
  77748. /** Gets or sets background color */
  77749. get background(): string;
  77750. set background(value: string);
  77751. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77752. get isThumbCircle(): boolean;
  77753. set isThumbCircle(value: boolean);
  77754. /**
  77755. * Creates a new Slider
  77756. * @param name defines the control name
  77757. */
  77758. constructor(name?: string | undefined);
  77759. protected _getTypeName(): string;
  77760. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77761. }
  77762. }
  77763. declare module BABYLON.GUI {
  77764. /** Class used to create a RadioGroup
  77765. * which contains groups of radio buttons
  77766. */
  77767. export class SelectorGroup {
  77768. /** name of SelectorGroup */
  77769. name: string;
  77770. private _groupPanel;
  77771. private _selectors;
  77772. private _groupHeader;
  77773. /**
  77774. * Creates a new SelectorGroup
  77775. * @param name of group, used as a group heading
  77776. */
  77777. constructor(
  77778. /** name of SelectorGroup */
  77779. name: string);
  77780. /** Gets the groupPanel of the SelectorGroup */
  77781. get groupPanel(): StackPanel;
  77782. /** Gets the selectors array */
  77783. get selectors(): StackPanel[];
  77784. /** Gets and sets the group header */
  77785. get header(): string;
  77786. set header(label: string);
  77787. /** @hidden */
  77788. private _addGroupHeader;
  77789. /** @hidden*/
  77790. _getSelector(selectorNb: number): StackPanel | undefined;
  77791. /** Removes the selector at the given position
  77792. * @param selectorNb the position of the selector within the group
  77793. */
  77794. removeSelector(selectorNb: number): void;
  77795. }
  77796. /** Class used to create a CheckboxGroup
  77797. * which contains groups of checkbox buttons
  77798. */
  77799. export class CheckboxGroup extends SelectorGroup {
  77800. /** Adds a checkbox as a control
  77801. * @param text is the label for the selector
  77802. * @param func is the function called when the Selector is checked
  77803. * @param checked is true when Selector is checked
  77804. */
  77805. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77806. /** @hidden */
  77807. _setSelectorLabel(selectorNb: number, label: string): void;
  77808. /** @hidden */
  77809. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77810. /** @hidden */
  77811. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77812. /** @hidden */
  77813. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77814. }
  77815. /** Class used to create a RadioGroup
  77816. * which contains groups of radio buttons
  77817. */
  77818. export class RadioGroup extends SelectorGroup {
  77819. private _selectNb;
  77820. /** Adds a radio button as a control
  77821. * @param label is the label for the selector
  77822. * @param func is the function called when the Selector is checked
  77823. * @param checked is true when Selector is checked
  77824. */
  77825. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77826. /** @hidden */
  77827. _setSelectorLabel(selectorNb: number, label: string): void;
  77828. /** @hidden */
  77829. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77830. /** @hidden */
  77831. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77832. /** @hidden */
  77833. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77834. }
  77835. /** Class used to create a SliderGroup
  77836. * which contains groups of slider buttons
  77837. */
  77838. export class SliderGroup extends SelectorGroup {
  77839. /**
  77840. * Adds a slider to the SelectorGroup
  77841. * @param label is the label for the SliderBar
  77842. * @param func is the function called when the Slider moves
  77843. * @param unit is a string describing the units used, eg degrees or metres
  77844. * @param min is the minimum value for the Slider
  77845. * @param max is the maximum value for the Slider
  77846. * @param value is the start value for the Slider between min and max
  77847. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77848. */
  77849. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77850. /** @hidden */
  77851. _setSelectorLabel(selectorNb: number, label: string): void;
  77852. /** @hidden */
  77853. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77854. /** @hidden */
  77855. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77856. /** @hidden */
  77857. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77858. }
  77859. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77860. * @see https://doc.babylonjs.com/how_to/selector
  77861. */
  77862. export class SelectionPanel extends Rectangle {
  77863. /** name of SelectionPanel */
  77864. name: string;
  77865. /** an array of SelectionGroups */
  77866. groups: SelectorGroup[];
  77867. private _panel;
  77868. private _buttonColor;
  77869. private _buttonBackground;
  77870. private _headerColor;
  77871. private _barColor;
  77872. private _barHeight;
  77873. private _spacerHeight;
  77874. private _labelColor;
  77875. private _groups;
  77876. private _bars;
  77877. /**
  77878. * Creates a new SelectionPanel
  77879. * @param name of SelectionPanel
  77880. * @param groups is an array of SelectionGroups
  77881. */
  77882. constructor(
  77883. /** name of SelectionPanel */
  77884. name: string,
  77885. /** an array of SelectionGroups */
  77886. groups?: SelectorGroup[]);
  77887. protected _getTypeName(): string;
  77888. /** Gets or sets the headerColor */
  77889. get headerColor(): string;
  77890. set headerColor(color: string);
  77891. private _setHeaderColor;
  77892. /** Gets or sets the button color */
  77893. get buttonColor(): string;
  77894. set buttonColor(color: string);
  77895. private _setbuttonColor;
  77896. /** Gets or sets the label color */
  77897. get labelColor(): string;
  77898. set labelColor(color: string);
  77899. private _setLabelColor;
  77900. /** Gets or sets the button background */
  77901. get buttonBackground(): string;
  77902. set buttonBackground(color: string);
  77903. private _setButtonBackground;
  77904. /** Gets or sets the color of separator bar */
  77905. get barColor(): string;
  77906. set barColor(color: string);
  77907. private _setBarColor;
  77908. /** Gets or sets the height of separator bar */
  77909. get barHeight(): string;
  77910. set barHeight(value: string);
  77911. private _setBarHeight;
  77912. /** Gets or sets the height of spacers*/
  77913. get spacerHeight(): string;
  77914. set spacerHeight(value: string);
  77915. private _setSpacerHeight;
  77916. /** Adds a bar between groups */
  77917. private _addSpacer;
  77918. /** Add a group to the selection panel
  77919. * @param group is the selector group to add
  77920. */
  77921. addGroup(group: SelectorGroup): void;
  77922. /** Remove the group from the given position
  77923. * @param groupNb is the position of the group in the list
  77924. */
  77925. removeGroup(groupNb: number): void;
  77926. /** Change a group header label
  77927. * @param label is the new group header label
  77928. * @param groupNb is the number of the group to relabel
  77929. * */
  77930. setHeaderName(label: string, groupNb: number): void;
  77931. /** Change selector label to the one given
  77932. * @param label is the new selector label
  77933. * @param groupNb is the number of the groupcontaining the selector
  77934. * @param selectorNb is the number of the selector within a group to relabel
  77935. * */
  77936. relabel(label: string, groupNb: number, selectorNb: number): void;
  77937. /** For a given group position remove the selector at the given position
  77938. * @param groupNb is the number of the group to remove the selector from
  77939. * @param selectorNb is the number of the selector within the group
  77940. */
  77941. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77942. /** For a given group position of correct type add a checkbox button
  77943. * @param groupNb is the number of the group to remove the selector from
  77944. * @param label is the label for the selector
  77945. * @param func is the function called when the Selector is checked
  77946. * @param checked is true when Selector is checked
  77947. */
  77948. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77949. /** For a given group position of correct type add a radio button
  77950. * @param groupNb is the number of the group to remove the selector from
  77951. * @param label is the label for the selector
  77952. * @param func is the function called when the Selector is checked
  77953. * @param checked is true when Selector is checked
  77954. */
  77955. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77956. /**
  77957. * For a given slider group add a slider
  77958. * @param groupNb is the number of the group to add the slider to
  77959. * @param label is the label for the Slider
  77960. * @param func is the function called when the Slider moves
  77961. * @param unit is a string describing the units used, eg degrees or metres
  77962. * @param min is the minimum value for the Slider
  77963. * @param max is the maximum value for the Slider
  77964. * @param value is the start value for the Slider between min and max
  77965. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77966. */
  77967. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77968. }
  77969. }
  77970. declare module BABYLON.GUI {
  77971. /**
  77972. * Class used to hold a the container for ScrollViewer
  77973. * @hidden
  77974. */
  77975. export class _ScrollViewerWindow extends Container {
  77976. parentClientWidth: number;
  77977. parentClientHeight: number;
  77978. private _freezeControls;
  77979. private _parentMeasure;
  77980. private _oldLeft;
  77981. private _oldTop;
  77982. get freezeControls(): boolean;
  77983. set freezeControls(value: boolean);
  77984. private _bucketWidth;
  77985. private _bucketHeight;
  77986. private _buckets;
  77987. private _bucketLen;
  77988. get bucketWidth(): number;
  77989. get bucketHeight(): number;
  77990. setBucketSizes(width: number, height: number): void;
  77991. private _useBuckets;
  77992. private _makeBuckets;
  77993. private _dispatchInBuckets;
  77994. private _updateMeasures;
  77995. private _updateChildrenMeasures;
  77996. private _restoreMeasures;
  77997. /**
  77998. * Creates a new ScrollViewerWindow
  77999. * @param name of ScrollViewerWindow
  78000. */
  78001. constructor(name?: string);
  78002. protected _getTypeName(): string;
  78003. /** @hidden */
  78004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78005. /** @hidden */
  78006. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78007. private _scrollChildren;
  78008. private _scrollChildrenWithBuckets;
  78009. /** @hidden */
  78010. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78011. protected _postMeasure(): void;
  78012. }
  78013. }
  78014. declare module BABYLON.GUI {
  78015. /**
  78016. * Class used to create slider controls
  78017. */
  78018. export class ScrollBar extends BaseSlider {
  78019. name?: string | undefined;
  78020. private _background;
  78021. private _borderColor;
  78022. private _tempMeasure;
  78023. /** Gets or sets border color */
  78024. get borderColor(): string;
  78025. set borderColor(value: string);
  78026. /** Gets or sets background color */
  78027. get background(): string;
  78028. set background(value: string);
  78029. /**
  78030. * Creates a new Slider
  78031. * @param name defines the control name
  78032. */
  78033. constructor(name?: string | undefined);
  78034. protected _getTypeName(): string;
  78035. protected _getThumbThickness(): number;
  78036. _draw(context: CanvasRenderingContext2D): void;
  78037. private _first;
  78038. private _originX;
  78039. private _originY;
  78040. /** @hidden */
  78041. protected _updateValueFromPointer(x: number, y: number): void;
  78042. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78043. }
  78044. }
  78045. declare module BABYLON.GUI {
  78046. /**
  78047. * Class used to create slider controls
  78048. */
  78049. export class ImageScrollBar extends BaseSlider {
  78050. name?: string | undefined;
  78051. private _backgroundBaseImage;
  78052. private _backgroundImage;
  78053. private _thumbImage;
  78054. private _thumbBaseImage;
  78055. private _thumbLength;
  78056. private _thumbHeight;
  78057. private _barImageHeight;
  78058. private _tempMeasure;
  78059. /** Number of 90° rotation to apply on the images when in vertical mode */
  78060. num90RotationInVerticalMode: number;
  78061. /**
  78062. * Gets or sets the image used to render the background for horizontal bar
  78063. */
  78064. get backgroundImage(): Image;
  78065. set backgroundImage(value: Image);
  78066. /**
  78067. * Gets or sets the image used to render the thumb
  78068. */
  78069. get thumbImage(): Image;
  78070. set thumbImage(value: Image);
  78071. /**
  78072. * Gets or sets the length of the thumb
  78073. */
  78074. get thumbLength(): number;
  78075. set thumbLength(value: number);
  78076. /**
  78077. * Gets or sets the height of the thumb
  78078. */
  78079. get thumbHeight(): number;
  78080. set thumbHeight(value: number);
  78081. /**
  78082. * Gets or sets the height of the bar image
  78083. */
  78084. get barImageHeight(): number;
  78085. set barImageHeight(value: number);
  78086. /**
  78087. * Creates a new ImageScrollBar
  78088. * @param name defines the control name
  78089. */
  78090. constructor(name?: string | undefined);
  78091. protected _getTypeName(): string;
  78092. protected _getThumbThickness(): number;
  78093. _draw(context: CanvasRenderingContext2D): void;
  78094. private _first;
  78095. private _originX;
  78096. private _originY;
  78097. /** @hidden */
  78098. protected _updateValueFromPointer(x: number, y: number): void;
  78099. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78100. }
  78101. }
  78102. declare module BABYLON.GUI {
  78103. /**
  78104. * Class used to hold a viewer window and sliders in a grid
  78105. */
  78106. export class ScrollViewer extends Rectangle {
  78107. private _grid;
  78108. private _horizontalBarSpace;
  78109. private _verticalBarSpace;
  78110. private _dragSpace;
  78111. private _horizontalBar;
  78112. private _verticalBar;
  78113. private _barColor;
  78114. private _barBackground;
  78115. private _barImage;
  78116. private _horizontalBarImage;
  78117. private _verticalBarImage;
  78118. private _barBackgroundImage;
  78119. private _horizontalBarBackgroundImage;
  78120. private _verticalBarBackgroundImage;
  78121. private _barSize;
  78122. private _window;
  78123. private _pointerIsOver;
  78124. private _wheelPrecision;
  78125. private _onWheelObserver;
  78126. private _clientWidth;
  78127. private _clientHeight;
  78128. private _useImageBar;
  78129. private _thumbLength;
  78130. private _thumbHeight;
  78131. private _barImageHeight;
  78132. private _horizontalBarImageHeight;
  78133. private _verticalBarImageHeight;
  78134. private _oldWindowContentsWidth;
  78135. private _oldWindowContentsHeight;
  78136. /**
  78137. * Gets the horizontal scrollbar
  78138. */
  78139. get horizontalBar(): ScrollBar | ImageScrollBar;
  78140. /**
  78141. * Gets the vertical scrollbar
  78142. */
  78143. get verticalBar(): ScrollBar | ImageScrollBar;
  78144. /**
  78145. * Adds a new control to the current container
  78146. * @param control defines the control to add
  78147. * @returns the current container
  78148. */
  78149. addControl(control: BABYLON.Nullable<Control>): Container;
  78150. /**
  78151. * Removes a control from the current container
  78152. * @param control defines the control to remove
  78153. * @returns the current container
  78154. */
  78155. removeControl(control: Control): Container;
  78156. /** Gets the list of children */
  78157. get children(): Control[];
  78158. _flagDescendantsAsMatrixDirty(): void;
  78159. /**
  78160. * Freezes or unfreezes the controls in the window.
  78161. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78162. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78163. */
  78164. get freezeControls(): boolean;
  78165. set freezeControls(value: boolean);
  78166. /** Gets the bucket width */
  78167. get bucketWidth(): number;
  78168. /** Gets the bucket height */
  78169. get bucketHeight(): number;
  78170. /**
  78171. * Sets the bucket sizes.
  78172. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78173. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78174. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78175. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78176. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78177. * used), that's why it is not enabled by default.
  78178. * @param width width of the bucket
  78179. * @param height height of the bucket
  78180. */
  78181. setBucketSizes(width: number, height: number): void;
  78182. private _forceHorizontalBar;
  78183. private _forceVerticalBar;
  78184. /**
  78185. * Forces the horizontal scroll bar to be displayed
  78186. */
  78187. get forceHorizontalBar(): boolean;
  78188. set forceHorizontalBar(value: boolean);
  78189. /**
  78190. * Forces the vertical scroll bar to be displayed
  78191. */
  78192. get forceVerticalBar(): boolean;
  78193. set forceVerticalBar(value: boolean);
  78194. /**
  78195. * Creates a new ScrollViewer
  78196. * @param name of ScrollViewer
  78197. */
  78198. constructor(name?: string, isImageBased?: boolean);
  78199. /** Reset the scroll viewer window to initial size */
  78200. resetWindow(): void;
  78201. protected _getTypeName(): string;
  78202. private _buildClientSizes;
  78203. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78204. protected _postMeasure(): void;
  78205. /**
  78206. * Gets or sets the mouse wheel precision
  78207. * from 0 to 1 with a default value of 0.05
  78208. * */
  78209. get wheelPrecision(): number;
  78210. set wheelPrecision(value: number);
  78211. /** Gets or sets the scroll bar container background color */
  78212. get scrollBackground(): string;
  78213. set scrollBackground(color: string);
  78214. /** Gets or sets the bar color */
  78215. get barColor(): string;
  78216. set barColor(color: string);
  78217. /** Gets or sets the bar image */
  78218. get thumbImage(): Image;
  78219. set thumbImage(value: Image);
  78220. /** Gets or sets the horizontal bar image */
  78221. get horizontalThumbImage(): Image;
  78222. set horizontalThumbImage(value: Image);
  78223. /** Gets or sets the vertical bar image */
  78224. get verticalThumbImage(): Image;
  78225. set verticalThumbImage(value: Image);
  78226. /** Gets or sets the size of the bar */
  78227. get barSize(): number;
  78228. set barSize(value: number);
  78229. /** Gets or sets the length of the thumb */
  78230. get thumbLength(): number;
  78231. set thumbLength(value: number);
  78232. /** Gets or sets the height of the thumb */
  78233. get thumbHeight(): number;
  78234. set thumbHeight(value: number);
  78235. /** Gets or sets the height of the bar image */
  78236. get barImageHeight(): number;
  78237. set barImageHeight(value: number);
  78238. /** Gets or sets the height of the horizontal bar image */
  78239. get horizontalBarImageHeight(): number;
  78240. set horizontalBarImageHeight(value: number);
  78241. /** Gets or sets the height of the vertical bar image */
  78242. get verticalBarImageHeight(): number;
  78243. set verticalBarImageHeight(value: number);
  78244. /** Gets or sets the bar background */
  78245. get barBackground(): string;
  78246. set barBackground(color: string);
  78247. /** Gets or sets the bar background image */
  78248. get barImage(): Image;
  78249. set barImage(value: Image);
  78250. /** Gets or sets the horizontal bar background image */
  78251. get horizontalBarImage(): Image;
  78252. set horizontalBarImage(value: Image);
  78253. /** Gets or sets the vertical bar background image */
  78254. get verticalBarImage(): Image;
  78255. set verticalBarImage(value: Image);
  78256. private _setWindowPosition;
  78257. /** @hidden */
  78258. private _updateScroller;
  78259. _link(host: AdvancedDynamicTexture): void;
  78260. /** @hidden */
  78261. private _addBar;
  78262. /** @hidden */
  78263. private _attachWheel;
  78264. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78265. /** Releases associated resources */
  78266. dispose(): void;
  78267. }
  78268. }
  78269. declare module BABYLON.GUI {
  78270. /** Class used to render a grid */
  78271. export class DisplayGrid extends Control {
  78272. name?: string | undefined;
  78273. private _cellWidth;
  78274. private _cellHeight;
  78275. private _minorLineTickness;
  78276. private _minorLineColor;
  78277. private _majorLineTickness;
  78278. private _majorLineColor;
  78279. private _majorLineFrequency;
  78280. private _background;
  78281. private _displayMajorLines;
  78282. private _displayMinorLines;
  78283. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78284. get displayMinorLines(): boolean;
  78285. set displayMinorLines(value: boolean);
  78286. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78287. get displayMajorLines(): boolean;
  78288. set displayMajorLines(value: boolean);
  78289. /** Gets or sets background color (Black by default) */
  78290. get background(): string;
  78291. set background(value: string);
  78292. /** Gets or sets the width of each cell (20 by default) */
  78293. get cellWidth(): number;
  78294. set cellWidth(value: number);
  78295. /** Gets or sets the height of each cell (20 by default) */
  78296. get cellHeight(): number;
  78297. set cellHeight(value: number);
  78298. /** Gets or sets the tickness of minor lines (1 by default) */
  78299. get minorLineTickness(): number;
  78300. set minorLineTickness(value: number);
  78301. /** Gets or sets the color of minor lines (DarkGray by default) */
  78302. get minorLineColor(): string;
  78303. set minorLineColor(value: string);
  78304. /** Gets or sets the tickness of major lines (2 by default) */
  78305. get majorLineTickness(): number;
  78306. set majorLineTickness(value: number);
  78307. /** Gets or sets the color of major lines (White by default) */
  78308. get majorLineColor(): string;
  78309. set majorLineColor(value: string);
  78310. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78311. get majorLineFrequency(): number;
  78312. set majorLineFrequency(value: number);
  78313. /**
  78314. * Creates a new GridDisplayRectangle
  78315. * @param name defines the control name
  78316. */
  78317. constructor(name?: string | undefined);
  78318. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78319. protected _getTypeName(): string;
  78320. }
  78321. }
  78322. declare module BABYLON.GUI {
  78323. /**
  78324. * Class used to create slider controls based on images
  78325. */
  78326. export class ImageBasedSlider extends BaseSlider {
  78327. name?: string | undefined;
  78328. private _backgroundImage;
  78329. private _thumbImage;
  78330. private _valueBarImage;
  78331. private _tempMeasure;
  78332. get displayThumb(): boolean;
  78333. set displayThumb(value: boolean);
  78334. /**
  78335. * Gets or sets the image used to render the background
  78336. */
  78337. get backgroundImage(): Image;
  78338. set backgroundImage(value: Image);
  78339. /**
  78340. * Gets or sets the image used to render the value bar
  78341. */
  78342. get valueBarImage(): Image;
  78343. set valueBarImage(value: Image);
  78344. /**
  78345. * Gets or sets the image used to render the thumb
  78346. */
  78347. get thumbImage(): Image;
  78348. set thumbImage(value: Image);
  78349. /**
  78350. * Creates a new ImageBasedSlider
  78351. * @param name defines the control name
  78352. */
  78353. constructor(name?: string | undefined);
  78354. protected _getTypeName(): string;
  78355. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78356. }
  78357. }
  78358. declare module BABYLON.GUI {
  78359. /**
  78360. * Forcing an export so that this code will execute
  78361. * @hidden
  78362. */
  78363. const name = "Statics";
  78364. }
  78365. declare module BABYLON.GUI {
  78366. /**
  78367. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78368. */
  78369. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78370. /**
  78371. * Define the instrumented AdvancedDynamicTexture.
  78372. */
  78373. texture: AdvancedDynamicTexture;
  78374. private _captureRenderTime;
  78375. private _renderTime;
  78376. private _captureLayoutTime;
  78377. private _layoutTime;
  78378. private _onBeginRenderObserver;
  78379. private _onEndRenderObserver;
  78380. private _onBeginLayoutObserver;
  78381. private _onEndLayoutObserver;
  78382. /**
  78383. * Gets the perf counter used to capture render time
  78384. */
  78385. get renderTimeCounter(): BABYLON.PerfCounter;
  78386. /**
  78387. * Gets the perf counter used to capture layout time
  78388. */
  78389. get layoutTimeCounter(): BABYLON.PerfCounter;
  78390. /**
  78391. * Enable or disable the render time capture
  78392. */
  78393. get captureRenderTime(): boolean;
  78394. set captureRenderTime(value: boolean);
  78395. /**
  78396. * Enable or disable the layout time capture
  78397. */
  78398. get captureLayoutTime(): boolean;
  78399. set captureLayoutTime(value: boolean);
  78400. /**
  78401. * Instantiates a new advanced dynamic texture instrumentation.
  78402. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78403. * @param texture Defines the AdvancedDynamicTexture to instrument
  78404. */
  78405. constructor(
  78406. /**
  78407. * Define the instrumented AdvancedDynamicTexture.
  78408. */
  78409. texture: AdvancedDynamicTexture);
  78410. /**
  78411. * Dispose and release associated resources.
  78412. */
  78413. dispose(): void;
  78414. }
  78415. }
  78416. declare module BABYLON.GUI {
  78417. /**
  78418. * Class used to load GUI via XML.
  78419. */
  78420. export class XmlLoader {
  78421. private _nodes;
  78422. private _nodeTypes;
  78423. private _isLoaded;
  78424. private _objectAttributes;
  78425. private _parentClass;
  78426. /**
  78427. * Create a new xml loader
  78428. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78429. */
  78430. constructor(parentClass?: null);
  78431. private _getChainElement;
  78432. private _getClassAttribute;
  78433. private _createGuiElement;
  78434. private _parseGrid;
  78435. private _parseElement;
  78436. private _prepareSourceElement;
  78437. private _parseElementsFromSource;
  78438. private _parseXml;
  78439. /**
  78440. * Gets if the loading has finished.
  78441. * @returns whether the loading has finished or not
  78442. */
  78443. isLoaded(): boolean;
  78444. /**
  78445. * Gets a loaded node / control by id.
  78446. * @param id the Controls id set in the xml
  78447. * @returns element of type Control
  78448. */
  78449. getNodeById(id: string): any;
  78450. /**
  78451. * Gets all loaded nodes / controls
  78452. * @returns Array of controls
  78453. */
  78454. getNodes(): any;
  78455. /**
  78456. * Initiates the xml layout loading
  78457. * @param xmlFile defines the xml layout to load
  78458. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78459. * @param callback defines the callback called on layout load.
  78460. */
  78461. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78462. }
  78463. }
  78464. declare module BABYLON.GUI {
  78465. /**
  78466. * Class used to create containers for controls
  78467. */
  78468. export class Container3D extends Control3D {
  78469. private _blockLayout;
  78470. /**
  78471. * Gets the list of child controls
  78472. */
  78473. protected _children: Control3D[];
  78474. /**
  78475. * Gets the list of child controls
  78476. */
  78477. get children(): Array<Control3D>;
  78478. /**
  78479. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78480. * This is helpful to optimize layout operation when adding multiple children in a row
  78481. */
  78482. get blockLayout(): boolean;
  78483. set blockLayout(value: boolean);
  78484. /**
  78485. * Creates a new container
  78486. * @param name defines the container name
  78487. */
  78488. constructor(name?: string);
  78489. /**
  78490. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78491. * @returns the current container
  78492. */
  78493. updateLayout(): Container3D;
  78494. /**
  78495. * Gets a boolean indicating if the given control is in the children of this control
  78496. * @param control defines the control to check
  78497. * @returns true if the control is in the child list
  78498. */
  78499. containsControl(control: Control3D): boolean;
  78500. /**
  78501. * Adds a control to the children of this control
  78502. * @param control defines the control to add
  78503. * @returns the current container
  78504. */
  78505. addControl(control: Control3D): Container3D;
  78506. /**
  78507. * This function will be called everytime a new control is added
  78508. */
  78509. protected _arrangeChildren(): void;
  78510. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78511. /**
  78512. * Removes a control from the children of this control
  78513. * @param control defines the control to remove
  78514. * @returns the current container
  78515. */
  78516. removeControl(control: Control3D): Container3D;
  78517. protected _getTypeName(): string;
  78518. /**
  78519. * Releases all associated resources
  78520. */
  78521. dispose(): void;
  78522. /** Control rotation will remain unchanged */
  78523. static readonly UNSET_ORIENTATION: number;
  78524. /** Control will rotate to make it look at sphere central axis */
  78525. static readonly FACEORIGIN_ORIENTATION: number;
  78526. /** Control will rotate to make it look back at sphere central axis */
  78527. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78528. /** Control will rotate to look at z axis (0, 0, 1) */
  78529. static readonly FACEFORWARD_ORIENTATION: number;
  78530. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78531. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78532. }
  78533. }
  78534. declare module BABYLON.GUI {
  78535. /**
  78536. * Class used to manage 3D user interface
  78537. * @see https://doc.babylonjs.com/how_to/gui3d
  78538. */
  78539. export class GUI3DManager implements BABYLON.IDisposable {
  78540. private _scene;
  78541. private _sceneDisposeObserver;
  78542. private _utilityLayer;
  78543. private _rootContainer;
  78544. private _pointerObserver;
  78545. private _pointerOutObserver;
  78546. /** @hidden */
  78547. _lastPickedControl: Control3D;
  78548. /** @hidden */
  78549. _lastControlOver: {
  78550. [pointerId: number]: Control3D;
  78551. };
  78552. /** @hidden */
  78553. _lastControlDown: {
  78554. [pointerId: number]: Control3D;
  78555. };
  78556. /**
  78557. * BABYLON.Observable raised when the point picked by the pointer events changed
  78558. */
  78559. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78560. /** @hidden */
  78561. _sharedMaterials: {
  78562. [key: string]: BABYLON.Material;
  78563. };
  78564. /** Gets the hosting scene */
  78565. get scene(): BABYLON.Scene;
  78566. /** Gets associated utility layer */
  78567. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78568. /**
  78569. * Creates a new GUI3DManager
  78570. * @param scene
  78571. */
  78572. constructor(scene?: BABYLON.Scene);
  78573. private _handlePointerOut;
  78574. private _doPicking;
  78575. /**
  78576. * Gets the root container
  78577. */
  78578. get rootContainer(): Container3D;
  78579. /**
  78580. * Gets a boolean indicating if the given control is in the root child list
  78581. * @param control defines the control to check
  78582. * @returns true if the control is in the root child list
  78583. */
  78584. containsControl(control: Control3D): boolean;
  78585. /**
  78586. * Adds a control to the root child list
  78587. * @param control defines the control to add
  78588. * @returns the current manager
  78589. */
  78590. addControl(control: Control3D): GUI3DManager;
  78591. /**
  78592. * Removes a control from the root child list
  78593. * @param control defines the control to remove
  78594. * @returns the current container
  78595. */
  78596. removeControl(control: Control3D): GUI3DManager;
  78597. /**
  78598. * Releases all associated resources
  78599. */
  78600. dispose(): void;
  78601. }
  78602. }
  78603. declare module BABYLON.GUI {
  78604. /**
  78605. * Class used to transport BABYLON.Vector3 information for pointer events
  78606. */
  78607. export class Vector3WithInfo extends BABYLON.Vector3 {
  78608. /** defines the current mouse button index */
  78609. buttonIndex: number;
  78610. /**
  78611. * Creates a new Vector3WithInfo
  78612. * @param source defines the vector3 data to transport
  78613. * @param buttonIndex defines the current mouse button index
  78614. */
  78615. constructor(source: BABYLON.Vector3,
  78616. /** defines the current mouse button index */
  78617. buttonIndex?: number);
  78618. }
  78619. }
  78620. declare module BABYLON.GUI {
  78621. /**
  78622. * Class used as base class for controls
  78623. */
  78624. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78625. /** Defines the control name */
  78626. name?: string | undefined;
  78627. /** @hidden */
  78628. _host: GUI3DManager;
  78629. private _node;
  78630. private _downCount;
  78631. private _enterCount;
  78632. private _downPointerIds;
  78633. private _isVisible;
  78634. /** Gets or sets the control position in world space */
  78635. get position(): BABYLON.Vector3;
  78636. set position(value: BABYLON.Vector3);
  78637. /** Gets or sets the control scaling in world space */
  78638. get scaling(): BABYLON.Vector3;
  78639. set scaling(value: BABYLON.Vector3);
  78640. /** Callback used to start pointer enter animation */
  78641. pointerEnterAnimation: () => void;
  78642. /** Callback used to start pointer out animation */
  78643. pointerOutAnimation: () => void;
  78644. /** Callback used to start pointer down animation */
  78645. pointerDownAnimation: () => void;
  78646. /** Callback used to start pointer up animation */
  78647. pointerUpAnimation: () => void;
  78648. /**
  78649. * An event triggered when the pointer move over the control
  78650. */
  78651. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78652. /**
  78653. * An event triggered when the pointer move out of the control
  78654. */
  78655. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78656. /**
  78657. * An event triggered when the pointer taps the control
  78658. */
  78659. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78660. /**
  78661. * An event triggered when pointer is up
  78662. */
  78663. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78664. /**
  78665. * An event triggered when a control is clicked on (with a mouse)
  78666. */
  78667. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78668. /**
  78669. * An event triggered when pointer enters the control
  78670. */
  78671. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78672. /**
  78673. * Gets or sets the parent container
  78674. */
  78675. parent: BABYLON.Nullable<Container3D>;
  78676. private _behaviors;
  78677. /**
  78678. * Gets the list of attached behaviors
  78679. * @see https://doc.babylonjs.com/features/behaviour
  78680. */
  78681. get behaviors(): BABYLON.Behavior<Control3D>[];
  78682. /**
  78683. * Attach a behavior to the control
  78684. * @see https://doc.babylonjs.com/features/behaviour
  78685. * @param behavior defines the behavior to attach
  78686. * @returns the current control
  78687. */
  78688. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78689. /**
  78690. * Remove an attached behavior
  78691. * @see https://doc.babylonjs.com/features/behaviour
  78692. * @param behavior defines the behavior to attach
  78693. * @returns the current control
  78694. */
  78695. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78696. /**
  78697. * Gets an attached behavior by name
  78698. * @param name defines the name of the behavior to look for
  78699. * @see https://doc.babylonjs.com/features/behaviour
  78700. * @returns null if behavior was not found else the requested behavior
  78701. */
  78702. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78703. /** Gets or sets a boolean indicating if the control is visible */
  78704. get isVisible(): boolean;
  78705. set isVisible(value: boolean);
  78706. /**
  78707. * Creates a new control
  78708. * @param name defines the control name
  78709. */
  78710. constructor(
  78711. /** Defines the control name */
  78712. name?: string | undefined);
  78713. /**
  78714. * Gets a string representing the class name
  78715. */
  78716. get typeName(): string;
  78717. /**
  78718. * Get the current class name of the control.
  78719. * @returns current class name
  78720. */
  78721. getClassName(): string;
  78722. protected _getTypeName(): string;
  78723. /**
  78724. * Gets the transform node used by this control
  78725. */
  78726. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78727. /**
  78728. * Gets the mesh used to render this control
  78729. */
  78730. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78731. /**
  78732. * Link the control as child of the given node
  78733. * @param node defines the node to link to. Use null to unlink the control
  78734. * @returns the current control
  78735. */
  78736. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78737. /** @hidden **/
  78738. _prepareNode(scene: BABYLON.Scene): void;
  78739. /**
  78740. * Node creation.
  78741. * Can be overriden by children
  78742. * @param scene defines the scene where the node must be attached
  78743. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78744. */
  78745. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78746. /**
  78747. * Affect a material to the given mesh
  78748. * @param mesh defines the mesh which will represent the control
  78749. */
  78750. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78751. /** @hidden */
  78752. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78753. /** @hidden */
  78754. _onPointerEnter(target: Control3D): boolean;
  78755. /** @hidden */
  78756. _onPointerOut(target: Control3D): void;
  78757. /** @hidden */
  78758. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78759. /** @hidden */
  78760. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78761. /** @hidden */
  78762. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78763. /** @hidden */
  78764. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78765. /** @hidden */
  78766. _disposeNode(): void;
  78767. /**
  78768. * Releases all associated resources
  78769. */
  78770. dispose(): void;
  78771. }
  78772. }
  78773. declare module BABYLON.GUI {
  78774. /**
  78775. * Class used as a root to all buttons
  78776. */
  78777. export class AbstractButton3D extends Control3D {
  78778. /**
  78779. * Creates a new button
  78780. * @param name defines the control name
  78781. */
  78782. constructor(name?: string);
  78783. protected _getTypeName(): string;
  78784. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78785. }
  78786. }
  78787. declare module BABYLON.GUI {
  78788. /**
  78789. * Class used to create a button in 3D
  78790. */
  78791. export class Button3D extends AbstractButton3D {
  78792. /** @hidden */
  78793. protected _currentMaterial: BABYLON.Material;
  78794. private _facadeTexture;
  78795. private _content;
  78796. private _contentResolution;
  78797. private _contentScaleRatio;
  78798. /**
  78799. * Gets or sets the texture resolution used to render content (512 by default)
  78800. */
  78801. get contentResolution(): BABYLON.int;
  78802. set contentResolution(value: BABYLON.int);
  78803. /**
  78804. * Gets or sets the texture scale ratio used to render content (2 by default)
  78805. */
  78806. get contentScaleRatio(): number;
  78807. set contentScaleRatio(value: number);
  78808. protected _disposeFacadeTexture(): void;
  78809. protected _resetContent(): void;
  78810. /**
  78811. * Creates a new button
  78812. * @param name defines the control name
  78813. */
  78814. constructor(name?: string);
  78815. /**
  78816. * Gets or sets the GUI 2D content used to display the button's facade
  78817. */
  78818. get content(): Control;
  78819. set content(value: Control);
  78820. /**
  78821. * Apply the facade texture (created from the content property).
  78822. * This function can be overloaded by child classes
  78823. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78824. */
  78825. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78826. protected _getTypeName(): string;
  78827. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78828. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78829. /**
  78830. * Releases all associated resources
  78831. */
  78832. dispose(): void;
  78833. }
  78834. }
  78835. declare module BABYLON.GUI {
  78836. /**
  78837. * Abstract class used to create a container panel deployed on the surface of a volume
  78838. */
  78839. export abstract class VolumeBasedPanel extends Container3D {
  78840. private _columns;
  78841. private _rows;
  78842. private _rowThenColum;
  78843. private _orientation;
  78844. protected _cellWidth: number;
  78845. protected _cellHeight: number;
  78846. /**
  78847. * Gets or sets the distance between elements
  78848. */
  78849. margin: number;
  78850. /**
  78851. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78852. * | Value | Type | Description |
  78853. * | ----- | ----------------------------------- | ----------- |
  78854. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78855. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78856. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78857. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78858. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78859. */
  78860. get orientation(): number;
  78861. set orientation(value: number);
  78862. /**
  78863. * Gets or sets the number of columns requested (10 by default).
  78864. * The panel will automatically compute the number of rows based on number of child controls.
  78865. */
  78866. get columns(): BABYLON.int;
  78867. set columns(value: BABYLON.int);
  78868. /**
  78869. * Gets or sets a the number of rows requested.
  78870. * The panel will automatically compute the number of columns based on number of child controls.
  78871. */
  78872. get rows(): BABYLON.int;
  78873. set rows(value: BABYLON.int);
  78874. /**
  78875. * Creates new VolumeBasedPanel
  78876. */
  78877. constructor();
  78878. protected _arrangeChildren(): void;
  78879. /** Child classes must implement this function to provide correct control positioning */
  78880. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78881. /** Child classes can implement this function to provide additional processing */
  78882. protected _finalProcessing(): void;
  78883. }
  78884. }
  78885. declare module BABYLON.GUI {
  78886. /**
  78887. * Class used to create a container panel deployed on the surface of a cylinder
  78888. */
  78889. export class CylinderPanel extends VolumeBasedPanel {
  78890. private _radius;
  78891. /**
  78892. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78893. */
  78894. get radius(): BABYLON.float;
  78895. set radius(value: BABYLON.float);
  78896. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78897. private _cylindricalMapping;
  78898. }
  78899. }
  78900. declare module BABYLON.GUI {
  78901. /** @hidden */
  78902. export var fluentVertexShader: {
  78903. name: string;
  78904. shader: string;
  78905. };
  78906. }
  78907. declare module BABYLON.GUI {
  78908. /** @hidden */
  78909. export var fluentPixelShader: {
  78910. name: string;
  78911. shader: string;
  78912. };
  78913. }
  78914. declare module BABYLON.GUI {
  78915. /** @hidden */
  78916. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78917. INNERGLOW: boolean;
  78918. BORDER: boolean;
  78919. HOVERLIGHT: boolean;
  78920. TEXTURE: boolean;
  78921. constructor();
  78922. }
  78923. /**
  78924. * Class used to render controls with fluent desgin
  78925. */
  78926. export class FluentMaterial extends BABYLON.PushMaterial {
  78927. /**
  78928. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78929. */
  78930. innerGlowColorIntensity: number;
  78931. /**
  78932. * Gets or sets the inner glow color (white by default)
  78933. */
  78934. innerGlowColor: BABYLON.Color3;
  78935. /**
  78936. * Gets or sets alpha value (default is 1.0)
  78937. */
  78938. alpha: number;
  78939. /**
  78940. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78941. */
  78942. albedoColor: BABYLON.Color3;
  78943. /**
  78944. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78945. */
  78946. renderBorders: boolean;
  78947. /**
  78948. * Gets or sets border width (default is 0.5)
  78949. */
  78950. borderWidth: number;
  78951. /**
  78952. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78953. */
  78954. edgeSmoothingValue: number;
  78955. /**
  78956. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78957. */
  78958. borderMinValue: number;
  78959. /**
  78960. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78961. */
  78962. renderHoverLight: boolean;
  78963. /**
  78964. * Gets or sets the radius used to render the hover light (default is 1.0)
  78965. */
  78966. hoverRadius: number;
  78967. /**
  78968. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78969. */
  78970. hoverColor: BABYLON.Color4;
  78971. /**
  78972. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78973. */
  78974. hoverPosition: BABYLON.Vector3;
  78975. private _albedoTexture;
  78976. /** Gets or sets the texture to use for albedo color */
  78977. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78978. /**
  78979. * Creates a new Fluent material
  78980. * @param name defines the name of the material
  78981. * @param scene defines the hosting scene
  78982. */
  78983. constructor(name: string, scene: BABYLON.Scene);
  78984. needAlphaBlending(): boolean;
  78985. needAlphaTesting(): boolean;
  78986. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78987. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78988. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78989. getActiveTextures(): BABYLON.BaseTexture[];
  78990. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78991. dispose(forceDisposeEffect?: boolean): void;
  78992. clone(name: string): FluentMaterial;
  78993. serialize(): any;
  78994. getClassName(): string;
  78995. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78996. }
  78997. }
  78998. declare module BABYLON.GUI {
  78999. /**
  79000. * Class used to create a holographic button in 3D
  79001. */
  79002. export class HolographicButton extends Button3D {
  79003. private _backPlate;
  79004. private _textPlate;
  79005. private _frontPlate;
  79006. private _text;
  79007. private _imageUrl;
  79008. private _shareMaterials;
  79009. private _frontMaterial;
  79010. private _backMaterial;
  79011. private _plateMaterial;
  79012. private _pickedPointObserver;
  79013. private _tooltipFade;
  79014. private _tooltipTextBlock;
  79015. private _tooltipTexture;
  79016. private _tooltipMesh;
  79017. private _tooltipHoverObserver;
  79018. private _tooltipOutObserver;
  79019. private _disposeTooltip;
  79020. /**
  79021. * Rendering ground id of all the mesh in the button
  79022. */
  79023. set renderingGroupId(id: number);
  79024. get renderingGroupId(): number;
  79025. /**
  79026. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79027. */
  79028. set tooltipText(text: BABYLON.Nullable<string>);
  79029. get tooltipText(): BABYLON.Nullable<string>;
  79030. /**
  79031. * Gets or sets text for the button
  79032. */
  79033. get text(): string;
  79034. set text(value: string);
  79035. /**
  79036. * Gets or sets the image url for the button
  79037. */
  79038. get imageUrl(): string;
  79039. set imageUrl(value: string);
  79040. /**
  79041. * Gets the back material used by this button
  79042. */
  79043. get backMaterial(): FluentMaterial;
  79044. /**
  79045. * Gets the front material used by this button
  79046. */
  79047. get frontMaterial(): FluentMaterial;
  79048. /**
  79049. * Gets the plate material used by this button
  79050. */
  79051. get plateMaterial(): BABYLON.StandardMaterial;
  79052. /**
  79053. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79054. */
  79055. get shareMaterials(): boolean;
  79056. /**
  79057. * Creates a new button
  79058. * @param name defines the control name
  79059. */
  79060. constructor(name?: string, shareMaterials?: boolean);
  79061. protected _getTypeName(): string;
  79062. private _rebuildContent;
  79063. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79064. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79065. private _createBackMaterial;
  79066. private _createFrontMaterial;
  79067. private _createPlateMaterial;
  79068. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79069. /**
  79070. * Releases all associated resources
  79071. */
  79072. dispose(): void;
  79073. }
  79074. }
  79075. declare module BABYLON.GUI {
  79076. /**
  79077. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79078. */
  79079. export class MeshButton3D extends Button3D {
  79080. /** @hidden */
  79081. protected _currentMesh: BABYLON.Mesh;
  79082. /**
  79083. * Creates a new 3D button based on a mesh
  79084. * @param mesh mesh to become a 3D button
  79085. * @param name defines the control name
  79086. */
  79087. constructor(mesh: BABYLON.Mesh, name?: string);
  79088. protected _getTypeName(): string;
  79089. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79090. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79091. }
  79092. }
  79093. declare module BABYLON.GUI {
  79094. /**
  79095. * Class used to create a container panel deployed on the surface of a plane
  79096. */
  79097. export class PlanePanel extends VolumeBasedPanel {
  79098. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79099. }
  79100. }
  79101. declare module BABYLON.GUI {
  79102. /**
  79103. * Class used to create a container panel where items get randomized planar mapping
  79104. */
  79105. export class ScatterPanel extends VolumeBasedPanel {
  79106. private _iteration;
  79107. /**
  79108. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79109. */
  79110. get iteration(): BABYLON.float;
  79111. set iteration(value: BABYLON.float);
  79112. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79113. private _scatterMapping;
  79114. protected _finalProcessing(): void;
  79115. }
  79116. }
  79117. declare module BABYLON.GUI {
  79118. /**
  79119. * Class used to create a container panel deployed on the surface of a sphere
  79120. */
  79121. export class SpherePanel extends VolumeBasedPanel {
  79122. private _radius;
  79123. /**
  79124. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79125. */
  79126. get radius(): BABYLON.float;
  79127. set radius(value: BABYLON.float);
  79128. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79129. private _sphericalMapping;
  79130. }
  79131. }
  79132. declare module BABYLON.GUI {
  79133. /**
  79134. * Class used to create a stack panel in 3D on XY plane
  79135. */
  79136. export class StackPanel3D extends Container3D {
  79137. private _isVertical;
  79138. /**
  79139. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79140. */
  79141. get isVertical(): boolean;
  79142. set isVertical(value: boolean);
  79143. /**
  79144. * Gets or sets the distance between elements
  79145. */
  79146. margin: number;
  79147. /**
  79148. * Creates new StackPanel
  79149. * @param isVertical
  79150. */
  79151. constructor(isVertical?: boolean);
  79152. protected _arrangeChildren(): void;
  79153. }
  79154. }
  79155. declare module BABYLON {
  79156. /**
  79157. * Configuration for glTF validation
  79158. */
  79159. export interface IGLTFValidationConfiguration {
  79160. /**
  79161. * The url of the glTF validator.
  79162. */
  79163. url: string;
  79164. }
  79165. /**
  79166. * glTF validation
  79167. */
  79168. export class GLTFValidation {
  79169. /**
  79170. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79171. */
  79172. static Configuration: IGLTFValidationConfiguration;
  79173. private static _LoadScriptPromise;
  79174. /**
  79175. * Validate a glTF asset using the glTF-Validator.
  79176. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79177. * @param rootUrl The root url for the glTF
  79178. * @param fileName The file name for the glTF
  79179. * @param getExternalResource The callback to get external resources for the glTF validator
  79180. * @returns A promise that resolves with the glTF validation results once complete
  79181. */
  79182. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79183. }
  79184. }
  79185. declare module BABYLON {
  79186. /**
  79187. * Mode that determines the coordinate system to use.
  79188. */
  79189. export enum GLTFLoaderCoordinateSystemMode {
  79190. /**
  79191. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79192. */
  79193. AUTO = 0,
  79194. /**
  79195. * Sets the useRightHandedSystem flag on the scene.
  79196. */
  79197. FORCE_RIGHT_HANDED = 1
  79198. }
  79199. /**
  79200. * Mode that determines what animations will start.
  79201. */
  79202. export enum GLTFLoaderAnimationStartMode {
  79203. /**
  79204. * No animation will start.
  79205. */
  79206. NONE = 0,
  79207. /**
  79208. * The first animation will start.
  79209. */
  79210. FIRST = 1,
  79211. /**
  79212. * All animations will start.
  79213. */
  79214. ALL = 2
  79215. }
  79216. /**
  79217. * Interface that contains the data for the glTF asset.
  79218. */
  79219. export interface IGLTFLoaderData {
  79220. /**
  79221. * The object that represents the glTF JSON.
  79222. */
  79223. json: Object;
  79224. /**
  79225. * The BIN chunk of a binary glTF.
  79226. */
  79227. bin: Nullable<IDataBuffer>;
  79228. }
  79229. /**
  79230. * Interface for extending the loader.
  79231. */
  79232. export interface IGLTFLoaderExtension {
  79233. /**
  79234. * The name of this extension.
  79235. */
  79236. readonly name: string;
  79237. /**
  79238. * Defines whether this extension is enabled.
  79239. */
  79240. enabled: boolean;
  79241. /**
  79242. * Defines the order of this extension.
  79243. * The loader sorts the extensions using these values when loading.
  79244. */
  79245. order?: number;
  79246. }
  79247. /**
  79248. * Loader state.
  79249. */
  79250. export enum GLTFLoaderState {
  79251. /**
  79252. * The asset is loading.
  79253. */
  79254. LOADING = 0,
  79255. /**
  79256. * The asset is ready for rendering.
  79257. */
  79258. READY = 1,
  79259. /**
  79260. * The asset is completely loaded.
  79261. */
  79262. COMPLETE = 2
  79263. }
  79264. /** @hidden */
  79265. export interface IImportMeshAsyncOutput {
  79266. meshes: AbstractMesh[];
  79267. particleSystems: IParticleSystem[];
  79268. skeletons: Skeleton[];
  79269. animationGroups: AnimationGroup[];
  79270. lights: Light[];
  79271. transformNodes: TransformNode[];
  79272. }
  79273. /** @hidden */
  79274. export interface IGLTFLoader extends IDisposable {
  79275. readonly state: Nullable<GLTFLoaderState>;
  79276. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79277. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79278. }
  79279. /**
  79280. * File loader for loading glTF files into a scene.
  79281. */
  79282. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79283. /** @hidden */
  79284. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79285. /** @hidden */
  79286. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79287. /**
  79288. * Raised when the asset has been parsed
  79289. */
  79290. onParsedObservable: Observable<IGLTFLoaderData>;
  79291. private _onParsedObserver;
  79292. /**
  79293. * Raised when the asset has been parsed
  79294. */
  79295. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79296. /**
  79297. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  79298. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79299. * Defaults to true.
  79300. * @hidden
  79301. */
  79302. static IncrementalLoading: boolean;
  79303. /**
  79304. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79305. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79306. * @hidden
  79307. */
  79308. static HomogeneousCoordinates: boolean;
  79309. /**
  79310. * The coordinate system mode. Defaults to AUTO.
  79311. */
  79312. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79313. /**
  79314. * The animation start mode. Defaults to FIRST.
  79315. */
  79316. animationStartMode: GLTFLoaderAnimationStartMode;
  79317. /**
  79318. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79319. */
  79320. compileMaterials: boolean;
  79321. /**
  79322. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79323. */
  79324. useClipPlane: boolean;
  79325. /**
  79326. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79327. */
  79328. compileShadowGenerators: boolean;
  79329. /**
  79330. * Defines if the Alpha blended materials are only applied as coverage.
  79331. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79332. * If true, no extra effects are applied to transparent pixels.
  79333. */
  79334. transparencyAsCoverage: boolean;
  79335. /**
  79336. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79337. * Enabling will disable offline support and glTF validator.
  79338. * Defaults to false.
  79339. */
  79340. useRangeRequests: boolean;
  79341. /**
  79342. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79343. */
  79344. createInstances: boolean;
  79345. /**
  79346. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  79347. */
  79348. alwaysComputeBoundingBox: boolean;
  79349. /**
  79350. * Function called before loading a url referenced by the asset.
  79351. */
  79352. preprocessUrlAsync: (url: string) => Promise<string>;
  79353. /**
  79354. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79355. */
  79356. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79357. private _onMeshLoadedObserver;
  79358. /**
  79359. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79360. */
  79361. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79362. /**
  79363. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79364. */
  79365. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79366. private _onTextureLoadedObserver;
  79367. /**
  79368. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79369. */
  79370. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79371. /**
  79372. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79373. */
  79374. readonly onMaterialLoadedObservable: Observable<Material>;
  79375. private _onMaterialLoadedObserver;
  79376. /**
  79377. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79378. */
  79379. set onMaterialLoaded(callback: (material: Material) => void);
  79380. /**
  79381. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79382. */
  79383. readonly onCameraLoadedObservable: Observable<Camera>;
  79384. private _onCameraLoadedObserver;
  79385. /**
  79386. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79387. */
  79388. set onCameraLoaded(callback: (camera: Camera) => void);
  79389. /**
  79390. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79391. * For assets with LODs, raised when all of the LODs are complete.
  79392. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79393. */
  79394. readonly onCompleteObservable: Observable<void>;
  79395. private _onCompleteObserver;
  79396. /**
  79397. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79398. * For assets with LODs, raised when all of the LODs are complete.
  79399. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79400. */
  79401. set onComplete(callback: () => void);
  79402. /**
  79403. * Observable raised when an error occurs.
  79404. */
  79405. readonly onErrorObservable: Observable<any>;
  79406. private _onErrorObserver;
  79407. /**
  79408. * Callback raised when an error occurs.
  79409. */
  79410. set onError(callback: (reason: any) => void);
  79411. /**
  79412. * Observable raised after the loader is disposed.
  79413. */
  79414. readonly onDisposeObservable: Observable<void>;
  79415. private _onDisposeObserver;
  79416. /**
  79417. * Callback raised after the loader is disposed.
  79418. */
  79419. set onDispose(callback: () => void);
  79420. /**
  79421. * Observable raised after a loader extension is created.
  79422. * Set additional options for a loader extension in this event.
  79423. */
  79424. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79425. private _onExtensionLoadedObserver;
  79426. /**
  79427. * Callback raised after a loader extension is created.
  79428. */
  79429. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79430. /**
  79431. * Defines if the loader logging is enabled.
  79432. */
  79433. get loggingEnabled(): boolean;
  79434. set loggingEnabled(value: boolean);
  79435. /**
  79436. * Defines if the loader should capture performance counters.
  79437. */
  79438. get capturePerformanceCounters(): boolean;
  79439. set capturePerformanceCounters(value: boolean);
  79440. /**
  79441. * Defines if the loader should validate the asset.
  79442. */
  79443. validate: boolean;
  79444. /**
  79445. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79446. */
  79447. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79448. private _onValidatedObserver;
  79449. /**
  79450. * Callback raised after a loader extension is created.
  79451. */
  79452. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79453. private _loader;
  79454. private _progressCallback?;
  79455. private _requests;
  79456. private static magicBase64Encoded;
  79457. /**
  79458. * Name of the loader ("gltf")
  79459. */
  79460. name: string;
  79461. /** @hidden */
  79462. extensions: ISceneLoaderPluginExtensions;
  79463. /**
  79464. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79465. */
  79466. dispose(): void;
  79467. /** @hidden */
  79468. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79469. /** @hidden */
  79470. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79471. /** @hidden */
  79472. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79473. meshes: AbstractMesh[];
  79474. particleSystems: IParticleSystem[];
  79475. skeletons: Skeleton[];
  79476. animationGroups: AnimationGroup[];
  79477. }>;
  79478. /** @hidden */
  79479. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79480. /** @hidden */
  79481. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79482. /** @hidden */
  79483. canDirectLoad(data: string): boolean;
  79484. /** @hidden */
  79485. directLoad(scene: Scene, data: string): Promise<any>;
  79486. /**
  79487. * The callback that allows custom handling of the root url based on the response url.
  79488. * @param rootUrl the original root url
  79489. * @param responseURL the response url if available
  79490. * @returns the new root url
  79491. */
  79492. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79493. /** @hidden */
  79494. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79495. /**
  79496. * The loader state or null if the loader is not active.
  79497. */
  79498. get loaderState(): Nullable<GLTFLoaderState>;
  79499. /**
  79500. * Returns a promise that resolves when the asset is completely loaded.
  79501. * @returns a promise that resolves when the asset is completely loaded.
  79502. */
  79503. whenCompleteAsync(): Promise<void>;
  79504. /** @hidden */
  79505. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79506. /** @hidden */
  79507. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79508. private _onProgress;
  79509. private _validate;
  79510. private _getLoader;
  79511. private _parseJson;
  79512. private _unpackBinaryAsync;
  79513. private _unpackBinaryV1Async;
  79514. private _unpackBinaryV2Async;
  79515. private static _parseVersion;
  79516. private static _compareVersion;
  79517. private static readonly _logSpaces;
  79518. private _logIndentLevel;
  79519. private _loggingEnabled;
  79520. /** @hidden */
  79521. _log: (message: string) => void;
  79522. /** @hidden */
  79523. _logOpen(message: string): void;
  79524. /** @hidden */
  79525. _logClose(): void;
  79526. private _logEnabled;
  79527. private _logDisabled;
  79528. private _capturePerformanceCounters;
  79529. /** @hidden */
  79530. _startPerformanceCounter: (counterName: string) => void;
  79531. /** @hidden */
  79532. _endPerformanceCounter: (counterName: string) => void;
  79533. private _startPerformanceCounterEnabled;
  79534. private _startPerformanceCounterDisabled;
  79535. private _endPerformanceCounterEnabled;
  79536. private _endPerformanceCounterDisabled;
  79537. }
  79538. }
  79539. declare module BABYLON.GLTF1 {
  79540. /**
  79541. * Enums
  79542. * @hidden
  79543. */
  79544. export enum EComponentType {
  79545. BYTE = 5120,
  79546. UNSIGNED_BYTE = 5121,
  79547. SHORT = 5122,
  79548. UNSIGNED_SHORT = 5123,
  79549. FLOAT = 5126
  79550. }
  79551. /** @hidden */
  79552. export enum EShaderType {
  79553. FRAGMENT = 35632,
  79554. VERTEX = 35633
  79555. }
  79556. /** @hidden */
  79557. export enum EParameterType {
  79558. BYTE = 5120,
  79559. UNSIGNED_BYTE = 5121,
  79560. SHORT = 5122,
  79561. UNSIGNED_SHORT = 5123,
  79562. INT = 5124,
  79563. UNSIGNED_INT = 5125,
  79564. FLOAT = 5126,
  79565. FLOAT_VEC2 = 35664,
  79566. FLOAT_VEC3 = 35665,
  79567. FLOAT_VEC4 = 35666,
  79568. INT_VEC2 = 35667,
  79569. INT_VEC3 = 35668,
  79570. INT_VEC4 = 35669,
  79571. BOOL = 35670,
  79572. BOOL_VEC2 = 35671,
  79573. BOOL_VEC3 = 35672,
  79574. BOOL_VEC4 = 35673,
  79575. FLOAT_MAT2 = 35674,
  79576. FLOAT_MAT3 = 35675,
  79577. FLOAT_MAT4 = 35676,
  79578. SAMPLER_2D = 35678
  79579. }
  79580. /** @hidden */
  79581. export enum ETextureWrapMode {
  79582. CLAMP_TO_EDGE = 33071,
  79583. MIRRORED_REPEAT = 33648,
  79584. REPEAT = 10497
  79585. }
  79586. /** @hidden */
  79587. export enum ETextureFilterType {
  79588. NEAREST = 9728,
  79589. LINEAR = 9728,
  79590. NEAREST_MIPMAP_NEAREST = 9984,
  79591. LINEAR_MIPMAP_NEAREST = 9985,
  79592. NEAREST_MIPMAP_LINEAR = 9986,
  79593. LINEAR_MIPMAP_LINEAR = 9987
  79594. }
  79595. /** @hidden */
  79596. export enum ETextureFormat {
  79597. ALPHA = 6406,
  79598. RGB = 6407,
  79599. RGBA = 6408,
  79600. LUMINANCE = 6409,
  79601. LUMINANCE_ALPHA = 6410
  79602. }
  79603. /** @hidden */
  79604. export enum ECullingType {
  79605. FRONT = 1028,
  79606. BACK = 1029,
  79607. FRONT_AND_BACK = 1032
  79608. }
  79609. /** @hidden */
  79610. export enum EBlendingFunction {
  79611. ZERO = 0,
  79612. ONE = 1,
  79613. SRC_COLOR = 768,
  79614. ONE_MINUS_SRC_COLOR = 769,
  79615. DST_COLOR = 774,
  79616. ONE_MINUS_DST_COLOR = 775,
  79617. SRC_ALPHA = 770,
  79618. ONE_MINUS_SRC_ALPHA = 771,
  79619. DST_ALPHA = 772,
  79620. ONE_MINUS_DST_ALPHA = 773,
  79621. CONSTANT_COLOR = 32769,
  79622. ONE_MINUS_CONSTANT_COLOR = 32770,
  79623. CONSTANT_ALPHA = 32771,
  79624. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79625. SRC_ALPHA_SATURATE = 776
  79626. }
  79627. /** @hidden */
  79628. export interface IGLTFProperty {
  79629. extensions?: {
  79630. [key: string]: any;
  79631. };
  79632. extras?: Object;
  79633. }
  79634. /** @hidden */
  79635. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79636. name?: string;
  79637. }
  79638. /** @hidden */
  79639. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79640. bufferView: string;
  79641. byteOffset: number;
  79642. byteStride: number;
  79643. count: number;
  79644. type: string;
  79645. componentType: EComponentType;
  79646. max?: number[];
  79647. min?: number[];
  79648. name?: string;
  79649. }
  79650. /** @hidden */
  79651. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79652. buffer: string;
  79653. byteOffset: number;
  79654. byteLength: number;
  79655. byteStride: number;
  79656. target?: number;
  79657. }
  79658. /** @hidden */
  79659. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79660. uri: string;
  79661. byteLength?: number;
  79662. type?: string;
  79663. }
  79664. /** @hidden */
  79665. export interface IGLTFShader extends IGLTFChildRootProperty {
  79666. uri: string;
  79667. type: EShaderType;
  79668. }
  79669. /** @hidden */
  79670. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79671. attributes: string[];
  79672. fragmentShader: string;
  79673. vertexShader: string;
  79674. }
  79675. /** @hidden */
  79676. export interface IGLTFTechniqueParameter {
  79677. type: number;
  79678. count?: number;
  79679. semantic?: string;
  79680. node?: string;
  79681. value?: number | boolean | string | Array<any>;
  79682. source?: string;
  79683. babylonValue?: any;
  79684. }
  79685. /** @hidden */
  79686. export interface IGLTFTechniqueCommonProfile {
  79687. lightingModel: string;
  79688. texcoordBindings: Object;
  79689. parameters?: Array<any>;
  79690. }
  79691. /** @hidden */
  79692. export interface IGLTFTechniqueStatesFunctions {
  79693. blendColor?: number[];
  79694. blendEquationSeparate?: number[];
  79695. blendFuncSeparate?: number[];
  79696. colorMask: boolean[];
  79697. cullFace: number[];
  79698. }
  79699. /** @hidden */
  79700. export interface IGLTFTechniqueStates {
  79701. enable: number[];
  79702. functions: IGLTFTechniqueStatesFunctions;
  79703. }
  79704. /** @hidden */
  79705. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79706. parameters: {
  79707. [key: string]: IGLTFTechniqueParameter;
  79708. };
  79709. program: string;
  79710. attributes: {
  79711. [key: string]: string;
  79712. };
  79713. uniforms: {
  79714. [key: string]: string;
  79715. };
  79716. states: IGLTFTechniqueStates;
  79717. }
  79718. /** @hidden */
  79719. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79720. technique?: string;
  79721. values: string[];
  79722. }
  79723. /** @hidden */
  79724. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79725. attributes: {
  79726. [key: string]: string;
  79727. };
  79728. indices: string;
  79729. material: string;
  79730. mode?: number;
  79731. }
  79732. /** @hidden */
  79733. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79734. primitives: IGLTFMeshPrimitive[];
  79735. }
  79736. /** @hidden */
  79737. export interface IGLTFImage extends IGLTFChildRootProperty {
  79738. uri: string;
  79739. }
  79740. /** @hidden */
  79741. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79742. magFilter?: number;
  79743. minFilter?: number;
  79744. wrapS?: number;
  79745. wrapT?: number;
  79746. }
  79747. /** @hidden */
  79748. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79749. sampler: string;
  79750. source: string;
  79751. format?: ETextureFormat;
  79752. internalFormat?: ETextureFormat;
  79753. target?: number;
  79754. type?: number;
  79755. babylonTexture?: Texture;
  79756. }
  79757. /** @hidden */
  79758. export interface IGLTFAmbienLight {
  79759. color?: number[];
  79760. }
  79761. /** @hidden */
  79762. export interface IGLTFDirectionalLight {
  79763. color?: number[];
  79764. }
  79765. /** @hidden */
  79766. export interface IGLTFPointLight {
  79767. color?: number[];
  79768. constantAttenuation?: number;
  79769. linearAttenuation?: number;
  79770. quadraticAttenuation?: number;
  79771. }
  79772. /** @hidden */
  79773. export interface IGLTFSpotLight {
  79774. color?: number[];
  79775. constantAttenuation?: number;
  79776. fallOfAngle?: number;
  79777. fallOffExponent?: number;
  79778. linearAttenuation?: number;
  79779. quadraticAttenuation?: number;
  79780. }
  79781. /** @hidden */
  79782. export interface IGLTFLight extends IGLTFChildRootProperty {
  79783. type: string;
  79784. }
  79785. /** @hidden */
  79786. export interface IGLTFCameraOrthographic {
  79787. xmag: number;
  79788. ymag: number;
  79789. zfar: number;
  79790. znear: number;
  79791. }
  79792. /** @hidden */
  79793. export interface IGLTFCameraPerspective {
  79794. aspectRatio: number;
  79795. yfov: number;
  79796. zfar: number;
  79797. znear: number;
  79798. }
  79799. /** @hidden */
  79800. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79801. type: string;
  79802. }
  79803. /** @hidden */
  79804. export interface IGLTFAnimationChannelTarget {
  79805. id: string;
  79806. path: string;
  79807. }
  79808. /** @hidden */
  79809. export interface IGLTFAnimationChannel {
  79810. sampler: string;
  79811. target: IGLTFAnimationChannelTarget;
  79812. }
  79813. /** @hidden */
  79814. export interface IGLTFAnimationSampler {
  79815. input: string;
  79816. output: string;
  79817. interpolation?: string;
  79818. }
  79819. /** @hidden */
  79820. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79821. channels?: IGLTFAnimationChannel[];
  79822. parameters?: {
  79823. [key: string]: string;
  79824. };
  79825. samplers?: {
  79826. [key: string]: IGLTFAnimationSampler;
  79827. };
  79828. }
  79829. /** @hidden */
  79830. export interface IGLTFNodeInstanceSkin {
  79831. skeletons: string[];
  79832. skin: string;
  79833. meshes: string[];
  79834. }
  79835. /** @hidden */
  79836. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79837. bindShapeMatrix: number[];
  79838. inverseBindMatrices: string;
  79839. jointNames: string[];
  79840. babylonSkeleton?: Skeleton;
  79841. }
  79842. /** @hidden */
  79843. export interface IGLTFNode extends IGLTFChildRootProperty {
  79844. camera?: string;
  79845. children: string[];
  79846. skin?: string;
  79847. jointName?: string;
  79848. light?: string;
  79849. matrix: number[];
  79850. mesh?: string;
  79851. meshes?: string[];
  79852. rotation?: number[];
  79853. scale?: number[];
  79854. translation?: number[];
  79855. babylonNode?: Node;
  79856. }
  79857. /** @hidden */
  79858. export interface IGLTFScene extends IGLTFChildRootProperty {
  79859. nodes: string[];
  79860. }
  79861. /** @hidden */
  79862. export interface IGLTFRuntime {
  79863. extensions: {
  79864. [key: string]: any;
  79865. };
  79866. accessors: {
  79867. [key: string]: IGLTFAccessor;
  79868. };
  79869. buffers: {
  79870. [key: string]: IGLTFBuffer;
  79871. };
  79872. bufferViews: {
  79873. [key: string]: IGLTFBufferView;
  79874. };
  79875. meshes: {
  79876. [key: string]: IGLTFMesh;
  79877. };
  79878. lights: {
  79879. [key: string]: IGLTFLight;
  79880. };
  79881. cameras: {
  79882. [key: string]: IGLTFCamera;
  79883. };
  79884. nodes: {
  79885. [key: string]: IGLTFNode;
  79886. };
  79887. images: {
  79888. [key: string]: IGLTFImage;
  79889. };
  79890. textures: {
  79891. [key: string]: IGLTFTexture;
  79892. };
  79893. shaders: {
  79894. [key: string]: IGLTFShader;
  79895. };
  79896. programs: {
  79897. [key: string]: IGLTFProgram;
  79898. };
  79899. samplers: {
  79900. [key: string]: IGLTFSampler;
  79901. };
  79902. techniques: {
  79903. [key: string]: IGLTFTechnique;
  79904. };
  79905. materials: {
  79906. [key: string]: IGLTFMaterial;
  79907. };
  79908. animations: {
  79909. [key: string]: IGLTFAnimation;
  79910. };
  79911. skins: {
  79912. [key: string]: IGLTFSkins;
  79913. };
  79914. currentScene?: Object;
  79915. scenes: {
  79916. [key: string]: IGLTFScene;
  79917. };
  79918. extensionsUsed: string[];
  79919. extensionsRequired?: string[];
  79920. buffersCount: number;
  79921. shaderscount: number;
  79922. scene: Scene;
  79923. rootUrl: string;
  79924. loadedBufferCount: number;
  79925. loadedBufferViews: {
  79926. [name: string]: ArrayBufferView;
  79927. };
  79928. loadedShaderCount: number;
  79929. importOnlyMeshes: boolean;
  79930. importMeshesNames?: string[];
  79931. dummyNodes: Node[];
  79932. forAssetContainer: boolean;
  79933. }
  79934. /** @hidden */
  79935. export interface INodeToRoot {
  79936. bone: Bone;
  79937. node: IGLTFNode;
  79938. id: string;
  79939. }
  79940. /** @hidden */
  79941. export interface IJointNode {
  79942. node: IGLTFNode;
  79943. id: string;
  79944. }
  79945. }
  79946. declare module BABYLON.GLTF1 {
  79947. /**
  79948. * Utils functions for GLTF
  79949. * @hidden
  79950. */
  79951. export class GLTFUtils {
  79952. /**
  79953. * Sets the given "parameter" matrix
  79954. * @param scene: the Scene object
  79955. * @param source: the source node where to pick the matrix
  79956. * @param parameter: the GLTF technique parameter
  79957. * @param uniformName: the name of the shader's uniform
  79958. * @param shaderMaterial: the shader material
  79959. */
  79960. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79961. /**
  79962. * Sets the given "parameter" matrix
  79963. * @param shaderMaterial: the shader material
  79964. * @param uniform: the name of the shader's uniform
  79965. * @param value: the value of the uniform
  79966. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79967. */
  79968. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79969. /**
  79970. * Returns the wrap mode of the texture
  79971. * @param mode: the mode value
  79972. */
  79973. static GetWrapMode(mode: number): number;
  79974. /**
  79975. * Returns the byte stride giving an accessor
  79976. * @param accessor: the GLTF accessor objet
  79977. */
  79978. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79979. /**
  79980. * Returns the texture filter mode giving a mode value
  79981. * @param mode: the filter mode value
  79982. */
  79983. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79984. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79985. /**
  79986. * Returns a buffer from its accessor
  79987. * @param gltfRuntime: the GLTF runtime
  79988. * @param accessor: the GLTF accessor
  79989. */
  79990. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79991. /**
  79992. * Decodes a buffer view into a string
  79993. * @param view: the buffer view
  79994. */
  79995. static DecodeBufferToText(view: ArrayBufferView): string;
  79996. /**
  79997. * Returns the default material of gltf. Related to
  79998. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79999. * @param scene: the Babylon.js scene
  80000. */
  80001. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80002. private static _DefaultMaterial;
  80003. }
  80004. }
  80005. declare module BABYLON.GLTF1 {
  80006. /**
  80007. * Implementation of the base glTF spec
  80008. * @hidden
  80009. */
  80010. export class GLTFLoaderBase {
  80011. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80012. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80013. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80014. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80015. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80016. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80017. }
  80018. /**
  80019. * glTF V1 Loader
  80020. * @hidden
  80021. */
  80022. export class GLTFLoader implements IGLTFLoader {
  80023. static Extensions: {
  80024. [name: string]: GLTFLoaderExtension;
  80025. };
  80026. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80027. state: Nullable<GLTFLoaderState>;
  80028. dispose(): void;
  80029. private _importMeshAsync;
  80030. /**
  80031. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80032. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80033. * @param scene the scene the meshes should be added to
  80034. * @param forAssetContainer defines if the entities must be stored in the scene
  80035. * @param data gltf data containing information of the meshes in a loaded file
  80036. * @param rootUrl root url to load from
  80037. * @param onProgress event that fires when loading progress has occured
  80038. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80039. */
  80040. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80041. private _loadAsync;
  80042. /**
  80043. * Imports all objects from a loaded gltf file and adds them to the scene
  80044. * @param scene the scene the objects should be added to
  80045. * @param data gltf data containing information of the meshes in a loaded file
  80046. * @param rootUrl root url to load from
  80047. * @param onProgress event that fires when loading progress has occured
  80048. * @returns a promise which completes when objects have been loaded to the scene
  80049. */
  80050. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80051. private _loadShadersAsync;
  80052. private _loadBuffersAsync;
  80053. private _createNodes;
  80054. }
  80055. /** @hidden */
  80056. export abstract class GLTFLoaderExtension {
  80057. private _name;
  80058. constructor(name: string);
  80059. get name(): string;
  80060. /**
  80061. * Defines an override for loading the runtime
  80062. * Return true to stop further extensions from loading the runtime
  80063. */
  80064. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80065. /**
  80066. * Defines an onverride for creating gltf runtime
  80067. * Return true to stop further extensions from creating the runtime
  80068. */
  80069. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80070. /**
  80071. * Defines an override for loading buffers
  80072. * Return true to stop further extensions from loading this buffer
  80073. */
  80074. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80075. /**
  80076. * Defines an override for loading texture buffers
  80077. * Return true to stop further extensions from loading this texture data
  80078. */
  80079. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80080. /**
  80081. * Defines an override for creating textures
  80082. * Return true to stop further extensions from loading this texture
  80083. */
  80084. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80085. /**
  80086. * Defines an override for loading shader strings
  80087. * Return true to stop further extensions from loading this shader data
  80088. */
  80089. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80090. /**
  80091. * Defines an override for loading materials
  80092. * Return true to stop further extensions from loading this material
  80093. */
  80094. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80095. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80096. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80097. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80098. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80099. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80100. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80101. private static LoadTextureBufferAsync;
  80102. private static CreateTextureAsync;
  80103. private static ApplyExtensions;
  80104. }
  80105. }
  80106. declare module BABYLON.GLTF1 {
  80107. /** @hidden */
  80108. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80109. private _bin;
  80110. constructor();
  80111. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80112. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80113. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80114. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80115. }
  80116. }
  80117. declare module BABYLON.GLTF1 {
  80118. /** @hidden */
  80119. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80120. constructor();
  80121. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80122. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80123. private _loadTexture;
  80124. }
  80125. }
  80126. declare module BABYLON.GLTF2.Loader {
  80127. /**
  80128. * Loader interface with an index field.
  80129. */
  80130. export interface IArrayItem {
  80131. /**
  80132. * The index of this item in the array.
  80133. */
  80134. index: number;
  80135. }
  80136. /**
  80137. * Loader interface with additional members.
  80138. */
  80139. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80140. /** @hidden */
  80141. _data?: Promise<ArrayBufferView>;
  80142. /** @hidden */
  80143. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80144. }
  80145. /**
  80146. * Loader interface with additional members.
  80147. */
  80148. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80149. }
  80150. /** @hidden */
  80151. export interface _IAnimationSamplerData {
  80152. input: Float32Array;
  80153. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80154. output: Float32Array;
  80155. }
  80156. /**
  80157. * Loader interface with additional members.
  80158. */
  80159. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80160. /** @hidden */
  80161. _data?: Promise<_IAnimationSamplerData>;
  80162. }
  80163. /**
  80164. * Loader interface with additional members.
  80165. */
  80166. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80167. channels: IAnimationChannel[];
  80168. samplers: IAnimationSampler[];
  80169. /** @hidden */
  80170. _babylonAnimationGroup?: AnimationGroup;
  80171. }
  80172. /**
  80173. * Loader interface with additional members.
  80174. */
  80175. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80176. /** @hidden */
  80177. _data?: Promise<ArrayBufferView>;
  80178. }
  80179. /**
  80180. * Loader interface with additional members.
  80181. */
  80182. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80183. /** @hidden */
  80184. _data?: Promise<ArrayBufferView>;
  80185. /** @hidden */
  80186. _babylonBuffer?: Promise<Buffer>;
  80187. }
  80188. /**
  80189. * Loader interface with additional members.
  80190. */
  80191. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80192. }
  80193. /**
  80194. * Loader interface with additional members.
  80195. */
  80196. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80197. /** @hidden */
  80198. _data?: Promise<ArrayBufferView>;
  80199. }
  80200. /**
  80201. * Loader interface with additional members.
  80202. */
  80203. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80204. }
  80205. /**
  80206. * Loader interface with additional members.
  80207. */
  80208. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80209. }
  80210. /**
  80211. * Loader interface with additional members.
  80212. */
  80213. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80214. baseColorTexture?: ITextureInfo;
  80215. metallicRoughnessTexture?: ITextureInfo;
  80216. }
  80217. /**
  80218. * Loader interface with additional members.
  80219. */
  80220. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80221. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80222. normalTexture?: IMaterialNormalTextureInfo;
  80223. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80224. emissiveTexture?: ITextureInfo;
  80225. /** @hidden */
  80226. _data?: {
  80227. [babylonDrawMode: number]: {
  80228. babylonMaterial: Material;
  80229. babylonMeshes: AbstractMesh[];
  80230. promise: Promise<void>;
  80231. };
  80232. };
  80233. }
  80234. /**
  80235. * Loader interface with additional members.
  80236. */
  80237. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80238. primitives: IMeshPrimitive[];
  80239. }
  80240. /**
  80241. * Loader interface with additional members.
  80242. */
  80243. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80244. /** @hidden */
  80245. _instanceData?: {
  80246. babylonSourceMesh: Mesh;
  80247. promise: Promise<any>;
  80248. };
  80249. }
  80250. /**
  80251. * Loader interface with additional members.
  80252. */
  80253. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80254. /**
  80255. * The parent glTF node.
  80256. */
  80257. parent?: INode;
  80258. /** @hidden */
  80259. _babylonTransformNode?: TransformNode;
  80260. /** @hidden */
  80261. _primitiveBabylonMeshes?: AbstractMesh[];
  80262. /** @hidden */
  80263. _babylonBones?: Bone[];
  80264. /** @hidden */
  80265. _numMorphTargets?: number;
  80266. }
  80267. /** @hidden */
  80268. export interface _ISamplerData {
  80269. noMipMaps: boolean;
  80270. samplingMode: number;
  80271. wrapU: number;
  80272. wrapV: number;
  80273. }
  80274. /**
  80275. * Loader interface with additional members.
  80276. */
  80277. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80278. /** @hidden */
  80279. _data?: _ISamplerData;
  80280. }
  80281. /**
  80282. * Loader interface with additional members.
  80283. */
  80284. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80285. }
  80286. /**
  80287. * Loader interface with additional members.
  80288. */
  80289. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80290. /** @hidden */
  80291. _data?: {
  80292. babylonSkeleton: Skeleton;
  80293. promise: Promise<void>;
  80294. };
  80295. }
  80296. /**
  80297. * Loader interface with additional members.
  80298. */
  80299. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80300. }
  80301. /**
  80302. * Loader interface with additional members.
  80303. */
  80304. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80305. }
  80306. /**
  80307. * Loader interface with additional members.
  80308. */
  80309. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80310. accessors?: IAccessor[];
  80311. animations?: IAnimation[];
  80312. buffers?: IBuffer[];
  80313. bufferViews?: IBufferView[];
  80314. cameras?: ICamera[];
  80315. images?: IImage[];
  80316. materials?: IMaterial[];
  80317. meshes?: IMesh[];
  80318. nodes?: INode[];
  80319. samplers?: ISampler[];
  80320. scenes?: IScene[];
  80321. skins?: ISkin[];
  80322. textures?: ITexture[];
  80323. }
  80324. }
  80325. declare module BABYLON.GLTF2 {
  80326. /**
  80327. * Interface for a glTF loader extension.
  80328. */
  80329. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80330. /**
  80331. * Called after the loader state changes to LOADING.
  80332. */
  80333. onLoading?(): void;
  80334. /**
  80335. * Called after the loader state changes to READY.
  80336. */
  80337. onReady?(): void;
  80338. /**
  80339. * Define this method to modify the default behavior when loading scenes.
  80340. * @param context The context when loading the asset
  80341. * @param scene The glTF scene property
  80342. * @returns A promise that resolves when the load is complete or null if not handled
  80343. */
  80344. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80345. /**
  80346. * Define this method to modify the default behavior when loading nodes.
  80347. * @param context The context when loading the asset
  80348. * @param node The glTF node property
  80349. * @param assign A function called synchronously after parsing the glTF properties
  80350. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80351. */
  80352. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80353. /**
  80354. * Define this method to modify the default behavior when loading cameras.
  80355. * @param context The context when loading the asset
  80356. * @param camera The glTF camera property
  80357. * @param assign A function called synchronously after parsing the glTF properties
  80358. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80359. */
  80360. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80361. /**
  80362. * @hidden
  80363. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80364. * @param context The context when loading the asset
  80365. * @param primitive The glTF mesh primitive property
  80366. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80367. */
  80368. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80369. /**
  80370. * @hidden
  80371. * Define this method to modify the default behavior when loading data for mesh primitives.
  80372. * @param context The context when loading the asset
  80373. * @param name The mesh name when loading the asset
  80374. * @param node The glTF node when loading the asset
  80375. * @param mesh The glTF mesh when loading the asset
  80376. * @param primitive The glTF mesh primitive property
  80377. * @param assign A function called synchronously after parsing the glTF properties
  80378. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80379. */
  80380. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80381. /**
  80382. * @hidden
  80383. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80384. * @param context The context when loading the asset
  80385. * @param material The glTF material property
  80386. * @param assign A function called synchronously after parsing the glTF properties
  80387. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80388. */
  80389. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80390. /**
  80391. * Define this method to modify the default behavior when creating materials.
  80392. * @param context The context when loading the asset
  80393. * @param material The glTF material property
  80394. * @param babylonDrawMode The draw mode for the Babylon material
  80395. * @returns The Babylon material or null if not handled
  80396. */
  80397. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80398. /**
  80399. * Define this method to modify the default behavior when loading material properties.
  80400. * @param context The context when loading the asset
  80401. * @param material The glTF material property
  80402. * @param babylonMaterial The Babylon material
  80403. * @returns A promise that resolves when the load is complete or null if not handled
  80404. */
  80405. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80406. /**
  80407. * Define this method to modify the default behavior when loading texture infos.
  80408. * @param context The context when loading the asset
  80409. * @param textureInfo The glTF texture info property
  80410. * @param assign A function called synchronously after parsing the glTF properties
  80411. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80412. */
  80413. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80414. /**
  80415. * @hidden
  80416. * Define this method to modify the default behavior when loading textures.
  80417. * @param context The context when loading the asset
  80418. * @param texture The glTF texture property
  80419. * @param assign A function called synchronously after parsing the glTF properties
  80420. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80421. */
  80422. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80423. /**
  80424. * Define this method to modify the default behavior when loading animations.
  80425. * @param context The context when loading the asset
  80426. * @param animation The glTF animation property
  80427. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80428. */
  80429. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80430. /**
  80431. * @hidden
  80432. * Define this method to modify the default behavior when loading skins.
  80433. * @param context The context when loading the asset
  80434. * @param node The glTF node property
  80435. * @param skin The glTF skin property
  80436. * @returns A promise that resolves when the load is complete or null if not handled
  80437. */
  80438. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80439. /**
  80440. * @hidden
  80441. * Define this method to modify the default behavior when loading uris.
  80442. * @param context The context when loading the asset
  80443. * @param property The glTF property associated with the uri
  80444. * @param uri The uri to load
  80445. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80446. */
  80447. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80448. /**
  80449. * Define this method to modify the default behavior when loading buffer views.
  80450. * @param context The context when loading the asset
  80451. * @param bufferView The glTF buffer view property
  80452. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80453. */
  80454. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80455. /**
  80456. * Define this method to modify the default behavior when loading buffers.
  80457. * @param context The context when loading the asset
  80458. * @param buffer The glTF buffer property
  80459. * @param byteOffset The byte offset to load
  80460. * @param byteLength The byte length to load
  80461. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80462. */
  80463. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80464. }
  80465. }
  80466. declare module BABYLON.GLTF2 {
  80467. /**
  80468. * Helper class for working with arrays when loading the glTF asset
  80469. */
  80470. export class ArrayItem {
  80471. /**
  80472. * Gets an item from the given array.
  80473. * @param context The context when loading the asset
  80474. * @param array The array to get the item from
  80475. * @param index The index to the array
  80476. * @returns The array item
  80477. */
  80478. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80479. /**
  80480. * Assign an `index` field to each item of the given array.
  80481. * @param array The array of items
  80482. */
  80483. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80484. }
  80485. /**
  80486. * The glTF 2.0 loader
  80487. */
  80488. export class GLTFLoader implements IGLTFLoader {
  80489. /** @hidden */
  80490. _completePromises: Promise<any>[];
  80491. /** @hidden */
  80492. _forAssetContainer: boolean;
  80493. /** Storage */
  80494. _babylonLights: Light[];
  80495. /** @hidden */
  80496. _disableInstancedMesh: number;
  80497. private _disposed;
  80498. private _parent;
  80499. private _state;
  80500. private _extensions;
  80501. private _rootUrl;
  80502. private _fileName;
  80503. private _uniqueRootUrl;
  80504. private _gltf;
  80505. private _bin;
  80506. private _babylonScene;
  80507. private _rootBabylonMesh;
  80508. private _defaultBabylonMaterialData;
  80509. private static _RegisteredExtensions;
  80510. /**
  80511. * The default glTF sampler.
  80512. */
  80513. static readonly DefaultSampler: ISampler;
  80514. /**
  80515. * Registers a loader extension.
  80516. * @param name The name of the loader extension.
  80517. * @param factory The factory function that creates the loader extension.
  80518. */
  80519. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80520. /**
  80521. * Unregisters a loader extension.
  80522. * @param name The name of the loader extension.
  80523. * @returns A boolean indicating whether the extension has been unregistered
  80524. */
  80525. static UnregisterExtension(name: string): boolean;
  80526. /**
  80527. * The loader state.
  80528. */
  80529. get state(): Nullable<GLTFLoaderState>;
  80530. /**
  80531. * The object that represents the glTF JSON.
  80532. */
  80533. get gltf(): IGLTF;
  80534. /**
  80535. * The BIN chunk of a binary glTF.
  80536. */
  80537. get bin(): Nullable<IDataBuffer>;
  80538. /**
  80539. * The parent file loader.
  80540. */
  80541. get parent(): GLTFFileLoader;
  80542. /**
  80543. * The Babylon scene when loading the asset.
  80544. */
  80545. get babylonScene(): Scene;
  80546. /**
  80547. * The root Babylon mesh when loading the asset.
  80548. */
  80549. get rootBabylonMesh(): Mesh;
  80550. /** @hidden */
  80551. constructor(parent: GLTFFileLoader);
  80552. /** @hidden */
  80553. dispose(): void;
  80554. /** @hidden */
  80555. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80556. /** @hidden */
  80557. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80558. private _loadAsync;
  80559. private _loadData;
  80560. private _setupData;
  80561. private _loadExtensions;
  80562. private _checkExtensions;
  80563. private _setState;
  80564. private _createRootNode;
  80565. /**
  80566. * Loads a glTF scene.
  80567. * @param context The context when loading the asset
  80568. * @param scene The glTF scene property
  80569. * @returns A promise that resolves when the load is complete
  80570. */
  80571. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80572. private _forEachPrimitive;
  80573. private _getMeshes;
  80574. private _getTransformNodes;
  80575. private _getSkeletons;
  80576. private _getAnimationGroups;
  80577. private _startAnimations;
  80578. /**
  80579. * Loads a glTF node.
  80580. * @param context The context when loading the asset
  80581. * @param node The glTF node property
  80582. * @param assign A function called synchronously after parsing the glTF properties
  80583. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80584. */
  80585. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80586. private _loadMeshAsync;
  80587. /**
  80588. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80589. * @param context The context when loading the asset
  80590. * @param name The mesh name when loading the asset
  80591. * @param node The glTF node when loading the asset
  80592. * @param mesh The glTF mesh when loading the asset
  80593. * @param primitive The glTF mesh primitive property
  80594. * @param assign A function called synchronously after parsing the glTF properties
  80595. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80596. */
  80597. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80598. private _loadVertexDataAsync;
  80599. private _createMorphTargets;
  80600. private _loadMorphTargetsAsync;
  80601. private _loadMorphTargetVertexDataAsync;
  80602. private static _LoadTransform;
  80603. private _loadSkinAsync;
  80604. private _loadBones;
  80605. private _loadBone;
  80606. private _loadSkinInverseBindMatricesDataAsync;
  80607. private _updateBoneMatrices;
  80608. private _getNodeMatrix;
  80609. /**
  80610. * Loads a glTF camera.
  80611. * @param context The context when loading the asset
  80612. * @param camera The glTF camera property
  80613. * @param assign A function called synchronously after parsing the glTF properties
  80614. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80615. */
  80616. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80617. private _loadAnimationsAsync;
  80618. /**
  80619. * Loads a glTF animation.
  80620. * @param context The context when loading the asset
  80621. * @param animation The glTF animation property
  80622. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80623. */
  80624. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80625. /**
  80626. * @hidden Loads a glTF animation channel.
  80627. * @param context The context when loading the asset
  80628. * @param animationContext The context of the animation when loading the asset
  80629. * @param animation The glTF animation property
  80630. * @param channel The glTF animation channel property
  80631. * @param babylonAnimationGroup The babylon animation group property
  80632. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80633. * @returns A void promise when the channel load is complete
  80634. */
  80635. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80636. private _loadAnimationSamplerAsync;
  80637. private _loadBufferAsync;
  80638. /**
  80639. * Loads a glTF buffer view.
  80640. * @param context The context when loading the asset
  80641. * @param bufferView The glTF buffer view property
  80642. * @returns A promise that resolves with the loaded data when the load is complete
  80643. */
  80644. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80645. private _loadAccessorAsync;
  80646. /** @hidden */
  80647. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80648. private _loadIndicesAccessorAsync;
  80649. private _loadVertexBufferViewAsync;
  80650. private _loadVertexAccessorAsync;
  80651. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80652. /** @hidden */
  80653. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80654. private _createDefaultMaterial;
  80655. /**
  80656. * Creates a Babylon material from a glTF material.
  80657. * @param context The context when loading the asset
  80658. * @param material The glTF material property
  80659. * @param babylonDrawMode The draw mode for the Babylon material
  80660. * @returns The Babylon material
  80661. */
  80662. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80663. /**
  80664. * Loads properties from a glTF material into a Babylon material.
  80665. * @param context The context when loading the asset
  80666. * @param material The glTF material property
  80667. * @param babylonMaterial The Babylon material
  80668. * @returns A promise that resolves when the load is complete
  80669. */
  80670. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80671. /**
  80672. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80673. * @param context The context when loading the asset
  80674. * @param material The glTF material property
  80675. * @param babylonMaterial The Babylon material
  80676. * @returns A promise that resolves when the load is complete
  80677. */
  80678. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80679. /**
  80680. * Loads the alpha properties from a glTF material into a Babylon material.
  80681. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80682. * @param context The context when loading the asset
  80683. * @param material The glTF material property
  80684. * @param babylonMaterial The Babylon material
  80685. */
  80686. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80687. /**
  80688. * Loads a glTF texture info.
  80689. * @param context The context when loading the asset
  80690. * @param textureInfo The glTF texture info property
  80691. * @param assign A function called synchronously after parsing the glTF properties
  80692. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80693. */
  80694. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80695. /** @hidden */
  80696. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80697. /** @hidden */
  80698. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80699. private _loadSampler;
  80700. /**
  80701. * Loads a glTF image.
  80702. * @param context The context when loading the asset
  80703. * @param image The glTF image property
  80704. * @returns A promise that resolves with the loaded data when the load is complete
  80705. */
  80706. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80707. /**
  80708. * Loads a glTF uri.
  80709. * @param context The context when loading the asset
  80710. * @param property The glTF property associated with the uri
  80711. * @param uri The base64 or relative uri
  80712. * @returns A promise that resolves with the loaded data when the load is complete
  80713. */
  80714. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80715. /**
  80716. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80717. * @param babylonObject the Babylon object with metadata
  80718. * @param pointer the JSON pointer
  80719. */
  80720. static AddPointerMetadata(babylonObject: {
  80721. metadata: any;
  80722. }, pointer: string): void;
  80723. private static _GetTextureWrapMode;
  80724. private static _GetTextureSamplingMode;
  80725. private static _GetTypedArrayConstructor;
  80726. private static _GetTypedArray;
  80727. private static _GetNumComponents;
  80728. private static _ValidateUri;
  80729. /** @hidden */
  80730. static _GetDrawMode(context: string, mode: number | undefined): number;
  80731. private _compileMaterialsAsync;
  80732. private _compileShadowGeneratorsAsync;
  80733. private _forEachExtensions;
  80734. private _applyExtensions;
  80735. private _extensionsOnLoading;
  80736. private _extensionsOnReady;
  80737. private _extensionsLoadSceneAsync;
  80738. private _extensionsLoadNodeAsync;
  80739. private _extensionsLoadCameraAsync;
  80740. private _extensionsLoadVertexDataAsync;
  80741. private _extensionsLoadMeshPrimitiveAsync;
  80742. private _extensionsLoadMaterialAsync;
  80743. private _extensionsCreateMaterial;
  80744. private _extensionsLoadMaterialPropertiesAsync;
  80745. private _extensionsLoadTextureInfoAsync;
  80746. private _extensionsLoadTextureAsync;
  80747. private _extensionsLoadAnimationAsync;
  80748. private _extensionsLoadSkinAsync;
  80749. private _extensionsLoadUriAsync;
  80750. private _extensionsLoadBufferViewAsync;
  80751. private _extensionsLoadBufferAsync;
  80752. /**
  80753. * Helper method called by a loader extension to load an glTF extension.
  80754. * @param context The context when loading the asset
  80755. * @param property The glTF property to load the extension from
  80756. * @param extensionName The name of the extension to load
  80757. * @param actionAsync The action to run
  80758. * @returns The promise returned by actionAsync or null if the extension does not exist
  80759. */
  80760. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80761. /**
  80762. * Helper method called by a loader extension to load a glTF extra.
  80763. * @param context The context when loading the asset
  80764. * @param property The glTF property to load the extra from
  80765. * @param extensionName The name of the extension to load
  80766. * @param actionAsync The action to run
  80767. * @returns The promise returned by actionAsync or null if the extra does not exist
  80768. */
  80769. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80770. /**
  80771. * Checks for presence of an extension.
  80772. * @param name The name of the extension to check
  80773. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80774. */
  80775. isExtensionUsed(name: string): boolean;
  80776. /**
  80777. * Increments the indentation level and logs a message.
  80778. * @param message The message to log
  80779. */
  80780. logOpen(message: string): void;
  80781. /**
  80782. * Decrements the indentation level.
  80783. */
  80784. logClose(): void;
  80785. /**
  80786. * Logs a message
  80787. * @param message The message to log
  80788. */
  80789. log(message: string): void;
  80790. /**
  80791. * Starts a performance counter.
  80792. * @param counterName The name of the performance counter
  80793. */
  80794. startPerformanceCounter(counterName: string): void;
  80795. /**
  80796. * Ends a performance counter.
  80797. * @param counterName The name of the performance counter
  80798. */
  80799. endPerformanceCounter(counterName: string): void;
  80800. }
  80801. }
  80802. declare module BABYLON.GLTF2.Loader.Extensions {
  80803. /** @hidden */
  80804. interface IEXTLightsImageBased_LightImageBased {
  80805. _babylonTexture?: BaseTexture;
  80806. _loaded?: Promise<void>;
  80807. }
  80808. /**
  80809. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80810. */
  80811. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80812. /**
  80813. * The name of this extension.
  80814. */
  80815. readonly name: string;
  80816. /**
  80817. * Defines whether this extension is enabled.
  80818. */
  80819. enabled: boolean;
  80820. private _loader;
  80821. private _lights?;
  80822. /** @hidden */
  80823. constructor(loader: GLTFLoader);
  80824. /** @hidden */
  80825. dispose(): void;
  80826. /** @hidden */
  80827. onLoading(): void;
  80828. /** @hidden */
  80829. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80830. private _loadLightAsync;
  80831. }
  80832. }
  80833. declare module BABYLON.GLTF2.Loader.Extensions {
  80834. /**
  80835. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80836. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80837. * !!! Experimental Extension Subject to Changes !!!
  80838. */
  80839. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80840. /**
  80841. * The name of this extension.
  80842. */
  80843. readonly name: string;
  80844. /**
  80845. * Defines whether this extension is enabled.
  80846. */
  80847. enabled: boolean;
  80848. private _loader;
  80849. /** @hidden */
  80850. constructor(loader: GLTFLoader);
  80851. /** @hidden */
  80852. dispose(): void;
  80853. /** @hidden */
  80854. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80855. }
  80856. }
  80857. declare module BABYLON.GLTF2.Loader.Extensions {
  80858. /**
  80859. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80860. */
  80861. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80862. /**
  80863. * The name of this extension.
  80864. */
  80865. readonly name: string;
  80866. /**
  80867. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80868. */
  80869. dracoCompression?: DracoCompression;
  80870. /**
  80871. * Defines whether this extension is enabled.
  80872. */
  80873. enabled: boolean;
  80874. private _loader;
  80875. /** @hidden */
  80876. constructor(loader: GLTFLoader);
  80877. /** @hidden */
  80878. dispose(): void;
  80879. /** @hidden */
  80880. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80881. }
  80882. }
  80883. declare module BABYLON.GLTF2.Loader.Extensions {
  80884. /**
  80885. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80886. */
  80887. export class KHR_lights implements IGLTFLoaderExtension {
  80888. /**
  80889. * The name of this extension.
  80890. */
  80891. readonly name: string;
  80892. /**
  80893. * Defines whether this extension is enabled.
  80894. */
  80895. enabled: boolean;
  80896. private _loader;
  80897. private _lights?;
  80898. /** @hidden */
  80899. constructor(loader: GLTFLoader);
  80900. /** @hidden */
  80901. dispose(): void;
  80902. /** @hidden */
  80903. onLoading(): void;
  80904. /** @hidden */
  80905. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80906. }
  80907. }
  80908. declare module BABYLON.GLTF2.Loader.Extensions {
  80909. /**
  80910. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80911. */
  80912. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80913. /**
  80914. * The name of this extension.
  80915. */
  80916. readonly name: string;
  80917. /**
  80918. * Defines whether this extension is enabled.
  80919. */
  80920. enabled: boolean;
  80921. /**
  80922. * Defines a number that determines the order the extensions are applied.
  80923. */
  80924. order: number;
  80925. private _loader;
  80926. /** @hidden */
  80927. constructor(loader: GLTFLoader);
  80928. /** @hidden */
  80929. dispose(): void;
  80930. /** @hidden */
  80931. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80932. private _loadSpecularGlossinessPropertiesAsync;
  80933. }
  80934. }
  80935. declare module BABYLON.GLTF2.Loader.Extensions {
  80936. /**
  80937. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80938. */
  80939. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80940. /**
  80941. * The name of this extension.
  80942. */
  80943. readonly name: string;
  80944. /**
  80945. * Defines whether this extension is enabled.
  80946. */
  80947. enabled: boolean;
  80948. /**
  80949. * Defines a number that determines the order the extensions are applied.
  80950. */
  80951. order: number;
  80952. private _loader;
  80953. /** @hidden */
  80954. constructor(loader: GLTFLoader);
  80955. /** @hidden */
  80956. dispose(): void;
  80957. /** @hidden */
  80958. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80959. private _loadUnlitPropertiesAsync;
  80960. }
  80961. }
  80962. declare module BABYLON.GLTF2.Loader.Extensions {
  80963. /**
  80964. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80965. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80966. * !!! Experimental Extension Subject to Changes !!!
  80967. */
  80968. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80969. /**
  80970. * The name of this extension.
  80971. */
  80972. readonly name: string;
  80973. /**
  80974. * Defines whether this extension is enabled.
  80975. */
  80976. enabled: boolean;
  80977. /**
  80978. * Defines a number that determines the order the extensions are applied.
  80979. */
  80980. order: number;
  80981. private _loader;
  80982. /** @hidden */
  80983. constructor(loader: GLTFLoader);
  80984. /** @hidden */
  80985. dispose(): void;
  80986. /** @hidden */
  80987. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80988. private _loadClearCoatPropertiesAsync;
  80989. }
  80990. }
  80991. declare module BABYLON.GLTF2.Loader.Extensions {
  80992. /**
  80993. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80994. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80995. * !!! Experimental Extension Subject to Changes !!!
  80996. */
  80997. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80998. /**
  80999. * The name of this extension.
  81000. */
  81001. readonly name: string;
  81002. /**
  81003. * Defines whether this extension is enabled.
  81004. */
  81005. enabled: boolean;
  81006. /**
  81007. * Defines a number that determines the order the extensions are applied.
  81008. */
  81009. order: number;
  81010. private _loader;
  81011. /** @hidden */
  81012. constructor(loader: GLTFLoader);
  81013. /** @hidden */
  81014. dispose(): void;
  81015. /** @hidden */
  81016. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81017. private _loadSheenPropertiesAsync;
  81018. }
  81019. }
  81020. declare module BABYLON.GLTF2.Loader.Extensions {
  81021. /**
  81022. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81023. * !!! Experimental Extension Subject to Changes !!!
  81024. */
  81025. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81026. /**
  81027. * The name of this extension.
  81028. */
  81029. readonly name: string;
  81030. /**
  81031. * Defines whether this extension is enabled.
  81032. */
  81033. enabled: boolean;
  81034. /**
  81035. * Defines a number that determines the order the extensions are applied.
  81036. */
  81037. order: number;
  81038. private _loader;
  81039. /** @hidden */
  81040. constructor(loader: GLTFLoader);
  81041. /** @hidden */
  81042. dispose(): void;
  81043. /** @hidden */
  81044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81045. private _loadSpecularPropertiesAsync;
  81046. }
  81047. }
  81048. declare module BABYLON.GLTF2.Loader.Extensions {
  81049. /**
  81050. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81051. * !!! Experimental Extension Subject to Changes !!!
  81052. */
  81053. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81054. /**
  81055. * Default ior Value from the spec.
  81056. */
  81057. private static readonly _DEFAULT_IOR;
  81058. /**
  81059. * The name of this extension.
  81060. */
  81061. readonly name: string;
  81062. /**
  81063. * Defines whether this extension is enabled.
  81064. */
  81065. enabled: boolean;
  81066. /**
  81067. * Defines a number that determines the order the extensions are applied.
  81068. */
  81069. order: number;
  81070. private _loader;
  81071. /** @hidden */
  81072. constructor(loader: GLTFLoader);
  81073. /** @hidden */
  81074. dispose(): void;
  81075. /** @hidden */
  81076. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81077. private _loadIorPropertiesAsync;
  81078. }
  81079. }
  81080. declare module BABYLON.GLTF2.Loader.Extensions {
  81081. /**
  81082. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81083. * !!! Experimental Extension Subject to Changes !!!
  81084. */
  81085. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81086. /**
  81087. * The name of this extension.
  81088. */
  81089. readonly name: string;
  81090. /**
  81091. * Defines whether this extension is enabled.
  81092. */
  81093. enabled: boolean;
  81094. private _loader;
  81095. /** @hidden */
  81096. constructor(loader: GLTFLoader);
  81097. /** @hidden */
  81098. dispose(): void;
  81099. /**
  81100. * Gets the list of available variant tag names for this asset.
  81101. * @param rootMesh The glTF root mesh
  81102. * @returns the list of all the variant names for this model
  81103. */
  81104. static GetAvailableVariants(rootMesh: Mesh): string[];
  81105. /**
  81106. * Gets the list of available variant tag names for this asset.
  81107. * @param rootMesh The glTF root mesh
  81108. * @returns the list of all the variant names for this model
  81109. */
  81110. getAvailableVariants(rootMesh: Mesh): string[];
  81111. /**
  81112. * Select a variant given a variant tag name or a list of variant tag names.
  81113. * @param rootMesh The glTF root mesh
  81114. * @param variantName The variant name(s) to select.
  81115. */
  81116. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81117. /**
  81118. * Select a variant given a variant tag name or a list of variant tag names.
  81119. * @param rootMesh The glTF root mesh
  81120. * @param variantName The variant name(s) to select.
  81121. */
  81122. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81123. /**
  81124. * Reset back to the original before selecting a variant.
  81125. * @param rootMesh The glTF root mesh
  81126. */
  81127. static Reset(rootMesh: Mesh): void;
  81128. /**
  81129. * Reset back to the original before selecting a variant.
  81130. * @param rootMesh The glTF root mesh
  81131. */
  81132. reset(rootMesh: Mesh): void;
  81133. /**
  81134. * Gets the last selected variant tag name(s) or null if original.
  81135. * @param rootMesh The glTF root mesh
  81136. * @returns The selected variant tag name(s).
  81137. */
  81138. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81139. /**
  81140. * Gets the last selected variant tag name(s) or null if original.
  81141. * @param rootMesh The glTF root mesh
  81142. * @returns The selected variant tag name(s).
  81143. */
  81144. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81145. private static _GetExtensionMetadata;
  81146. /** @hidden */
  81147. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81148. }
  81149. }
  81150. declare module BABYLON.GLTF2.Loader.Extensions {
  81151. /**
  81152. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81153. * !!! Experimental Extension Subject to Changes !!!
  81154. */
  81155. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81156. /**
  81157. * The name of this extension.
  81158. */
  81159. readonly name: string;
  81160. /**
  81161. * Defines whether this extension is enabled.
  81162. */
  81163. enabled: boolean;
  81164. /**
  81165. * Defines a number that determines the order the extensions are applied.
  81166. */
  81167. order: number;
  81168. private _loader;
  81169. /** @hidden */
  81170. constructor(loader: GLTFLoader);
  81171. /** @hidden */
  81172. dispose(): void;
  81173. /** @hidden */
  81174. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81175. private _loadTransparentPropertiesAsync;
  81176. }
  81177. }
  81178. declare module BABYLON.GLTF2.Loader.Extensions {
  81179. /**
  81180. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81181. */
  81182. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81183. /**
  81184. * The name of this extension.
  81185. */
  81186. readonly name: string;
  81187. /**
  81188. * Defines whether this extension is enabled.
  81189. */
  81190. enabled: boolean;
  81191. /** @hidden */
  81192. constructor(loader: GLTFLoader);
  81193. /** @hidden */
  81194. dispose(): void;
  81195. }
  81196. }
  81197. declare module BABYLON.GLTF2.Loader.Extensions {
  81198. /**
  81199. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81200. * !!! Experimental Extension Subject to Changes !!!
  81201. */
  81202. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81203. /** The name of this extension. */
  81204. readonly name: string;
  81205. /** Defines whether this extension is enabled. */
  81206. enabled: boolean;
  81207. private _loader;
  81208. /** @hidden */
  81209. constructor(loader: GLTFLoader);
  81210. /** @hidden */
  81211. dispose(): void;
  81212. /** @hidden */
  81213. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81214. }
  81215. }
  81216. declare module BABYLON.GLTF2.Loader.Extensions {
  81217. /**
  81218. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81219. */
  81220. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81221. /**
  81222. * The name of this extension.
  81223. */
  81224. readonly name: string;
  81225. /**
  81226. * Defines whether this extension is enabled.
  81227. */
  81228. enabled: boolean;
  81229. private _loader;
  81230. /** @hidden */
  81231. constructor(loader: GLTFLoader);
  81232. /** @hidden */
  81233. dispose(): void;
  81234. /** @hidden */
  81235. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81236. }
  81237. }
  81238. declare module BABYLON.GLTF2.Loader.Extensions {
  81239. /**
  81240. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81241. * !!! Experimental Extension Subject to Changes !!!
  81242. */
  81243. export class KHR_xmp implements IGLTFLoaderExtension {
  81244. /**
  81245. * The name of this extension.
  81246. */
  81247. readonly name: string;
  81248. /**
  81249. * Defines whether this extension is enabled.
  81250. */
  81251. enabled: boolean;
  81252. /**
  81253. * Defines a number that determines the order the extensions are applied.
  81254. */
  81255. order: number;
  81256. private _loader;
  81257. /** @hidden */
  81258. constructor(loader: GLTFLoader);
  81259. /** @hidden */
  81260. dispose(): void;
  81261. /**
  81262. * Called after the loader state changes to LOADING.
  81263. */
  81264. onLoading(): void;
  81265. }
  81266. }
  81267. declare module BABYLON.GLTF2.Loader.Extensions {
  81268. /**
  81269. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81270. */
  81271. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81272. /**
  81273. * The name of this extension.
  81274. */
  81275. readonly name: string;
  81276. /**
  81277. * Defines whether this extension is enabled.
  81278. */
  81279. enabled: boolean;
  81280. private _loader;
  81281. private _clips;
  81282. private _emitters;
  81283. /** @hidden */
  81284. constructor(loader: GLTFLoader);
  81285. /** @hidden */
  81286. dispose(): void;
  81287. /** @hidden */
  81288. onLoading(): void;
  81289. /** @hidden */
  81290. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81291. /** @hidden */
  81292. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81293. /** @hidden */
  81294. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81295. private _loadClipAsync;
  81296. private _loadEmitterAsync;
  81297. private _getEventAction;
  81298. private _loadAnimationEventAsync;
  81299. }
  81300. }
  81301. declare module BABYLON.GLTF2.Loader.Extensions {
  81302. /**
  81303. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81304. */
  81305. export class MSFT_lod implements IGLTFLoaderExtension {
  81306. /**
  81307. * The name of this extension.
  81308. */
  81309. readonly name: string;
  81310. /**
  81311. * Defines whether this extension is enabled.
  81312. */
  81313. enabled: boolean;
  81314. /**
  81315. * Defines a number that determines the order the extensions are applied.
  81316. */
  81317. order: number;
  81318. /**
  81319. * Maximum number of LODs to load, starting from the lowest LOD.
  81320. */
  81321. maxLODsToLoad: number;
  81322. /**
  81323. * Observable raised when all node LODs of one level are loaded.
  81324. * The event data is the index of the loaded LOD starting from zero.
  81325. * Dispose the loader to cancel the loading of the next level of LODs.
  81326. */
  81327. onNodeLODsLoadedObservable: Observable<number>;
  81328. /**
  81329. * Observable raised when all material LODs of one level are loaded.
  81330. * The event data is the index of the loaded LOD starting from zero.
  81331. * Dispose the loader to cancel the loading of the next level of LODs.
  81332. */
  81333. onMaterialLODsLoadedObservable: Observable<number>;
  81334. private _loader;
  81335. private _bufferLODs;
  81336. private _nodeIndexLOD;
  81337. private _nodeSignalLODs;
  81338. private _nodePromiseLODs;
  81339. private _nodeBufferLODs;
  81340. private _materialIndexLOD;
  81341. private _materialSignalLODs;
  81342. private _materialPromiseLODs;
  81343. private _materialBufferLODs;
  81344. /** @hidden */
  81345. constructor(loader: GLTFLoader);
  81346. /** @hidden */
  81347. dispose(): void;
  81348. /** @hidden */
  81349. onReady(): void;
  81350. /** @hidden */
  81351. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81352. /** @hidden */
  81353. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81354. /** @hidden */
  81355. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81356. /** @hidden */
  81357. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81358. /** @hidden */
  81359. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81360. private _loadBufferLOD;
  81361. /**
  81362. * Gets an array of LOD properties from lowest to highest.
  81363. */
  81364. private _getLODs;
  81365. private _disposeTransformNode;
  81366. private _disposeMaterials;
  81367. }
  81368. }
  81369. declare module BABYLON.GLTF2.Loader.Extensions {
  81370. /** @hidden */
  81371. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81372. readonly name: string;
  81373. enabled: boolean;
  81374. private _loader;
  81375. constructor(loader: GLTFLoader);
  81376. dispose(): void;
  81377. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81378. }
  81379. }
  81380. declare module BABYLON.GLTF2.Loader.Extensions {
  81381. /** @hidden */
  81382. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81383. readonly name: string;
  81384. enabled: boolean;
  81385. private _loader;
  81386. constructor(loader: GLTFLoader);
  81387. dispose(): void;
  81388. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81389. }
  81390. }
  81391. declare module BABYLON.GLTF2.Loader.Extensions {
  81392. /**
  81393. * Store glTF extras (if present) in BJS objects' metadata
  81394. */
  81395. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81396. /**
  81397. * The name of this extension.
  81398. */
  81399. readonly name: string;
  81400. /**
  81401. * Defines whether this extension is enabled.
  81402. */
  81403. enabled: boolean;
  81404. private _loader;
  81405. private _assignExtras;
  81406. /** @hidden */
  81407. constructor(loader: GLTFLoader);
  81408. /** @hidden */
  81409. dispose(): void;
  81410. /** @hidden */
  81411. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81412. /** @hidden */
  81413. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81414. /** @hidden */
  81415. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81416. }
  81417. }
  81418. declare module BABYLON {
  81419. /**
  81420. * Class reading and parsing the MTL file bundled with the obj file.
  81421. */
  81422. export class MTLFileLoader {
  81423. /**
  81424. * Invert Y-Axis of referenced textures on load
  81425. */
  81426. static INVERT_TEXTURE_Y: boolean;
  81427. /**
  81428. * All material loaded from the mtl will be set here
  81429. */
  81430. materials: StandardMaterial[];
  81431. /**
  81432. * This function will read the mtl file and create each material described inside
  81433. * This function could be improve by adding :
  81434. * -some component missing (Ni, Tf...)
  81435. * -including the specific options available
  81436. *
  81437. * @param scene defines the scene the material will be created in
  81438. * @param data defines the mtl data to parse
  81439. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81440. * @param forAssetContainer defines if the material should be registered in the scene
  81441. */
  81442. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81443. /**
  81444. * Gets the texture for the material.
  81445. *
  81446. * If the material is imported from input file,
  81447. * We sanitize the url to ensure it takes the textre from aside the material.
  81448. *
  81449. * @param rootUrl The root url to load from
  81450. * @param value The value stored in the mtl
  81451. * @return The Texture
  81452. */
  81453. private static _getTexture;
  81454. }
  81455. }
  81456. declare module BABYLON {
  81457. /**
  81458. * Options for loading OBJ/MTL files
  81459. */
  81460. type MeshLoadOptions = {
  81461. /**
  81462. * Defines if UVs are optimized by default during load.
  81463. */
  81464. OptimizeWithUV: boolean;
  81465. /**
  81466. * Defines custom scaling of UV coordinates of loaded meshes.
  81467. */
  81468. UVScaling: Vector2;
  81469. /**
  81470. * Invert model on y-axis (does a model scaling inversion)
  81471. */
  81472. InvertY: boolean;
  81473. /**
  81474. * Invert Y-Axis of referenced textures on load
  81475. */
  81476. InvertTextureY: boolean;
  81477. /**
  81478. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81479. */
  81480. ImportVertexColors: boolean;
  81481. /**
  81482. * Compute the normals for the model, even if normals are present in the file.
  81483. */
  81484. ComputeNormals: boolean;
  81485. /**
  81486. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81487. */
  81488. SkipMaterials: boolean;
  81489. /**
  81490. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81491. */
  81492. MaterialLoadingFailsSilently: boolean;
  81493. };
  81494. /**
  81495. * OBJ file type loader.
  81496. * This is a babylon scene loader plugin.
  81497. */
  81498. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81499. /**
  81500. * Defines if UVs are optimized by default during load.
  81501. */
  81502. static OPTIMIZE_WITH_UV: boolean;
  81503. /**
  81504. * Invert model on y-axis (does a model scaling inversion)
  81505. */
  81506. static INVERT_Y: boolean;
  81507. /**
  81508. * Invert Y-Axis of referenced textures on load
  81509. */
  81510. static get INVERT_TEXTURE_Y(): boolean;
  81511. static set INVERT_TEXTURE_Y(value: boolean);
  81512. /**
  81513. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81514. */
  81515. static IMPORT_VERTEX_COLORS: boolean;
  81516. /**
  81517. * Compute the normals for the model, even if normals are present in the file.
  81518. */
  81519. static COMPUTE_NORMALS: boolean;
  81520. /**
  81521. * Defines custom scaling of UV coordinates of loaded meshes.
  81522. */
  81523. static UV_SCALING: Vector2;
  81524. /**
  81525. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81526. */
  81527. static SKIP_MATERIALS: boolean;
  81528. /**
  81529. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81530. *
  81531. * Defaults to true for backwards compatibility.
  81532. */
  81533. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81534. /**
  81535. * Defines the name of the plugin.
  81536. */
  81537. name: string;
  81538. /**
  81539. * Defines the extension the plugin is able to load.
  81540. */
  81541. extensions: string;
  81542. /** @hidden */
  81543. obj: RegExp;
  81544. /** @hidden */
  81545. group: RegExp;
  81546. /** @hidden */
  81547. mtllib: RegExp;
  81548. /** @hidden */
  81549. usemtl: RegExp;
  81550. /** @hidden */
  81551. smooth: RegExp;
  81552. /** @hidden */
  81553. vertexPattern: RegExp;
  81554. /** @hidden */
  81555. normalPattern: RegExp;
  81556. /** @hidden */
  81557. uvPattern: RegExp;
  81558. /** @hidden */
  81559. facePattern1: RegExp;
  81560. /** @hidden */
  81561. facePattern2: RegExp;
  81562. /** @hidden */
  81563. facePattern3: RegExp;
  81564. /** @hidden */
  81565. facePattern4: RegExp;
  81566. /** @hidden */
  81567. facePattern5: RegExp;
  81568. private _forAssetContainer;
  81569. private _meshLoadOptions;
  81570. /**
  81571. * Creates loader for .OBJ files
  81572. *
  81573. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81574. */
  81575. constructor(meshLoadOptions?: MeshLoadOptions);
  81576. private static get currentMeshLoadOptions();
  81577. /**
  81578. * Calls synchronously the MTL file attached to this obj.
  81579. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81580. * Without this function materials are not displayed in the first frame (but displayed after).
  81581. * In consequence it is impossible to get material information in your HTML file
  81582. *
  81583. * @param url The URL of the MTL file
  81584. * @param rootUrl
  81585. * @param onSuccess Callback function to be called when the MTL file is loaded
  81586. * @private
  81587. */
  81588. private _loadMTL;
  81589. /**
  81590. * Instantiates a OBJ file loader plugin.
  81591. * @returns the created plugin
  81592. */
  81593. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81594. /**
  81595. * If the data string can be loaded directly.
  81596. *
  81597. * @param data string containing the file data
  81598. * @returns if the data can be loaded directly
  81599. */
  81600. canDirectLoad(data: string): boolean;
  81601. /**
  81602. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81603. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81604. * @param scene the scene the meshes should be added to
  81605. * @param data the OBJ data to load
  81606. * @param rootUrl root url to load from
  81607. * @param onProgress event that fires when loading progress has occured
  81608. * @param fileName Defines the name of the file to load
  81609. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81610. */
  81611. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81612. meshes: AbstractMesh[];
  81613. particleSystems: IParticleSystem[];
  81614. skeletons: Skeleton[];
  81615. animationGroups: AnimationGroup[];
  81616. }>;
  81617. /**
  81618. * Imports all objects from the loaded OBJ data and adds them to the scene
  81619. * @param scene the scene the objects should be added to
  81620. * @param data the OBJ data to load
  81621. * @param rootUrl root url to load from
  81622. * @param onProgress event that fires when loading progress has occured
  81623. * @param fileName Defines the name of the file to load
  81624. * @returns a promise which completes when objects have been loaded to the scene
  81625. */
  81626. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81627. /**
  81628. * Load into an asset container.
  81629. * @param scene The scene to load into
  81630. * @param data The data to import
  81631. * @param rootUrl The root url for scene and resources
  81632. * @param onProgress The callback when the load progresses
  81633. * @param fileName Defines the name of the file to load
  81634. * @returns The loaded asset container
  81635. */
  81636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81637. /**
  81638. * Read the OBJ file and create an Array of meshes.
  81639. * Each mesh contains all information given by the OBJ and the MTL file.
  81640. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81641. *
  81642. * @param meshesNames
  81643. * @param scene Scene The scene where are displayed the data
  81644. * @param data String The content of the obj file
  81645. * @param rootUrl String The path to the folder
  81646. * @returns Array<AbstractMesh>
  81647. * @private
  81648. */
  81649. private _parseSolid;
  81650. }
  81651. }
  81652. declare module BABYLON {
  81653. /**
  81654. * STL file type loader.
  81655. * This is a babylon scene loader plugin.
  81656. */
  81657. export class STLFileLoader implements ISceneLoaderPlugin {
  81658. /** @hidden */
  81659. solidPattern: RegExp;
  81660. /** @hidden */
  81661. facetsPattern: RegExp;
  81662. /** @hidden */
  81663. normalPattern: RegExp;
  81664. /** @hidden */
  81665. vertexPattern: RegExp;
  81666. /**
  81667. * Defines the name of the plugin.
  81668. */
  81669. name: string;
  81670. /**
  81671. * Defines the extensions the stl loader is able to load.
  81672. * force data to come in as an ArrayBuffer
  81673. * we'll convert to string if it looks like it's an ASCII .stl
  81674. */
  81675. extensions: ISceneLoaderPluginExtensions;
  81676. /**
  81677. * Import meshes into a scene.
  81678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81679. * @param scene The scene to import into
  81680. * @param data The data to import
  81681. * @param rootUrl The root url for scene and resources
  81682. * @param meshes The meshes array to import into
  81683. * @param particleSystems The particle systems array to import into
  81684. * @param skeletons The skeletons array to import into
  81685. * @param onError The callback when import fails
  81686. * @returns True if successful or false otherwise
  81687. */
  81688. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81689. /**
  81690. * Load into a scene.
  81691. * @param scene The scene to load into
  81692. * @param data The data to import
  81693. * @param rootUrl The root url for scene and resources
  81694. * @param onError The callback when import fails
  81695. * @returns true if successful or false otherwise
  81696. */
  81697. load(scene: Scene, data: any, rootUrl: string): boolean;
  81698. /**
  81699. * Load into an asset container.
  81700. * @param scene The scene to load into
  81701. * @param data The data to import
  81702. * @param rootUrl The root url for scene and resources
  81703. * @param onError The callback when import fails
  81704. * @returns The loaded asset container
  81705. */
  81706. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81707. private _isBinary;
  81708. private _parseBinary;
  81709. private _parseASCII;
  81710. }
  81711. }
  81712. declare module BABYLON {
  81713. /**
  81714. * Class for generating OBJ data from a Babylon scene.
  81715. */
  81716. export class OBJExport {
  81717. /**
  81718. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81719. * @param mesh defines the list of meshes to serialize
  81720. * @param materials defines if materials should be exported
  81721. * @param matlibname defines the name of the associated mtl file
  81722. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81723. * @returns the OBJ content
  81724. */
  81725. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81726. /**
  81727. * Exports the material(s) of a mesh in .MTL file format (text)
  81728. * @param mesh defines the mesh to extract the material from
  81729. * @returns the mtl content
  81730. */
  81731. static MTL(mesh: Mesh): string;
  81732. }
  81733. }
  81734. declare module BABYLON {
  81735. /** @hidden */
  81736. export var __IGLTFExporterExtension: number;
  81737. /**
  81738. * Interface for extending the exporter
  81739. * @hidden
  81740. */
  81741. export interface IGLTFExporterExtension {
  81742. /**
  81743. * The name of this extension
  81744. */
  81745. readonly name: string;
  81746. /**
  81747. * Defines whether this extension is enabled
  81748. */
  81749. enabled: boolean;
  81750. /**
  81751. * Defines whether this extension is required
  81752. */
  81753. required: boolean;
  81754. }
  81755. }
  81756. declare module BABYLON.GLTF2.Exporter {
  81757. /** @hidden */
  81758. export var __IGLTFExporterExtensionV2: number;
  81759. /**
  81760. * Interface for a glTF exporter extension
  81761. * @hidden
  81762. */
  81763. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81764. /**
  81765. * Define this method to modify the default behavior before exporting a texture
  81766. * @param context The context when loading the asset
  81767. * @param babylonTexture The Babylon.js texture
  81768. * @param mimeType The mime-type of the generated image
  81769. * @returns A promise that resolves with the exported texture
  81770. */
  81771. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81772. /**
  81773. * Define this method to get notified when a texture info is created
  81774. * @param context The context when loading the asset
  81775. * @param textureInfo The glTF texture info
  81776. * @param babylonTexture The Babylon.js texture
  81777. */
  81778. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81779. /**
  81780. * Define this method to modify the default behavior when exporting texture info
  81781. * @param context The context when loading the asset
  81782. * @param meshPrimitive glTF mesh primitive
  81783. * @param babylonSubMesh Babylon submesh
  81784. * @param binaryWriter glTF serializer binary writer instance
  81785. * @returns nullable IMeshPrimitive promise
  81786. */
  81787. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81788. /**
  81789. * Define this method to modify the default behavior when exporting a node
  81790. * @param context The context when exporting the node
  81791. * @param node glTF node
  81792. * @param babylonNode BabylonJS node
  81793. * @returns nullable INode promise
  81794. */
  81795. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81796. [key: number]: number;
  81797. }): Promise<Nullable<INode>>;
  81798. /**
  81799. * Define this method to modify the default behavior when exporting a material
  81800. * @param material glTF material
  81801. * @param babylonMaterial BabylonJS material
  81802. * @returns nullable IMaterial promise
  81803. */
  81804. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81805. /**
  81806. * Define this method to return additional textures to export from a material
  81807. * @param material glTF material
  81808. * @param babylonMaterial BabylonJS material
  81809. * @returns List of textures
  81810. */
  81811. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81812. /** Gets a boolean indicating that this extension was used */
  81813. wasUsed: boolean;
  81814. /** Gets a boolean indicating that this extension is required for the file to work */
  81815. required: boolean;
  81816. /**
  81817. * Called after the exporter state changes to EXPORTING
  81818. */
  81819. onExporting?(): void;
  81820. }
  81821. }
  81822. declare module BABYLON.GLTF2.Exporter {
  81823. /**
  81824. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81825. * @hidden
  81826. */
  81827. export class _GLTFMaterialExporter {
  81828. /**
  81829. * Represents the dielectric specular values for R, G and B
  81830. */
  81831. private static readonly _DielectricSpecular;
  81832. /**
  81833. * Allows the maximum specular power to be defined for material calculations
  81834. */
  81835. private static readonly _MaxSpecularPower;
  81836. /**
  81837. * Mapping to store textures
  81838. */
  81839. private _textureMap;
  81840. /**
  81841. * Numeric tolerance value
  81842. */
  81843. private static readonly _Epsilon;
  81844. /**
  81845. * Reference to the glTF Exporter
  81846. */
  81847. private _exporter;
  81848. constructor(exporter: _Exporter);
  81849. /**
  81850. * Specifies if two colors are approximately equal in value
  81851. * @param color1 first color to compare to
  81852. * @param color2 second color to compare to
  81853. * @param epsilon threshold value
  81854. */
  81855. private static FuzzyEquals;
  81856. /**
  81857. * Gets the materials from a Babylon scene and converts them to glTF materials
  81858. * @param scene babylonjs scene
  81859. * @param mimeType texture mime type
  81860. * @param images array of images
  81861. * @param textures array of textures
  81862. * @param materials array of materials
  81863. * @param imageData mapping of texture names to base64 textures
  81864. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81865. */
  81866. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81867. /**
  81868. * Makes a copy of the glTF material without the texture parameters
  81869. * @param originalMaterial original glTF material
  81870. * @returns glTF material without texture parameters
  81871. */
  81872. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81873. /**
  81874. * Specifies if the material has any texture parameters present
  81875. * @param material glTF Material
  81876. * @returns boolean specifying if texture parameters are present
  81877. */
  81878. _hasTexturesPresent(material: IMaterial): boolean;
  81879. /**
  81880. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81881. * @param babylonStandardMaterial
  81882. * @returns glTF Metallic Roughness Material representation
  81883. */
  81884. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81885. /**
  81886. * Computes the metallic factor
  81887. * @param diffuse diffused value
  81888. * @param specular specular value
  81889. * @param oneMinusSpecularStrength one minus the specular strength
  81890. * @returns metallic value
  81891. */
  81892. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81893. /**
  81894. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81895. * @param glTFMaterial glTF material
  81896. * @param babylonMaterial Babylon material
  81897. */
  81898. private static _SetAlphaMode;
  81899. /**
  81900. * Converts a Babylon Standard Material to a glTF Material
  81901. * @param babylonStandardMaterial BJS Standard Material
  81902. * @param mimeType mime type to use for the textures
  81903. * @param images array of glTF image interfaces
  81904. * @param textures array of glTF texture interfaces
  81905. * @param materials array of glTF material interfaces
  81906. * @param imageData map of image file name to data
  81907. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81908. */
  81909. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81910. private _finishMaterial;
  81911. /**
  81912. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81913. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81914. * @param mimeType mime type to use for the textures
  81915. * @param images array of glTF image interfaces
  81916. * @param textures array of glTF texture interfaces
  81917. * @param materials array of glTF material interfaces
  81918. * @param imageData map of image file name to data
  81919. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81920. */
  81921. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81922. /**
  81923. * Converts an image typed array buffer to a base64 image
  81924. * @param buffer typed array buffer
  81925. * @param width width of the image
  81926. * @param height height of the image
  81927. * @param mimeType mimetype of the image
  81928. * @returns base64 image string
  81929. */
  81930. private _createBase64FromCanvasAsync;
  81931. /**
  81932. * Generates a white texture based on the specified width and height
  81933. * @param width width of the texture in pixels
  81934. * @param height height of the texture in pixels
  81935. * @param scene babylonjs scene
  81936. * @returns white texture
  81937. */
  81938. private _createWhiteTexture;
  81939. /**
  81940. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  81941. * @param texture1 first texture to resize
  81942. * @param texture2 second texture to resize
  81943. * @param scene babylonjs scene
  81944. * @returns resized textures or null
  81945. */
  81946. private _resizeTexturesToSameDimensions;
  81947. /**
  81948. * Converts an array of pixels to a Float32Array
  81949. * Throws an error if the pixel format is not supported
  81950. * @param pixels - array buffer containing pixel values
  81951. * @returns Float32 of pixels
  81952. */
  81953. private _convertPixelArrayToFloat32;
  81954. /**
  81955. * Convert Specular Glossiness Textures to Metallic Roughness
  81956. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81957. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81958. * @param diffuseTexture texture used to store diffuse information
  81959. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81960. * @param factors specular glossiness material factors
  81961. * @param mimeType the mime type to use for the texture
  81962. * @returns pbr metallic roughness interface or null
  81963. */
  81964. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81965. /**
  81966. * Converts specular glossiness material properties to metallic roughness
  81967. * @param specularGlossiness interface with specular glossiness material properties
  81968. * @returns interface with metallic roughness material properties
  81969. */
  81970. private _convertSpecularGlossinessToMetallicRoughness;
  81971. /**
  81972. * Calculates the surface reflectance, independent of lighting conditions
  81973. * @param color Color source to calculate brightness from
  81974. * @returns number representing the perceived brightness, or zero if color is undefined
  81975. */
  81976. private _getPerceivedBrightness;
  81977. /**
  81978. * Returns the maximum color component value
  81979. * @param color
  81980. * @returns maximum color component value, or zero if color is null or undefined
  81981. */
  81982. private _getMaxComponent;
  81983. /**
  81984. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81985. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81986. * @param mimeType mime type to use for the textures
  81987. * @param images array of glTF image interfaces
  81988. * @param textures array of glTF texture interfaces
  81989. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81990. * @param imageData map of image file name to data
  81991. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81992. * @returns glTF PBR Metallic Roughness factors
  81993. */
  81994. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81995. private _getGLTFTextureSampler;
  81996. private _getGLTFTextureWrapMode;
  81997. private _getGLTFTextureWrapModesSampler;
  81998. /**
  81999. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82000. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82001. * @param mimeType mime type to use for the textures
  82002. * @param images array of glTF image interfaces
  82003. * @param textures array of glTF texture interfaces
  82004. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82005. * @param imageData map of image file name to data
  82006. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82007. * @returns glTF PBR Metallic Roughness factors
  82008. */
  82009. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82010. /**
  82011. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82012. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82013. * @param mimeType mime type to use for the textures
  82014. * @param images array of glTF image interfaces
  82015. * @param textures array of glTF texture interfaces
  82016. * @param materials array of glTF material interfaces
  82017. * @param imageData map of image file name to data
  82018. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82019. */
  82020. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82021. private setMetallicRoughnessPbrMaterial;
  82022. private getPixelsFromTexture;
  82023. /**
  82024. * Extracts a texture from a Babylon texture into file data and glTF data
  82025. * @param babylonTexture Babylon texture to extract
  82026. * @param mimeType Mime Type of the babylonTexture
  82027. * @return glTF texture info, or null if the texture format is not supported
  82028. */
  82029. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82030. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82031. /**
  82032. * Builds a texture from base64 string
  82033. * @param base64Texture base64 texture string
  82034. * @param baseTextureName Name to use for the texture
  82035. * @param mimeType image mime type for the texture
  82036. * @param images array of images
  82037. * @param textures array of textures
  82038. * @param imageData map of image data
  82039. * @returns glTF texture info, or null if the texture format is not supported
  82040. */
  82041. private _getTextureInfoFromBase64;
  82042. }
  82043. }
  82044. declare module BABYLON {
  82045. /**
  82046. * Class for holding and downloading glTF file data
  82047. */
  82048. export class GLTFData {
  82049. /**
  82050. * Object which contains the file name as the key and its data as the value
  82051. */
  82052. glTFFiles: {
  82053. [fileName: string]: string | Blob;
  82054. };
  82055. /**
  82056. * Initializes the glTF file object
  82057. */
  82058. constructor();
  82059. /**
  82060. * Downloads the glTF data as files based on their names and data
  82061. */
  82062. downloadFiles(): void;
  82063. }
  82064. }
  82065. declare module BABYLON {
  82066. /**
  82067. * Holds a collection of exporter options and parameters
  82068. */
  82069. export interface IExportOptions {
  82070. /**
  82071. * Function which indicates whether a babylon node should be exported or not
  82072. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82073. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82074. */
  82075. shouldExportNode?(node: Node): boolean;
  82076. /**
  82077. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82078. * @param metadata source metadata to read from
  82079. * @returns the data to store to glTF node extras
  82080. */
  82081. metadataSelector?(metadata: any): any;
  82082. /**
  82083. * The sample rate to bake animation curves
  82084. */
  82085. animationSampleRate?: number;
  82086. /**
  82087. * Begin serialization without waiting for the scene to be ready
  82088. */
  82089. exportWithoutWaitingForScene?: boolean;
  82090. /**
  82091. * Indicates if coordinate system swapping root nodes should be included in export
  82092. */
  82093. includeCoordinateSystemConversionNodes?: boolean;
  82094. }
  82095. /**
  82096. * Class for generating glTF data from a Babylon scene.
  82097. */
  82098. export class GLTF2Export {
  82099. /**
  82100. * Exports the geometry of the scene to .gltf file format asynchronously
  82101. * @param scene Babylon scene with scene hierarchy information
  82102. * @param filePrefix File prefix to use when generating the glTF file
  82103. * @param options Exporter options
  82104. * @returns Returns an object with a .gltf file and associates texture names
  82105. * as keys and their data and paths as values
  82106. */
  82107. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82108. private static _PreExportAsync;
  82109. private static _PostExportAsync;
  82110. /**
  82111. * Exports the geometry of the scene to .glb file format asychronously
  82112. * @param scene Babylon scene with scene hierarchy information
  82113. * @param filePrefix File prefix to use when generating glb file
  82114. * @param options Exporter options
  82115. * @returns Returns an object with a .glb filename as key and data as value
  82116. */
  82117. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82118. }
  82119. }
  82120. declare module BABYLON.GLTF2.Exporter {
  82121. /**
  82122. * @hidden
  82123. */
  82124. export class _GLTFUtilities {
  82125. /**
  82126. * Creates a buffer view based on the supplied arguments
  82127. * @param bufferIndex index value of the specified buffer
  82128. * @param byteOffset byte offset value
  82129. * @param byteLength byte length of the bufferView
  82130. * @param byteStride byte distance between conequential elements
  82131. * @param name name of the buffer view
  82132. * @returns bufferView for glTF
  82133. */
  82134. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82135. /**
  82136. * Creates an accessor based on the supplied arguments
  82137. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82138. * @param name The name of the accessor
  82139. * @param type The type of the accessor
  82140. * @param componentType The datatype of components in the attribute
  82141. * @param count The number of attributes referenced by this accessor
  82142. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82143. * @param min Minimum value of each component in this attribute
  82144. * @param max Maximum value of each component in this attribute
  82145. * @returns accessor for glTF
  82146. */
  82147. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82148. /**
  82149. * Calculates the minimum and maximum values of an array of position floats
  82150. * @param positions Positions array of a mesh
  82151. * @param vertexStart Starting vertex offset to calculate min and max values
  82152. * @param vertexCount Number of vertices to check for min and max values
  82153. * @returns min number array and max number array
  82154. */
  82155. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82156. min: number[];
  82157. max: number[];
  82158. };
  82159. /**
  82160. * Converts a new right-handed Vector3
  82161. * @param vector vector3 array
  82162. * @returns right-handed Vector3
  82163. */
  82164. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82165. /**
  82166. * Converts a Vector3 to right-handed
  82167. * @param vector Vector3 to convert to right-handed
  82168. */
  82169. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82170. /**
  82171. * Converts a three element number array to right-handed
  82172. * @param vector number array to convert to right-handed
  82173. */
  82174. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82175. /**
  82176. * Converts a new right-handed Vector3
  82177. * @param vector vector3 array
  82178. * @returns right-handed Vector3
  82179. */
  82180. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82181. /**
  82182. * Converts a Vector3 to right-handed
  82183. * @param vector Vector3 to convert to right-handed
  82184. */
  82185. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82186. /**
  82187. * Converts a three element number array to right-handed
  82188. * @param vector number array to convert to right-handed
  82189. */
  82190. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82191. /**
  82192. * Converts a Vector4 to right-handed
  82193. * @param vector Vector4 to convert to right-handed
  82194. */
  82195. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82196. /**
  82197. * Converts a Vector4 to right-handed
  82198. * @param vector Vector4 to convert to right-handed
  82199. */
  82200. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82201. /**
  82202. * Converts a Quaternion to right-handed
  82203. * @param quaternion Source quaternion to convert to right-handed
  82204. */
  82205. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82206. /**
  82207. * Converts a Quaternion to right-handed
  82208. * @param quaternion Source quaternion to convert to right-handed
  82209. */
  82210. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82211. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82212. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82213. }
  82214. }
  82215. declare module BABYLON.GLTF2.Exporter {
  82216. /**
  82217. * Converts Babylon Scene into glTF 2.0.
  82218. * @hidden
  82219. */
  82220. export class _Exporter {
  82221. /**
  82222. * Stores the glTF to export
  82223. */
  82224. _glTF: IGLTF;
  82225. /**
  82226. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82227. */
  82228. _bufferViews: IBufferView[];
  82229. /**
  82230. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82231. */
  82232. _accessors: IAccessor[];
  82233. /**
  82234. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82235. */
  82236. _nodes: INode[];
  82237. /**
  82238. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82239. */
  82240. private _scenes;
  82241. /**
  82242. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82243. */
  82244. private _meshes;
  82245. /**
  82246. * Stores all the generated material information, which represents the appearance of each primitive
  82247. */
  82248. _materials: IMaterial[];
  82249. _materialMap: {
  82250. [materialID: number]: number;
  82251. };
  82252. /**
  82253. * Stores all the generated texture information, which is referenced by glTF materials
  82254. */
  82255. _textures: ITexture[];
  82256. /**
  82257. * Stores all the generated image information, which is referenced by glTF textures
  82258. */
  82259. _images: IImage[];
  82260. /**
  82261. * Stores all the texture samplers
  82262. */
  82263. _samplers: ISampler[];
  82264. /**
  82265. * Stores all the generated glTF skins
  82266. */
  82267. _skins: ISkin[];
  82268. /**
  82269. * Stores all the generated animation samplers, which is referenced by glTF animations
  82270. */
  82271. /**
  82272. * Stores the animations for glTF models
  82273. */
  82274. private _animations;
  82275. /**
  82276. * Stores the total amount of bytes stored in the glTF buffer
  82277. */
  82278. private _totalByteLength;
  82279. /**
  82280. * Stores a reference to the Babylon scene containing the source geometry and material information
  82281. */
  82282. _babylonScene: Scene;
  82283. /**
  82284. * Stores a map of the image data, where the key is the file name and the value
  82285. * is the image data
  82286. */
  82287. _imageData: {
  82288. [fileName: string]: {
  82289. data: Uint8Array;
  82290. mimeType: ImageMimeType;
  82291. };
  82292. };
  82293. /**
  82294. * Stores a map of the unique id of a node to its index in the node array
  82295. */
  82296. _nodeMap: {
  82297. [key: number]: number;
  82298. };
  82299. /**
  82300. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82301. */
  82302. _convertToRightHandedSystem: boolean;
  82303. /**
  82304. * Specifies if a Babylon node should be converted to right-handed on export
  82305. */
  82306. _convertToRightHandedSystemMap: {
  82307. [nodeId: number]: boolean;
  82308. };
  82309. _includeCoordinateSystemConversionNodes: boolean;
  82310. /**
  82311. * Baked animation sample rate
  82312. */
  82313. private _animationSampleRate;
  82314. private _options;
  82315. private _localEngine;
  82316. _glTFMaterialExporter: _GLTFMaterialExporter;
  82317. private _extensions;
  82318. private static _ExtensionNames;
  82319. private static _ExtensionFactories;
  82320. private _applyExtension;
  82321. private _applyExtensions;
  82322. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82323. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82324. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82325. [key: number]: number;
  82326. }): Promise<Nullable<INode>>;
  82327. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82328. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82329. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82330. private _forEachExtensions;
  82331. private _extensionsOnExporting;
  82332. /**
  82333. * Load glTF serializer extensions
  82334. */
  82335. private _loadExtensions;
  82336. /**
  82337. * Creates a glTF Exporter instance, which can accept optional exporter options
  82338. * @param babylonScene Babylon scene object
  82339. * @param options Options to modify the behavior of the exporter
  82340. */
  82341. constructor(babylonScene: Scene, options?: IExportOptions);
  82342. dispose(): void;
  82343. /**
  82344. * Registers a glTF exporter extension
  82345. * @param name Name of the extension to export
  82346. * @param factory The factory function that creates the exporter extension
  82347. */
  82348. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82349. /**
  82350. * Un-registers an exporter extension
  82351. * @param name The name fo the exporter extension
  82352. * @returns A boolean indicating whether the extension has been un-registered
  82353. */
  82354. static UnregisterExtension(name: string): boolean;
  82355. /**
  82356. * Lazy load a local engine
  82357. */
  82358. _getLocalEngine(): Engine;
  82359. private reorderIndicesBasedOnPrimitiveMode;
  82360. /**
  82361. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82362. * clock-wise during export to glTF
  82363. * @param submesh BabylonJS submesh
  82364. * @param primitiveMode Primitive mode of the mesh
  82365. * @param sideOrientation the winding order of the submesh
  82366. * @param vertexBufferKind The type of vertex attribute
  82367. * @param meshAttributeArray The vertex attribute data
  82368. * @param byteOffset The offset to the binary data
  82369. * @param binaryWriter The binary data for the glTF file
  82370. * @param convertToRightHandedSystem Converts the values to right-handed
  82371. */
  82372. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82373. /**
  82374. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82375. * clock-wise during export to glTF
  82376. * @param submesh BabylonJS submesh
  82377. * @param primitiveMode Primitive mode of the mesh
  82378. * @param sideOrientation the winding order of the submesh
  82379. * @param vertexBufferKind The type of vertex attribute
  82380. * @param meshAttributeArray The vertex attribute data
  82381. * @param byteOffset The offset to the binary data
  82382. * @param binaryWriter The binary data for the glTF file
  82383. * @param convertToRightHandedSystem Converts the values to right-handed
  82384. */
  82385. private reorderTriangleFillMode;
  82386. /**
  82387. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82388. * clock-wise during export to glTF
  82389. * @param submesh BabylonJS submesh
  82390. * @param primitiveMode Primitive mode of the mesh
  82391. * @param sideOrientation the winding order of the submesh
  82392. * @param vertexBufferKind The type of vertex attribute
  82393. * @param meshAttributeArray The vertex attribute data
  82394. * @param byteOffset The offset to the binary data
  82395. * @param binaryWriter The binary data for the glTF file
  82396. * @param convertToRightHandedSystem Converts the values to right-handed
  82397. */
  82398. private reorderTriangleStripDrawMode;
  82399. /**
  82400. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82401. * clock-wise during export to glTF
  82402. * @param submesh BabylonJS submesh
  82403. * @param primitiveMode Primitive mode of the mesh
  82404. * @param sideOrientation the winding order of the submesh
  82405. * @param vertexBufferKind The type of vertex attribute
  82406. * @param meshAttributeArray The vertex attribute data
  82407. * @param byteOffset The offset to the binary data
  82408. * @param binaryWriter The binary data for the glTF file
  82409. * @param convertToRightHandedSystem Converts the values to right-handed
  82410. */
  82411. private reorderTriangleFanMode;
  82412. /**
  82413. * Writes the vertex attribute data to binary
  82414. * @param vertices The vertices to write to the binary writer
  82415. * @param byteOffset The offset into the binary writer to overwrite binary data
  82416. * @param vertexAttributeKind The vertex attribute type
  82417. * @param meshAttributeArray The vertex attribute data
  82418. * @param binaryWriter The writer containing the binary data
  82419. * @param convertToRightHandedSystem Converts the values to right-handed
  82420. */
  82421. private writeVertexAttributeData;
  82422. /**
  82423. * Writes mesh attribute data to a data buffer
  82424. * Returns the bytelength of the data
  82425. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82426. * @param meshAttributeArray Array containing the attribute data
  82427. * @param byteStride Specifies the space between data
  82428. * @param binaryWriter The buffer to write the binary data to
  82429. * @param convertToRightHandedSystem Converts the values to right-handed
  82430. */
  82431. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82432. /**
  82433. * Generates glTF json data
  82434. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82435. * @param glTFPrefix Text to use when prefixing a glTF file
  82436. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82437. * @returns json data as string
  82438. */
  82439. private generateJSON;
  82440. /**
  82441. * Generates data for .gltf and .bin files based on the glTF prefix string
  82442. * @param glTFPrefix Text to use when prefixing a glTF file
  82443. * @param dispose Dispose the exporter
  82444. * @returns GLTFData with glTF file data
  82445. */
  82446. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82447. /**
  82448. * Creates a binary buffer for glTF
  82449. * @returns array buffer for binary data
  82450. */
  82451. private _generateBinaryAsync;
  82452. /**
  82453. * Pads the number to a multiple of 4
  82454. * @param num number to pad
  82455. * @returns padded number
  82456. */
  82457. private _getPadding;
  82458. /**
  82459. * @hidden
  82460. */
  82461. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82462. /**
  82463. * Sets the TRS for each node
  82464. * @param node glTF Node for storing the transformation data
  82465. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82466. * @param convertToRightHandedSystem Converts the values to right-handed
  82467. */
  82468. private setNodeTransformation;
  82469. private getVertexBufferFromMesh;
  82470. /**
  82471. * Creates a bufferview based on the vertices type for the Babylon mesh
  82472. * @param kind Indicates the type of vertices data
  82473. * @param componentType Indicates the numerical type used to store the data
  82474. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82475. * @param binaryWriter The buffer to write the bufferview data to
  82476. * @param convertToRightHandedSystem Converts the values to right-handed
  82477. */
  82478. private createBufferViewKind;
  82479. /**
  82480. * The primitive mode of the Babylon mesh
  82481. * @param babylonMesh The BabylonJS mesh
  82482. */
  82483. private getMeshPrimitiveMode;
  82484. /**
  82485. * Sets the primitive mode of the glTF mesh primitive
  82486. * @param meshPrimitive glTF mesh primitive
  82487. * @param primitiveMode The primitive mode
  82488. */
  82489. private setPrimitiveMode;
  82490. /**
  82491. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82492. * @param meshPrimitive glTF mesh primitive
  82493. * @param attributeKind vertex attribute
  82494. * @returns boolean specifying if uv coordinates are present
  82495. */
  82496. private setAttributeKind;
  82497. /**
  82498. * Sets data for the primitive attributes of each submesh
  82499. * @param mesh glTF Mesh object to store the primitive attribute information
  82500. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82501. * @param binaryWriter Buffer to write the attribute data to
  82502. * @param convertToRightHandedSystem Converts the values to right-handed
  82503. */
  82504. private setPrimitiveAttributesAsync;
  82505. /**
  82506. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82507. * @param node The node to check
  82508. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82509. */
  82510. private isBabylonCoordinateSystemConvertingNode;
  82511. /**
  82512. * Creates a glTF scene based on the array of meshes
  82513. * Returns the the total byte offset
  82514. * @param babylonScene Babylon scene to get the mesh data from
  82515. * @param binaryWriter Buffer to write binary data to
  82516. */
  82517. private createSceneAsync;
  82518. /**
  82519. * Creates a mapping of Node unique id to node index and handles animations
  82520. * @param babylonScene Babylon Scene
  82521. * @param nodes Babylon transform nodes
  82522. * @param binaryWriter Buffer to write binary data to
  82523. * @returns Node mapping of unique id to index
  82524. */
  82525. private createNodeMapAndAnimationsAsync;
  82526. /**
  82527. * Creates a glTF node from a Babylon mesh
  82528. * @param babylonMesh Source Babylon mesh
  82529. * @param binaryWriter Buffer for storing geometry data
  82530. * @param convertToRightHandedSystem Converts the values to right-handed
  82531. * @param nodeMap Node mapping of unique id to glTF node index
  82532. * @returns glTF node
  82533. */
  82534. private createNodeAsync;
  82535. /**
  82536. * Creates a glTF skin from a Babylon skeleton
  82537. * @param babylonScene Babylon Scene
  82538. * @param nodes Babylon transform nodes
  82539. * @param binaryWriter Buffer to write binary data to
  82540. * @returns Node mapping of unique id to index
  82541. */
  82542. private createSkinsAsync;
  82543. }
  82544. /**
  82545. * @hidden
  82546. *
  82547. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82548. */
  82549. export class _BinaryWriter {
  82550. /**
  82551. * Array buffer which stores all binary data
  82552. */
  82553. private _arrayBuffer;
  82554. /**
  82555. * View of the array buffer
  82556. */
  82557. private _dataView;
  82558. /**
  82559. * byte offset of data in array buffer
  82560. */
  82561. private _byteOffset;
  82562. /**
  82563. * Initialize binary writer with an initial byte length
  82564. * @param byteLength Initial byte length of the array buffer
  82565. */
  82566. constructor(byteLength: number);
  82567. /**
  82568. * Resize the array buffer to the specified byte length
  82569. * @param byteLength
  82570. */
  82571. private resizeBuffer;
  82572. /**
  82573. * Get an array buffer with the length of the byte offset
  82574. * @returns ArrayBuffer resized to the byte offset
  82575. */
  82576. getArrayBuffer(): ArrayBuffer;
  82577. /**
  82578. * Get the byte offset of the array buffer
  82579. * @returns byte offset
  82580. */
  82581. getByteOffset(): number;
  82582. /**
  82583. * Stores an UInt8 in the array buffer
  82584. * @param entry
  82585. * @param byteOffset If defined, specifies where to set the value as an offset.
  82586. */
  82587. setUInt8(entry: number, byteOffset?: number): void;
  82588. /**
  82589. * Stores an UInt16 in the array buffer
  82590. * @param entry
  82591. * @param byteOffset If defined, specifies where to set the value as an offset.
  82592. */
  82593. setUInt16(entry: number, byteOffset?: number): void;
  82594. /**
  82595. * Gets an UInt32 in the array buffer
  82596. * @param entry
  82597. * @param byteOffset If defined, specifies where to set the value as an offset.
  82598. */
  82599. getUInt32(byteOffset: number): number;
  82600. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82601. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82602. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82603. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82604. /**
  82605. * Stores a Float32 in the array buffer
  82606. * @param entry
  82607. */
  82608. setFloat32(entry: number, byteOffset?: number): void;
  82609. /**
  82610. * Stores an UInt32 in the array buffer
  82611. * @param entry
  82612. * @param byteOffset If defined, specifies where to set the value as an offset.
  82613. */
  82614. setUInt32(entry: number, byteOffset?: number): void;
  82615. }
  82616. }
  82617. declare module BABYLON.GLTF2.Exporter {
  82618. /**
  82619. * @hidden
  82620. * Interface to store animation data.
  82621. */
  82622. export interface _IAnimationData {
  82623. /**
  82624. * Keyframe data.
  82625. */
  82626. inputs: number[];
  82627. /**
  82628. * Value data.
  82629. */
  82630. outputs: number[][];
  82631. /**
  82632. * Animation interpolation data.
  82633. */
  82634. samplerInterpolation: AnimationSamplerInterpolation;
  82635. /**
  82636. * Minimum keyframe value.
  82637. */
  82638. inputsMin: number;
  82639. /**
  82640. * Maximum keyframe value.
  82641. */
  82642. inputsMax: number;
  82643. }
  82644. /**
  82645. * @hidden
  82646. */
  82647. export interface _IAnimationInfo {
  82648. /**
  82649. * The target channel for the animation
  82650. */
  82651. animationChannelTargetPath: AnimationChannelTargetPath;
  82652. /**
  82653. * The glTF accessor type for the data.
  82654. */
  82655. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82656. /**
  82657. * Specifies if quaternions should be used.
  82658. */
  82659. useQuaternion: boolean;
  82660. }
  82661. /**
  82662. * @hidden
  82663. * Utility class for generating glTF animation data from BabylonJS.
  82664. */
  82665. export class _GLTFAnimation {
  82666. /**
  82667. * @ignore
  82668. *
  82669. * Creates glTF channel animation from BabylonJS animation.
  82670. * @param babylonTransformNode - BabylonJS mesh.
  82671. * @param animation - animation.
  82672. * @param animationChannelTargetPath - The target animation channel.
  82673. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82674. * @param useQuaternion - Specifies if quaternions are used.
  82675. * @returns nullable IAnimationData
  82676. */
  82677. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82678. private static _DeduceAnimationInfo;
  82679. /**
  82680. * @ignore
  82681. * Create node animations from the transform node animations
  82682. * @param babylonNode
  82683. * @param runtimeGLTFAnimation
  82684. * @param idleGLTFAnimations
  82685. * @param nodeMap
  82686. * @param nodes
  82687. * @param binaryWriter
  82688. * @param bufferViews
  82689. * @param accessors
  82690. * @param convertToRightHandedSystem
  82691. * @param animationSampleRate
  82692. */
  82693. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82694. [key: number]: number;
  82695. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82696. /**
  82697. * @ignore
  82698. * Create node animations from the animation groups
  82699. * @param babylonScene
  82700. * @param glTFAnimations
  82701. * @param nodeMap
  82702. * @param nodes
  82703. * @param binaryWriter
  82704. * @param bufferViews
  82705. * @param accessors
  82706. * @param convertToRightHandedSystemMap
  82707. * @param animationSampleRate
  82708. */
  82709. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82710. [key: number]: number;
  82711. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82712. [nodeId: number]: boolean;
  82713. }, animationSampleRate: number): void;
  82714. private static AddAnimation;
  82715. /**
  82716. * Create a baked animation
  82717. * @param babylonTransformNode BabylonJS mesh
  82718. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82719. * @param animationChannelTargetPath animation target channel
  82720. * @param minFrame minimum animation frame
  82721. * @param maxFrame maximum animation frame
  82722. * @param fps frames per second of the animation
  82723. * @param inputs input key frames of the animation
  82724. * @param outputs output key frame data of the animation
  82725. * @param convertToRightHandedSystem converts the values to right-handed
  82726. * @param useQuaternion specifies if quaternions should be used
  82727. */
  82728. private static _CreateBakedAnimation;
  82729. private static _ConvertFactorToVector3OrQuaternion;
  82730. private static _SetInterpolatedValue;
  82731. /**
  82732. * Creates linear animation from the animation key frames
  82733. * @param babylonTransformNode BabylonJS mesh
  82734. * @param animation BabylonJS animation
  82735. * @param animationChannelTargetPath The target animation channel
  82736. * @param frameDelta The difference between the last and first frame of the animation
  82737. * @param inputs Array to store the key frame times
  82738. * @param outputs Array to store the key frame data
  82739. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82740. * @param useQuaternion Specifies if quaternions are used in the animation
  82741. */
  82742. private static _CreateLinearOrStepAnimation;
  82743. /**
  82744. * Creates cubic spline animation from the animation key frames
  82745. * @param babylonTransformNode BabylonJS mesh
  82746. * @param animation BabylonJS animation
  82747. * @param animationChannelTargetPath The target animation channel
  82748. * @param frameDelta The difference between the last and first frame of the animation
  82749. * @param inputs Array to store the key frame times
  82750. * @param outputs Array to store the key frame data
  82751. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82752. * @param useQuaternion Specifies if quaternions are used in the animation
  82753. */
  82754. private static _CreateCubicSplineAnimation;
  82755. private static _GetBasePositionRotationOrScale;
  82756. /**
  82757. * Adds a key frame value
  82758. * @param keyFrame
  82759. * @param animation
  82760. * @param outputs
  82761. * @param animationChannelTargetPath
  82762. * @param basePositionRotationOrScale
  82763. * @param convertToRightHandedSystem
  82764. * @param useQuaternion
  82765. */
  82766. private static _AddKeyframeValue;
  82767. /**
  82768. * Determine the interpolation based on the key frames
  82769. * @param keyFrames
  82770. * @param animationChannelTargetPath
  82771. * @param useQuaternion
  82772. */
  82773. private static _DeduceInterpolation;
  82774. /**
  82775. * Adds an input tangent or output tangent to the output data
  82776. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82777. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82778. * @param outputs The animation data by keyframe
  82779. * @param animationChannelTargetPath The target animation channel
  82780. * @param interpolation The interpolation type
  82781. * @param keyFrame The key frame with the animation data
  82782. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82783. * @param useQuaternion Specifies if quaternions are used
  82784. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82785. */
  82786. private static AddSplineTangent;
  82787. /**
  82788. * Get the minimum and maximum key frames' frame values
  82789. * @param keyFrames animation key frames
  82790. * @returns the minimum and maximum key frame value
  82791. */
  82792. private static calculateMinMaxKeyFrames;
  82793. }
  82794. }
  82795. declare module BABYLON.GLTF2.Exporter {
  82796. /** @hidden */
  82797. export var textureTransformPixelShader: {
  82798. name: string;
  82799. shader: string;
  82800. };
  82801. }
  82802. declare module BABYLON.GLTF2.Exporter.Extensions {
  82803. /**
  82804. * @hidden
  82805. */
  82806. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82807. private _recordedTextures;
  82808. /** Name of this extension */
  82809. readonly name: string;
  82810. /** Defines whether this extension is enabled */
  82811. enabled: boolean;
  82812. /** Defines whether this extension is required */
  82813. required: boolean;
  82814. /** Reference to the glTF exporter */
  82815. private _wasUsed;
  82816. constructor(exporter: _Exporter);
  82817. dispose(): void;
  82818. /** @hidden */
  82819. get wasUsed(): boolean;
  82820. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82821. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82822. /**
  82823. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82824. * @param babylonTexture
  82825. * @param offset
  82826. * @param rotation
  82827. * @param scale
  82828. * @param scene
  82829. */
  82830. private _textureTransformTextureAsync;
  82831. }
  82832. }
  82833. declare module BABYLON.GLTF2.Exporter.Extensions {
  82834. /**
  82835. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82836. */
  82837. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82838. /** The name of this extension. */
  82839. readonly name: string;
  82840. /** Defines whether this extension is enabled. */
  82841. enabled: boolean;
  82842. /** Defines whether this extension is required */
  82843. required: boolean;
  82844. /** Reference to the glTF exporter */
  82845. private _exporter;
  82846. private _lights;
  82847. /** @hidden */
  82848. constructor(exporter: _Exporter);
  82849. /** @hidden */
  82850. dispose(): void;
  82851. /** @hidden */
  82852. get wasUsed(): boolean;
  82853. /** @hidden */
  82854. onExporting(): void;
  82855. /**
  82856. * Define this method to modify the default behavior when exporting a node
  82857. * @param context The context when exporting the node
  82858. * @param node glTF node
  82859. * @param babylonNode BabylonJS node
  82860. * @param nodeMap Node mapping of unique id to glTF node index
  82861. * @returns nullable INode promise
  82862. */
  82863. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82864. [key: number]: number;
  82865. }): Promise<Nullable<INode>>;
  82866. }
  82867. }
  82868. declare module BABYLON.GLTF2.Exporter.Extensions {
  82869. /**
  82870. * @hidden
  82871. */
  82872. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82873. /** Name of this extension */
  82874. readonly name: string;
  82875. /** Defines whether this extension is enabled */
  82876. enabled: boolean;
  82877. /** Defines whether this extension is required */
  82878. required: boolean;
  82879. /** Reference to the glTF exporter */
  82880. private _textureInfos;
  82881. private _exportedTextures;
  82882. private _wasUsed;
  82883. constructor(exporter: _Exporter);
  82884. dispose(): void;
  82885. /** @hidden */
  82886. get wasUsed(): boolean;
  82887. private _getTextureIndex;
  82888. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82889. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82890. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82891. }
  82892. }
  82893. declare module BABYLON.GLTF2.Exporter.Extensions {
  82894. /**
  82895. * @hidden
  82896. */
  82897. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82898. /** Name of this extension */
  82899. readonly name: string;
  82900. /** Defines whether this extension is enabled */
  82901. enabled: boolean;
  82902. /** Defines whether this extension is required */
  82903. required: boolean;
  82904. private _wasUsed;
  82905. constructor(exporter: _Exporter);
  82906. /** @hidden */
  82907. get wasUsed(): boolean;
  82908. dispose(): void;
  82909. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82910. }
  82911. }
  82912. declare module BABYLON {
  82913. /**
  82914. * Class for generating STL data from a Babylon scene.
  82915. */
  82916. export class STLExport {
  82917. /**
  82918. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82919. * @param meshes list defines the mesh to serialize
  82920. * @param download triggers the automatic download of the file.
  82921. * @param fileName changes the downloads fileName.
  82922. * @param binary changes the STL to a binary type.
  82923. * @param isLittleEndian toggle for binary type exporter.
  82924. * @returns the STL as UTF8 string
  82925. */
  82926. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82927. }
  82928. }
  82929. declare module "babylonjs-gltf2interface" {
  82930. export = BABYLON.GLTF2;
  82931. }
  82932. /**
  82933. * Module for glTF 2.0 Interface
  82934. */
  82935. declare module BABYLON.GLTF2 {
  82936. /**
  82937. * The datatype of the components in the attribute
  82938. */
  82939. const enum AccessorComponentType {
  82940. /**
  82941. * Byte
  82942. */
  82943. BYTE = 5120,
  82944. /**
  82945. * Unsigned Byte
  82946. */
  82947. UNSIGNED_BYTE = 5121,
  82948. /**
  82949. * Short
  82950. */
  82951. SHORT = 5122,
  82952. /**
  82953. * Unsigned Short
  82954. */
  82955. UNSIGNED_SHORT = 5123,
  82956. /**
  82957. * Unsigned Int
  82958. */
  82959. UNSIGNED_INT = 5125,
  82960. /**
  82961. * Float
  82962. */
  82963. FLOAT = 5126,
  82964. }
  82965. /**
  82966. * Specifies if the attirbute is a scalar, vector, or matrix
  82967. */
  82968. const enum AccessorType {
  82969. /**
  82970. * Scalar
  82971. */
  82972. SCALAR = "SCALAR",
  82973. /**
  82974. * Vector2
  82975. */
  82976. VEC2 = "VEC2",
  82977. /**
  82978. * Vector3
  82979. */
  82980. VEC3 = "VEC3",
  82981. /**
  82982. * Vector4
  82983. */
  82984. VEC4 = "VEC4",
  82985. /**
  82986. * Matrix2x2
  82987. */
  82988. MAT2 = "MAT2",
  82989. /**
  82990. * Matrix3x3
  82991. */
  82992. MAT3 = "MAT3",
  82993. /**
  82994. * Matrix4x4
  82995. */
  82996. MAT4 = "MAT4",
  82997. }
  82998. /**
  82999. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83000. */
  83001. const enum AnimationChannelTargetPath {
  83002. /**
  83003. * Translation
  83004. */
  83005. TRANSLATION = "translation",
  83006. /**
  83007. * Rotation
  83008. */
  83009. ROTATION = "rotation",
  83010. /**
  83011. * Scale
  83012. */
  83013. SCALE = "scale",
  83014. /**
  83015. * Weights
  83016. */
  83017. WEIGHTS = "weights",
  83018. }
  83019. /**
  83020. * Interpolation algorithm
  83021. */
  83022. const enum AnimationSamplerInterpolation {
  83023. /**
  83024. * The animated values are linearly interpolated between keyframes
  83025. */
  83026. LINEAR = "LINEAR",
  83027. /**
  83028. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83029. */
  83030. STEP = "STEP",
  83031. /**
  83032. * The animation's interpolation is computed using a cubic spline with specified tangents
  83033. */
  83034. CUBICSPLINE = "CUBICSPLINE",
  83035. }
  83036. /**
  83037. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83038. */
  83039. const enum CameraType {
  83040. /**
  83041. * A perspective camera containing properties to create a perspective projection matrix
  83042. */
  83043. PERSPECTIVE = "perspective",
  83044. /**
  83045. * An orthographic camera containing properties to create an orthographic projection matrix
  83046. */
  83047. ORTHOGRAPHIC = "orthographic",
  83048. }
  83049. /**
  83050. * The mime-type of the image
  83051. */
  83052. const enum ImageMimeType {
  83053. /**
  83054. * JPEG Mime-type
  83055. */
  83056. JPEG = "image/jpeg",
  83057. /**
  83058. * PNG Mime-type
  83059. */
  83060. PNG = "image/png",
  83061. }
  83062. /**
  83063. * The alpha rendering mode of the material
  83064. */
  83065. const enum MaterialAlphaMode {
  83066. /**
  83067. * The alpha value is ignored and the rendered output is fully opaque
  83068. */
  83069. OPAQUE = "OPAQUE",
  83070. /**
  83071. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83072. */
  83073. MASK = "MASK",
  83074. /**
  83075. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  83076. */
  83077. BLEND = "BLEND",
  83078. }
  83079. /**
  83080. * The type of the primitives to render
  83081. */
  83082. const enum MeshPrimitiveMode {
  83083. /**
  83084. * Points
  83085. */
  83086. POINTS = 0,
  83087. /**
  83088. * Lines
  83089. */
  83090. LINES = 1,
  83091. /**
  83092. * Line Loop
  83093. */
  83094. LINE_LOOP = 2,
  83095. /**
  83096. * Line Strip
  83097. */
  83098. LINE_STRIP = 3,
  83099. /**
  83100. * Triangles
  83101. */
  83102. TRIANGLES = 4,
  83103. /**
  83104. * Triangle Strip
  83105. */
  83106. TRIANGLE_STRIP = 5,
  83107. /**
  83108. * Triangle Fan
  83109. */
  83110. TRIANGLE_FAN = 6,
  83111. }
  83112. /**
  83113. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83114. */
  83115. const enum TextureMagFilter {
  83116. /**
  83117. * Nearest
  83118. */
  83119. NEAREST = 9728,
  83120. /**
  83121. * Linear
  83122. */
  83123. LINEAR = 9729,
  83124. }
  83125. /**
  83126. * Minification filter. All valid values correspond to WebGL enums
  83127. */
  83128. const enum TextureMinFilter {
  83129. /**
  83130. * Nearest
  83131. */
  83132. NEAREST = 9728,
  83133. /**
  83134. * Linear
  83135. */
  83136. LINEAR = 9729,
  83137. /**
  83138. * Nearest Mip-Map Nearest
  83139. */
  83140. NEAREST_MIPMAP_NEAREST = 9984,
  83141. /**
  83142. * Linear Mipmap Nearest
  83143. */
  83144. LINEAR_MIPMAP_NEAREST = 9985,
  83145. /**
  83146. * Nearest Mipmap Linear
  83147. */
  83148. NEAREST_MIPMAP_LINEAR = 9986,
  83149. /**
  83150. * Linear Mipmap Linear
  83151. */
  83152. LINEAR_MIPMAP_LINEAR = 9987,
  83153. }
  83154. /**
  83155. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83156. */
  83157. const enum TextureWrapMode {
  83158. /**
  83159. * Clamp to Edge
  83160. */
  83161. CLAMP_TO_EDGE = 33071,
  83162. /**
  83163. * Mirrored Repeat
  83164. */
  83165. MIRRORED_REPEAT = 33648,
  83166. /**
  83167. * Repeat
  83168. */
  83169. REPEAT = 10497,
  83170. }
  83171. /**
  83172. * glTF Property
  83173. */
  83174. interface IProperty {
  83175. /**
  83176. * Dictionary object with extension-specific objects
  83177. */
  83178. extensions?: {
  83179. [key: string]: any;
  83180. };
  83181. /**
  83182. * Application-Specific data
  83183. */
  83184. extras?: any;
  83185. }
  83186. /**
  83187. * glTF Child of Root Property
  83188. */
  83189. interface IChildRootProperty extends IProperty {
  83190. /**
  83191. * The user-defined name of this object
  83192. */
  83193. name?: string;
  83194. }
  83195. /**
  83196. * Indices of those attributes that deviate from their initialization value
  83197. */
  83198. interface IAccessorSparseIndices extends IProperty {
  83199. /**
  83200. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83201. */
  83202. bufferView: number;
  83203. /**
  83204. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83205. */
  83206. byteOffset?: number;
  83207. /**
  83208. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83209. */
  83210. componentType: AccessorComponentType;
  83211. }
  83212. /**
  83213. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83214. */
  83215. interface IAccessorSparseValues extends IProperty {
  83216. /**
  83217. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83218. */
  83219. bufferView: number;
  83220. /**
  83221. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83222. */
  83223. byteOffset?: number;
  83224. }
  83225. /**
  83226. * Sparse storage of attributes that deviate from their initialization value
  83227. */
  83228. interface IAccessorSparse extends IProperty {
  83229. /**
  83230. * The number of attributes encoded in this sparse accessor
  83231. */
  83232. count: number;
  83233. /**
  83234. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83235. */
  83236. indices: IAccessorSparseIndices;
  83237. /**
  83238. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  83239. */
  83240. values: IAccessorSparseValues;
  83241. }
  83242. /**
  83243. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  83244. */
  83245. interface IAccessor extends IChildRootProperty {
  83246. /**
  83247. * The index of the bufferview
  83248. */
  83249. bufferView?: number;
  83250. /**
  83251. * The offset relative to the start of the bufferView in bytes
  83252. */
  83253. byteOffset?: number;
  83254. /**
  83255. * The datatype of components in the attribute
  83256. */
  83257. componentType: AccessorComponentType;
  83258. /**
  83259. * Specifies whether integer data values should be normalized
  83260. */
  83261. normalized?: boolean;
  83262. /**
  83263. * The number of attributes referenced by this accessor
  83264. */
  83265. count: number;
  83266. /**
  83267. * Specifies if the attribute is a scalar, vector, or matrix
  83268. */
  83269. type: AccessorType;
  83270. /**
  83271. * Maximum value of each component in this attribute
  83272. */
  83273. max?: number[];
  83274. /**
  83275. * Minimum value of each component in this attribute
  83276. */
  83277. min?: number[];
  83278. /**
  83279. * Sparse storage of attributes that deviate from their initialization value
  83280. */
  83281. sparse?: IAccessorSparse;
  83282. }
  83283. /**
  83284. * Targets an animation's sampler at a node's property
  83285. */
  83286. interface IAnimationChannel extends IProperty {
  83287. /**
  83288. * The index of a sampler in this animation used to compute the value for the target
  83289. */
  83290. sampler: number;
  83291. /**
  83292. * The index of the node and TRS property to target
  83293. */
  83294. target: IAnimationChannelTarget;
  83295. }
  83296. /**
  83297. * The index of the node and TRS property that an animation channel targets
  83298. */
  83299. interface IAnimationChannelTarget extends IProperty {
  83300. /**
  83301. * The index of the node to target
  83302. */
  83303. node: number;
  83304. /**
  83305. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83306. */
  83307. path: AnimationChannelTargetPath;
  83308. }
  83309. /**
  83310. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83311. */
  83312. interface IAnimationSampler extends IProperty {
  83313. /**
  83314. * The index of an accessor containing keyframe input values, e.g., time
  83315. */
  83316. input: number;
  83317. /**
  83318. * Interpolation algorithm
  83319. */
  83320. interpolation?: AnimationSamplerInterpolation;
  83321. /**
  83322. * The index of an accessor, containing keyframe output values
  83323. */
  83324. output: number;
  83325. }
  83326. /**
  83327. * A keyframe animation
  83328. */
  83329. interface IAnimation extends IChildRootProperty {
  83330. /**
  83331. * An array of channels, each of which targets an animation's sampler at a node's property
  83332. */
  83333. channels: IAnimationChannel[];
  83334. /**
  83335. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83336. */
  83337. samplers: IAnimationSampler[];
  83338. }
  83339. /**
  83340. * Metadata about the glTF asset
  83341. */
  83342. interface IAsset extends IChildRootProperty {
  83343. /**
  83344. * A copyright message suitable for display to credit the content creator
  83345. */
  83346. copyright?: string;
  83347. /**
  83348. * Tool that generated this glTF model. Useful for debugging
  83349. */
  83350. generator?: string;
  83351. /**
  83352. * The glTF version that this asset targets
  83353. */
  83354. version: string;
  83355. /**
  83356. * The minimum glTF version that this asset targets
  83357. */
  83358. minVersion?: string;
  83359. }
  83360. /**
  83361. * A buffer points to binary geometry, animation, or skins
  83362. */
  83363. interface IBuffer extends IChildRootProperty {
  83364. /**
  83365. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  83366. */
  83367. uri?: string;
  83368. /**
  83369. * The length of the buffer in bytes
  83370. */
  83371. byteLength: number;
  83372. }
  83373. /**
  83374. * A view into a buffer generally representing a subset of the buffer
  83375. */
  83376. interface IBufferView extends IChildRootProperty {
  83377. /**
  83378. * The index of the buffer
  83379. */
  83380. buffer: number;
  83381. /**
  83382. * The offset into the buffer in bytes
  83383. */
  83384. byteOffset?: number;
  83385. /**
  83386. * The lenth of the bufferView in bytes
  83387. */
  83388. byteLength: number;
  83389. /**
  83390. * The stride, in bytes
  83391. */
  83392. byteStride?: number;
  83393. }
  83394. /**
  83395. * An orthographic camera containing properties to create an orthographic projection matrix
  83396. */
  83397. interface ICameraOrthographic extends IProperty {
  83398. /**
  83399. * The floating-point horizontal magnification of the view. Must not be zero
  83400. */
  83401. xmag: number;
  83402. /**
  83403. * The floating-point vertical magnification of the view. Must not be zero
  83404. */
  83405. ymag: number;
  83406. /**
  83407. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83408. */
  83409. zfar: number;
  83410. /**
  83411. * The floating-point distance to the near clipping plane
  83412. */
  83413. znear: number;
  83414. }
  83415. /**
  83416. * A perspective camera containing properties to create a perspective projection matrix
  83417. */
  83418. interface ICameraPerspective extends IProperty {
  83419. /**
  83420. * The floating-point aspect ratio of the field of view
  83421. */
  83422. aspectRatio?: number;
  83423. /**
  83424. * The floating-point vertical field of view in radians
  83425. */
  83426. yfov: number;
  83427. /**
  83428. * The floating-point distance to the far clipping plane
  83429. */
  83430. zfar?: number;
  83431. /**
  83432. * The floating-point distance to the near clipping plane
  83433. */
  83434. znear: number;
  83435. }
  83436. /**
  83437. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83438. */
  83439. interface ICamera extends IChildRootProperty {
  83440. /**
  83441. * An orthographic camera containing properties to create an orthographic projection matrix
  83442. */
  83443. orthographic?: ICameraOrthographic;
  83444. /**
  83445. * A perspective camera containing properties to create a perspective projection matrix
  83446. */
  83447. perspective?: ICameraPerspective;
  83448. /**
  83449. * Specifies if the camera uses a perspective or orthographic projection
  83450. */
  83451. type: CameraType;
  83452. }
  83453. /**
  83454. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83455. */
  83456. interface IImage extends IChildRootProperty {
  83457. /**
  83458. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  83459. */
  83460. uri?: string;
  83461. /**
  83462. * The image's MIME type
  83463. */
  83464. mimeType?: ImageMimeType;
  83465. /**
  83466. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83467. */
  83468. bufferView?: number;
  83469. }
  83470. /**
  83471. * Material Normal Texture Info
  83472. */
  83473. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83474. /**
  83475. * The scalar multiplier applied to each normal vector of the normal texture
  83476. */
  83477. scale?: number;
  83478. }
  83479. /**
  83480. * Material Occlusion Texture Info
  83481. */
  83482. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83483. /**
  83484. * A scalar multiplier controlling the amount of occlusion applied
  83485. */
  83486. strength?: number;
  83487. }
  83488. /**
  83489. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83490. */
  83491. interface IMaterialPbrMetallicRoughness {
  83492. /**
  83493. * The material's base color factor
  83494. */
  83495. baseColorFactor?: number[];
  83496. /**
  83497. * The base color texture
  83498. */
  83499. baseColorTexture?: ITextureInfo;
  83500. /**
  83501. * The metalness of the material
  83502. */
  83503. metallicFactor?: number;
  83504. /**
  83505. * The roughness of the material
  83506. */
  83507. roughnessFactor?: number;
  83508. /**
  83509. * The metallic-roughness texture
  83510. */
  83511. metallicRoughnessTexture?: ITextureInfo;
  83512. }
  83513. /**
  83514. * The material appearance of a primitive
  83515. */
  83516. interface IMaterial extends IChildRootProperty {
  83517. /**
  83518. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  83519. */
  83520. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83521. /**
  83522. * The normal map texture
  83523. */
  83524. normalTexture?: IMaterialNormalTextureInfo;
  83525. /**
  83526. * The occlusion map texture
  83527. */
  83528. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83529. /**
  83530. * The emissive map texture
  83531. */
  83532. emissiveTexture?: ITextureInfo;
  83533. /**
  83534. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  83535. */
  83536. emissiveFactor?: number[];
  83537. /**
  83538. * The alpha rendering mode of the material
  83539. */
  83540. alphaMode?: MaterialAlphaMode;
  83541. /**
  83542. * The alpha cutoff value of the material
  83543. */
  83544. alphaCutoff?: number;
  83545. /**
  83546. * Specifies whether the material is double sided
  83547. */
  83548. doubleSided?: boolean;
  83549. }
  83550. /**
  83551. * Geometry to be rendered with the given material
  83552. */
  83553. interface IMeshPrimitive extends IProperty {
  83554. /**
  83555. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83556. */
  83557. attributes: {
  83558. [name: string]: number;
  83559. };
  83560. /**
  83561. * The index of the accessor that contains the indices
  83562. */
  83563. indices?: number;
  83564. /**
  83565. * The index of the material to apply to this primitive when rendering
  83566. */
  83567. material?: number;
  83568. /**
  83569. * The type of primitives to render. All valid values correspond to WebGL enums
  83570. */
  83571. mode?: MeshPrimitiveMode;
  83572. /**
  83573. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  83574. */
  83575. targets?: {
  83576. [name: string]: number;
  83577. }[];
  83578. }
  83579. /**
  83580. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83581. */
  83582. interface IMesh extends IChildRootProperty {
  83583. /**
  83584. * An array of primitives, each defining geometry to be rendered with a material
  83585. */
  83586. primitives: IMeshPrimitive[];
  83587. /**
  83588. * Array of weights to be applied to the Morph Targets
  83589. */
  83590. weights?: number[];
  83591. }
  83592. /**
  83593. * A node in the node hierarchy
  83594. */
  83595. interface INode extends IChildRootProperty {
  83596. /**
  83597. * The index of the camera referenced by this node
  83598. */
  83599. camera?: number;
  83600. /**
  83601. * The indices of this node's children
  83602. */
  83603. children?: number[];
  83604. /**
  83605. * The index of the skin referenced by this node
  83606. */
  83607. skin?: number;
  83608. /**
  83609. * A floating-point 4x4 transformation matrix stored in column-major order
  83610. */
  83611. matrix?: number[];
  83612. /**
  83613. * The index of the mesh in this node
  83614. */
  83615. mesh?: number;
  83616. /**
  83617. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83618. */
  83619. rotation?: number[];
  83620. /**
  83621. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83622. */
  83623. scale?: number[];
  83624. /**
  83625. * The node's translation along the x, y, and z axes
  83626. */
  83627. translation?: number[];
  83628. /**
  83629. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83630. */
  83631. weights?: number[];
  83632. }
  83633. /**
  83634. * Texture sampler properties for filtering and wrapping modes
  83635. */
  83636. interface ISampler extends IChildRootProperty {
  83637. /**
  83638. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83639. */
  83640. magFilter?: TextureMagFilter;
  83641. /**
  83642. * Minification filter. All valid values correspond to WebGL enums
  83643. */
  83644. minFilter?: TextureMinFilter;
  83645. /**
  83646. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83647. */
  83648. wrapS?: TextureWrapMode;
  83649. /**
  83650. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83651. */
  83652. wrapT?: TextureWrapMode;
  83653. }
  83654. /**
  83655. * The root nodes of a scene
  83656. */
  83657. interface IScene extends IChildRootProperty {
  83658. /**
  83659. * The indices of each root node
  83660. */
  83661. nodes: number[];
  83662. }
  83663. /**
  83664. * Joints and matrices defining a skin
  83665. */
  83666. interface ISkin extends IChildRootProperty {
  83667. /**
  83668. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  83669. */
  83670. inverseBindMatrices?: number;
  83671. /**
  83672. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83673. */
  83674. skeleton?: number;
  83675. /**
  83676. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  83677. */
  83678. joints: number[];
  83679. }
  83680. /**
  83681. * A texture and its sampler
  83682. */
  83683. interface ITexture extends IChildRootProperty {
  83684. /**
  83685. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83686. */
  83687. sampler?: number;
  83688. /**
  83689. * The index of the image used by this texture
  83690. */
  83691. source: number;
  83692. }
  83693. /**
  83694. * Reference to a texture
  83695. */
  83696. interface ITextureInfo extends IProperty {
  83697. /**
  83698. * The index of the texture
  83699. */
  83700. index: number;
  83701. /**
  83702. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83703. */
  83704. texCoord?: number;
  83705. }
  83706. /**
  83707. * The root object for a glTF asset
  83708. */
  83709. interface IGLTF extends IProperty {
  83710. /**
  83711. * An array of accessors. An accessor is a typed view into a bufferView
  83712. */
  83713. accessors?: IAccessor[];
  83714. /**
  83715. * An array of keyframe animations
  83716. */
  83717. animations?: IAnimation[];
  83718. /**
  83719. * Metadata about the glTF asset
  83720. */
  83721. asset: IAsset;
  83722. /**
  83723. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83724. */
  83725. buffers?: IBuffer[];
  83726. /**
  83727. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83728. */
  83729. bufferViews?: IBufferView[];
  83730. /**
  83731. * An array of cameras
  83732. */
  83733. cameras?: ICamera[];
  83734. /**
  83735. * Names of glTF extensions used somewhere in this asset
  83736. */
  83737. extensionsUsed?: string[];
  83738. /**
  83739. * Names of glTF extensions required to properly load this asset
  83740. */
  83741. extensionsRequired?: string[];
  83742. /**
  83743. * An array of images. An image defines data used to create a texture
  83744. */
  83745. images?: IImage[];
  83746. /**
  83747. * An array of materials. A material defines the appearance of a primitive
  83748. */
  83749. materials?: IMaterial[];
  83750. /**
  83751. * An array of meshes. A mesh is a set of primitives to be rendered
  83752. */
  83753. meshes?: IMesh[];
  83754. /**
  83755. * An array of nodes
  83756. */
  83757. nodes?: INode[];
  83758. /**
  83759. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83760. */
  83761. samplers?: ISampler[];
  83762. /**
  83763. * The index of the default scene
  83764. */
  83765. scene?: number;
  83766. /**
  83767. * An array of scenes
  83768. */
  83769. scenes?: IScene[];
  83770. /**
  83771. * An array of skins. A skin is defined by joints and matrices
  83772. */
  83773. skins?: ISkin[];
  83774. /**
  83775. * An array of textures
  83776. */
  83777. textures?: ITexture[];
  83778. }
  83779. /**
  83780. * The glTF validation results
  83781. * @ignore
  83782. */
  83783. interface IGLTFValidationResults {
  83784. info: {
  83785. generator: string;
  83786. hasAnimations: boolean;
  83787. hasDefaultScene: boolean;
  83788. hasMaterials: boolean;
  83789. hasMorphTargets: boolean;
  83790. hasSkins: boolean;
  83791. hasTextures: boolean;
  83792. maxAttributesUsed: number;
  83793. primitivesCount: number
  83794. };
  83795. issues: {
  83796. messages: Array<string>;
  83797. numErrors: number;
  83798. numHints: number;
  83799. numInfos: number;
  83800. numWarnings: number;
  83801. truncated: boolean
  83802. };
  83803. mimeType: string;
  83804. uri: string;
  83805. validatedAt: string;
  83806. validatorVersion: string;
  83807. }
  83808. /**
  83809. * The glTF validation options
  83810. */
  83811. interface IGLTFValidationOptions {
  83812. /** Uri to use */
  83813. uri?: string;
  83814. /** Function used to load external resources */
  83815. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83816. /** Boolean indicating that we need to validate accessor data */
  83817. validateAccessorData?: boolean;
  83818. /** max number of issues allowed */
  83819. maxIssues?: number;
  83820. /** Ignored issues */
  83821. ignoredIssues?: Array<string>;
  83822. /** Value to override severy settings */
  83823. severityOverrides?: Object;
  83824. }
  83825. /**
  83826. * The glTF validator object
  83827. * @ignore
  83828. */
  83829. interface IGLTFValidator {
  83830. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83831. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83832. }
  83833. /**
  83834. * Interfaces from the EXT_lights_image_based extension
  83835. */
  83836. /** @hidden */
  83837. interface IEXTLightsImageBased_LightReferenceImageBased {
  83838. light: number;
  83839. }
  83840. /** @hidden */
  83841. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83842. intensity: number;
  83843. rotation: number[];
  83844. specularImageSize: number;
  83845. specularImages: number[][];
  83846. irradianceCoefficients: number[][];
  83847. }
  83848. /** @hidden */
  83849. interface IEXTLightsImageBased {
  83850. lights: IEXTLightsImageBased_LightImageBased[];
  83851. }
  83852. /**
  83853. * Interfaces from the EXT_mesh_gpu_instancing extension
  83854. * !!! Experimental Extension Subject to Changes !!!
  83855. */
  83856. /** @hidden */
  83857. interface IEXTMeshGpuInstancing {
  83858. mesh?: number;
  83859. attributes: { [name: string]: number };
  83860. }
  83861. /**
  83862. * Interfaces from the KHR_draco_mesh_compression extension
  83863. */
  83864. /** @hidden */
  83865. interface IKHRDracoMeshCompression {
  83866. bufferView: number;
  83867. attributes: { [name: string]: number };
  83868. }
  83869. /**
  83870. * Interfaces from the KHR_lights_punctual extension
  83871. */
  83872. /** @hidden */
  83873. const enum IKHRLightsPunctual_LightType {
  83874. DIRECTIONAL = "directional",
  83875. POINT = "point",
  83876. SPOT = "spot"
  83877. }
  83878. /** @hidden */
  83879. interface IKHRLightsPunctual_LightReference {
  83880. light: number;
  83881. }
  83882. /** @hidden */
  83883. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83884. type: IKHRLightsPunctual_LightType;
  83885. color?: number[];
  83886. intensity?: number;
  83887. range?: number;
  83888. spot?: {
  83889. innerConeAngle?: number;
  83890. outerConeAngle?: number;
  83891. };
  83892. }
  83893. /** @hidden */
  83894. interface IKHRLightsPunctual {
  83895. lights: IKHRLightsPunctual_Light[];
  83896. }
  83897. /**
  83898. * Interfaces from the KHR_materials_clearcoat extension
  83899. * !!! Experimental Extension Subject to Changes !!!
  83900. */
  83901. /** @hidden */
  83902. interface IKHRMaterialsClearcoat {
  83903. clearcoatFactor: number;
  83904. clearcoatTexture: ITextureInfo;
  83905. clearcoatRoughnessFactor: number;
  83906. clearcoatRoughnessTexture: ITextureInfo;
  83907. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83908. }
  83909. /**
  83910. * Interfaces from the KHR_materials_ior extension
  83911. * !!! Experimental Extension Subject to Changes !!!
  83912. */
  83913. /** @hidden */
  83914. interface IKHRMaterialsIor {
  83915. ior: number;
  83916. }
  83917. /**
  83918. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83919. */
  83920. /** @hidden */
  83921. interface IKHRMaterialsPbrSpecularGlossiness {
  83922. diffuseFactor: number[];
  83923. diffuseTexture: ITextureInfo;
  83924. specularFactor: number[];
  83925. glossinessFactor: number;
  83926. specularGlossinessTexture: ITextureInfo;
  83927. }
  83928. /**
  83929. * Interfaces from the KHR_materials_sheen extension
  83930. * !!! Experimental Extension Subject to Changes !!!
  83931. */
  83932. /** @hidden */
  83933. interface IKHRMaterialsSheen {
  83934. sheenColorFactor?: number[];
  83935. sheenTexture?: ITextureInfo;
  83936. sheenRoughnessFactor?: number;
  83937. }
  83938. /**
  83939. * Interfaces from the KHR_materials_specular extension
  83940. * !!! Experimental Extension Subject to Changes !!!
  83941. */
  83942. /** @hidden */
  83943. interface IKHRMaterialsSpecular {
  83944. specularFactor: number;
  83945. specularColorFactor: number[];
  83946. specularTexture: ITextureInfo;
  83947. }
  83948. /**
  83949. * Interfaces from the KHR_materials_transmission extension
  83950. * !!! Experimental Extension Subject to Changes !!!
  83951. */
  83952. /** @hidden */
  83953. interface IKHRMaterialsTransmission {
  83954. transmissionFactor?: number;
  83955. transmissionTexture?: ITextureInfo;
  83956. }
  83957. /**
  83958. * Interfaces from the KHR_materials_variants extension
  83959. * !!! Experimental Extension Subject to Changes !!!
  83960. */
  83961. /** @hidden */
  83962. interface IKHRMaterialVariants_Mapping {
  83963. tags: string[];
  83964. material: number;
  83965. }
  83966. /** @hidden */
  83967. interface IKHRMaterialVariants {
  83968. mapping: IKHRMaterialVariants_Mapping[];
  83969. }
  83970. /**
  83971. * Interfaces from the KHR_texture_basisu extension
  83972. * !!! Experimental Extension Subject to Changes !!!
  83973. */
  83974. /** @hidden */
  83975. interface IKHRTextureBasisU {
  83976. source: number;
  83977. }
  83978. /**
  83979. * Interfaces from the KHR_texture_transform extension
  83980. */
  83981. /** @hidden */
  83982. interface IKHRTextureTransform {
  83983. offset?: number[];
  83984. rotation?: number;
  83985. scale?: number[];
  83986. texCoord?: number;
  83987. }
  83988. /**
  83989. * Interfaces from the KHR_xmp extension
  83990. * !!! Experimental Extension Subject to Changes !!!
  83991. */
  83992. /** @hidden */
  83993. interface IKHRXmp_Data {
  83994. [key: string]: unknown;
  83995. }
  83996. /** @hidden */
  83997. interface IKHRXmp_Gltf {
  83998. packets: IKHRXmp_Data[];
  83999. }
  84000. /** @hidden */
  84001. interface IKHRXmp_Node {
  84002. packet: number;
  84003. }
  84004. /**
  84005. * Interfaces from the MSFT_audio_emitter extension
  84006. */
  84007. /** @hidden */
  84008. interface IMSFTAudioEmitter_ClipReference {
  84009. clip: number;
  84010. weight?: number;
  84011. }
  84012. /** @hidden */
  84013. interface IMSFTAudioEmitter_EmittersReference {
  84014. emitters: number[];
  84015. }
  84016. /** @hidden */
  84017. const enum IMSFTAudioEmitter_DistanceModel {
  84018. linear = "linear",
  84019. inverse = "inverse",
  84020. exponential = "exponential",
  84021. }
  84022. /** @hidden */
  84023. interface IMSFTAudioEmitter_Emitter {
  84024. name?: string;
  84025. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84026. refDistance?: number;
  84027. maxDistance?: number;
  84028. rolloffFactor?: number;
  84029. innerAngle?: number;
  84030. outerAngle?: number;
  84031. loop?: boolean;
  84032. volume?: number;
  84033. clips: IMSFTAudioEmitter_ClipReference[];
  84034. }
  84035. /** @hidden */
  84036. const enum IMSFTAudioEmitter_AudioMimeType {
  84037. WAV = "audio/wav",
  84038. }
  84039. /** @hidden */
  84040. interface IMSFTAudioEmitter_Clip extends IProperty {
  84041. uri?: string;
  84042. bufferView?: number;
  84043. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84044. }
  84045. /** @hidden */
  84046. const enum IMSFTAudioEmitter_AnimationEventAction {
  84047. play = "play",
  84048. pause = "pause",
  84049. stop = "stop",
  84050. }
  84051. /** @hidden */
  84052. interface IMSFTAudioEmitter_AnimationEvent {
  84053. action: IMSFTAudioEmitter_AnimationEventAction;
  84054. emitter: number;
  84055. time: number;
  84056. startOffset?: number;
  84057. }
  84058. /**
  84059. * Interfaces from the MSFT_lod extension
  84060. */
  84061. /** @hidden */
  84062. interface IMSFTLOD {
  84063. ids: number[];
  84064. }
  84065. }
  84066. declare module BABYLON {
  84067. /** @hidden */
  84068. export var cellPixelShader: {
  84069. name: string;
  84070. shader: string;
  84071. };
  84072. }
  84073. declare module BABYLON {
  84074. /** @hidden */
  84075. export var cellVertexShader: {
  84076. name: string;
  84077. shader: string;
  84078. };
  84079. }
  84080. declare module BABYLON {
  84081. export class CellMaterial extends BABYLON.PushMaterial {
  84082. private _diffuseTexture;
  84083. diffuseTexture: BABYLON.BaseTexture;
  84084. diffuseColor: BABYLON.Color3;
  84085. _computeHighLevel: boolean;
  84086. computeHighLevel: boolean;
  84087. private _disableLighting;
  84088. disableLighting: boolean;
  84089. private _maxSimultaneousLights;
  84090. maxSimultaneousLights: number;
  84091. constructor(name: string, scene: BABYLON.Scene);
  84092. needAlphaBlending(): boolean;
  84093. needAlphaTesting(): boolean;
  84094. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84095. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84096. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84097. getAnimatables(): BABYLON.IAnimatable[];
  84098. getActiveTextures(): BABYLON.BaseTexture[];
  84099. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84100. dispose(forceDisposeEffect?: boolean): void;
  84101. getClassName(): string;
  84102. clone(name: string): CellMaterial;
  84103. serialize(): any;
  84104. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84105. }
  84106. }
  84107. declare module BABYLON {
  84108. export class CustomShaderStructure {
  84109. FragmentStore: string;
  84110. VertexStore: string;
  84111. constructor();
  84112. }
  84113. export class ShaderSpecialParts {
  84114. constructor();
  84115. Fragment_Begin: string;
  84116. Fragment_Definitions: string;
  84117. Fragment_MainBegin: string;
  84118. Fragment_Custom_Diffuse: string;
  84119. Fragment_Before_Lights: string;
  84120. Fragment_Before_Fog: string;
  84121. Fragment_Custom_Alpha: string;
  84122. Fragment_Before_FragColor: string;
  84123. Vertex_Begin: string;
  84124. Vertex_Definitions: string;
  84125. Vertex_MainBegin: string;
  84126. Vertex_Before_PositionUpdated: string;
  84127. Vertex_Before_NormalUpdated: string;
  84128. Vertex_After_WorldPosComputed: string;
  84129. Vertex_MainEnd: string;
  84130. }
  84131. export class CustomMaterial extends BABYLON.StandardMaterial {
  84132. static ShaderIndexer: number;
  84133. CustomParts: ShaderSpecialParts;
  84134. _isCreatedShader: boolean;
  84135. _createdShaderName: string;
  84136. _customUniform: string[];
  84137. _newUniforms: string[];
  84138. _newUniformInstances: {
  84139. [name: string]: any;
  84140. };
  84141. _newSamplerInstances: {
  84142. [name: string]: BABYLON.Texture;
  84143. };
  84144. _customAttributes: string[];
  84145. FragmentShader: string;
  84146. VertexShader: string;
  84147. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84148. ReviewUniform(name: string, arr: string[]): string[];
  84149. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84150. constructor(name: string, scene: BABYLON.Scene);
  84151. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84152. AddAttribute(name: string): CustomMaterial;
  84153. Fragment_Begin(shaderPart: string): CustomMaterial;
  84154. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84155. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84156. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84157. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84158. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84159. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84160. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84161. Vertex_Begin(shaderPart: string): CustomMaterial;
  84162. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84163. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84164. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84165. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84166. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84167. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84168. }
  84169. }
  84170. declare module BABYLON {
  84171. export class ShaderAlebdoParts {
  84172. constructor();
  84173. Fragment_Begin: string;
  84174. Fragment_Definitions: string;
  84175. Fragment_MainBegin: string;
  84176. Fragment_Custom_Albedo: string;
  84177. Fragment_Before_Lights: string;
  84178. Fragment_Custom_MetallicRoughness: string;
  84179. Fragment_Custom_MicroSurface: string;
  84180. Fragment_Before_Fog: string;
  84181. Fragment_Custom_Alpha: string;
  84182. Fragment_Before_FragColor: string;
  84183. Vertex_Begin: string;
  84184. Vertex_Definitions: string;
  84185. Vertex_MainBegin: string;
  84186. Vertex_Before_PositionUpdated: string;
  84187. Vertex_Before_NormalUpdated: string;
  84188. Vertex_After_WorldPosComputed: string;
  84189. Vertex_MainEnd: string;
  84190. }
  84191. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84192. static ShaderIndexer: number;
  84193. CustomParts: ShaderAlebdoParts;
  84194. _isCreatedShader: boolean;
  84195. _createdShaderName: string;
  84196. _customUniform: string[];
  84197. _newUniforms: string[];
  84198. _newUniformInstances: {
  84199. [name: string]: any;
  84200. };
  84201. _newSamplerInstances: {
  84202. [name: string]: BABYLON.Texture;
  84203. };
  84204. _customAttributes: string[];
  84205. FragmentShader: string;
  84206. VertexShader: string;
  84207. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84208. ReviewUniform(name: string, arr: string[]): string[];
  84209. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84210. constructor(name: string, scene: BABYLON.Scene);
  84211. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84212. AddAttribute(name: string): PBRCustomMaterial;
  84213. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84214. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84215. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84216. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84217. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84218. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84219. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84220. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84221. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84222. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84223. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84224. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84225. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84226. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84227. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84228. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84229. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84230. }
  84231. }
  84232. declare module BABYLON {
  84233. /** @hidden */
  84234. export var firePixelShader: {
  84235. name: string;
  84236. shader: string;
  84237. };
  84238. }
  84239. declare module BABYLON {
  84240. /** @hidden */
  84241. export var fireVertexShader: {
  84242. name: string;
  84243. shader: string;
  84244. };
  84245. }
  84246. declare module BABYLON {
  84247. export class FireMaterial extends BABYLON.PushMaterial {
  84248. private _diffuseTexture;
  84249. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84250. private _distortionTexture;
  84251. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84252. private _opacityTexture;
  84253. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84254. diffuseColor: BABYLON.Color3;
  84255. speed: number;
  84256. private _scaledDiffuse;
  84257. private _lastTime;
  84258. constructor(name: string, scene: BABYLON.Scene);
  84259. needAlphaBlending(): boolean;
  84260. needAlphaTesting(): boolean;
  84261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84264. getAnimatables(): BABYLON.IAnimatable[];
  84265. getActiveTextures(): BABYLON.BaseTexture[];
  84266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84267. getClassName(): string;
  84268. dispose(forceDisposeEffect?: boolean): void;
  84269. clone(name: string): FireMaterial;
  84270. serialize(): any;
  84271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84272. }
  84273. }
  84274. declare module BABYLON {
  84275. /** @hidden */
  84276. export var furPixelShader: {
  84277. name: string;
  84278. shader: string;
  84279. };
  84280. }
  84281. declare module BABYLON {
  84282. /** @hidden */
  84283. export var furVertexShader: {
  84284. name: string;
  84285. shader: string;
  84286. };
  84287. }
  84288. declare module BABYLON {
  84289. export class FurMaterial extends BABYLON.PushMaterial {
  84290. private _diffuseTexture;
  84291. diffuseTexture: BABYLON.BaseTexture;
  84292. private _heightTexture;
  84293. heightTexture: BABYLON.BaseTexture;
  84294. diffuseColor: BABYLON.Color3;
  84295. furLength: number;
  84296. furAngle: number;
  84297. furColor: BABYLON.Color3;
  84298. furOffset: number;
  84299. furSpacing: number;
  84300. furGravity: BABYLON.Vector3;
  84301. furSpeed: number;
  84302. furDensity: number;
  84303. furOcclusion: number;
  84304. furTexture: BABYLON.DynamicTexture;
  84305. private _disableLighting;
  84306. disableLighting: boolean;
  84307. private _maxSimultaneousLights;
  84308. maxSimultaneousLights: number;
  84309. highLevelFur: boolean;
  84310. _meshes: BABYLON.AbstractMesh[];
  84311. private _furTime;
  84312. constructor(name: string, scene: BABYLON.Scene);
  84313. get furTime(): number;
  84314. set furTime(furTime: number);
  84315. needAlphaBlending(): boolean;
  84316. needAlphaTesting(): boolean;
  84317. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84318. updateFur(): void;
  84319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84321. getAnimatables(): BABYLON.IAnimatable[];
  84322. getActiveTextures(): BABYLON.BaseTexture[];
  84323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84324. dispose(forceDisposeEffect?: boolean): void;
  84325. clone(name: string): FurMaterial;
  84326. serialize(): any;
  84327. getClassName(): string;
  84328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84329. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84330. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84331. }
  84332. }
  84333. declare module BABYLON {
  84334. /** @hidden */
  84335. export var gradientPixelShader: {
  84336. name: string;
  84337. shader: string;
  84338. };
  84339. }
  84340. declare module BABYLON {
  84341. /** @hidden */
  84342. export var gradientVertexShader: {
  84343. name: string;
  84344. shader: string;
  84345. };
  84346. }
  84347. declare module BABYLON {
  84348. export class GradientMaterial extends BABYLON.PushMaterial {
  84349. private _maxSimultaneousLights;
  84350. maxSimultaneousLights: number;
  84351. topColor: BABYLON.Color3;
  84352. topColorAlpha: number;
  84353. bottomColor: BABYLON.Color3;
  84354. bottomColorAlpha: number;
  84355. offset: number;
  84356. scale: number;
  84357. smoothness: number;
  84358. private _disableLighting;
  84359. disableLighting: boolean;
  84360. constructor(name: string, scene: BABYLON.Scene);
  84361. needAlphaBlending(): boolean;
  84362. needAlphaTesting(): boolean;
  84363. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84364. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84365. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84366. getAnimatables(): BABYLON.IAnimatable[];
  84367. dispose(forceDisposeEffect?: boolean): void;
  84368. clone(name: string): GradientMaterial;
  84369. serialize(): any;
  84370. getClassName(): string;
  84371. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84372. }
  84373. }
  84374. declare module BABYLON {
  84375. /** @hidden */
  84376. export var gridPixelShader: {
  84377. name: string;
  84378. shader: string;
  84379. };
  84380. }
  84381. declare module BABYLON {
  84382. /** @hidden */
  84383. export var gridVertexShader: {
  84384. name: string;
  84385. shader: string;
  84386. };
  84387. }
  84388. declare module BABYLON {
  84389. /**
  84390. * The grid materials allows you to wrap any shape with a grid.
  84391. * Colors are customizable.
  84392. */
  84393. export class GridMaterial extends BABYLON.PushMaterial {
  84394. /**
  84395. * Main color of the grid (e.g. between lines)
  84396. */
  84397. mainColor: BABYLON.Color3;
  84398. /**
  84399. * Color of the grid lines.
  84400. */
  84401. lineColor: BABYLON.Color3;
  84402. /**
  84403. * The scale of the grid compared to unit.
  84404. */
  84405. gridRatio: number;
  84406. /**
  84407. * Allows setting an offset for the grid lines.
  84408. */
  84409. gridOffset: BABYLON.Vector3;
  84410. /**
  84411. * The frequency of thicker lines.
  84412. */
  84413. majorUnitFrequency: number;
  84414. /**
  84415. * The visibility of minor units in the grid.
  84416. */
  84417. minorUnitVisibility: number;
  84418. /**
  84419. * The grid opacity outside of the lines.
  84420. */
  84421. opacity: number;
  84422. /**
  84423. * Determine RBG output is premultiplied by alpha value.
  84424. */
  84425. preMultiplyAlpha: boolean;
  84426. private _opacityTexture;
  84427. opacityTexture: BABYLON.BaseTexture;
  84428. private _gridControl;
  84429. /**
  84430. * constructor
  84431. * @param name The name given to the material in order to identify it afterwards.
  84432. * @param scene The scene the material is used in.
  84433. */
  84434. constructor(name: string, scene: BABYLON.Scene);
  84435. /**
  84436. * Returns wehter or not the grid requires alpha blending.
  84437. */
  84438. needAlphaBlending(): boolean;
  84439. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84440. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84442. /**
  84443. * Dispose the material and its associated resources.
  84444. * @param forceDisposeEffect will also dispose the used effect when true
  84445. */
  84446. dispose(forceDisposeEffect?: boolean): void;
  84447. clone(name: string): GridMaterial;
  84448. serialize(): any;
  84449. getClassName(): string;
  84450. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84451. }
  84452. }
  84453. declare module BABYLON {
  84454. /** @hidden */
  84455. export var lavaPixelShader: {
  84456. name: string;
  84457. shader: string;
  84458. };
  84459. }
  84460. declare module BABYLON {
  84461. /** @hidden */
  84462. export var lavaVertexShader: {
  84463. name: string;
  84464. shader: string;
  84465. };
  84466. }
  84467. declare module BABYLON {
  84468. export class LavaMaterial extends BABYLON.PushMaterial {
  84469. private _diffuseTexture;
  84470. diffuseTexture: BABYLON.BaseTexture;
  84471. noiseTexture: BABYLON.BaseTexture;
  84472. fogColor: BABYLON.Color3;
  84473. speed: number;
  84474. movingSpeed: number;
  84475. lowFrequencySpeed: number;
  84476. fogDensity: number;
  84477. private _lastTime;
  84478. diffuseColor: BABYLON.Color3;
  84479. private _disableLighting;
  84480. disableLighting: boolean;
  84481. private _unlit;
  84482. unlit: boolean;
  84483. private _maxSimultaneousLights;
  84484. maxSimultaneousLights: number;
  84485. private _scaledDiffuse;
  84486. constructor(name: string, scene: BABYLON.Scene);
  84487. needAlphaBlending(): boolean;
  84488. needAlphaTesting(): boolean;
  84489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84492. getAnimatables(): BABYLON.IAnimatable[];
  84493. getActiveTextures(): BABYLON.BaseTexture[];
  84494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84495. dispose(forceDisposeEffect?: boolean): void;
  84496. clone(name: string): LavaMaterial;
  84497. serialize(): any;
  84498. getClassName(): string;
  84499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84500. }
  84501. }
  84502. declare module BABYLON {
  84503. /** @hidden */
  84504. export var mixPixelShader: {
  84505. name: string;
  84506. shader: string;
  84507. };
  84508. }
  84509. declare module BABYLON {
  84510. /** @hidden */
  84511. export var mixVertexShader: {
  84512. name: string;
  84513. shader: string;
  84514. };
  84515. }
  84516. declare module BABYLON {
  84517. export class MixMaterial extends BABYLON.PushMaterial {
  84518. /**
  84519. * Mix textures
  84520. */
  84521. private _mixTexture1;
  84522. mixTexture1: BABYLON.BaseTexture;
  84523. private _mixTexture2;
  84524. mixTexture2: BABYLON.BaseTexture;
  84525. /**
  84526. * Diffuse textures
  84527. */
  84528. private _diffuseTexture1;
  84529. diffuseTexture1: BABYLON.Texture;
  84530. private _diffuseTexture2;
  84531. diffuseTexture2: BABYLON.Texture;
  84532. private _diffuseTexture3;
  84533. diffuseTexture3: BABYLON.Texture;
  84534. private _diffuseTexture4;
  84535. diffuseTexture4: BABYLON.Texture;
  84536. private _diffuseTexture5;
  84537. diffuseTexture5: BABYLON.Texture;
  84538. private _diffuseTexture6;
  84539. diffuseTexture6: BABYLON.Texture;
  84540. private _diffuseTexture7;
  84541. diffuseTexture7: BABYLON.Texture;
  84542. private _diffuseTexture8;
  84543. diffuseTexture8: BABYLON.Texture;
  84544. /**
  84545. * Uniforms
  84546. */
  84547. diffuseColor: BABYLON.Color3;
  84548. specularColor: BABYLON.Color3;
  84549. specularPower: number;
  84550. private _disableLighting;
  84551. disableLighting: boolean;
  84552. private _maxSimultaneousLights;
  84553. maxSimultaneousLights: number;
  84554. constructor(name: string, scene: BABYLON.Scene);
  84555. needAlphaBlending(): boolean;
  84556. needAlphaTesting(): boolean;
  84557. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84560. getAnimatables(): BABYLON.IAnimatable[];
  84561. getActiveTextures(): BABYLON.BaseTexture[];
  84562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84563. dispose(forceDisposeEffect?: boolean): void;
  84564. clone(name: string): MixMaterial;
  84565. serialize(): any;
  84566. getClassName(): string;
  84567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84568. }
  84569. }
  84570. declare module BABYLON {
  84571. /** @hidden */
  84572. export var normalPixelShader: {
  84573. name: string;
  84574. shader: string;
  84575. };
  84576. }
  84577. declare module BABYLON {
  84578. /** @hidden */
  84579. export var normalVertexShader: {
  84580. name: string;
  84581. shader: string;
  84582. };
  84583. }
  84584. declare module BABYLON {
  84585. export class NormalMaterial extends BABYLON.PushMaterial {
  84586. private _diffuseTexture;
  84587. diffuseTexture: BABYLON.BaseTexture;
  84588. diffuseColor: BABYLON.Color3;
  84589. private _disableLighting;
  84590. disableLighting: boolean;
  84591. private _maxSimultaneousLights;
  84592. maxSimultaneousLights: number;
  84593. constructor(name: string, scene: BABYLON.Scene);
  84594. needAlphaBlending(): boolean;
  84595. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84596. needAlphaTesting(): boolean;
  84597. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84599. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84600. getAnimatables(): BABYLON.IAnimatable[];
  84601. getActiveTextures(): BABYLON.BaseTexture[];
  84602. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84603. dispose(forceDisposeEffect?: boolean): void;
  84604. clone(name: string): NormalMaterial;
  84605. serialize(): any;
  84606. getClassName(): string;
  84607. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84608. }
  84609. }
  84610. declare module BABYLON {
  84611. /** @hidden */
  84612. export var shadowOnlyPixelShader: {
  84613. name: string;
  84614. shader: string;
  84615. };
  84616. }
  84617. declare module BABYLON {
  84618. /** @hidden */
  84619. export var shadowOnlyVertexShader: {
  84620. name: string;
  84621. shader: string;
  84622. };
  84623. }
  84624. declare module BABYLON {
  84625. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84626. private _activeLight;
  84627. private _needAlphaBlending;
  84628. constructor(name: string, scene: BABYLON.Scene);
  84629. shadowColor: BABYLON.Color3;
  84630. needAlphaBlending(): boolean;
  84631. needAlphaTesting(): boolean;
  84632. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84633. get activeLight(): BABYLON.IShadowLight;
  84634. set activeLight(light: BABYLON.IShadowLight);
  84635. private _getFirstShadowLightForMesh;
  84636. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84637. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84638. clone(name: string): ShadowOnlyMaterial;
  84639. serialize(): any;
  84640. getClassName(): string;
  84641. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84642. }
  84643. }
  84644. declare module BABYLON {
  84645. /** @hidden */
  84646. export var simplePixelShader: {
  84647. name: string;
  84648. shader: string;
  84649. };
  84650. }
  84651. declare module BABYLON {
  84652. /** @hidden */
  84653. export var simpleVertexShader: {
  84654. name: string;
  84655. shader: string;
  84656. };
  84657. }
  84658. declare module BABYLON {
  84659. export class SimpleMaterial extends BABYLON.PushMaterial {
  84660. private _diffuseTexture;
  84661. diffuseTexture: BABYLON.BaseTexture;
  84662. diffuseColor: BABYLON.Color3;
  84663. private _disableLighting;
  84664. disableLighting: boolean;
  84665. private _maxSimultaneousLights;
  84666. maxSimultaneousLights: number;
  84667. constructor(name: string, scene: BABYLON.Scene);
  84668. needAlphaBlending(): boolean;
  84669. needAlphaTesting(): boolean;
  84670. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84671. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84672. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84673. getAnimatables(): BABYLON.IAnimatable[];
  84674. getActiveTextures(): BABYLON.BaseTexture[];
  84675. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84676. dispose(forceDisposeEffect?: boolean): void;
  84677. clone(name: string): SimpleMaterial;
  84678. serialize(): any;
  84679. getClassName(): string;
  84680. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84681. }
  84682. }
  84683. declare module BABYLON {
  84684. /** @hidden */
  84685. export var skyPixelShader: {
  84686. name: string;
  84687. shader: string;
  84688. };
  84689. }
  84690. declare module BABYLON {
  84691. /** @hidden */
  84692. export var skyVertexShader: {
  84693. name: string;
  84694. shader: string;
  84695. };
  84696. }
  84697. declare module BABYLON {
  84698. /**
  84699. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84700. * @see https://doc.babylonjs.com/extensions/sky
  84701. */
  84702. export class SkyMaterial extends BABYLON.PushMaterial {
  84703. /**
  84704. * Defines the overall luminance of sky in interval ]0, 1[.
  84705. */
  84706. luminance: number;
  84707. /**
  84708. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84709. */
  84710. turbidity: number;
  84711. /**
  84712. * Defines the sky appearance (light intensity).
  84713. */
  84714. rayleigh: number;
  84715. /**
  84716. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84717. */
  84718. mieCoefficient: number;
  84719. /**
  84720. * Defines the amount of haze particles following the Mie scattering theory.
  84721. */
  84722. mieDirectionalG: number;
  84723. /**
  84724. * Defines the distance of the sun according to the active scene camera.
  84725. */
  84726. distance: number;
  84727. /**
  84728. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84729. * "inclined".
  84730. */
  84731. inclination: number;
  84732. /**
  84733. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84734. * an object direction and a reference direction.
  84735. */
  84736. azimuth: number;
  84737. /**
  84738. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84739. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84740. */
  84741. sunPosition: BABYLON.Vector3;
  84742. /**
  84743. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84744. * .sunPosition property.
  84745. */
  84746. useSunPosition: boolean;
  84747. /**
  84748. * Defines an offset vector used to get a horizon offset.
  84749. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84750. */
  84751. cameraOffset: BABYLON.Vector3;
  84752. private _cameraPosition;
  84753. /**
  84754. * Instantiates a new sky material.
  84755. * This material allows to create dynamic and texture free
  84756. * effects for skyboxes by taking care of the atmosphere state.
  84757. * @see https://doc.babylonjs.com/extensions/sky
  84758. * @param name Define the name of the material in the scene
  84759. * @param scene Define the scene the material belong to
  84760. */
  84761. constructor(name: string, scene: BABYLON.Scene);
  84762. /**
  84763. * Specifies if the material will require alpha blending
  84764. * @returns a boolean specifying if alpha blending is needed
  84765. */
  84766. needAlphaBlending(): boolean;
  84767. /**
  84768. * Specifies if this material should be rendered in alpha test mode
  84769. * @returns false as the sky material doesn't need alpha testing.
  84770. */
  84771. needAlphaTesting(): boolean;
  84772. /**
  84773. * Get the texture used for alpha test purpose.
  84774. * @returns null as the sky material has no texture.
  84775. */
  84776. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84777. /**
  84778. * Get if the submesh is ready to be used and all its information available.
  84779. * Child classes can use it to update shaders
  84780. * @param mesh defines the mesh to check
  84781. * @param subMesh defines which submesh to check
  84782. * @param useInstances specifies that instances should be used
  84783. * @returns a boolean indicating that the submesh is ready or not
  84784. */
  84785. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84786. /**
  84787. * Binds the submesh to this material by preparing the effect and shader to draw
  84788. * @param world defines the world transformation matrix
  84789. * @param mesh defines the mesh containing the submesh
  84790. * @param subMesh defines the submesh to bind the material to
  84791. */
  84792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84793. /**
  84794. * Get the list of animatables in the material.
  84795. * @returns the list of animatables object used in the material
  84796. */
  84797. getAnimatables(): BABYLON.IAnimatable[];
  84798. /**
  84799. * Disposes the material
  84800. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84801. */
  84802. dispose(forceDisposeEffect?: boolean): void;
  84803. /**
  84804. * Makes a duplicate of the material, and gives it a new name
  84805. * @param name defines the new name for the duplicated material
  84806. * @returns the cloned material
  84807. */
  84808. clone(name: string): SkyMaterial;
  84809. /**
  84810. * Serializes this material in a JSON representation
  84811. * @returns the serialized material object
  84812. */
  84813. serialize(): any;
  84814. /**
  84815. * Gets the current class name of the material e.g. "SkyMaterial"
  84816. * Mainly use in serialization.
  84817. * @returns the class name
  84818. */
  84819. getClassName(): string;
  84820. /**
  84821. * Creates a sky material from parsed material data
  84822. * @param source defines the JSON representation of the material
  84823. * @param scene defines the hosting scene
  84824. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84825. * @returns a new sky material
  84826. */
  84827. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84828. }
  84829. }
  84830. declare module BABYLON {
  84831. /** @hidden */
  84832. export var terrainPixelShader: {
  84833. name: string;
  84834. shader: string;
  84835. };
  84836. }
  84837. declare module BABYLON {
  84838. /** @hidden */
  84839. export var terrainVertexShader: {
  84840. name: string;
  84841. shader: string;
  84842. };
  84843. }
  84844. declare module BABYLON {
  84845. export class TerrainMaterial extends BABYLON.PushMaterial {
  84846. private _mixTexture;
  84847. mixTexture: BABYLON.BaseTexture;
  84848. private _diffuseTexture1;
  84849. diffuseTexture1: BABYLON.Texture;
  84850. private _diffuseTexture2;
  84851. diffuseTexture2: BABYLON.Texture;
  84852. private _diffuseTexture3;
  84853. diffuseTexture3: BABYLON.Texture;
  84854. private _bumpTexture1;
  84855. bumpTexture1: BABYLON.Texture;
  84856. private _bumpTexture2;
  84857. bumpTexture2: BABYLON.Texture;
  84858. private _bumpTexture3;
  84859. bumpTexture3: BABYLON.Texture;
  84860. diffuseColor: BABYLON.Color3;
  84861. specularColor: BABYLON.Color3;
  84862. specularPower: number;
  84863. private _disableLighting;
  84864. disableLighting: boolean;
  84865. private _maxSimultaneousLights;
  84866. maxSimultaneousLights: number;
  84867. constructor(name: string, scene: BABYLON.Scene);
  84868. needAlphaBlending(): boolean;
  84869. needAlphaTesting(): boolean;
  84870. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84871. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84872. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84873. getAnimatables(): BABYLON.IAnimatable[];
  84874. getActiveTextures(): BABYLON.BaseTexture[];
  84875. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84876. dispose(forceDisposeEffect?: boolean): void;
  84877. clone(name: string): TerrainMaterial;
  84878. serialize(): any;
  84879. getClassName(): string;
  84880. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84881. }
  84882. }
  84883. declare module BABYLON {
  84884. /** @hidden */
  84885. export var triplanarPixelShader: {
  84886. name: string;
  84887. shader: string;
  84888. };
  84889. }
  84890. declare module BABYLON {
  84891. /** @hidden */
  84892. export var triplanarVertexShader: {
  84893. name: string;
  84894. shader: string;
  84895. };
  84896. }
  84897. declare module BABYLON {
  84898. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84899. mixTexture: BABYLON.BaseTexture;
  84900. private _diffuseTextureX;
  84901. diffuseTextureX: BABYLON.BaseTexture;
  84902. private _diffuseTextureY;
  84903. diffuseTextureY: BABYLON.BaseTexture;
  84904. private _diffuseTextureZ;
  84905. diffuseTextureZ: BABYLON.BaseTexture;
  84906. private _normalTextureX;
  84907. normalTextureX: BABYLON.BaseTexture;
  84908. private _normalTextureY;
  84909. normalTextureY: BABYLON.BaseTexture;
  84910. private _normalTextureZ;
  84911. normalTextureZ: BABYLON.BaseTexture;
  84912. tileSize: number;
  84913. diffuseColor: BABYLON.Color3;
  84914. specularColor: BABYLON.Color3;
  84915. specularPower: number;
  84916. private _disableLighting;
  84917. disableLighting: boolean;
  84918. private _maxSimultaneousLights;
  84919. maxSimultaneousLights: number;
  84920. constructor(name: string, scene: BABYLON.Scene);
  84921. needAlphaBlending(): boolean;
  84922. needAlphaTesting(): boolean;
  84923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84924. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84925. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84926. getAnimatables(): BABYLON.IAnimatable[];
  84927. getActiveTextures(): BABYLON.BaseTexture[];
  84928. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84929. dispose(forceDisposeEffect?: boolean): void;
  84930. clone(name: string): TriPlanarMaterial;
  84931. serialize(): any;
  84932. getClassName(): string;
  84933. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84934. }
  84935. }
  84936. declare module BABYLON {
  84937. /** @hidden */
  84938. export var waterPixelShader: {
  84939. name: string;
  84940. shader: string;
  84941. };
  84942. }
  84943. declare module BABYLON {
  84944. /** @hidden */
  84945. export var waterVertexShader: {
  84946. name: string;
  84947. shader: string;
  84948. };
  84949. }
  84950. declare module BABYLON {
  84951. export class WaterMaterial extends BABYLON.PushMaterial {
  84952. renderTargetSize: BABYLON.Vector2;
  84953. private _bumpTexture;
  84954. bumpTexture: BABYLON.BaseTexture;
  84955. diffuseColor: BABYLON.Color3;
  84956. specularColor: BABYLON.Color3;
  84957. specularPower: number;
  84958. private _disableLighting;
  84959. disableLighting: boolean;
  84960. private _maxSimultaneousLights;
  84961. maxSimultaneousLights: number;
  84962. /**
  84963. * @param {number}: Represents the wind force
  84964. */
  84965. windForce: number;
  84966. /**
  84967. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84968. */
  84969. windDirection: BABYLON.Vector2;
  84970. /**
  84971. * @param {number}: Wave height, represents the height of the waves
  84972. */
  84973. waveHeight: number;
  84974. /**
  84975. * @param {number}: Bump height, represents the bump height related to the bump map
  84976. */
  84977. bumpHeight: number;
  84978. /**
  84979. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84980. */
  84981. private _bumpSuperimpose;
  84982. bumpSuperimpose: boolean;
  84983. /**
  84984. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84985. */
  84986. private _fresnelSeparate;
  84987. fresnelSeparate: boolean;
  84988. /**
  84989. * @param {boolean}: bump Waves modify the reflection.
  84990. */
  84991. private _bumpAffectsReflection;
  84992. bumpAffectsReflection: boolean;
  84993. /**
  84994. * @param {number}: The water color blended with the refraction (near)
  84995. */
  84996. waterColor: BABYLON.Color3;
  84997. /**
  84998. * @param {number}: The blend factor related to the water color
  84999. */
  85000. colorBlendFactor: number;
  85001. /**
  85002. * @param {number}: The water color blended with the reflection (far)
  85003. */
  85004. waterColor2: BABYLON.Color3;
  85005. /**
  85006. * @param {number}: The blend factor related to the water color (reflection, far)
  85007. */
  85008. colorBlendFactor2: number;
  85009. /**
  85010. * @param {number}: Represents the maximum length of a wave
  85011. */
  85012. waveLength: number;
  85013. /**
  85014. * @param {number}: Defines the waves speed
  85015. */
  85016. waveSpeed: number;
  85017. /**
  85018. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85019. * will avoid calculating useless pixels in the pixel shader of the water material.
  85020. */
  85021. disableClipPlane: boolean;
  85022. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85023. private _mesh;
  85024. private _refractionRTT;
  85025. private _reflectionRTT;
  85026. private _reflectionTransform;
  85027. private _lastTime;
  85028. private _lastDeltaTime;
  85029. private _useLogarithmicDepth;
  85030. private _waitingRenderList;
  85031. private _imageProcessingConfiguration;
  85032. private _imageProcessingObserver;
  85033. /**
  85034. * Gets a boolean indicating that current material needs to register RTT
  85035. */
  85036. get hasRenderTargetTextures(): boolean;
  85037. /**
  85038. * Constructor
  85039. */
  85040. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85041. get useLogarithmicDepth(): boolean;
  85042. set useLogarithmicDepth(value: boolean);
  85043. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85044. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85045. addToRenderList(node: any): void;
  85046. enableRenderTargets(enable: boolean): void;
  85047. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85048. get renderTargetsEnabled(): boolean;
  85049. needAlphaBlending(): boolean;
  85050. needAlphaTesting(): boolean;
  85051. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85052. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85053. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85054. private _createRenderTargets;
  85055. getAnimatables(): BABYLON.IAnimatable[];
  85056. getActiveTextures(): BABYLON.BaseTexture[];
  85057. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85058. dispose(forceDisposeEffect?: boolean): void;
  85059. clone(name: string): WaterMaterial;
  85060. serialize(): any;
  85061. getClassName(): string;
  85062. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85063. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85064. }
  85065. }
  85066. declare module BABYLON {
  85067. /** @hidden */
  85068. export var asciiartPixelShader: {
  85069. name: string;
  85070. shader: string;
  85071. };
  85072. }
  85073. declare module BABYLON {
  85074. /**
  85075. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85076. *
  85077. * It basically takes care rendering the font front the given font size to a texture.
  85078. * This is used later on in the postprocess.
  85079. */
  85080. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85081. private _font;
  85082. private _text;
  85083. private _charSize;
  85084. /**
  85085. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85086. */
  85087. get charSize(): number;
  85088. /**
  85089. * Create a new instance of the Ascii Art FontTexture class
  85090. * @param name the name of the texture
  85091. * @param font the font to use, use the W3C CSS notation
  85092. * @param text the caracter set to use in the rendering.
  85093. * @param scene the scene that owns the texture
  85094. */
  85095. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85096. /**
  85097. * Gets the max char width of a font.
  85098. * @param font the font to use, use the W3C CSS notation
  85099. * @return the max char width
  85100. */
  85101. private getFontWidth;
  85102. /**
  85103. * Gets the max char height of a font.
  85104. * @param font the font to use, use the W3C CSS notation
  85105. * @return the max char height
  85106. */
  85107. private getFontHeight;
  85108. /**
  85109. * Clones the current AsciiArtTexture.
  85110. * @return the clone of the texture.
  85111. */
  85112. clone(): AsciiArtFontTexture;
  85113. /**
  85114. * Parses a json object representing the texture and returns an instance of it.
  85115. * @param source the source JSON representation
  85116. * @param scene the scene to create the texture for
  85117. * @return the parsed texture
  85118. */
  85119. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85120. }
  85121. /**
  85122. * Option available in the Ascii Art Post Process.
  85123. */
  85124. export interface IAsciiArtPostProcessOptions {
  85125. /**
  85126. * The font to use following the w3c font definition.
  85127. */
  85128. font?: string;
  85129. /**
  85130. * The character set to use in the postprocess.
  85131. */
  85132. characterSet?: string;
  85133. /**
  85134. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85135. * This number is defined between 0 and 1;
  85136. */
  85137. mixToTile?: number;
  85138. /**
  85139. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85140. * This number is defined between 0 and 1;
  85141. */
  85142. mixToNormal?: number;
  85143. }
  85144. /**
  85145. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85146. *
  85147. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85148. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85149. */
  85150. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85151. /**
  85152. * The font texture used to render the char in the post process.
  85153. */
  85154. private _asciiArtFontTexture;
  85155. /**
  85156. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85157. * This number is defined between 0 and 1;
  85158. */
  85159. mixToTile: number;
  85160. /**
  85161. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85162. * This number is defined between 0 and 1;
  85163. */
  85164. mixToNormal: number;
  85165. /**
  85166. * Instantiates a new Ascii Art Post Process.
  85167. * @param name the name to give to the postprocess
  85168. * @camera the camera to apply the post process to.
  85169. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85170. */
  85171. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85172. }
  85173. }
  85174. declare module BABYLON {
  85175. /** @hidden */
  85176. export var digitalrainPixelShader: {
  85177. name: string;
  85178. shader: string;
  85179. };
  85180. }
  85181. declare module BABYLON {
  85182. /**
  85183. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85184. *
  85185. * It basically takes care rendering the font front the given font size to a texture.
  85186. * This is used later on in the postprocess.
  85187. */
  85188. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85189. private _font;
  85190. private _text;
  85191. private _charSize;
  85192. /**
  85193. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85194. */
  85195. get charSize(): number;
  85196. /**
  85197. * Create a new instance of the Digital Rain FontTexture class
  85198. * @param name the name of the texture
  85199. * @param font the font to use, use the W3C CSS notation
  85200. * @param text the caracter set to use in the rendering.
  85201. * @param scene the scene that owns the texture
  85202. */
  85203. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85204. /**
  85205. * Gets the max char width of a font.
  85206. * @param font the font to use, use the W3C CSS notation
  85207. * @return the max char width
  85208. */
  85209. private getFontWidth;
  85210. /**
  85211. * Gets the max char height of a font.
  85212. * @param font the font to use, use the W3C CSS notation
  85213. * @return the max char height
  85214. */
  85215. private getFontHeight;
  85216. /**
  85217. * Clones the current DigitalRainFontTexture.
  85218. * @return the clone of the texture.
  85219. */
  85220. clone(): DigitalRainFontTexture;
  85221. /**
  85222. * Parses a json object representing the texture and returns an instance of it.
  85223. * @param source the source JSON representation
  85224. * @param scene the scene to create the texture for
  85225. * @return the parsed texture
  85226. */
  85227. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85228. }
  85229. /**
  85230. * Option available in the Digital Rain Post Process.
  85231. */
  85232. export interface IDigitalRainPostProcessOptions {
  85233. /**
  85234. * The font to use following the w3c font definition.
  85235. */
  85236. font?: string;
  85237. /**
  85238. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85239. * This number is defined between 0 and 1;
  85240. */
  85241. mixToTile?: number;
  85242. /**
  85243. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85244. * This number is defined between 0 and 1;
  85245. */
  85246. mixToNormal?: number;
  85247. }
  85248. /**
  85249. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85250. *
  85251. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85252. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85253. */
  85254. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85255. /**
  85256. * The font texture used to render the char in the post process.
  85257. */
  85258. private _digitalRainFontTexture;
  85259. /**
  85260. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85261. * This number is defined between 0 and 1;
  85262. */
  85263. mixToTile: number;
  85264. /**
  85265. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85266. * This number is defined between 0 and 1;
  85267. */
  85268. mixToNormal: number;
  85269. /**
  85270. * Instantiates a new Digital Rain Post Process.
  85271. * @param name the name to give to the postprocess
  85272. * @camera the camera to apply the post process to.
  85273. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85274. */
  85275. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85276. }
  85277. }
  85278. declare module BABYLON {
  85279. /** @hidden */
  85280. export var brickProceduralTexturePixelShader: {
  85281. name: string;
  85282. shader: string;
  85283. };
  85284. }
  85285. declare module BABYLON {
  85286. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85287. private _numberOfBricksHeight;
  85288. private _numberOfBricksWidth;
  85289. private _jointColor;
  85290. private _brickColor;
  85291. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85292. updateShaderUniforms(): void;
  85293. get numberOfBricksHeight(): number;
  85294. set numberOfBricksHeight(value: number);
  85295. get numberOfBricksWidth(): number;
  85296. set numberOfBricksWidth(value: number);
  85297. get jointColor(): BABYLON.Color3;
  85298. set jointColor(value: BABYLON.Color3);
  85299. get brickColor(): BABYLON.Color3;
  85300. set brickColor(value: BABYLON.Color3);
  85301. /**
  85302. * Serializes this brick procedural texture
  85303. * @returns a serialized brick procedural texture object
  85304. */
  85305. serialize(): any;
  85306. /**
  85307. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85308. * @param parsedTexture defines parsed texture data
  85309. * @param scene defines the current scene
  85310. * @param rootUrl defines the root URL containing brick procedural texture information
  85311. * @returns a parsed Brick Procedural BABYLON.Texture
  85312. */
  85313. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85314. }
  85315. }
  85316. declare module BABYLON {
  85317. /** @hidden */
  85318. export var cloudProceduralTexturePixelShader: {
  85319. name: string;
  85320. shader: string;
  85321. };
  85322. }
  85323. declare module BABYLON {
  85324. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85325. private _skyColor;
  85326. private _cloudColor;
  85327. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85328. updateShaderUniforms(): void;
  85329. get skyColor(): BABYLON.Color4;
  85330. set skyColor(value: BABYLON.Color4);
  85331. get cloudColor(): BABYLON.Color4;
  85332. set cloudColor(value: BABYLON.Color4);
  85333. /**
  85334. * Serializes this cloud procedural texture
  85335. * @returns a serialized cloud procedural texture object
  85336. */
  85337. serialize(): any;
  85338. /**
  85339. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85340. * @param parsedTexture defines parsed texture data
  85341. * @param scene defines the current scene
  85342. * @param rootUrl defines the root URL containing cloud procedural texture information
  85343. * @returns a parsed Cloud Procedural BABYLON.Texture
  85344. */
  85345. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85346. }
  85347. }
  85348. declare module BABYLON {
  85349. /** @hidden */
  85350. export var fireProceduralTexturePixelShader: {
  85351. name: string;
  85352. shader: string;
  85353. };
  85354. }
  85355. declare module BABYLON {
  85356. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85357. private _time;
  85358. private _speed;
  85359. private _autoGenerateTime;
  85360. private _fireColors;
  85361. private _alphaThreshold;
  85362. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85363. updateShaderUniforms(): void;
  85364. render(useCameraPostProcess?: boolean): void;
  85365. static get PurpleFireColors(): BABYLON.Color3[];
  85366. static get GreenFireColors(): BABYLON.Color3[];
  85367. static get RedFireColors(): BABYLON.Color3[];
  85368. static get BlueFireColors(): BABYLON.Color3[];
  85369. get autoGenerateTime(): boolean;
  85370. set autoGenerateTime(value: boolean);
  85371. get fireColors(): BABYLON.Color3[];
  85372. set fireColors(value: BABYLON.Color3[]);
  85373. get time(): number;
  85374. set time(value: number);
  85375. get speed(): BABYLON.Vector2;
  85376. set speed(value: BABYLON.Vector2);
  85377. get alphaThreshold(): number;
  85378. set alphaThreshold(value: number);
  85379. /**
  85380. * Serializes this fire procedural texture
  85381. * @returns a serialized fire procedural texture object
  85382. */
  85383. serialize(): any;
  85384. /**
  85385. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85386. * @param parsedTexture defines parsed texture data
  85387. * @param scene defines the current scene
  85388. * @param rootUrl defines the root URL containing fire procedural texture information
  85389. * @returns a parsed Fire Procedural BABYLON.Texture
  85390. */
  85391. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85392. }
  85393. }
  85394. declare module BABYLON {
  85395. /** @hidden */
  85396. export var grassProceduralTexturePixelShader: {
  85397. name: string;
  85398. shader: string;
  85399. };
  85400. }
  85401. declare module BABYLON {
  85402. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85403. private _grassColors;
  85404. private _groundColor;
  85405. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85406. updateShaderUniforms(): void;
  85407. get grassColors(): BABYLON.Color3[];
  85408. set grassColors(value: BABYLON.Color3[]);
  85409. get groundColor(): BABYLON.Color3;
  85410. set groundColor(value: BABYLON.Color3);
  85411. /**
  85412. * Serializes this grass procedural texture
  85413. * @returns a serialized grass procedural texture object
  85414. */
  85415. serialize(): any;
  85416. /**
  85417. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85418. * @param parsedTexture defines parsed texture data
  85419. * @param scene defines the current scene
  85420. * @param rootUrl defines the root URL containing grass procedural texture information
  85421. * @returns a parsed Grass Procedural BABYLON.Texture
  85422. */
  85423. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85424. }
  85425. }
  85426. declare module BABYLON {
  85427. /** @hidden */
  85428. export var marbleProceduralTexturePixelShader: {
  85429. name: string;
  85430. shader: string;
  85431. };
  85432. }
  85433. declare module BABYLON {
  85434. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85435. private _numberOfTilesHeight;
  85436. private _numberOfTilesWidth;
  85437. private _amplitude;
  85438. private _jointColor;
  85439. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85440. updateShaderUniforms(): void;
  85441. get numberOfTilesHeight(): number;
  85442. set numberOfTilesHeight(value: number);
  85443. get amplitude(): number;
  85444. set amplitude(value: number);
  85445. get numberOfTilesWidth(): number;
  85446. set numberOfTilesWidth(value: number);
  85447. get jointColor(): BABYLON.Color3;
  85448. set jointColor(value: BABYLON.Color3);
  85449. /**
  85450. * Serializes this marble procedural texture
  85451. * @returns a serialized marble procedural texture object
  85452. */
  85453. serialize(): any;
  85454. /**
  85455. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85456. * @param parsedTexture defines parsed texture data
  85457. * @param scene defines the current scene
  85458. * @param rootUrl defines the root URL containing marble procedural texture information
  85459. * @returns a parsed Marble Procedural BABYLON.Texture
  85460. */
  85461. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85462. }
  85463. }
  85464. declare module BABYLON {
  85465. /** @hidden */
  85466. export var normalMapProceduralTexturePixelShader: {
  85467. name: string;
  85468. shader: string;
  85469. };
  85470. }
  85471. declare module BABYLON {
  85472. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85473. private _baseTexture;
  85474. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85475. updateShaderUniforms(): void;
  85476. render(useCameraPostProcess?: boolean): void;
  85477. resize(size: any, generateMipMaps: any): void;
  85478. get baseTexture(): BABYLON.Texture;
  85479. set baseTexture(texture: BABYLON.Texture);
  85480. /**
  85481. * Serializes this normal map procedural texture
  85482. * @returns a serialized normal map procedural texture object
  85483. */
  85484. serialize(): any;
  85485. /**
  85486. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85487. * @param parsedTexture defines parsed texture data
  85488. * @param scene defines the current scene
  85489. * @param rootUrl defines the root URL containing normal map procedural texture information
  85490. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85491. */
  85492. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85493. }
  85494. }
  85495. declare module BABYLON {
  85496. /** @hidden */
  85497. export var perlinNoiseProceduralTexturePixelShader: {
  85498. name: string;
  85499. shader: string;
  85500. };
  85501. }
  85502. declare module BABYLON {
  85503. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85504. time: number;
  85505. timeScale: number;
  85506. translationSpeed: number;
  85507. private _currentTranslation;
  85508. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85509. updateShaderUniforms(): void;
  85510. render(useCameraPostProcess?: boolean): void;
  85511. resize(size: any, generateMipMaps: any): void;
  85512. /**
  85513. * Serializes this perlin noise procedural texture
  85514. * @returns a serialized perlin noise procedural texture object
  85515. */
  85516. serialize(): any;
  85517. /**
  85518. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85519. * @param parsedTexture defines parsed texture data
  85520. * @param scene defines the current scene
  85521. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85522. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85523. */
  85524. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85525. }
  85526. }
  85527. declare module BABYLON {
  85528. /** @hidden */
  85529. export var roadProceduralTexturePixelShader: {
  85530. name: string;
  85531. shader: string;
  85532. };
  85533. }
  85534. declare module BABYLON {
  85535. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85536. private _roadColor;
  85537. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85538. updateShaderUniforms(): void;
  85539. get roadColor(): BABYLON.Color3;
  85540. set roadColor(value: BABYLON.Color3);
  85541. /**
  85542. * Serializes this road procedural texture
  85543. * @returns a serialized road procedural texture object
  85544. */
  85545. serialize(): any;
  85546. /**
  85547. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85548. * @param parsedTexture defines parsed texture data
  85549. * @param scene defines the current scene
  85550. * @param rootUrl defines the root URL containing road procedural texture information
  85551. * @returns a parsed Road Procedural BABYLON.Texture
  85552. */
  85553. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85554. }
  85555. }
  85556. declare module BABYLON {
  85557. /** @hidden */
  85558. export var starfieldProceduralTexturePixelShader: {
  85559. name: string;
  85560. shader: string;
  85561. };
  85562. }
  85563. declare module BABYLON {
  85564. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85565. private _time;
  85566. private _alpha;
  85567. private _beta;
  85568. private _zoom;
  85569. private _formuparam;
  85570. private _stepsize;
  85571. private _tile;
  85572. private _brightness;
  85573. private _darkmatter;
  85574. private _distfading;
  85575. private _saturation;
  85576. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85577. updateShaderUniforms(): void;
  85578. get time(): number;
  85579. set time(value: number);
  85580. get alpha(): number;
  85581. set alpha(value: number);
  85582. get beta(): number;
  85583. set beta(value: number);
  85584. get formuparam(): number;
  85585. set formuparam(value: number);
  85586. get stepsize(): number;
  85587. set stepsize(value: number);
  85588. get zoom(): number;
  85589. set zoom(value: number);
  85590. get tile(): number;
  85591. set tile(value: number);
  85592. get brightness(): number;
  85593. set brightness(value: number);
  85594. get darkmatter(): number;
  85595. set darkmatter(value: number);
  85596. get distfading(): number;
  85597. set distfading(value: number);
  85598. get saturation(): number;
  85599. set saturation(value: number);
  85600. /**
  85601. * Serializes this starfield procedural texture
  85602. * @returns a serialized starfield procedural texture object
  85603. */
  85604. serialize(): any;
  85605. /**
  85606. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85607. * @param parsedTexture defines parsed texture data
  85608. * @param scene defines the current scene
  85609. * @param rootUrl defines the root URL containing startfield procedural texture information
  85610. * @returns a parsed Starfield Procedural BABYLON.Texture
  85611. */
  85612. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85613. }
  85614. }
  85615. declare module BABYLON {
  85616. /** @hidden */
  85617. export var woodProceduralTexturePixelShader: {
  85618. name: string;
  85619. shader: string;
  85620. };
  85621. }
  85622. declare module BABYLON {
  85623. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85624. private _ampScale;
  85625. private _woodColor;
  85626. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85627. updateShaderUniforms(): void;
  85628. get ampScale(): number;
  85629. set ampScale(value: number);
  85630. get woodColor(): BABYLON.Color3;
  85631. set woodColor(value: BABYLON.Color3);
  85632. /**
  85633. * Serializes this wood procedural texture
  85634. * @returns a serialized wood procedural texture object
  85635. */
  85636. serialize(): any;
  85637. /**
  85638. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85639. * @param parsedTexture defines parsed texture data
  85640. * @param scene defines the current scene
  85641. * @param rootUrl defines the root URL containing wood procedural texture information
  85642. * @returns a parsed Wood Procedural BABYLON.Texture
  85643. */
  85644. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85645. }
  85646. }